diff options
author | Campbell Barton <ideasman42@gmail.com> | 2017-03-19 04:49:03 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2017-03-19 04:49:18 +0300 |
commit | 57f376e9465c6b79ebd4409bc30e0b5930dd4140 (patch) | |
tree | 8dc6d5940bc8c39d7979d3b35c19d91f4bb83bf0 /rigify/rigs/pitchipoy | |
parent | 1338695613af08ae912e6507f0fc89d54577e11a (diff) |
Cleanup: trailing space
Diffstat (limited to 'rigify/rigs/pitchipoy')
-rw-r--r-- | rigify/rigs/pitchipoy/limbs/arm.py | 18 | ||||
-rw-r--r-- | rigify/rigs/pitchipoy/limbs/leg.py | 68 | ||||
-rw-r--r-- | rigify/rigs/pitchipoy/limbs/limb_utils.py | 14 | ||||
-rw-r--r-- | rigify/rigs/pitchipoy/limbs/paw.py | 24 | ||||
-rw-r--r-- | rigify/rigs/pitchipoy/limbs/super_limb.py | 138 | ||||
-rw-r--r-- | rigify/rigs/pitchipoy/limbs/ui.py | 10 | ||||
-rw-r--r-- | rigify/rigs/pitchipoy/simple_tentacle.py | 90 | ||||
-rw-r--r-- | rigify/rigs/pitchipoy/super_copy.py | 24 | ||||
-rwxr-xr-x | rigify/rigs/pitchipoy/super_face.py | 358 | ||||
-rw-r--r-- | rigify/rigs/pitchipoy/super_finger.py | 116 | ||||
-rw-r--r-- | rigify/rigs/pitchipoy/super_torso_turbo.py | 212 | ||||
-rw-r--r-- | rigify/rigs/pitchipoy/super_widgets.py | 14 | ||||
-rw-r--r-- | rigify/rigs/pitchipoy/tentacle.py | 138 |
13 files changed, 612 insertions, 612 deletions
diff --git a/rigify/rigs/pitchipoy/limbs/arm.py b/rigify/rigs/pitchipoy/limbs/arm.py index 43327ec8..17bf5535 100644 --- a/rigify/rigs/pitchipoy/limbs/arm.py +++ b/rigify/rigs/pitchipoy/limbs/arm.py @@ -27,26 +27,26 @@ from rna_prop_ui import rna_idprop_ui_prop_get def create_arm( cls, bones ): org_bones = cls.org_bones - + bpy.ops.object.mode_set(mode='EDIT') eb = cls.obj.data.edit_bones ctrl = get_bone_name( org_bones[2], 'ctrl', 'ik' ) - + # Create IK arm control ctrl = copy_bone( cls.obj, org_bones[2], ctrl ) - # clear parent (so that rigify will parent to root) + # clear parent (so that rigify will parent to root) eb[ ctrl ].parent = None eb[ ctrl ].use_connect = False - # Parent + # Parent eb[ bones['ik']['mch_target'] ].parent = eb[ ctrl ] eb[ bones['ik']['mch_target'] ].use_connect = False - + # Set up constraints # Constrain mch target bone to the ik control and mch stretch - + make_constraint( cls, bones['ik']['mch_target'], { 'constraint' : 'COPY_LOCATION', 'subtarget' : bones['ik']['mch_str'], @@ -80,7 +80,7 @@ def create_arm( cls, bones ): # Create ik/fk switch property pb_parent = pb[ bones['parent'] ] - + pb_parent['IK_Strertch'] = 1.0 prop = rna_idprop_ui_prop_get( pb_parent, 'IK_Strertch', create=True ) prop["min"] = 0.0 @@ -93,7 +93,7 @@ def create_arm( cls, bones ): b = bones['ik']['mch_str'] drv = pb[b].constraints[-1].driver_add("influence").driver drv.type = 'SUM' - + var = drv.variables.new() var.name = prop.name var.type = "SINGLE_PROP" @@ -102,7 +102,7 @@ def create_arm( cls, bones ): pb_parent.path_from_id() + '['+ '"' + prop.name + '"' + ']' drv_modifier = cls.obj.animation_data.drivers[-1].modifiers[0] - + drv_modifier.mode = 'POLYNOMIAL' drv_modifier.poly_order = 1 drv_modifier.coefficients[0] = 1.0 diff --git a/rigify/rigs/pitchipoy/limbs/leg.py b/rigify/rigs/pitchipoy/limbs/leg.py index 9176bd92..14fd6f13 100644 --- a/rigify/rigs/pitchipoy/limbs/leg.py +++ b/rigify/rigs/pitchipoy/limbs/leg.py @@ -31,7 +31,7 @@ def create_leg( cls, bones ): ) bones['ik']['ctrl']['terminal'] = [] - + bpy.ops.object.mode_set(mode='EDIT') eb = cls.obj.data.edit_bones @@ -49,7 +49,7 @@ def create_leg( cls, bones ): ctrl = get_bone_name( org_bones[2], 'ctrl', 'ik' ) ctrl = copy_bone( cls.obj, org_bones[2], ctrl ) - # clear parent (so that rigify will parent to root) + # clear parent (so that rigify will parent to root) eb[ ctrl ].parent = None eb[ ctrl ].use_connect = False @@ -64,7 +64,7 @@ def create_leg( cls, bones ): orient_bone( cls, eb[ ctrl ], 'y', reverse = True ) eb[ ctrl ].length = l - # Parent + # Parent eb[ heel ].use_connect = False eb[ heel ].parent = eb[ ctrl ] @@ -91,38 +91,38 @@ def create_leg( cls, bones ): # Create 2nd roll mch, and two rock mch bones roll2_mch = get_bone_name( tmp_heel, 'mch', 'roll' ) - roll2_mch = copy_bone( cls.obj, org_bones[3], roll2_mch ) + roll2_mch = copy_bone( cls.obj, org_bones[3], roll2_mch ) eb[ roll2_mch ].use_connect = False eb[ roll2_mch ].parent = None - - put_bone( - cls.obj, - roll2_mch, + + put_bone( + cls.obj, + roll2_mch, ( eb[ tmp_heel ].head + eb[ tmp_heel ].tail ) / 2 ) eb[ roll2_mch ].length /= 4 - + # Rock MCH bones rock1_mch = get_bone_name( tmp_heel, 'mch', 'rock' ) - rock1_mch = copy_bone( cls.obj, tmp_heel, rock1_mch ) + rock1_mch = copy_bone( cls.obj, tmp_heel, rock1_mch ) eb[ rock1_mch ].use_connect = False - eb[ rock1_mch ].parent = None - + eb[ rock1_mch ].parent = None + orient_bone( cls, eb[ rock1_mch ], 'y', 1.0, reverse = True ) eb[ rock1_mch ].length = eb[ tmp_heel ].length / 2 - + rock2_mch = get_bone_name( tmp_heel, 'mch', 'rock' ) rock2_mch = copy_bone( cls.obj, tmp_heel, rock2_mch ) eb[ rock2_mch ].use_connect = False - eb[ rock2_mch ].parent = None + eb[ rock2_mch ].parent = None orient_bone( cls, eb[ rock2_mch ], 'y', 1.0 ) eb[ rock2_mch ].length = eb[ tmp_heel ].length / 2 - + # Parent rock and roll MCH bones eb[ roll1_mch ].parent = eb[ roll2_mch ] eb[ roll2_mch ].parent = eb[ rock1_mch ] @@ -135,7 +135,7 @@ def create_leg( cls, bones ): 'subtarget' : heel, 'owner_space' : 'LOCAL', 'target_space' : 'LOCAL' - }) + }) make_constraint( cls, roll1_mch, { 'constraint' : 'LIMIT_ROTATION', 'use_limit_x' : True, @@ -150,15 +150,15 @@ def create_leg( cls, bones ): 'invert_x' : True, 'owner_space' : 'LOCAL', 'target_space' : 'LOCAL' - }) + }) make_constraint( cls, roll2_mch, { 'constraint' : 'LIMIT_ROTATION', 'use_limit_x' : True, 'max_x' : math.radians(360), 'owner_space' : 'LOCAL' - }) + }) - pb = cls.obj.pose.bones + pb = cls.obj.pose.bones for i,b in enumerate([ rock1_mch, rock2_mch ]): head_tail = pb[b].head - pb[tmp_heel].head if '.L' in b: @@ -176,7 +176,7 @@ def create_leg( cls, bones ): min_y = 0 max_y = math.radians(360) - + make_constraint( cls, b, { 'constraint' : 'COPY_ROTATION', 'subtarget' : heel, @@ -184,14 +184,14 @@ def create_leg( cls, bones ): 'use_z' : False, 'owner_space' : 'LOCAL', 'target_space' : 'LOCAL' - }) + }) make_constraint( cls, b, { 'constraint' : 'LIMIT_ROTATION', 'use_limit_y' : True, 'min_y' : min_y, 'max_y' : max_y, 'owner_space' : 'LOCAL' - }) + }) # Constrain 4th ORG to roll2 MCH bone make_constraint( cls, org_bones[3], { @@ -201,7 +201,7 @@ def create_leg( cls, bones ): # Set up constraints # Constrain mch target bone to the ik control and mch stretch - + make_constraint( cls, bones['ik']['mch_target'], { 'constraint' : 'COPY_LOCATION', 'subtarget' : bones['ik']['mch_str'], @@ -235,7 +235,7 @@ def create_leg( cls, bones ): # Create ik/fk switch property pb_parent = pb[ bones['parent'] ] - + pb_parent['IK_Strertch'] = 1.0 prop = rna_idprop_ui_prop_get( pb_parent, 'IK_Strertch', create=True ) prop["min"] = 0.0 @@ -248,7 +248,7 @@ def create_leg( cls, bones ): b = bones['ik']['mch_str'] drv = pb[b].constraints[-1].driver_add("influence").driver drv.type = 'AVERAGE' - + var = drv.variables.new() var.name = prop.name var.type = "SINGLE_PROP" @@ -257,7 +257,7 @@ def create_leg( cls, bones ): pb_parent.path_from_id() + '['+ '"' + prop.name + '"' + ']' drv_modifier = cls.obj.animation_data.drivers[-1].modifiers[0] - + drv_modifier.mode = 'POLYNOMIAL' drv_modifier.poly_order = 1 drv_modifier.coefficients[0] = 1.0 @@ -284,7 +284,7 @@ def create_leg( cls, bones ): eb[ toes ].use_connect = False eb[ toes ].parent = eb[ org_bones[3] ] - + # Constrain toes def bones make_constraint( cls, bones['def'][-2], { 'constraint' : 'DAMPED_TRACK', @@ -293,8 +293,8 @@ def create_leg( cls, bones ): make_constraint( cls, bones['def'][-2], { 'constraint' : 'STRETCH_TO', 'subtarget' : toes - }) - + }) + make_constraint( cls, bones['def'][-1], { 'constraint' : 'COPY_TRANSFORMS', 'subtarget' : toes @@ -303,12 +303,12 @@ def create_leg( cls, bones ): # Find IK/FK switch property pb = cls.obj.pose.bones prop = rna_idprop_ui_prop_get( pb[ bones['parent'] ], 'IK/FK' ) - + # Add driver to limit scale constraint influence b = org_bones[3] drv = pb[b].constraints[-1].driver_add("influence").driver drv.type = 'AVERAGE' - + var = drv.variables.new() var.name = prop.name var.type = "SINGLE_PROP" @@ -317,17 +317,17 @@ def create_leg( cls, bones ): pb_parent.path_from_id() + '['+ '"' + prop.name + '"' + ']' drv_modifier = cls.obj.animation_data.drivers[-1].modifiers[0] - + drv_modifier.mode = 'POLYNOMIAL' drv_modifier.poly_order = 1 drv_modifier.coefficients[0] = 1.0 drv_modifier.coefficients[1] = -1.0 - + # Create toe circle widget create_circle_widget(cls.obj, toes, radius=0.4, head_tail=0.5) bones['ik']['ctrl']['terminal'] += [ toes ] bones['ik']['ctrl']['terminal'] += [ heel, ctrl ] - + return bones diff --git a/rigify/rigs/pitchipoy/limbs/limb_utils.py b/rigify/rigs/pitchipoy/limbs/limb_utils.py index 73e4f472..ce6a0761 100644 --- a/rigify/rigs/pitchipoy/limbs/limb_utils.py +++ b/rigify/rigs/pitchipoy/limbs/limb_utils.py @@ -7,13 +7,13 @@ bilateral_suffixes = ['.L','.R'] def orient_bone( cls, eb, axis, scale = 1.0, reverse = False ): v = Vector((0,0,0)) - + setattr(v,axis,scale) if reverse: tail_vec = v * cls.obj.matrix_world eb.head[:] = eb.tail - eb.tail[:] = eb.head + tail_vec + eb.tail[:] = eb.head + tail_vec else: tail_vec = v * cls.obj.matrix_world eb.tail[:] = eb.head + tail_vec @@ -29,22 +29,22 @@ def make_constraint( cls, bone, constraint ): constraint['target'] = cls.obj - # filter contraint props to those that actually exist in the currnet + # filter contraint props to those that actually exist in the currnet # type of constraint, then assign values to each for p in [ k for k in constraint.keys() if k in dir(const) ]: if p in dir( const ): setattr( const, p, constraint[p] ) else: raise MetarigError( - "RIGIFY ERROR: property %s does not exist in %s constraint" % ( + "RIGIFY ERROR: property %s does not exist in %s constraint" % ( p, constraint['constraint'] )) def get_bone_name( name, btype, suffix = '' ): # RE pattern match right or left parts - # match the letter "L" (or "R"), followed by an optional dot (".") + # match the letter "L" (or "R"), followed by an optional dot (".") # and 0 or more digits at the end of the the string - pattern = r'^(\S+)(\.\S+)$' + pattern = r'^(\S+)(\.\S+)$' name = strip_org( name ) @@ -60,7 +60,7 @@ def get_bone_name( name, btype, suffix = '' ): if suffix: results = re.match( pattern, name ) bname, addition = ('','') - + if results: bname, addition = results.groups() name = bname + "_" + suffix + addition diff --git a/rigify/rigs/pitchipoy/limbs/paw.py b/rigify/rigs/pitchipoy/limbs/paw.py index 89de5e90..03ccd25f 100644 --- a/rigify/rigs/pitchipoy/limbs/paw.py +++ b/rigify/rigs/pitchipoy/limbs/paw.py @@ -32,7 +32,7 @@ def create_paw( cls, bones ): bones['ik']['ctrl']['terminal'] = [] - + bpy.ops.object.mode_set(mode='EDIT') eb = cls.obj.data.edit_bones @@ -57,7 +57,7 @@ def create_paw( cls, bones ): eb[ heel ].use_connect = False flip_bone( cls.obj, heel ) - + eb[ bones['ik']['mch_target'] ].parent = eb[ heel ] eb[ bones['ik']['mch_target'] ].use_connect = False @@ -68,7 +68,7 @@ def create_paw( cls, bones ): # Set up constraints # Constrain mch target bone to the ik control and mch stretch - + make_constraint( cls, bones['ik']['mch_target'], { 'constraint' : 'COPY_LOCATION', 'subtarget' : bones['ik']['mch_str'], @@ -104,7 +104,7 @@ def create_paw( cls, bones ): # Create ik/fk switch property pb_parent = pb[ bones['parent'] ] - + pb_parent['IK_Strertch'] = 1.0 prop = rna_idprop_ui_prop_get( pb_parent, 'IK_Strertch', create=True ) prop["min"] = 0.0 @@ -117,7 +117,7 @@ def create_paw( cls, bones ): b = bones['ik']['mch_str'] drv = pb[b].constraints[-1].driver_add("influence").driver drv.type = 'AVERAGE' - + var = drv.variables.new() var.name = prop.name var.type = "SINGLE_PROP" @@ -126,7 +126,7 @@ def create_paw( cls, bones ): pb_parent.path_from_id() + '['+ '"' + prop.name + '"' + ']' drv_modifier = cls.obj.animation_data.drivers[-1].modifiers[0] - + drv_modifier.mode = 'POLYNOMIAL' drv_modifier.poly_order = 1 drv_modifier.coefficients[0] = 1.0 @@ -151,7 +151,7 @@ def create_paw( cls, bones ): eb[ toes ].use_connect = False eb[ toes ].parent = eb[ org_bones[3] ] - + # Create toes mch bone toes_mch = get_bone_name( org_bones[3], 'mch' ) toes_mch = copy_bone( cls.obj, org_bones[3], toes_mch ) @@ -160,7 +160,7 @@ def create_paw( cls, bones ): eb[ toes_mch ].parent = eb[ ctrl ] eb[ toes_mch ].length /= 4 - + # Constrain 4th ORG to toes MCH bone make_constraint( cls, org_bones[3], { 'constraint' : 'COPY_TRANSFORMS', @@ -184,12 +184,12 @@ def create_paw( cls, bones ): # Find IK/FK switch property pb = cls.obj.pose.bones prop = rna_idprop_ui_prop_get( pb[ bones['parent'] ], 'IK/FK' ) - + # Add driver to limit scale constraint influence b = org_bones[3] drv = pb[b].constraints[-1].driver_add("influence").driver drv.type = 'AVERAGE' - + var = drv.variables.new() var.name = prop.name var.type = "SINGLE_PROP" @@ -198,12 +198,12 @@ def create_paw( cls, bones ): pb_parent.path_from_id() + '['+ '"' + prop.name + '"' + ']' drv_modifier = cls.obj.animation_data.drivers[-1].modifiers[0] - + drv_modifier.mode = 'POLYNOMIAL' drv_modifier.poly_order = 1 drv_modifier.coefficients[0] = 1.0 drv_modifier.coefficients[1] = -1.0 - + # Create toe circle widget create_circle_widget(cls.obj, toes, radius=0.4, head_tail=0.5) diff --git a/rigify/rigs/pitchipoy/limbs/super_limb.py b/rigify/rigs/pitchipoy/limbs/super_limb.py index 40447097..b1d58ea7 100644 --- a/rigify/rigs/pitchipoy/limbs/super_limb.py +++ b/rigify/rigs/pitchipoy/limbs/super_limb.py @@ -47,7 +47,7 @@ class Rig: def create_parent( self ): org_bones = self.org_bones - + bpy.ops.object.mode_set(mode ='EDIT') eb = self.obj.data.edit_bones @@ -58,9 +58,9 @@ class Rig: eb[ mch ].length = eb[ org_bones[0] ].length / 4 eb[ mch ].parent = eb[ org_bones[0] ].parent - + eb[ mch ].roll = 0.0 - + # Constraints make_constraint( self, mch, { 'constraint' : 'COPY_ROTATION', @@ -71,7 +71,7 @@ class Rig: 'constraint' : 'COPY_SCALE', 'subtarget' : 'root' }) - + # Limb Follow Driver pb = self.obj.pose.bones @@ -79,7 +79,7 @@ class Rig: pb[ mch ][ name ] = 0.0 prop = rna_idprop_ui_prop_get( pb[ mch ], name, create = True ) - + prop["min"] = 0.0 prop["max"] = 1.0 prop["soft_min"] = 0.0 @@ -100,11 +100,11 @@ class Rig: def create_tweak( self ): org_bones = self.org_bones - + bpy.ops.object.mode_set(mode ='EDIT') eb = self.obj.data.edit_bones - tweaks = {} + tweaks = {} tweaks['ctrl'] = [] tweaks['mch' ] = [] @@ -116,15 +116,15 @@ class Rig: # MCH name = get_bone_name( strip_org(org), 'mch', 'tweak' ) mch = copy_bone( self.obj, org, name ) - + # CTRL name = get_bone_name( strip_org(org), 'ctrl', 'tweak' ) ctrl = copy_bone( self.obj, org, name ) - + eb[ mch ].length /= self.segments eb[ ctrl ].length /= self.segments - # If we have more than one segments, place the head of the + # If we have more than one segments, place the head of the # 2nd and onwards at the correct position if j > 0: put_bone(self.obj, mch, eb[ tweaks['mch' ][-1] ].tail) @@ -137,23 +137,23 @@ class Rig: eb[ mch ].parent = eb[ org ] eb[ ctrl ].parent = eb[ mch ] - else: # Last limb bone - is not subdivided - name = get_bone_name( strip_org(org), 'mch', 'tweak' ) + else: # Last limb bone - is not subdivided + name = get_bone_name( strip_org(org), 'mch', 'tweak' ) mch = copy_bone( self.obj, org_bones[i-1], name ) eb[ mch ].length = eb[org].length / 4 put_bone( - self.obj, + self.obj, mch, eb[org_bones[i-1]].tail - ) - + ) + ctrl = get_bone_name( strip_org(org), 'ctrl', 'tweak' ) ctrl = copy_bone( self.obj, org, ctrl ) - eb[ ctrl ].length = eb[org].length / 2 + eb[ ctrl ].length = eb[org].length / 2 tweaks['mch'] += [ mch ] tweaks['ctrl'] += [ ctrl ] - + # Parenting the tweak ctrls to mchs eb[ mch ].parent = eb[ org ] eb[ ctrl ].parent = eb[ mch ] @@ -256,19 +256,19 @@ class Rig: pb[t].lock_scale = False, True, False create_sphere_widget(self.obj, t, bone_transform_name=None) - + if self.tweak_layers: - pb[t].bone.layers = self.tweak_layers - + pb[t].bone.layers = self.tweak_layers + return tweaks def create_def( self, tweaks ): org_bones = self.org_bones - + bpy.ops.object.mode_set(mode ='EDIT') eb = self.obj.data.edit_bones - + def_bones = [] for i,org in enumerate(org_bones): if i < len(org_bones) - 1: @@ -276,7 +276,7 @@ class Rig: for j in range( self.segments ): name = get_bone_name( strip_org(org), 'def' ) def_name = copy_bone( self.obj, org, name ) - + eb[ def_name ].length /= self.segments # If we have more than one segments, place the 2nd and @@ -338,7 +338,7 @@ class Rig: pb[t][name] = 1.0 prop = rna_idprop_ui_prop_get( pb[t], name, create=True ) - + prop["min"] = 0.0 prop["max"] = 2.0 prop["soft_min"] = 0.0 @@ -365,13 +365,13 @@ class Rig: var.targets[0].id = self.obj var.targets[0].data_path = pb[tweaks[d]].path_from_id() + \ '[' + '"' + name + '"' + ']' - + return def_bones - - + + def create_ik( self, parent ): org_bones = self.org_bones - + bpy.ops.object.mode_set(mode ='EDIT') eb = self.obj.data.edit_bones @@ -387,7 +387,7 @@ class Rig: # Create MCH Stretch mch_str = copy_bone( - self.obj, + self.obj, org_bones[0], get_bone_name( org_bones[0], 'mch', 'ik_stretch' ) ) @@ -396,13 +396,13 @@ class Rig: eb[ mch_str ].tail = eb[ org_bones[-1] ].head else: eb[ mch_str ].tail = eb[ org_bones[-2] ].head - + # Parenting eb[ ctrl ].parent = eb[ parent ] eb[ mch_str ].parent = eb[ parent ] eb[ mch_ik ].parent = eb[ ctrl ] - - + + make_constraint( self, mch_ik, { 'constraint' : 'IK', 'subtarget' : mch_target, @@ -421,13 +421,13 @@ class Rig: # Locks and Widget pb[ ctrl ].lock_rotation = True, False, True create_ikarrow_widget( self.obj, ctrl, bone_transform_name=None ) - - return { 'ctrl' : { 'limb' : ctrl }, - 'mch_ik' : mch_ik, + + return { 'ctrl' : { 'limb' : ctrl }, + 'mch_ik' : mch_ik, 'mch_target' : mch_target, 'mch_str' : mch_str } - + def create_fk( self, parent ): org_bones = self.org_bones.copy() @@ -438,19 +438,19 @@ class Rig: bpy.ops.object.mode_set(mode ='EDIT') eb = self.obj.data.edit_bones - ctrls = [] + ctrls = [] for o in org_bones: bone = copy_bone( self.obj, o, get_bone_name( o, 'ctrl', 'fk' ) ) ctrls.append( bone ) - + # MCH - mch = copy_bone( + mch = copy_bone( self.obj, org_bones[-1], get_bone_name( o, 'mch', 'fk' ) ) eb[ mch ].length /= 4 - + # Parenting eb[ ctrls[0] ].parent = eb[ parent ] eb[ ctrls[1] ].parent = eb[ ctrls[0] ] @@ -464,7 +464,7 @@ class Rig: 'constraint' : 'COPY_SCALE', 'subtarget' : 'root' }) - + # Locks and widgets pb = self.obj.pose.bones pb[ ctrls[2] ].lock_location = True, True, True @@ -479,7 +479,7 @@ class Rig: pb[c].bone.layers = self.fk_layers return { 'ctrl' : ctrls, 'mch' : mch } - + def org_parenting_and_switch( self, org, ik, fk, parent ): bpy.ops.object.mode_set(mode ='EDIT') @@ -517,11 +517,11 @@ class Rig: 'constraint' : 'COPY_TRANSFORMS', 'subtarget' : f }) - + # Add driver to relevant constraint drv = pb[o].constraints[-1].driver_add("influence").driver drv.type = 'AVERAGE' - + var = drv.variables.new() var.name = prop.name var.type = "SINGLE_PROP" @@ -547,48 +547,48 @@ class Rig: for bone in self.org_bones[1:]: eb[bone].use_connect = False eb[bone].parent = None - + bones = {} # Create mch limb parent bones['parent'] = self.create_parent() - bones['tweak'] = self.create_tweak() + bones['tweak'] = self.create_tweak() bones['def'] = self.create_def( bones['tweak']['ctrl'] ) bones['ik'] = self.create_ik( bones['parent'] ) bones['fk'] = self.create_fk( bones['parent'] ) - self.org_parenting_and_switch( - self.org_bones, bones['ik'], bones['fk']['ctrl'], bones['parent'] + self.org_parenting_and_switch( + self.org_bones, bones['ik'], bones['fk']['ctrl'], bones['parent'] ) bones = self.create_terminal( self.limb_type, bones ) - + return [ create_script( bones, self.limb_type ) ] - + def add_parameters( params ): """ Add the parameters of this rig type to the RigifyParameters PropertyGroup """ items = [ - ('arm', 'Arm', ''), - ('leg', 'Leg', ''), + ('arm', 'Arm', ''), + ('leg', 'Leg', ''), ('paw', 'Paw', '') ] params.limb_type = bpy.props.EnumProperty( - items = items, - name = "Limb Type", + items = items, + name = "Limb Type", default = 'arm' ) items = [ - ('x', 'X', ''), - ('y', 'Y', ''), + ('x', 'X', ''), + ('y', 'Y', ''), ('z', 'Z', '') ] params.rotation_axis = bpy.props.EnumProperty( - items = items, - name = "Rotation Axis", + items = items, + name = "Rotation Axis", default = 'x' ) @@ -598,7 +598,7 @@ def add_parameters( params ): min = 1, description = 'Number of segments' ) - + params.bbones = bpy.props.IntProperty( name = 'bbone segments', default = 10, @@ -607,9 +607,9 @@ def add_parameters( params ): ) # Setting up extra layers for the FK and tweak - params.tweak_extra_layers = bpy.props.BoolProperty( - name = "tweak_extra_layers", - default = True, + params.tweak_extra_layers = bpy.props.BoolProperty( + name = "tweak_extra_layers", + default = True, description = "" ) @@ -618,11 +618,11 @@ def add_parameters( params ): description = "Layers for the tweak controls to be on", default = tuple( [ i == 1 for i in range(0, 32) ] ) ) - + # Setting up extra layers for the FK and tweak - params.fk_extra_layers = bpy.props.BoolProperty( - name = "fk_extra_layers", - default = True, + params.fk_extra_layers = bpy.props.BoolProperty( + name = "fk_extra_layers", + default = True, description = "" ) @@ -638,7 +638,7 @@ def parameters_ui(layout, params): r = layout.row() r.prop(params, "limb_type") - + r = layout.row() r.prop(params, "rotation_axis") @@ -652,7 +652,7 @@ def parameters_ui(layout, params): r = layout.row() r.prop(params, layer + "_extra_layers") r.active = params.tweak_extra_layers - + col = r.column(align=True) row = col.row(align=True) @@ -716,7 +716,7 @@ def create_sample(obj): except AttributeError: pass try: - pbone.rigify_parameters.ik_layers = [ + pbone.rigify_parameters.ik_layers = [ False, False, False, False, False, False, False, False, True, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, diff --git a/rigify/rigs/pitchipoy/limbs/ui.py b/rigify/rigs/pitchipoy/limbs/ui.py index 37921dc0..a7ed95a7 100644 --- a/rigify/rigs/pitchipoy/limbs/ui.py +++ b/rigify/rigs/pitchipoy/limbs/ui.py @@ -29,15 +29,15 @@ if is_selected( controls ): for t in tweaks: if is_selected( t ): layout.prop( pose_bones[ t ], '["%s"]', slider = True ) - + # IK Stretch on IK Control bone if is_selected( ik_ctrl ): layout.prop( pose_bones[ parent ], '["%s"]', slider = True ) - + # FK limb follow if is_selected( fk_ctrl ): layout.prop( pose_bones[ parent ], '["%s"]', slider = True ) -""" +""" script_leg = """ controls = [%s] @@ -95,8 +95,8 @@ def create_script( bones, limb_type=None): # All tweaks have their own bbone prop tweaks = bones['tweak']['ctrl'][1:-1] tweaks_string = ", ".join(["'" + x + "'" for x in tweaks]) - - # IK ctrl has IK stretch + + # IK ctrl has IK stretch ik_ctrl = [ bones['ik']['ctrl']['terminal'][-1] ] ik_ctrl += [ bones['ik']['mch_ik'] ] ik_ctrl += [ bones['ik']['mch_target'] ] diff --git a/rigify/rigs/pitchipoy/simple_tentacle.py b/rigify/rigs/pitchipoy/simple_tentacle.py index 4edb15e6..9351a659 100644 --- a/rigify/rigs/pitchipoy/simple_tentacle.py +++ b/rigify/rigs/pitchipoy/simple_tentacle.py @@ -7,27 +7,27 @@ from ...utils import MetarigError from rna_prop_ui import rna_idprop_ui_prop_get class Rig: - + def __init__(self, obj, bone_name, params): self.obj = obj self.org_bones = [bone_name] + connected_children_names(obj, bone_name) self.params = params self.copy_rotaion_axes = params.copy_rotaion_axes - + if params.tweak_extra_layers: self.tweak_layers = list( params.tweak_layers ) else: self.tweak_layers = None - + if len(self.org_bones) <= 1: raise MetarigError( "RIGIFY ERROR: invalid rig structure" % (strip_org(bone_name)) ) - + def make_controls( self ): - + bpy.ops.object.mode_set(mode ='EDIT') org_bones = self.org_bones @@ -36,8 +36,8 @@ class Rig: name = org_bones[i] ctrl_bone = copy_bone( - self.obj, - name, + self.obj, + name, strip_org(name) ) @@ -48,12 +48,12 @@ class Rig: for ctrl in ctrl_chain: create_circle_widget(self.obj, ctrl, radius=0.3, head_tail=0.5) - + return ctrl_chain def make_tweaks( self ): - + bpy.ops.object.mode_set(mode ='EDIT') eb = self.obj.data.edit_bones org_bones = self.org_bones @@ -67,19 +67,19 @@ class Rig: name = org_bones[i] tweak_bone = copy_bone( - self.obj, - name, + self.obj, + name, "tweak_" + strip_org(name) ) tweak_e = eb[ tweak_bone ] - + tweak_e.length /= 2 # Set size to half - + if i == len( org_bones ): # Position final tweak at the tip put_bone( self.obj, tweak_bone, eb[ org_bones[-1]].tail ) - + tweak_chain.append( tweak_bone ) # Make widgets @@ -102,12 +102,12 @@ class Rig: # Set up tweak bone layers if self.tweak_layers: tweak_pb.bone.layers = self.tweak_layers - - return tweak_chain + + return tweak_chain def make_deform( self ): - + bpy.ops.object.mode_set(mode ='EDIT') org_bones = self.org_bones @@ -116,18 +116,18 @@ class Rig: name = org_bones[i] def_bone = copy_bone( - self.obj, - name, + self.obj, + name, make_deformer_name(strip_org(name)) ) def_chain.append( def_bone ) - + return def_chain def parent_bones( self, all_bones ): - + bpy.ops.object.mode_set(mode ='EDIT') org_bones = self.org_bones eb = self.obj.data.edit_bones @@ -136,7 +136,7 @@ class Rig: for bone in all_bones['control'][1:]: previous_index = all_bones['control'].index( bone ) - 1 eb[ bone ].parent = eb[ all_bones['control'][previous_index] ] - + # Parent tweak bones tweaks = all_bones['tweak'] for tweak in all_bones['tweak']: @@ -145,7 +145,7 @@ class Rig: parent = all_bones['control'][ -1 ] else: parent = all_bones['control'][ tweaks.index( tweak ) ] - + eb[ tweak ].parent = eb[ parent ] # Parent deform bones @@ -157,15 +157,15 @@ class Rig: # Parent org bones ( to tweaks by default, or to the controls ) for org, tweak in zip( org_bones, all_bones['tweak'] ): - eb[ org ].parent = eb[ tweak ] - - + eb[ org ].parent = eb[ tweak ] + + def make_constraints( self, all_bones ): - + bpy.ops.object.mode_set(mode ='OBJECT') org_bones = self.org_bones pb = self.obj.pose.bones - + # Deform bones' constraints ctrls = all_bones['control'] tweaks = all_bones['tweak' ] @@ -175,15 +175,15 @@ class Rig: con = pb[deform].constraints.new('COPY_TRANSFORMS') con.target = self.obj con.subtarget = tweak - + con = pb[deform].constraints.new('DAMPED_TRACK') con.target = self.obj con.subtarget = tweaks[ tweaks.index( tweak ) + 1 ] - + con = pb[deform].constraints.new('STRETCH_TO') con.target = self.obj con.subtarget = tweaks[ tweaks.index( tweak ) + 1 ] - + # Control bones' constraints if ctrl != ctrls[0]: con = pb[ctrl].constraints.new('COPY_ROTATION') @@ -198,7 +198,7 @@ class Rig: con.target_space = 'LOCAL' con.owner_space = 'LOCAL' - + def generate(self): bpy.ops.object.mode_set(mode ='EDIT') @@ -208,7 +208,7 @@ class Rig: for bone in self.org_bones: # eb[ bone ].parent = None eb[ bone ].use_connect = False - + # Creating all bones ctrl_chain = self.make_controls() tweak_chain = self.make_tweaks() @@ -219,7 +219,7 @@ class Rig: 'tweak' : tweak_chain, 'deform' : def_chain } - + self.make_constraints( all_bones ) self.parent_bones( all_bones ) @@ -233,10 +233,10 @@ def add_parameters(params): description = "Layers for the tweak controls to be on", default = tuple( [ i == 0 for i in range(0, 3) ] ) ) - + # Setting up extra tweak layers - params.tweak_extra_layers = bpy.props.BoolProperty( - name = "tweak_extra_layers", + params.tweak_extra_layers = bpy.props.BoolProperty( + name = "tweak_extra_layers", default = True, description = "" ) @@ -261,7 +261,7 @@ def parameters_ui(layout, params): r = layout.row() r.prop(params, "tweak_extra_layers") r.active = params.tweak_extra_layers - + col = r.column(align=True) row = col.row(align=True) @@ -271,19 +271,19 @@ def parameters_ui(layout, params): row = col.row(align=True) for i in range( 16, 24 ): # Layers 16-23 - row.prop(params, "tweak_layers", index=i, toggle=True, text="") - + row.prop(params, "tweak_layers", index=i, toggle=True, text="") + col = r.column(align=True) row = col.row(align=True) for i in range( 8, 16 ): # Layers 8-15 - row.prop(params, "tweak_layers", index=i, toggle=True, text="") + row.prop(params, "tweak_layers", index=i, toggle=True, text="") row = col.row(align=True) for i in range( 24, 32 ): # Layers 24-31 row.prop(params, "tweak_layers", index=i, toggle=True, text="") - + def create_sample(obj): # generated by rigify.utils.write_metarig bpy.ops.object.mode_set(mode='EDIT') @@ -297,7 +297,7 @@ def create_sample(obj): bone.roll = 0.0000 bone.use_connect = False bones['Bone'] = bone.name - + bone = arm.edit_bones.new('Bone.002') bone.head[:] = 0.0000, 0.0000, 0.3333 bone.tail[:] = 0.0000, 0.0000, 0.6667 @@ -305,7 +305,7 @@ def create_sample(obj): bone.use_connect = True bone.parent = arm.edit_bones[bones['Bone']] bones['Bone.002'] = bone.name - + bone = arm.edit_bones.new('Bone.001') bone.head[:] = 0.0000, 0.0000, 0.6667 bone.tail[:] = 0.0000, 0.0000, 1.0000 @@ -313,7 +313,7 @@ def create_sample(obj): bone.use_connect = True bone.parent = arm.edit_bones[bones['Bone.002']] bones['Bone.001'] = bone.name - + bpy.ops.object.mode_set(mode='OBJECT') pbone = obj.pose.bones[bones['Bone']] pbone.rigify_type = 'pitchipoy.simple_tentacle' diff --git a/rigify/rigs/pitchipoy/super_copy.py b/rigify/rigs/pitchipoy/super_copy.py index d05d68c4..27e88775 100644 --- a/rigify/rigs/pitchipoy/super_copy.py +++ b/rigify/rigs/pitchipoy/super_copy.py @@ -91,22 +91,22 @@ def add_parameters(params): """ Add the parameters of this rig type to the RigifyParameters PropertyGroup """ - params.make_control = bpy.props.BoolProperty( - name = "Control", - default = True, - description = "Create a control bone for the copy" + params.make_control = bpy.props.BoolProperty( + name = "Control", + default = True, + description = "Create a control bone for the copy" ) - params.make_widget = bpy.props.BoolProperty( - name = "Widget", - default = True, - description = "Choose a widget for the bone control" + params.make_widget = bpy.props.BoolProperty( + name = "Widget", + default = True, + description = "Choose a widget for the bone control" ) - params.make_deform = bpy.props.BoolProperty( - name = "Deform", - default = True, - description = "Create a deform bone for the copy" + params.make_deform = bpy.props.BoolProperty( + name = "Deform", + default = True, + description = "Create a deform bone for the copy" ) diff --git a/rigify/rigs/pitchipoy/super_face.py b/rigify/rigs/pitchipoy/super_face.py index 6ed7eba0..341596a1 100755 --- a/rigify/rigs/pitchipoy/super_face.py +++ b/rigify/rigs/pitchipoy/super_face.py @@ -18,17 +18,17 @@ if is_selected(all_controls): layout.prop(pose_bones[eyes_ctrl_name], '["%s"]', slider=True) """ class Rig: - + def __init__(self, obj, bone_name, params): self.obj = obj b = self.obj.data.bones - children = [ - "nose", "lip.T.L", "lip.B.L", "jaw", "ear.L", "ear.R", "lip.T.R", - "lip.B.R", "brow.B.L", "lid.T.L", "brow.B.R", "lid.T.R", + children = [ + "nose", "lip.T.L", "lip.B.L", "jaw", "ear.L", "ear.R", "lip.T.R", + "lip.B.R", "brow.B.L", "lid.T.L", "brow.B.R", "lid.T.R", "forehead.L", "forehead.R", "forehead.L.001", "forehead.R.001", - "forehead.L.002", "forehead.R.002", "eye.L", "eye.R", "cheek.T.L", + "forehead.L.002", "forehead.R.002", "eye.L", "eye.R", "cheek.T.L", "cheek.T.R", "teeth.T", "teeth.B", "tongue", "temple.L", "temple.R" ] @@ -40,7 +40,7 @@ class Rig: for child in children: grand_children += connected_children_names( self.obj, child ) - + self.org_bones = [bone_name] + children + grand_children self.face_length = obj.data.edit_bones[ self.org_bones[0] ].length self.params = params @@ -58,22 +58,22 @@ class Rig: def symmetrical_split( self, bones ): # RE pattern match right or left parts - # match the letter "L" (or "R"), followed by an optional dot (".") + # match the letter "L" (or "R"), followed by an optional dot (".") # and 0 or more digits at the end of the the string - left_pattern = 'L\.?\d*$' + left_pattern = 'L\.?\d*$' right_pattern = 'R\.?\d*$' left = sorted( [ name for name in bones if re.search( left_pattern, name ) ] ) - right = sorted( [ name for name in bones if re.search( right_pattern, name ) ] ) + right = sorted( [ name for name in bones if re.search( right_pattern, name ) ] ) return left, right - + def create_deformation( self ): org_bones = self.org_bones - + bpy.ops.object.mode_set(mode ='EDIT') eb = self.obj.data.edit_bones - + def_bones = [] for org in org_bones: if 'face' in org or 'teeth' in org or 'eye' in org: @@ -97,12 +97,12 @@ class Rig: brow_left.reverse() brow_right.reverse() - for browL, browR, foreheadL, foreheadR in zip( + for browL, browR, foreheadL, foreheadR in zip( brow_left, brow_right, forehead_left, forehead_right ): eb[foreheadL].tail = eb[browL].head eb[foreheadR].tail = eb[browR].head - + return { 'all' : def_bones } @@ -112,53 +112,53 @@ class Rig: ## create control bones bpy.ops.object.mode_set(mode ='EDIT') eb = self.obj.data.edit_bones - + # eyes ctrls eyeL_e = eb[ bones['eyes'][0] ] eyeR_e = eb[ bones['eyes'][1] ] - + distance = ( eyeL_e.head - eyeR_e.head ) * 3 distance = distance.cross( (0, 0, 1) ) eye_length = eyeL_e.length eyeL_ctrl_name = strip_org( bones['eyes'][0] ) eyeR_ctrl_name = strip_org( bones['eyes'][1] ) - + eyeL_ctrl_name = copy_bone( self.obj, bones['eyes'][0], eyeL_ctrl_name ) eyeR_ctrl_name = copy_bone( self.obj, bones['eyes'][1], eyeR_ctrl_name ) eyes_ctrl_name = copy_bone( self.obj, bones['eyes'][0], 'eyes' ) - + eyeL_ctrl_e = eb[ eyeL_ctrl_name ] eyeR_ctrl_e = eb[ eyeR_ctrl_name ] eyes_ctrl_e = eb[ 'eyes' ] - + eyeL_ctrl_e.head += distance eyeR_ctrl_e.head += distance eyes_ctrl_e.head[:] = ( eyeL_ctrl_e.head + eyeR_ctrl_e.head ) / 2 - + for bone in [ eyeL_ctrl_e, eyeR_ctrl_e, eyes_ctrl_e ]: bone.tail[:] = bone.head + Vector( [ 0, 0, eye_length * 0.75 ] ) ## Widget for transforming the both eyes eye_master_names = [] for bone in bones['eyes']: - eye_master = copy_bone( - self.obj, - bone, + eye_master = copy_bone( + self.obj, + bone, 'master_' + strip_org(bone) ) eye_master_names.append( eye_master ) - + ## turbo: adding a master nose for transforming the whole nose master_nose = copy_bone(self.obj, 'ORG-nose.004', 'nose_master') eb[master_nose].tail[:] = \ eb[master_nose].head + Vector([0, self.face_length / -4, 0]) - + # ears ctrls earL_name = strip_org( bones['ears'][0] ) earR_name = strip_org( bones['ears'][1] ) - + earL_ctrl_name = copy_bone( self.obj, org( bones['ears'][0] ), earL_name ) earR_ctrl_name = copy_bone( self.obj, org( bones['ears'][1] ), earR_name ) @@ -171,29 +171,29 @@ class Rig: jaw_org_e = eb[ bones['jaw'][2] ] eb[ jaw_ctrl_name ].head[:] = ( jawL_org_e.head + jawR_org_e.head ) / 2 - + # teeth ctrls teethT_name = strip_org( bones['teeth'][0] ) teethB_name = strip_org( bones['teeth'][1] ) - + teethT_ctrl_name = copy_bone( self.obj, org( bones['teeth'][0] ), teethT_name ) teethB_ctrl_name = copy_bone( self.obj, org( bones['teeth'][1] ), teethB_name ) - + # tongue ctrl tongue_org = bones['tongue'].pop() tongue_name = strip_org( tongue_org ) + '_master' - + tongue_ctrl_name = copy_bone( self.obj, tongue_org, tongue_name ) - + flip_bone( self.obj, tongue_ctrl_name ) - + ## Assign widgets bpy.ops.object.mode_set(mode ='OBJECT') - + # Assign each eye widgets create_eye_widget( self.obj, eyeL_ctrl_name ) create_eye_widget( self.obj, eyeR_ctrl_name ) - + # Assign eyes widgets create_eyes_widget( self.obj, eyes_ctrl_name ) @@ -203,25 +203,25 @@ class Rig: # Assign nose_master widget create_square_widget( self.obj, master_nose, size = 1 ) - + # Assign ears widget create_ear_widget( self.obj, earL_ctrl_name ) create_ear_widget( self.obj, earR_ctrl_name ) # Assign jaw widget create_jaw_widget( self.obj, jaw_ctrl_name ) - + # Assign teeth widget create_teeth_widget( self.obj, teethT_ctrl_name ) create_teeth_widget( self.obj, teethB_ctrl_name ) - + # Assign tongue widget ( using the jaw widget ) create_jaw_widget( self.obj, tongue_ctrl_name ) - return { - 'eyes' : [ - eyeL_ctrl_name, - eyeR_ctrl_name, + return { + 'eyes' : [ + eyeL_ctrl_name, + eyeR_ctrl_name, eyes_ctrl_name, ] + eye_master_names, 'ears' : [ earL_ctrl_name, earR_ctrl_name ], @@ -230,7 +230,7 @@ class Rig: 'tongue' : [ tongue_ctrl_name ], 'nose' : [ master_nose ] } - + def create_tweak( self, bones, uniques, tails ): org_bones = self.org_bones @@ -240,7 +240,7 @@ class Rig: eb = self.obj.data.edit_bones tweaks = [] - + for bone in bones + list( uniques.keys() ): tweak_name = strip_org( bone ) @@ -273,21 +273,21 @@ class Rig: eb[ tweak_name ].head = eb[ bone ].tail eb[ tweak_name ].tail[:] = \ eb[ tweak_name ].head + Vector(( 0, 0, self.face_length / 7 )) - + tweaks.append( tweak_name ) - + bpy.ops.object.mode_set(mode ='OBJECT') pb = self.obj.pose.bones - + primary_tweaks = [ - "lid.B.L.002", "lid.T.L.002", "lid.B.R.002", "lid.T.R.002", - "chin", "brow.T.L.001", "brow.T.L.002", "brow.T.L.003", - "brow.T.R.001", "brow.T.R.002", "brow.T.R.003", "lip.B", - "lip.B.L.001", "lip.B.R.001", "cheek.B.L.001", "cheek.B.R.001", - "lips.L", "lips.R", "lip.T.L.001", "lip.T.R.001", "lip.T", + "lid.B.L.002", "lid.T.L.002", "lid.B.R.002", "lid.T.R.002", + "chin", "brow.T.L.001", "brow.T.L.002", "brow.T.L.003", + "brow.T.R.001", "brow.T.R.002", "brow.T.R.003", "lip.B", + "lip.B.L.001", "lip.B.R.001", "cheek.B.L.001", "cheek.B.R.001", + "lips.L", "lips.R", "lip.T.L.001", "lip.T.R.001", "lip.T", "nose.002", "nose.L.001", "nose.R.001" ] - + for bone in tweaks: if bone in primary_tweaks: if self.primary_layers: @@ -297,7 +297,7 @@ class Rig: if self.secondary_layers: pb[bone].bone.layers = self.secondary_layers create_face_widget( self.obj, bone ) - + return { 'all' : tweaks } @@ -322,20 +322,20 @@ class Rig: tweak_exceptions = [] # bones not used to create tweaks tweak_exceptions += [ bone for bone in org_bones if 'forehead' in bone or 'temple' in bone ] - - tweak_tail = [ 'brow.B.L.003', 'brow.B.R.003', 'nose.004', 'chin.001' ] - tweak_tail += [ 'lip.T.L.001', 'lip.T.R.001', 'tongue.002' ] + + tweak_tail = [ 'brow.B.L.003', 'brow.B.R.003', 'nose.004', 'chin.001' ] + tweak_tail += [ 'lip.T.L.001', 'lip.T.R.001', 'tongue.002' ] tweak_exceptions += [ 'lip.T.R', 'lip.B.R', 'ear.L.001', 'ear.R.001' ] + list(tweak_unique.keys()) tweak_exceptions += [ 'face', 'cheek.T.L', 'cheek.T.R', 'cheek.B.L', 'cheek.B.R' ] tweak_exceptions += [ 'ear.L', 'ear.R', 'eye.L', 'eye.R' ] - - tweak_exceptions += org_to_ctrls.keys() + + tweak_exceptions += org_to_ctrls.keys() tweak_exceptions += org_to_ctrls['teeth'] - + tweak_exceptions.pop( tweak_exceptions.index('tongue') ) tweak_exceptions.pop( tweak_exceptions.index('jaw') ) - + tweak_exceptions = [ org( bone ) for bone in tweak_exceptions ] tweak_tail = [ org( bone ) for bone in tweak_tail ] @@ -343,14 +343,14 @@ class Rig: ctrls = self.create_ctrl( org_to_ctrls ) tweaks = self.create_tweak( org_to_tweak, tweak_unique, tweak_tail ) - + return { 'ctrls' : ctrls, 'tweaks' : tweaks }, tweak_unique def create_mch( self, jaw_ctrl, tongue_ctrl ): org_bones = self.org_bones bpy.ops.object.mode_set(mode ='EDIT') eb = self.obj.data.edit_bones - + # Create eyes mch bones eyes = [ bone for bone in org_bones if 'eye' in bone ] @@ -372,24 +372,24 @@ class Rig: eb[ mch_name ].head[:] = eb[ mch_name ].tail eb[ mch_name ].tail[:] = eb[ mch_name ].head + Vector( ( 0, 0, 0.005 ) ) - + # Create the eyes' parent mch face = [ bone for bone in org_bones if 'face' in bone ].pop() - + mch_name = 'eyes_parent' mch_name = make_mechanism_name( mch_name ) mch_name = copy_bone( self.obj, face, mch_name ) eb[ mch_name ].use_connect = False eb[ mch_name ].parent = None - + eb[ mch_name ].length /= 4 mch_bones['eyes_parent'] = [ mch_name ] - + # Create the lids' mch bones all_lids = [ bone for bone in org_bones if 'lid' in bone ] lids_L, lids_R = self.symmetrical_split( all_lids ) - + all_lids = [ lids_L, lids_R ] mch_bones['lids'] = [] @@ -403,11 +403,11 @@ class Rig: eb[ mch_name ].parent = None eb[ mch_name ].tail[:] = eb[ bone ].head - - mch_bones['lids'].append( mch_name ) - + + mch_bones['lids'].append( mch_name ) + mch_bones['jaw'] = [] - + length_subtractor = eb[ jaw_ctrl ].length / 6 # Create the jaw mch bones for i in range( 6 ): @@ -426,9 +426,9 @@ class Rig: mch_bones['jaw'].append( mch_name ) # Tongue mch bones - + mch_bones['tongue'] = [] - + # create mch bones for all tongue org_bones except the first one for bone in sorted([ org for org in org_bones if 'tongue' in org ])[1:]: mch_name = make_mechanism_name( strip_org( bone ) ) @@ -436,18 +436,18 @@ class Rig: eb[ mch_name ].use_connect = False eb[ mch_name ].parent = None - + mch_bones['tongue'].append( mch_name ) - + return mch_bones - + def parent_bones( self, all_bones, tweak_unique ): org_bones = self.org_bones bpy.ops.object.mode_set(mode ='EDIT') eb = self.obj.data.edit_bones - + face_name = [ bone for bone in org_bones if 'face' in bone ].pop() - + # Initially parenting all bones to the face org bone. for category in list( all_bones.keys() ): for area in list( all_bones[category] ): @@ -455,7 +455,7 @@ class Rig: eb[ bone ].parent = eb[ face_name ] ## Parenting all deformation bones and org bones - + # Parent all the deformation bones that have respective tweaks def_tweaks = [ bone for bone in all_bones['deform']['all'] if bone[4:] in all_bones['tweaks']['all'] ] @@ -464,10 +464,10 @@ class Rig: eb[ bone ].parent = eb[ org('face') ] for bone in def_tweaks: - # the def and the matching org bone are parented to their corresponding tweak, + # the def and the matching org bone are parented to their corresponding tweak, # whose name is the same as that of the def bone, without the "DEF-" (first 4 chars) eb[ bone ].parent = eb[ bone[4:] ] - eb[ org( bone[4:] ) ].parent = eb[ bone[4:] ] + eb[ org( bone[4:] ) ].parent = eb[ bone[4:] ] # Parent ORG eyes to corresponding mch bones for bone in [ bone for bone in org_bones if 'eye' in bone ]: @@ -478,10 +478,10 @@ class Rig: # example: 'lip.B' matches 'DEF-lip.B.R' and 'DEF-lip.B.L' if # you cut off the "DEF-" [4:] and the ".L" or ".R" [:-2] lip_defs = [ bone for bone in all_bones['deform']['all'] if bone[4:-2] == lip_tweak ] - + for bone in lip_defs: eb[bone].parent = eb[ lip_tweak ] - + # parent cheek bones top respetive tweaks lips = [ 'lips.L', 'lips.R' ] brows = [ 'brow.T.L', 'brow.T.R' ] @@ -491,11 +491,11 @@ class Rig: for lip, brow, cheekB, cheekT in zip( lips, brows, cheekB_defs, cheekT_defs ): eb[ cheekB ].parent = eb[ lip ] eb[ cheekT ].parent = eb[ brow ] - + # parent ear deform bones to their controls ear_defs = [ 'DEF-ear.L', 'DEF-ear.L.001', 'DEF-ear.R', 'DEF-ear.R.001' ] ear_ctrls = [ 'ear.L', 'ear.R' ] - + eb[ 'DEF-jaw' ].parent = eb[ 'jaw' ] # Parent jaw def bone to jaw tweak for ear_ctrl in ear_ctrls: @@ -505,30 +505,30 @@ class Rig: # Parent eyelid deform bones (each lid def bone is parented to its respective MCH bone) def_lids = [ bone for bone in all_bones['deform']['all'] if 'lid' in bone ] - + for bone in def_lids: mch = make_mechanism_name( bone[4:] ) eb[ bone ].parent = eb[ mch ] - + ## Parenting all mch bones - + eb[ 'MCH-eyes_parent' ].parent = None # eyes_parent will be parented to root - + # parent all mch tongue bones to the jaw master control bone for bone in all_bones['mch']['tongue']: eb[ bone ].parent = eb[ all_bones['ctrls']['jaw'][0] ] ## Parenting the control bones - + # parent teeth.B and tongue master controls to the jaw master control bone for bone in [ 'teeth.B', 'tongue_master' ]: eb[ bone ].parent = eb[ all_bones['ctrls']['jaw'][0] ] # eyes eb[ 'eyes' ].parent = eb[ 'MCH-eyes_parent' ] - - eyes = [ - bone for bone in all_bones['ctrls']['eyes'] if 'eyes' not in bone + + eyes = [ + bone for bone in all_bones['ctrls']['eyes'] if 'eyes' not in bone ][0:2] for eye in eyes: @@ -539,17 +539,17 @@ class Rig: eb[ eye_master ].parent = eb[ 'ORG-face' ] # Parent brow.b, eyes mch and lid tweaks and mch bones to masters - tweaks = [ + tweaks = [ b for b in all_bones['tweaks']['all'] if 'lid' in b or 'brow.B' in b ] mch = all_bones['mch']['lids'] + \ all_bones['mch']['eye.R'] + \ all_bones['mch']['eye.L'] - + everyone = tweaks + mch - + left, right = self.symmetrical_split( everyone ) - + for l in left: eb[ l ].parent = eb[ 'master_eye.L' ] @@ -557,7 +557,7 @@ class Rig: eb[ r ].parent = eb[ 'master_eye.R' ] ## turbo: nose to mch jaw.004 - eb[ all_bones['ctrls']['nose'].pop() ].parent = eb['MCH-jaw_master.004'] + eb[ all_bones['ctrls']['nose'].pop() ].parent = eb['MCH-jaw_master.004'] ## Parenting the tweak bones @@ -600,12 +600,12 @@ class Rig: 'nose.L.001', 'nose.R.001' ] - } - + } + for parent in list( groups.keys() ): for bone in groups[parent]: eb[ bone ].parent = eb[ parent ] - + # Remaining arbitrary relatioships for tweak bone parenting eb[ 'chin.001' ].parent = eb[ 'chin' ] eb[ 'chin.002' ].parent = eb[ 'lip.B' ] @@ -620,14 +620,14 @@ class Rig: eb[ bone ].parent = eb[ 'ear.L' ] eb[ bone.replace( '.L', '.R' ) ].parent = eb[ 'ear.R' ] - + def make_constraits( self, constraint_type, bone, subtarget, influence = 1 ): org_bones = self.org_bones bpy.ops.object.mode_set(mode ='OBJECT') pb = self.obj.pose.bones owner_pb = pb[bone] - + if constraint_type == 'def_tweak': const = owner_pb.constraints.new( 'DAMPED_TRACK' ) @@ -649,28 +649,28 @@ class Rig: const.target = self.obj const.subtarget = subtarget const.head_tail = 1.0 - + elif constraint_type == 'mch_eyes': - + const = owner_pb.constraints.new( 'DAMPED_TRACK' ) const.target = self.obj const.subtarget = subtarget - + elif constraint_type == 'mch_eyes_lids_follow': const = owner_pb.constraints.new( 'COPY_LOCATION' ) const.target = self.obj const.subtarget = subtarget const.head_tail = 1.0 - + elif constraint_type == 'mch_eyes_parent': - + const = owner_pb.constraints.new( 'COPY_TRANSFORMS' ) const.target = self.obj const.subtarget = subtarget - + elif constraint_type == 'mch_jaw_master': - + const = owner_pb.constraints.new( 'COPY_TRANSFORMS' ) const.target = self.obj const.subtarget = subtarget @@ -682,9 +682,9 @@ class Rig: const.target = self.obj const.subtarget = subtarget const.influence = influence - + elif constraint_type == 'tweak_copyloc': - + const = owner_pb.constraints.new( 'COPY_LOCATION' ) const.target = self.obj const.subtarget = subtarget @@ -692,25 +692,25 @@ class Rig: const.use_offset = True const.target_space = 'LOCAL' const.owner_space = 'LOCAL' - + elif constraint_type == 'tweak_copy_rot_scl': - + const = owner_pb.constraints.new( 'COPY_ROTATION' ) const.target = self.obj const.subtarget = subtarget const.use_offset = True const.target_space = 'LOCAL' const.owner_space = 'LOCAL' - + const = owner_pb.constraints.new( 'COPY_SCALE' ) const.target = self.obj const.subtarget = subtarget const.use_offset = True const.target_space = 'LOCAL' const.owner_space = 'LOCAL' - + elif constraint_type == 'tweak_copyloc_inv': - + const = owner_pb.constraints.new( 'COPY_LOCATION' ) const.target = self.obj const.subtarget = subtarget @@ -721,18 +721,18 @@ class Rig: const.invert_x = True const.invert_y = True const.invert_z = True - + elif constraint_type == 'mch_tongue_copy_trans': - + const = owner_pb.constraints.new( 'COPY_TRANSFORMS' ) const.target = self.obj const.subtarget = subtarget const.influence = influence - + def constraints( self, all_bones ): ## Def bone constraints - + def_specials = { # 'bone' : 'target' 'DEF-jaw' : 'chin', @@ -780,42 +780,42 @@ class Rig: else: tweak = "".join( matches ) + ".001" self.make_constraits('def_tweak', bone, tweak ) - + def_lids = sorted( [ bone for bone in all_bones['deform']['all'] if 'lid' in bone ] ) mch_lids = sorted( [ bone for bone in all_bones['mch']['lids'] ] ) - + def_lidsL, def_lidsR = self.symmetrical_split( def_lids ) mch_lidsL, mch_lidsR = self.symmetrical_split( mch_lids ) # Take the last mch_lid bone and place it at the end mch_lidsL = mch_lidsL[1:] + [ mch_lidsL[0] ] mch_lidsR = mch_lidsR[1:] + [ mch_lidsR[0] ] - + for boneL, boneR, mchL, mchR in zip( def_lidsL, def_lidsR, mch_lidsL, mch_lidsR ): self.make_constraits('def_lids', boneL, mchL ) self.make_constraits('def_lids', boneR, mchR ) ## MCH constraints - + # mch lids constraints for bone in all_bones['mch']['lids']: tweak = bone[4:] # remove "MCH-" from bone name self.make_constraits('mch_eyes', bone, tweak ) - + # mch eyes constraints for bone in [ 'MCH-eye.L', 'MCH-eye.R' ]: ctrl = bone[4:] # remove "MCH-" from bone name self.make_constraits('mch_eyes', bone, ctrl ) - + for bone in [ 'MCH-eye.L.001', 'MCH-eye.R.001' ]: target = bone[:-4] # remove number from the end of the name self.make_constraits('mch_eyes_lids_follow', bone, target ) - + # mch eyes parent constraints self.make_constraits('mch_eyes_parent', 'MCH-eyes_parent', 'ORG-face' ) - + ## Jaw constraints - + # jaw master mch bones self.make_constraits( 'mch_jaw_master', 'MCH-mouth_lock', 'jaw_master', 0.20 ) self.make_constraits( 'mch_jaw_master', 'MCH-jaw_master', 'jaw_master', 1.00 ) @@ -829,9 +829,9 @@ class Rig: for bone in all_bones['mch']['jaw'][1:-1]: self.make_constraits( 'mch_jaw_master', bone, 'MCH-mouth_lock' ) - + ## Tweak bones constraints - + # copy location constraints for tweak bones of both sides tweak_copyloc_L = { 'brow.T.L.002' : [ [ 'brow.T.L.001', 'brow.T.L.003' ], [ 0.5, 0.5 ] ], @@ -853,15 +853,15 @@ class Rig: 'lip.T.L.001' : [ [ 'lips.L', 'lip.T' ], [ 0.25, 0.5 ] ], 'lip.B.L.001' : [ [ 'lips.L', 'lip.B' ], [ 0.25, 0.5 ] ] } - + for owner in list( tweak_copyloc_L.keys() ): - + targets, influences = tweak_copyloc_L[owner] for target, influence in zip( targets, influences ): - # Left side constraints + # Left side constraints self.make_constraits( 'tweak_copyloc', owner, target, influence ) - + # create constraints for the right side too ownerR = owner.replace( '.L', '.R' ) targetR = target.replace( '.L', '.R' ) @@ -872,7 +872,7 @@ class Rig: 'lip.T.L.001' : 'lip.T', 'lip.B.L.001' : 'lip.B' } - + for owner in list( tweak_copy_rot_scl_L.keys() ): target = tweak_copy_rot_scl_L[owner] influence = tweak_copy_rot_scl_L[owner] @@ -881,7 +881,7 @@ class Rig: # create constraints for the right side too owner = owner.replace( '.L', '.R' ) self.make_constraits( 'tweak_copy_rot_scl', owner, target ) - + # inverted tweak bones constraints tweak_nose = { 'nose.001' : [ 'nose.002', 0.35 ], @@ -889,12 +889,12 @@ class Rig: 'nose.005' : [ 'lip.T', 0.5 ], 'chin.002' : [ 'lip.B', 0.5 ] } - + for owner in list( tweak_nose.keys() ): target = tweak_nose[owner][0] influence = tweak_nose[owner][1] self.make_constraits( 'tweak_copyloc_inv', owner, target, influence ) - + # MCH tongue constraints divider = len( all_bones['mch']['tongue'] ) + 1 factor = len( all_bones['mch']['tongue'] ) @@ -905,16 +905,16 @@ class Rig: def drivers_and_props( self, all_bones ): - + bpy.ops.object.mode_set(mode ='OBJECT') pb = self.obj.pose.bones - + jaw_ctrl = all_bones['ctrls']['jaw'][0] eyes_ctrl = all_bones['ctrls']['eyes'][2] jaw_prop = 'mouth_lock' eyes_prop = 'eyes_follow' - + for bone, prop_name in zip( [ jaw_ctrl, eyes_ctrl ], [ jaw_prop, eyes_prop ] ): if bone == jaw_ctrl: pb[ bone ][ prop_name ] = 0.0 @@ -927,33 +927,33 @@ class Rig: prop["soft_min"] = 0.0 prop["soft_max"] = 1.0 prop["description"] = prop_name - + # Jaw drivers mch_jaws = all_bones['mch']['jaw'][1:-1] - + for bone in mch_jaws: drv = pb[ bone ].constraints[1].driver_add("influence").driver drv.type='SUM' - + var = drv.variables.new() var.name = jaw_prop var.type = "SINGLE_PROP" var.targets[0].id = self.obj var.targets[0].data_path = pb[ jaw_ctrl ].path_from_id() + '['+ '"' + jaw_prop + '"' + ']' - + # Eyes driver mch_eyes_parent = all_bones['mch']['eyes_parent'][0] drv = pb[ mch_eyes_parent ].constraints[0].driver_add("influence").driver drv.type='SUM' - + var = drv.variables.new() var.name = eyes_prop var.type = "SINGLE_PROP" var.targets[0].id = self.obj var.targets[0].data_path = pb[ eyes_ctrl ].path_from_id() + '['+ '"' + eyes_prop + '"' + ']' - + return jaw_prop, eyes_prop def create_bones(self): @@ -967,58 +967,58 @@ class Rig: eb[bone].parent = None all_bones = {} - + def_names = self.create_deformation() ctrls, tweak_unique = self.all_controls() - mchs = self.create_mch( - ctrls['ctrls']['jaw'][0], - ctrls['ctrls']['tongue'][0] + mchs = self.create_mch( + ctrls['ctrls']['jaw'][0], + ctrls['ctrls']['tongue'][0] ) - return { - 'deform' : def_names, - 'ctrls' : ctrls['ctrls'], - 'tweaks' : ctrls['tweaks'], - 'mch' : mchs + return { + 'deform' : def_names, + 'ctrls' : ctrls['ctrls'], + 'tweaks' : ctrls['tweaks'], + 'mch' : mchs }, tweak_unique def generate(self): - + all_bones, tweak_unique = self.create_bones() self.parent_bones( all_bones, tweak_unique ) self.constraints( all_bones ) jaw_prop, eyes_prop = self.drivers_and_props( all_bones ) - + # Create UI all_controls = [] all_controls += [ bone for bone in [ bgroup for bgroup in [ all_bones['ctrls'][group] for group in list( all_bones['ctrls'].keys() ) ] ] ] all_controls += [ bone for bone in [ bgroup for bgroup in [ all_bones['tweaks'][group] for group in list( all_bones['tweaks'].keys() ) ] ] ] - + all_ctrls = [] for group in all_controls: for bone in group: all_ctrls.append( bone ) - + controls_string = ", ".join(["'" + x + "'" for x in all_ctrls]) return [ script % ( - controls_string, + controls_string, all_bones['ctrls']['jaw'][0], all_bones['ctrls']['eyes'][2], jaw_prop, eyes_prop ) ] - - + + def add_parameters(params): """ Add the parameters of this rig type to the RigifyParameters PropertyGroup """ #Setting up extra layers for the tweak bones - params.primary_layers_extra = bpy.props.BoolProperty( - name = "primary_layers_extra", - default = True, + params.primary_layers_extra = bpy.props.BoolProperty( + name = "primary_layers_extra", + default = True, description = "" ) params.primary_layers = bpy.props.BoolVectorProperty( @@ -1026,9 +1026,9 @@ def add_parameters(params): description = "Layers for the 1st tweak controls to be on", default = tuple( [ i == 1 for i in range(0, 32) ] ) ) - params.secondary_layers_extra = bpy.props.BoolProperty( - name = "secondary_layers_extra", - default = True, + params.secondary_layers_extra = bpy.props.BoolProperty( + name = "secondary_layers_extra", + default = True, description = "" ) params.secondary_layers = bpy.props.BoolVectorProperty( @@ -1041,12 +1041,12 @@ def add_parameters(params): def parameters_ui(layout, params): """ Create the ui for the rig parameters.""" layers = ["primary_layers", "secondary_layers"] - + for layer in layers: r = layout.row() r.prop( params, layer + "_extra" ) r.active = getattr( params, layer + "_extra" ) - + col = r.column(align=True) row = col.row(align=True) for i in range(8): @@ -1055,10 +1055,10 @@ def parameters_ui(layout, params): row = col.row(align=True) for i in range(16,24): row.prop(params, layer, index=i, toggle=True, text="") - + col = r.column(align=True) row = col.row(align=True) - + for i in range(8,16): row.prop(params, layer, index=i, toggle=True, text="") @@ -2381,10 +2381,10 @@ def create_square_widget(rig, bone_name, size=1.0, bone_transform_name=None): obj = create_widget(rig, bone_name, bone_transform_name) if obj is not None: verts = [ - ( 0.5 * size, -2.9802322387695312e-08 * size, 0.5 * size ), - ( -0.5 * size, -2.9802322387695312e-08 * size, 0.5 * size ), - ( 0.5 * size, 2.9802322387695312e-08 * size, -0.5 * size ), - ( -0.5 * size, 2.9802322387695312e-08 * size, -0.5 * size ), + ( 0.5 * size, -2.9802322387695312e-08 * size, 0.5 * size ), + ( -0.5 * size, -2.9802322387695312e-08 * size, 0.5 * size ), + ( 0.5 * size, 2.9802322387695312e-08 * size, -0.5 * size ), + ( -0.5 * size, 2.9802322387695312e-08 * size, -0.5 * size ), ] edges = [(0, 1), (2, 3), (0, 2), (3, 1) ] diff --git a/rigify/rigs/pitchipoy/super_finger.py b/rigify/rigs/pitchipoy/super_finger.py index 86733921..6a9c5f09 100644 --- a/rigify/rigs/pitchipoy/super_finger.py +++ b/rigify/rigs/pitchipoy/super_finger.py @@ -14,58 +14,58 @@ if is_selected(controls): """ class Rig: - + def __init__(self, obj, bone_name, params): self.obj = obj self.org_bones = [bone_name] + connected_children_names(obj, bone_name) self.params = params - + if len(self.org_bones) <= 1: - raise MetarigError("RIGIFY ERROR: Bone '%s': listen bro, that finger rig jusaint put tugetha rite. A little hint, use more than one bone!!" % (strip_org(bone_name))) + raise MetarigError("RIGIFY ERROR: Bone '%s': listen bro, that finger rig jusaint put tugetha rite. A little hint, use more than one bone!!" % (strip_org(bone_name))) def generate(self): org_bones = self.org_bones - + bpy.ops.object.mode_set(mode ='EDIT') eb = self.obj.data.edit_bones - + # Bone name lists ctrl_chain = [] def_chain = [] mch_chain = [] mch_drv_chain = [] - + # Create ctrl master bone org_name = self.org_bones[0] temp_name = strip_org(self.org_bones[0]) - + suffix = temp_name[-2:] master_name = temp_name[:-5] + "_master" + suffix master_name = copy_bone( self.obj, org_name, master_name ) ctrl_bone_master = eb[ master_name ] - + ## Parenting bug fix ?? ctrl_bone_master.use_connect = False ctrl_bone_master.parent = None - + ctrl_bone_master.tail += ( eb[ org_bones[-1] ].tail - eb[org_name].head ) * 1.25 for bone in org_bones: eb[bone].use_connect = False if org_bones.index( bone ) != 0: eb[bone].parent = None - + # Creating the bone chains for i in range(len(self.org_bones)): - + name = self.org_bones[i] ctrl_name = strip_org(name) - + # Create control bones ctrl_bone = copy_bone( self.obj, name, ctrl_name ) ctrl_bone_e = eb[ ctrl_name ] - + # Create deformation bones def_name = make_deformer_name( ctrl_name ) def_bone = copy_bone( self.obj, name, def_name ) @@ -73,26 +73,26 @@ class Rig: # Create mechanism bones mch_name = make_mechanism_name( ctrl_name ) mch_bone = copy_bone( self.obj, name, mch_name ) - + # Create mechanism driver bones drv_name = make_mechanism_name(ctrl_name) + "_drv" mch_bone_drv = copy_bone(self.obj, name, drv_name) mch_bone_drv_e = eb[drv_name] - + # Adding to lists ctrl_chain += [ctrl_name] - def_chain += [def_bone] + def_chain += [def_bone] mch_chain += [mch_bone] mch_drv_chain += [drv_name] - + # Restoring org chain parenting for bone in org_bones[1:]: eb[bone].parent = eb[ org_bones[ org_bones.index(bone) - 1 ] ] - + # Parenting the master bone to the first org ctrl_bone_master = eb[ master_name ] ctrl_bone_master.parent = eb[ org_bones[0] ] - + # Parenting chain bones for i in range(len(self.org_bones)): # Edit bone references @@ -100,7 +100,7 @@ class Rig: ctrl_bone_e = eb[ctrl_chain[i]] mch_bone_e = eb[mch_chain[i]] mch_bone_drv_e = eb[mch_drv_chain[i]] - + if i == 0: # First ctl bone ctrl_bone_e.parent = mch_bone_drv_e @@ -117,19 +117,19 @@ class Rig: else: # The rest ctrl_bone_e.parent = mch_bone_drv_e - ctrl_bone_e.use_connect = False - + ctrl_bone_e.use_connect = False + def_bone_e.parent = eb[def_chain[i-1]] def_bone_e.use_connect = True - + mch_bone_drv_e.parent = eb[ctrl_chain[i-1]] mch_bone_drv_e.use_connect = False # Parenting mch bone mch_bone_e.parent = ctrl_bone_e mch_bone_e.use_connect = False - - # Creating tip conrtol bone + + # Creating tip conrtol bone tip_name = copy_bone( self.obj, org_bones[-1], temp_name ) ctrl_bone_tip = eb[ tip_name ] flip_bone( self.obj, tip_name ) @@ -138,17 +138,17 @@ class Rig: ctrl_bone_tip.parent = eb[ctrl_chain[-1]] bpy.ops.object.mode_set(mode ='OBJECT') - + pb = self.obj.pose.bones - + # Setting pose bones locks pb_master = pb[master_name] pb_master.lock_scale = True,False,True - + pb[tip_name].lock_scale = True,True,True pb[tip_name].lock_rotation = True,True,True pb[tip_name].lock_rotation_w = True - + pb_master['finger_curve'] = 0.0 prop = rna_idprop_ui_prop_get(pb_master, 'finger_curve') prop["min"] = 0.0 @@ -159,7 +159,7 @@ class Rig: # Pose settings for org, ctrl, deform, mch, mch_drv in zip(self.org_bones, ctrl_chain, def_chain, mch_chain, mch_drv_chain): - + # Constraining the org bones #con = pb[org].constraints.new('COPY_TRANSFORMS') #con.target = self.obj @@ -169,31 +169,31 @@ class Rig: con = pb[deform].constraints.new('COPY_TRANSFORMS') con.target = self.obj con.subtarget = mch - + # Constraining the mch bones if mch_chain.index(mch) == 0: con = pb[mch].constraints.new('COPY_LOCATION') con.target = self.obj con.subtarget = ctrl - + con = pb[mch].constraints.new('COPY_SCALE') con.target = self.obj con.subtarget = ctrl - + con = pb[mch].constraints.new('DAMPED_TRACK') con.target = self.obj con.subtarget = ctrl_chain[ctrl_chain.index(ctrl)+1] - + con = pb[mch].constraints.new('STRETCH_TO') con.target = self.obj con.subtarget = ctrl_chain[ctrl_chain.index(ctrl)+1] con.volume = 'NO_VOLUME' - + elif mch_chain.index(mch) == len(mch_chain) - 1: con = pb[mch].constraints.new('DAMPED_TRACK') con.target = self.obj con.subtarget = tip_name - + con = pb[mch].constraints.new('STRETCH_TO') con.target = self.obj con.subtarget = tip_name @@ -202,7 +202,7 @@ class Rig: con = pb[mch].constraints.new('DAMPED_TRACK') con.target = self.obj con.subtarget = ctrl_chain[ctrl_chain.index(ctrl)+1] - + con = pb[mch].constraints.new('STRETCH_TO') con.target = self.obj con.subtarget = ctrl_chain[ctrl_chain.index(ctrl)+1] @@ -210,19 +210,19 @@ class Rig: # Constraining and driving mch driver bones pb[mch_drv].rotation_mode = 'YZX' - + if mch_drv_chain.index(mch_drv) == 0: # Constraining to master bone con = pb[mch_drv].constraints.new('COPY_LOCATION') con.target = self.obj con.subtarget = master_name - + con = pb[mch_drv].constraints.new('COPY_ROTATION') con.target = self.obj con.subtarget = master_name con.target_space = 'LOCAL' con.owner_space = 'LOCAL' - + else: # Match axis to expression options = { @@ -239,7 +239,7 @@ class Rig: "-Z" : { "axis" : 2, "expr" : '-((1-sy)*pi)' } } - + axis = self.params.primary_rotation_axis # Drivers @@ -251,7 +251,7 @@ class Rig: drv_var.type = "SINGLE_PROP" drv_var.targets[0].id = self.obj drv_var.targets[0].data_path = pb[master_name].path_from_id() + '.scale.y' - + # Setting bone curvature setting, costum property, and drivers def_bone = self.obj.data.bones[deform] @@ -264,7 +264,7 @@ class Rig: drv_var.type = "SINGLE_PROP" drv_var.targets[0].id = self.obj drv_var.targets[0].data_path = pb_master.path_from_id() + '["finger_curve"]' - + drv = def_bone.driver_add("bbone_out").driver # Ease out drv.type='SUM' @@ -274,10 +274,10 @@ class Rig: drv_var.targets[0].id = self.obj drv_var.targets[0].data_path = pb_master.path_from_id() + '["finger_curve"]' - + # Assigning shapes to control bones create_circle_widget(self.obj, ctrl, radius=0.3, head_tail=0.5) - + # Create ctrl master widget w = create_widget(self.obj, master_name) if w is not None: @@ -292,17 +292,17 @@ class Rig: edges = [(0, 1), (1, 2), (2, 3), (3, 4), (4, 5), (5, 1)] mesh.from_pydata(verts, edges, []) mesh.update() - + # Create tip control widget create_circle_widget(self.obj, tip_name, radius=0.3, head_tail=0.0) - + # Create UI controls_string = ", ".join( ["'" + x + "'" for x in ctrl_chain] ) + ", " + "'" + master_name + "'" return [script % (controls_string, master_name, 'finger_curve')] - - + + def add_parameters(params): """ Add the parameters of this rig type to the RigifyParameters PropertyGroup @@ -316,9 +316,9 @@ def parameters_ui(layout, params): """ r = layout.row() r.label(text="Bend rotation axis:") - r.prop(params, "primary_rotation_axis", text="") - - + r.prop(params, "primary_rotation_axis", text="") + + def create_sample(obj): # generated by rigify.utils.write_metarig bpy.ops.object.mode_set(mode='EDIT') @@ -406,9 +406,9 @@ def create_sample(obj): bone.select = True bone.select_head = True bone.select_tail = True - arm.edit_bones.active = bone - - - - - + arm.edit_bones.active = bone + + + + + diff --git a/rigify/rigs/pitchipoy/super_torso_turbo.py b/rigify/rigs/pitchipoy/super_torso_turbo.py index e1ff5b0e..b6b70085 100644 --- a/rigify/rigs/pitchipoy/super_torso_turbo.py +++ b/rigify/rigs/pitchipoy/super_torso_turbo.py @@ -1,7 +1,7 @@ import bpy from mathutils import Vector from ...utils import copy_bone, flip_bone, put_bone, org -from ...utils import strip_org, make_deformer_name, connected_children_names +from ...utils import strip_org, make_deformer_name, connected_children_names from ...utils import create_circle_widget, create_sphere_widget, create_widget from ...utils import MetarigError, make_mechanism_name, create_cube_widget from rna_prop_ui import rna_idprop_ui_prop_get @@ -16,7 +16,7 @@ if is_selected( controls ): """ class Rig: - + def __init__(self, obj, bone_name, params): """ Initialize torso rig and key rig properties """ @@ -59,7 +59,7 @@ class Rig: if len(self.org_bones) <= 4: raise MetarigError( "RIGIFY ERROR: invalid rig structure" % (strip_org(bone_name)) - ) + ) def build_bone_structure( self ): @@ -67,14 +67,14 @@ class Rig: Neck --> Upper torso --> Lower torso --> Tail (optional) """ if self.pivot_pos and self.neck_pos: - + neck_index = self.neck_pos - 1 pivot_index = self.pivot_pos - 1 tail_index = 0 if 'tail_pos' in dir(self): tail_index = self.tail_pos - 1 - + neck_bones = self.org_bones[neck_index::] upper_torso_bones = self.org_bones[pivot_index:neck_index] lower_torso_bones = self.org_bones[tail_index:pivot_index] @@ -85,8 +85,8 @@ class Rig: return { 'neck' : neck_bones, - 'upper' : upper_torso_bones, - 'lower' : lower_torso_bones, + 'upper' : upper_torso_bones, + 'lower' : lower_torso_bones, 'tail' : tail_bones } @@ -95,13 +95,13 @@ class Rig: def orient_bone( self, eb, axis, scale, reverse = False ): v = Vector((0,0,0)) - + setattr(v,axis,scale) if reverse: tail_vec = v * self.obj.matrix_world eb.head[:] = eb.tail - eb.tail[:] = eb.head + tail_vec + eb.tail[:] = eb.head + tail_vec else: tail_vec = v * self.obj.matrix_world eb.tail[:] = eb.head + tail_vec @@ -114,19 +114,19 @@ class Rig: bpy.ops.object.mode_set(mode ='EDIT') eb = self.obj.data.edit_bones - - # Create torso control bone + + # Create torso control bone torso_name = 'torso' ctrl_name = copy_bone(self.obj, pivot_name, torso_name) ctrl_eb = eb[ ctrl_name ] - + self.orient_bone( ctrl_eb, 'y', self.spine_length / 2.5 ) - + # Create mch_pivot mch_name = make_mechanism_name( 'pivot' ) mch_name = copy_bone(self.obj, ctrl_name, mch_name) mch_eb = eb[ mch_name ] - + mch_eb.length /= 4 # Positioning pivot in a more usable location for animators @@ -142,28 +142,28 @@ class Rig: 'mch' : mch_name } - + def create_deform( self ): org_bones = self.org_bones - + bpy.ops.object.mode_set(mode ='EDIT') eb = self.obj.data.edit_bones - + def_bones = [] for org in org_bones: def_name = make_deformer_name( strip_org( org ) ) def_name = copy_bone( self.obj, org, def_name ) def_bones.append( def_name ) - + return def_bones - + def create_neck( self, neck_bones ): org_bones = self.org_bones - + bpy.ops.object.mode_set(mode ='EDIT') eb = self.obj.data.edit_bones - + # Create neck control neck = copy_bone( self.obj, org(neck_bones[0]), 'neck' ) neck_eb = eb[ neck ] @@ -179,14 +179,14 @@ class Rig: mch_str = copy_bone( self.obj, neck, make_mechanism_name('STR-neck') ) # Neck MCH rotation - mch_neck = copy_bone( + mch_neck = copy_bone( self.obj, neck, make_mechanism_name('ROT-neck') ) self.orient_bone( eb[mch_neck], 'y', self.spine_length / 10 ) # Head MCH rotation - mch_head = copy_bone( + mch_head = copy_bone( self.obj, head, make_mechanism_name('ROT-head') ) @@ -204,8 +204,8 @@ class Rig: # Tweak bones for b in neck_bones[:-1]: # All except last bone twk_name = "tweak_" + b - twk_name = copy_bone( self.obj, org(b), twk_name ) - + twk_name = copy_bone( self.obj, org(b), twk_name ) + eb[twk_name].length /= 2 twk += [ twk_name ] @@ -223,25 +223,25 @@ class Rig: def create_chest( self, chest_bones ): org_bones = self.org_bones - + bpy.ops.object.mode_set(mode ='EDIT') eb = self.obj.data.edit_bones # get total spine length - + # Create chest control bone chest = copy_bone( self.obj, org( chest_bones[0] ), 'chest' ) self.orient_bone( eb[chest], 'y', self.spine_length / 3 ) # create chest mch_wgt - mch_wgt = copy_bone( - self.obj, org( chest_bones[-1] ), - make_mechanism_name( 'WGT-chest' ) + mch_wgt = copy_bone( + self.obj, org( chest_bones[-1] ), + make_mechanism_name( 'WGT-chest' ) ) - + # Create mch and twk bones twk,mch = [],[] - + for b in chest_bones: mch_name = copy_bone( self.obj, org(b), make_mechanism_name(b) ) self.orient_bone( eb[mch_name], 'y', self.spine_length / 10 ) @@ -263,36 +263,36 @@ class Rig: def create_hips( self, hip_bones ): org_bones = self.org_bones - + bpy.ops.object.mode_set(mode ='EDIT') eb = self.obj.data.edit_bones - + # Create hips control bone hips = copy_bone( self.obj, org( hip_bones[-1] ), 'hips' ) - self.orient_bone( - eb[hips], - 'y', - self.spine_length / 4, - reverse = True + self.orient_bone( + eb[hips], + 'y', + self.spine_length / 4, + reverse = True ) # create hips mch_wgt - mch_wgt = copy_bone( - self.obj, org( hip_bones[0] ), - make_mechanism_name( 'WGT-hips' ) + mch_wgt = copy_bone( + self.obj, org( hip_bones[0] ), + make_mechanism_name( 'WGT-hips' ) ) # Create mch and tweak bones twk,mch = [],[] for b in hip_bones: mch_name = copy_bone( self.obj, org(b), make_mechanism_name(b) ) - self.orient_bone( - eb[mch_name], 'y', self.spine_length / 10, reverse = True + self.orient_bone( + eb[mch_name], 'y', self.spine_length / 10, reverse = True ) twk_name = "tweak_" + b twk_name = copy_bone( self.obj, org( b ), twk_name ) - + eb[twk_name].length /= 2 mch += [ mch_name ] @@ -315,13 +315,13 @@ class Rig: bpy.ops.object.mode_set(mode ='EDIT') eb = self.obj.data.edit_bones - + # Parent deform bones for i,b in enumerate( bones['def'] ): if i > 0: # For all bones but the first (which has no parent) eb[b].parent = eb[ bones['def'][i-1] ] # to previous eb[b].use_connect = True - + # Parent control bones # Head control => MCH-rotation_head eb[ bones['neck']['ctrl'] ].parent = eb[ bones['neck']['mch_head'] ] @@ -343,7 +343,7 @@ class Rig: parent = eb[ bones['neck']['mch_str'] ] for i,b in enumerate([ eb[n] for n in bones['neck']['mch'] ]): b.parent = parent - + # Chest mch bones and neck mch chest_mch = bones['chest']['mch'] + [ bones['neck']['mch_neck'] ] for i,b in enumerate(chest_mch): @@ -358,14 +358,14 @@ class Rig: eb[b].parent = eb[ bones['pivot']['ctrl'] ] else: eb[b].parent = eb[ bones['hips']['mch'][i+1] ] - + # mch pivot eb[ bones['pivot']['mch'] ].parent = eb[ bones['chest']['mch'][0] ] # MCH widgets eb[ bones['chest']['mch_wgt'] ].parent = eb[ bones['chest']['mch'][-1] ] eb[ bones['hips' ]['mch_wgt'] ].parent = eb[ bones['hips' ]['mch'][0 ] ] - + # Tweaks # Neck tweaks @@ -374,14 +374,14 @@ class Rig: eb[ twk ].parent = eb[ bones['neck']['ctrl_neck'] ] else: eb[ twk ].parent = eb[ bones['neck']['mch'][i-1] ] - + # Chest tweaks for twk,mch in zip( bones['chest']['tweak'], bones['chest']['mch'] ): if bones['chest']['tweak'].index( twk ) == 0: eb[ twk ].parent = eb[ bones['pivot']['mch'] ] else: eb[ twk ].parent = eb[ mch ] - + # Hips tweaks for i,twk in enumerate(bones['hips']['tweak']): if i == 0: @@ -408,7 +408,7 @@ class Rig: const = owner_pb.constraints.new( constraint['constraint'] ) const.target = self.obj - # filter contraint props to those that actually exist in the currnet + # filter contraint props to those that actually exist in the currnet # type of constraint, then assign values to each for p in [ k for k in constraint.keys() if k in dir(const) ]: setattr( const, p, constraint[p] ) @@ -419,11 +419,11 @@ class Rig: # head and neck MCH bones for b in [ bones['neck']['mch_head'], bones['neck']['mch_neck'] ]: - self.make_constraint( b, { + self.make_constraint( b, { 'constraint' : 'COPY_ROTATION', 'subtarget' : bones['pivot']['ctrl'], } ) - self.make_constraint( b, { + self.make_constraint( b, { 'constraint' : 'COPY_SCALE', 'subtarget' : bones['pivot']['ctrl'], } ) @@ -437,11 +437,11 @@ class Rig: self.make_constraint( bones['neck']['mch_str'], { 'constraint' : 'STRETCH_TO', 'subtarget' : bones['neck']['ctrl'], - }) - + }) + # Intermediary mch bones intermediaries = [ bones['neck'], bones['chest'], bones['hips'] ] - + if 'tail' in bones.keys(): intermediaries += bones['tail'] @@ -452,21 +452,21 @@ class Rig: for j,b in enumerate(mch): if i == 0: nfactor = float( (j + 1) / len( mch ) ) - self.make_constraint( b, { + self.make_constraint( b, { 'constraint' : 'COPY_ROTATION', 'subtarget' : l['ctrl'], 'influence' : nfactor } ) else: - self.make_constraint( b, { + self.make_constraint( b, { 'constraint' : 'COPY_TRANSFORMS', 'subtarget' : l['ctrl'], 'influence' : factor, 'owner_space' : 'LOCAL', 'target_space' : 'LOCAL' - } ) + } ) + - # MCH pivot self.make_constraint( bones['pivot']['mch'], { 'constraint' : 'COPY_TRANSFORMS', @@ -474,7 +474,7 @@ class Rig: 'owner_space' : 'LOCAL', 'target_space' : 'LOCAL' }) - + # DEF bones deform = bones['def'] tweaks = bones['hips']['tweak'] + bones['chest']['tweak'] @@ -509,13 +509,13 @@ class Rig: def create_drivers( self, bones ): bpy.ops.object.mode_set(mode ='OBJECT') pb = self.obj.pose.bones - + # Setting the torso's props torso = pb[ bones['pivot']['ctrl'] ] props = [ "head_follow", "neck_follow" ] owners = [ bones['neck']['mch_head'], bones['neck']['mch_neck'] ] - + for prop in props: if prop == 'neck_follow': torso[prop] = 0.5 @@ -528,13 +528,13 @@ class Rig: prop["soft_min"] = 0.0 prop["soft_max"] = 1.0 prop["description"] = prop - + # driving the follow rotation switches for neck and head for bone, prop, in zip( owners, props ): # Add driver to copy rotation constraint drv = pb[ bone ].constraints[ 0 ].driver_add("influence").driver drv.type = 'AVERAGE' - + var = drv.variables.new() var.name = prop var.type = "SINGLE_PROP" @@ -543,13 +543,13 @@ class Rig: torso.path_from_id() + '['+ '"' + prop + '"' + ']' drv_modifier = self.obj.animation_data.drivers[-1].modifiers[0] - + drv_modifier.mode = 'POLYNOMIAL' drv_modifier.poly_order = 1 drv_modifier.coefficients[0] = 1.0 drv_modifier.coefficients[1] = -1.0 - + def locks_and_widgets( self, bones ): bpy.ops.object.mode_set(mode ='OBJECT') pb = self.obj.pose.bones @@ -564,7 +564,7 @@ class Rig: # Locks tweaks = bones['neck']['tweak'] + bones['chest']['tweak'] tweaks += bones['hips']['tweak'] - + if 'tail' in bones.keys(): tweaks += bones['tail']['tweak'] @@ -577,39 +577,39 @@ class Rig: # Assigning a widget to torso bone create_cube_widget( - self.obj, - bones['pivot']['ctrl'], - radius = 0.5, + self.obj, + bones['pivot']['ctrl'], + radius = 0.5, bone_transform_name = None ) - + # Assigning widgets to control bones - gen_ctrls = [ - bones['neck']['ctrl_neck'], + gen_ctrls = [ + bones['neck']['ctrl_neck'], bones['chest']['ctrl'], bones['hips']['ctrl'] ] - + if 'tail' in bones.keys(): gen_ctrls += [ bones['tail']['ctrl'] ] - + for bone in gen_ctrls: create_circle_widget( - self.obj, + self.obj, bone, - radius = 1.0, - head_tail = 0.5, - with_line = False, + radius = 1.0, + head_tail = 0.5, + with_line = False, bone_transform_name = None ) # Head widget create_circle_widget( - self.obj, - bones['neck']['ctrl'], - radius = 0.75, - head_tail = 1.0, - with_line = False, + self.obj, + bones['neck']['ctrl'], + radius = 0.75, + head_tail = 1.0, + with_line = False, bone_transform_name = None ) @@ -617,7 +617,7 @@ class Rig: chest_widget_loc = pb[ bones['chest']['mch_wgt'] ] pb[ bones['chest']['ctrl'] ].custom_shape_transform = chest_widget_loc - hips_widget_loc = pb[ bones['hips']['mch_wgt'] ] + hips_widget_loc = pb[ bones['hips']['mch_wgt'] ] if 'tail' in bones.keys(): hips_widget_loc = bones['def'][self.tail_pos -1] @@ -626,13 +626,13 @@ class Rig: # Assigning widgets to tweak bones and layers for bone in tweaks: create_sphere_widget(self.obj, bone, bone_transform_name=None) - + if self.tweak_layers: - pb[bone].bone.layers = self.tweak_layers + pb[bone].bone.layers = self.tweak_layers def generate( self ): - + # Torso Rig Anatomy: # Neck: all bones above neck point, last bone is head # Upper torso: all bones between pivot and neck start @@ -682,15 +682,15 @@ class Rig: controls = [ bones['neck']['ctrl'], bones['neck']['ctrl_neck'] ] controls += [ bones['chest']['ctrl'], bones['hips']['ctrl'] ] controls += [ bones['pivot']['ctrl'] ] - + if 'tail' in bones.keys(): controls += [ bones['tail']['ctrl'] ] # Create UI controls_string = ", ".join(["'" + x + "'" for x in controls]) return [script % ( - controls_string, - bones['pivot']['ctrl'], + controls_string, + bones['pivot']['ctrl'], 'head_follow', 'neck_follow' )] @@ -721,9 +721,9 @@ def add_parameters( params ): ) # Setting up extra layers for the FK and tweak - params.tweak_extra_layers = bpy.props.BoolProperty( - name = "tweak_extra_layers", - default = True, + params.tweak_extra_layers = bpy.props.BoolProperty( + name = "tweak_extra_layers", + default = True, description = "" ) @@ -736,7 +736,7 @@ def add_parameters( params ): def parameters_ui(layout, params): """ Create the ui for the rig parameters.""" - + r = layout.row() r.prop(params, "neck_pos") @@ -749,7 +749,7 @@ def parameters_ui(layout, params): r = layout.row() r.prop(params, "tweak_extra_layers") r.active = params.tweak_extra_layers - + col = r.column(align=True) row = col.row(align=True) @@ -785,7 +785,7 @@ def create_sample(obj): bone.roll = 0.0000 bone.use_connect = False bones['spine'] = bone.name - + bone = arm.edit_bones.new('spine.001') bone.head[:] = 0.0000, 0.0172, 1.1573 bone.tail[:] = 0.0000, 0.0004, 1.2929 @@ -793,7 +793,7 @@ def create_sample(obj): bone.use_connect = True bone.parent = arm.edit_bones[bones['spine']] bones['spine.001'] = bone.name - + bone = arm.edit_bones.new('spine.002') bone.head[:] = 0.0000, 0.0004, 1.2929 bone.tail[:] = 0.0000, 0.0059, 1.4657 @@ -801,7 +801,7 @@ def create_sample(obj): bone.use_connect = True bone.parent = arm.edit_bones[bones['spine.001']] bones['spine.002'] = bone.name - + bone = arm.edit_bones.new('spine.003') bone.head[:] = 0.0000, 0.0059, 1.4657 bone.tail[:] = 0.0000, 0.0114, 1.6582 @@ -809,7 +809,7 @@ def create_sample(obj): bone.use_connect = True bone.parent = arm.edit_bones[bones['spine.002']] bones['spine.003'] = bone.name - + bone = arm.edit_bones.new('spine.004') bone.head[:] = 0.0000, 0.0114, 1.6582 bone.tail[:] = 0.0000, -0.0067, 1.7197 @@ -817,7 +817,7 @@ def create_sample(obj): bone.use_connect = True bone.parent = arm.edit_bones[bones['spine.003']] bones['spine.004'] = bone.name - + bone = arm.edit_bones.new('spine.005') bone.head[:] = 0.0000, -0.0067, 1.7197 bone.tail[:] = 0.0000, -0.0247, 1.7813 @@ -825,7 +825,7 @@ def create_sample(obj): bone.use_connect = True bone.parent = arm.edit_bones[bones['spine.004']] bones['spine.005'] = bone.name - + bone = arm.edit_bones.new('spine.006') bone.head[:] = 0.0000, -0.0247, 1.7813 bone.tail[:] = 0.0000, -0.0247, 1.9796 @@ -833,7 +833,7 @@ def create_sample(obj): bone.use_connect = True bone.parent = arm.edit_bones[bones['spine.005']] bones['spine.006'] = bone.name - + bpy.ops.object.mode_set(mode='OBJECT') pbone = obj.pose.bones[bones['spine']] diff --git a/rigify/rigs/pitchipoy/super_widgets.py b/rigify/rigs/pitchipoy/super_widgets.py index aee6c14e..8930ba91 100644 --- a/rigify/rigs/pitchipoy/super_widgets.py +++ b/rigify/rigs/pitchipoy/super_widgets.py @@ -43,7 +43,7 @@ def create_ear_widget(rig, bone_name, size=1.0, bone_transform_name=None): verts = [(-2.4903741291382175e-09*size, 1.0*size, -3.123863123732917e-08*size), (-7.450580596923828e-09*size, 0.9829629063606262*size, 0.0776456817984581*size), (-1.4901161193847656e-08*size, 0.9330127239227295*size, 0.1499999761581421*size), (-2.9802322387695312e-08*size, 0.8535534143447876*size, 0.2121320217847824*size), (-2.9802322387695312e-08*size, 0.75*size, 0.25980761647224426*size), (-2.9802322387695312e-08*size, 0.6294095516204834*size, 0.2897777259349823*size), (-2.9802322387695312e-08*size, 0.5000000596046448*size, 0.29999998211860657*size), (-5.960464477539063e-08*size, 0.37059056758880615*size, 0.2897777855396271*size), (-5.960464477539063e-08*size, 0.25000008940696716*size, 0.25980767607688904*size), (-4.470348358154297e-08*size, 0.14644670486450195*size, 0.21213211119174957*size), (-4.470348358154297e-08*size, 0.06698736548423767*size, 0.15000009536743164*size), (-4.470348358154297e-08*size, 0.017037123441696167*size, 0.07764581590890884*size), (-3.6718930118695425e-08*size, 0.0*size, 1.1981423142515268e-07*size), (-2.9802322387695312e-08*size, 0.017037034034729004*size, -0.07764559239149094*size), (-2.9802322387695312e-08*size, 0.06698718667030334*size, -0.14999987185001373*size), (-1.4901161193847656e-08*size, 0.14644640684127808*size, -0.21213191747665405*size), (0.0*size, 0.24999985098838806*size, -0.25980761647224426*size), (0.0*size, 0.3705902695655823*size, -0.2897777259349823*size), (0.0*size, 0.4999997615814209*size, -0.30000004172325134*size), (0.0*size, 0.6294092535972595*size, -0.2897777855396271*size), (0.0*size, 0.7499997615814209*size, -0.2598077356815338*size), (1.4901161193847656e-08*size, 0.8535531759262085*size, -0.21213220059871674*size), (0.0*size, 0.9330125451087952*size, -0.15000019967556*size), (0.0*size, 0.9829628467559814*size, -0.07764596492052078*size), ] edges = [(1, 0), (2, 1), (3, 2), (4, 3), (5, 4), (6, 5), (7, 6), (8, 7), (9, 8), (10, 9), (11, 10), (12, 11), (13, 12), (14, 13), (15, 14), (16, 15), (17, 16), (18, 17), (19, 18), (20, 19), (21, 20), (22, 21), (23, 22), (0, 23), ] faces = [] - + mesh = obj.data mesh.from_pydata(verts, edges, faces) mesh.update() @@ -58,7 +58,7 @@ def create_jaw_widget(rig, bone_name, size=1.0, bone_transform_name=None): verts = [(0.606898307800293*size, 0.6533132195472717*size, 0.09324522316455841*size), (0.5728408694267273*size, 0.7130533456802368*size, 0.04735109210014343*size), (0.478340744972229*size, 0.856249213218689*size, 0.0167550016194582*size), (0.3405401408672333*size, 1.0092359781265259*size, 0.003642391413450241*size), (0.1764744222164154*size, 1.1159402132034302*size, 0.0003642391529865563*size), (0.5728408694267273*size, 0.7130533456802368*size, 0.1391393542289734*size), (0.478340744972229*size, 0.856249213218689*size, 0.16973544657230377*size), (0.3405401408672333*size, 1.0092359781265259*size, 0.18284805119037628*size), (0.1764744222164154*size, 1.1159402132034302*size, 0.1861262023448944*size), (0.0*size, 1.153113603591919*size, 0.0*size), (-0.606898307800293*size, 0.6533132195472717*size, 0.09324522316455841*size), (-0.5728408694267273*size, 0.7130533456802368*size, 0.04735109210014343*size), (-0.478340744972229*size, 0.856249213218689*size, 0.0167550016194582*size), (-0.3405401408672333*size, 1.0092359781265259*size, 0.003642391413450241*size), (-0.1764744222164154*size, 1.1159402132034302*size, 0.0003642391529865563*size), (0.0*size, 1.153113603591919*size, 0.18649044632911682*size), (-0.5728408694267273*size, 0.7130533456802368*size, 0.1391393542289734*size), (-0.478340744972229*size, 0.856249213218689*size, 0.16973544657230377*size), (-0.3405401408672333*size, 1.0092359781265259*size, 0.18284805119037628*size), (-0.1764744222164154*size, 1.1159402132034302*size, 0.1861262023448944*size), ] edges = [(1, 0), (2, 1), (3, 2), (4, 3), (9, 4), (6, 5), (7, 6), (8, 7), (15, 8), (5, 0), (11, 10), (12, 11), (13, 12), (14, 13), (9, 14), (17, 16), (18, 17), (19, 18), (15, 19), (16, 10), ] faces = [] - + mesh = obj.data mesh.from_pydata(verts, edges, faces) mesh.update() @@ -66,21 +66,21 @@ def create_jaw_widget(rig, bone_name, size=1.0, bone_transform_name=None): else: return None - + def create_teeth_widget(rig, bone_name, size=1.0, bone_transform_name=None): obj = create_widget(rig, bone_name, bone_transform_name) if obj is not None: verts = [(0.6314387321472168*size, 0.4999997019767761*size, 0.09999999403953552*size), (0.5394065976142883*size, 0.29289281368255615*size, 0.09999999403953552*size), (0.3887903690338135*size, 0.1339743733406067*size, 0.09999999403953552*size), (0.19801488518714905*size, 0.03407406806945801*size, 0.09999999403953552*size), (-3.4034394502668874e-07*size, 0.0*size, 0.09999999403953552*size), (-0.19801555573940277*size, 0.034074246883392334*size, 0.09999999403953552*size), (-0.7000000476837158*size, 1.0000001192092896*size, -0.10000000894069672*size), (-0.6778771877288818*size, 0.7411810755729675*size, -0.10000000894069672*size), (-0.6314389705657959*size, 0.5000001192092896*size, -0.10000000894069672*size), (-0.5394070148468018*size, 0.2928934097290039*size, -0.10000000894069672*size), (-0.38879096508026123*size, 0.13397473096847534*size, -0.10000000894069672*size), (-0.19801555573940277*size, 0.034074246883392334*size, -0.10000000894069672*size), (-3.4034394502668874e-07*size, 0.0*size, -0.10000000894069672*size), (0.19801488518714905*size, 0.03407406806945801*size, -0.10000000894069672*size), (0.3887903690338135*size, 0.1339743733406067*size, -0.10000000894069672*size), (0.5394065976142883*size, 0.29289281368255615*size, -0.10000000894069672*size), (0.6314387321472168*size, 0.4999997019767761*size, -0.10000000894069672*size), (0.6778769493103027*size, 0.7411805391311646*size, -0.10000000894069672*size), (0.6999999284744263*size, 0.9999995231628418*size, -0.10000000894069672*size), (-0.38879096508026123*size, 0.13397473096847534*size, 0.09999999403953552*size), (-0.5394070148468018*size, 0.2928934097290039*size, 0.09999999403953552*size), (-0.6314389705657959*size, 0.5000001192092896*size, 0.09999999403953552*size), (-0.6778771877288818*size, 0.7411810755729675*size, 0.09999999403953552*size), (-0.7000000476837158*size, 1.0000001192092896*size, 0.09999999403953552*size), (0.6778769493103027*size, 0.7411805391311646*size, 0.09999999403953552*size), (0.6999999284744263*size, 0.9999995231628418*size, 0.09999999403953552*size), ] edges = [(25, 24), (24, 0), (0, 1), (1, 2), (2, 3), (3, 4), (7, 6), (8, 7), (9, 8), (10, 9), (11, 10), (12, 11), (13, 12), (14, 13), (15, 14), (16, 15), (17, 16), (18, 17), (4, 5), (5, 19), (19, 20), (20, 21), (21, 22), (22, 23), (18, 25), (6, 23), ] faces = [] - + mesh = obj.data mesh.from_pydata(verts, edges, faces) mesh.update() return obj else: return None - + def create_face_widget(rig, bone_name, size=1.0, bone_transform_name=None): obj = create_widget(rig, bone_name, bone_transform_name) if obj is not None: @@ -132,7 +132,7 @@ def create_hand_widget(rig, bone_name, size=1.0, bone_transform_name=None): def create_foot_widget(rig, bone_name, size=1.0, bone_transform_name=None): # Create hand widget obj = create_widget(rig, bone_name, bone_transform_name) - if obj is not None: + if obj is not None: verts = [(-0.6999998688697815*size, -0.5242648720741272*size, 0.0*size), (-0.7000001072883606*size, 1.2257349491119385*size, 0.0*size), (0.6999998688697815*size, 1.2257351875305176*size, 0.0*size), (0.7000001072883606*size, -0.5242648720741272*size, 0.0*size), (-0.6999998688697815*size, 0.2527350187301636*size, 0.0*size), (0.7000001072883606*size, 0.2527352571487427*size, 0.0*size), (-0.7000001072883606*size, 0.975735068321228*size, 0.0*size), (0.6999998688697815*size, 0.9757352471351624*size, 0.0*size), ] edges = [(1, 2), (0, 3), (0, 4), (3, 5), (4, 6), (1, 6), (5, 7), (2, 7), ] faces = [] @@ -153,7 +153,7 @@ def create_ballsocket_widget(rig, bone_name, size=1.0, bone_transform_name=None) verts = [(-0.050000108778476715*size, 0.779460072517395*size, -0.2224801927804947*size), (0.049999915063381195*size, 0.779460072517395*size, -0.22248023748397827*size), (0.09999985247850418*size, 0.6790841817855835*size, -0.3658318817615509*size), (-2.3089636158601934e-07*size, 0.5930476188659668*size, -0.488704651594162*size), (-0.10000013560056686*size, 0.6790841817855835*size, -0.3658317029476166*size), (0.04999981075525284*size, 0.6790841817855835*size, -0.36583182215690613*size), (-0.050000183284282684*size, 0.6790841817855835*size, -0.3658318519592285*size), (-0.3658319115638733*size, 0.6790841221809387*size, 0.05000019446015358*size), (-0.3658318817615509*size, 0.6790841221809387*size, -0.04999979957938194*size), (-0.36583176255226135*size, 0.6790841221809387*size, 0.10000018030405045*size), (-0.48870471119880676*size, 0.5930476188659668*size, 2.4472291215715813e-07*size), (-0.3658319413661957*size, 0.679084062576294*size, -0.0999998077750206*size), (-0.22248037159442902*size, 0.7794600129127502*size, -0.04999985918402672*size), (-0.22248034179210663*size, 0.7794600129127502*size, 0.05000016465783119*size), (0.3658319115638733*size, 0.6790841221809387*size, -0.05000000819563866*size), (0.3658319115638733*size, 0.6790841221809387*size, 0.05000000074505806*size), (0.36583179235458374*size, 0.6790841221809387*size, -0.09999998658895493*size), (0.4887046813964844*size, 0.5930476188659668*size, -3.8399143420519977e-08*size), (0.3658319413661957*size, 0.679084062576294*size, 0.10000000149011612*size), (0.050000034272670746*size, 0.7794599533081055*size, 0.2224804311990738*size), (-0.04999997466802597*size, 0.7794599533081055*size, 0.2224804311990738*size), (-0.09999992698431015*size, 0.679084062576294*size, 0.36583200097084045*size), (1.267315070663244e-07*size, 0.5930474996566772*size, 0.48870477080345154*size), (0.1000000610947609*size, 0.679084062576294*size, 0.3658318519592285*size), (-0.049999915063381195*size, 0.679084062576294*size, 0.3658319413661957*size), (0.05000007897615433*size, 0.679084062576294*size, 0.36583197116851807*size), (0.22248029708862305*size, 0.7794600129127502*size, 0.05000004544854164*size), (0.22248028218746185*size, 0.7794600129127502*size, -0.04999994859099388*size), (-4.752442350763886e-08*size, 0.8284152746200562*size, -0.1499999612569809*size), (-0.03882290795445442*size, 0.8284152746200562*size, -0.14488883316516876*size), (-0.07500004768371582*size, 0.8284152746200562*size, -0.12990377843379974*size), (-0.10606606304645538*size, 0.8284152746200562*size, -0.10606598109006882*size), (-0.1299038827419281*size, 0.8284152746200562*size, -0.07499996572732925*size), (-0.14488893747329712*size, 0.8284152746200562*size, -0.038822825998067856*size), (-0.15000006556510925*size, 0.8284152746200562*size, 2.4781975582754967e-08*size), (-0.1448889672756195*size, 0.8284152746200562*size, 0.038822878152132034*size), (-0.1299038827419281*size, 0.8284152746200562*size, 0.07500001043081284*size), (-0.10606609284877777*size, 0.8284152746200562*size, 0.1060660257935524*size), (-0.0750000923871994*size, 0.8284152746200562*size, 0.12990383803844452*size), (-0.038822952657938004*size, 0.8284152746200562*size, 0.14488889276981354*size), (-1.0593657862045802e-07*size, 0.8284152746200562*size, 0.15000005066394806*size), (0.03882275149226189*size, 0.8284152746200562*size, 0.14488892257213593*size), (0.07499989867210388*size, 0.8284152746200562*size, 0.1299038976430893*size), (0.10606591403484344*size, 0.8284152746200562*size, 0.10606611520051956*size), (0.12990373373031616*size, 0.8284152746200562*size, 0.0750000849366188*size), (0.14488881826400757*size, 0.8284152746200562*size, 0.038822952657938004*size), (0.1499999463558197*size, 0.8284152746200562*size, 1.0584351883835552e-07*size), (0.14488881826400757*size, 0.8284152746200562*size, -0.03882275149226189*size), (0.12990379333496094*size, 0.8284152746200562*size, -0.07499989122152328*size), (0.10606604814529419*size, 0.8284152746200562*size, -0.10606592148542404*size), (0.07500004768371582*size, 0.8284152746200562*size, -0.12990371882915497*size), (0.03882291540503502*size, 0.8284152746200562*size, -0.14488880336284637*size), ] edges = [(1, 0), (3, 2), (5, 2), (4, 3), (6, 4), (1, 5), (0, 6), (13, 7), (12, 8), (7, 9), (9, 10), (8, 11), (27, 14), (26, 15), (14, 16), (16, 17), (15, 18), (17, 18), (10, 11), (12, 13), (20, 19), (22, 21), (24, 21), (23, 22), (29, 28), (30, 29), (31, 30), (32, 31), (33, 32), (34, 33), (35, 34), (36, 35), (37, 36), (38, 37), (39, 38), (40, 39), (41, 40), (42, 41), (43, 42), (44, 43), (45, 44), (46, 45), (47, 46), (48, 47), (49, 48), (50, 49), (51, 50), (28, 51), (26, 27), (25, 23), (20, 24), (19, 25), ] faces = [] - + mesh = obj.data mesh.from_pydata(verts, edges, faces) mesh.update() diff --git a/rigify/rigs/pitchipoy/tentacle.py b/rigify/rigs/pitchipoy/tentacle.py index b8d52e88..0d24be16 100644 --- a/rigify/rigs/pitchipoy/tentacle.py +++ b/rigify/rigs/pitchipoy/tentacle.py @@ -16,17 +16,17 @@ if is_selected( controls ): """ class Rig: - + def __init__(self, obj, bone_name, params): self.obj = obj self.org_bones = [bone_name] + connected_children_names(obj, bone_name) self.params = params - + if params.tweak_extra_layers: self.tweak_layers = list( params.tweak_layers ) else: self.tweak_layers = None - + if len(self.org_bones) <= 1: raise MetarigError( "RIGIFY ERROR: invalid rig structure" % (strip_org(bone_name)) @@ -39,49 +39,49 @@ class Rig: org_bones = self.org_bones mch_parent = self.obj.data.bones[ org_bones[0] ].parent - + mch_parent_name = mch_parent.name # Storing the mch parent's name - + if not mch_parent: mch_parent = self.obj.data.edit_bones[ org_bones[0] ] mch_bone = copy_bone( - self.obj, + self.obj, mch_parent_name, make_mechanism_name( strip_org( org_bones[0] ) ) ) else: mch_bone = copy_bone( - self.obj, + self.obj, mch_parent_name, make_mechanism_name( strip_org( org_bones[0] ) ) - ) - + ) + put_bone( self.obj, mch_bone, eb[ mch_parent_name ].tail ) - + eb[ mch_bone ].length /= 4 # reduce length to fourth of original - + return mch_bone - + def make_master( self ): bpy.ops.object.mode_set(mode ='EDIT') org_bones = self.org_bones - + master_bone = copy_bone( - self.obj, - org_bones[0], + self.obj, + org_bones[0], "master_" + strip_org( org_bones[0] ) - ) + ) # Make widgets - bpy.ops.object.mode_set(mode ='OBJECT') + bpy.ops.object.mode_set(mode ='OBJECT') create_square_widget( self.obj, master_bone ) - + return master_bone - + def make_controls( self ): bpy.ops.object.mode_set(mode ='EDIT') @@ -92,8 +92,8 @@ class Rig: name = org_bones[i] ctrl_bone = copy_bone( - self.obj, - name, + self.obj, + name, strip_org(name) ) @@ -104,7 +104,7 @@ class Rig: for ctrl in ctrl_chain: create_circle_widget(self.obj, ctrl, radius=0.3, head_tail=0.5) - + return ctrl_chain @@ -122,19 +122,19 @@ class Rig: name = org_bones[i] tweak_bone = copy_bone( - self.obj, - name, + self.obj, + name, "tweak_" + strip_org(name) ) tweak_e = eb[ tweak_bone ] - + tweak_e.length /= 2 # Set size to half - + if i == len( org_bones ): # Position final tweak at the tip put_bone( self.obj, tweak_bone, eb[ org_bones[-1]].tail ) - + tweak_chain.append( tweak_bone ) # Make widgets @@ -157,8 +157,8 @@ class Rig: # Set up tweak bone layers if self.tweak_layers: tweak_pb.bone.layers = self.tweak_layers - - return tweak_chain + + return tweak_chain def make_deform( self ): @@ -171,13 +171,13 @@ class Rig: name = org_bones[i] def_bone = copy_bone( - self.obj, - name, + self.obj, + name, make_deformer_name(strip_org(name)) ) def_chain.append( def_bone ) - + return def_chain @@ -207,7 +207,7 @@ class Rig: for bone in ctrls_n_parent[1:]: previous_index = ctrls_n_parent.index( bone ) - 1 eb[ bone ].parent = eb[ ctrls_n_parent[previous_index] ] - + # Parent tweak bones tweaks = all_bones['tweak'] for tweak in all_bones['tweak']: @@ -216,7 +216,7 @@ class Rig: parent = all_bones['control'][ -1 ] else: parent = all_bones['control'][ tweaks.index( tweak ) ] - + eb[ tweak ].parent = eb[ parent ] # Parent deform bones @@ -228,15 +228,15 @@ class Rig: # Parent org bones ( to tweaks by default, or to the controls ) for org, tweak in zip( org_bones, all_bones['tweak'] ): - eb[ org ].parent = eb[ tweak ] - - + eb[ org ].parent = eb[ tweak ] + + def make_constraints( self, all_bones ): bpy.ops.object.mode_set(mode ='OBJECT') org_bones = self.org_bones pb = self.obj.pose.bones - + ## MCH bone constraints if pb[ org_bones[0] ].parent: mch_pb = pb[ all_bones['mch'] ] @@ -249,37 +249,37 @@ class Rig: con = mch_pb.constraints.new('COPY_ROTATION') con.target = self.obj con.subtarget = pb[ org_bones[0] ].parent.name - + con = mch_pb.constraints.new('COPY_SCALE') con.target = self.obj con.subtarget = pb[ org_bones[0] ].parent.name - """ + """ # Setting the MCH prop master_pb = pb[ all_bones['master'] ] prop_name_r = "rotation_follow" prop_name_s = "scale_follow" - + prop_names = [ prop_name_r, prop_name_s ] - + for prop_name in prop_names: master_pb[prop_name] = 1.0 - + prop = rna_idprop_ui_prop_get( master_pb, prop_name ) prop["min"] = 0.0 prop["max"] = 1.0 prop["soft_min"] = 0.0 prop["soft_max"] = 1.0 prop["description"] = prop_name - + # driving the MCH follow rotation switch - drv = mch_pb.constraints[ - prop_names.index(prop_name) +1 + drv = mch_pb.constraints[ + prop_names.index(prop_name) +1 ].driver_add("influence").driver - + drv.type='SUM' - + var = drv.variables.new() var.name = prop_name var.type = "SINGLE_PROP" @@ -298,15 +298,15 @@ class Rig: con = pb[deform].constraints.new('COPY_TRANSFORMS') con.target = self.obj con.subtarget = tweak - + con = pb[deform].constraints.new('DAMPED_TRACK') con.target = self.obj con.subtarget = tweaks[ tweaks.index( tweak ) + 1 ] - + con = pb[deform].constraints.new('STRETCH_TO') con.target = self.obj con.subtarget = tweaks[ tweaks.index( tweak ) + 1 ] - + ## Control bones' constraints if self.params.make_rotations: if ctrl != ctrls[0]: @@ -316,7 +316,7 @@ class Rig: con.use_offset = True con.target_space = 'LOCAL' con.owner_space = 'LOCAL' - + def generate(self): bpy.ops.object.mode_set(mode ='EDIT') @@ -326,7 +326,7 @@ class Rig: for bone in self.org_bones: # eb[ bone ].parent = None eb[ bone ].use_connect = False - + # Creating all bones mch = self.make_mch() # master = self.make_master() @@ -341,7 +341,7 @@ class Rig: 'tweak' : tweak_chain, 'deform' : def_chain } - + self.make_constraints( all_bones ) self.parent_bones( all_bones ) @@ -350,7 +350,7 @@ class Rig: all_controls = all_bones['control'] + all_bones['tweak'] # + [ all_bones['master'] ] controls_string = ", ".join(["'" + x + "'" for x in all_controls]) return [script % ( - controls_string, + controls_string, 'rotation_follow', 'scale_follow' )] @@ -361,14 +361,14 @@ def add_parameters(params): RigifyParameters PropertyGroup """ params.make_rotations = bpy.props.BoolProperty( - name = "Rotations", - default = True, + name = "Rotations", + default = True, description = "Make bones follow parent rotation" ) # Setting up extra tweak layers - params.tweak_extra_layers = bpy.props.BoolProperty( - name = "tweak_extra_layers", + params.tweak_extra_layers = bpy.props.BoolProperty( + name = "tweak_extra_layers", default = True, description = "" ) @@ -390,7 +390,7 @@ def parameters_ui(layout, params): r = layout.row() r.prop(params, "tweak_extra_layers") r.active = params.tweak_extra_layers - + col = r.column(align=True) row = col.row(align=True) @@ -400,28 +400,28 @@ def parameters_ui(layout, params): row = col.row(align=True) for i in range( 16, 24 ): # Layers 16-23 - row.prop(params, "tweak_layers", index=i, toggle=True, text="") - + row.prop(params, "tweak_layers", index=i, toggle=True, text="") + col = r.column(align=True) row = col.row(align=True) for i in range( 8, 16 ): # Layers 8-15 - row.prop(params, "tweak_layers", index=i, toggle=True, text="") + row.prop(params, "tweak_layers", index=i, toggle=True, text="") row = col.row(align=True) for i in range( 24, 32 ): # Layers 24-31 - row.prop(params, "tweak_layers", index=i, toggle=True, text="") + row.prop(params, "tweak_layers", index=i, toggle=True, text="") def create_square_widget(rig, bone_name, size=1.0, bone_transform_name=None): obj = create_widget(rig, bone_name, bone_transform_name) if obj is not None: verts = [ - ( 0.5 * size, -2.9802322387695312e-08 * size, 0.5 * size ), - ( -0.5 * size, -2.9802322387695312e-08 * size, 0.5 * size ), - ( 0.5 * size, 2.9802322387695312e-08 * size, -0.5 * size ), - ( -0.5 * size, 2.9802322387695312e-08 * size, -0.5 * size ), + ( 0.5 * size, -2.9802322387695312e-08 * size, 0.5 * size ), + ( -0.5 * size, -2.9802322387695312e-08 * size, 0.5 * size ), + ( 0.5 * size, 2.9802322387695312e-08 * size, -0.5 * size ), + ( -0.5 * size, 2.9802322387695312e-08 * size, -0.5 * size ), ] edges = [(0, 1), (2, 3), (0, 2), (3, 1) ] @@ -435,7 +435,7 @@ def create_square_widget(rig, bone_name, size=1.0, bone_transform_name=None): else: return None -def create_sample(obj): +def create_sample(obj): # generated by rigify.utils.write_metarig bpy.ops.object.mode_set(mode='EDIT') |