diff options
author | Lucio Rossi <lucio.rossi75@gmail.com> | 2016-09-28 19:24:42 +0300 |
---|---|---|
committer | Lucio Rossi <lucio.rossi75@gmail.com> | 2016-09-28 19:24:42 +0300 |
commit | bf668cc3eef5f77831f86033af0d541f875a2fba (patch) | |
tree | 07c9bf81e1905cc672e43185d4109d3ec24c5bab | |
parent | c528bf78a2026ff4ab10008eba763ec8b8e9e1e3 (diff) |
Rigify: final fixes of super_arm and super_leg ik_follow.
Removed: child_of constraints and double matrix mult.
-rwxr-xr-x | rigify/rig_ui_pitchipoy_template.py | 33 | ||||
-rw-r--r-- | rigify/rigs/pitchipoy/limbs/super_arm.py | 55 | ||||
-rw-r--r-- | rigify/rigs/pitchipoy/limbs/super_leg.py | 60 |
3 files changed, 80 insertions, 68 deletions
diff --git a/rigify/rig_ui_pitchipoy_template.py b/rigify/rig_ui_pitchipoy_template.py index f5838b8d..082016da 100755 --- a/rigify/rig_ui_pitchipoy_template.py +++ b/rigify/rig_ui_pitchipoy_template.py @@ -362,23 +362,6 @@ def ik2fk_arm(obj, fk, ik): # Rotation Correction correct_rotation(uarmi, uarm) - #Correct matrix if handi has IK_follow property - if 'IK_follow' in handi.keys(): - - cns = handi.constraints[0] - parent = obj.pose.bones[cns.subtarget] - cns1 = handi.constraints[1] - parent1 = obj.pose.bones[cns1.subtarget] - infl = cns.influence - - C = parent.matrix.inverted() - F=parent1.matrix_channel.inverted() - - C=C*C - F=F*F - G = C.lerp(F,1-infl) - handi.matrix = G*handi.matrix - # farmi.constraints["IK"].pole_target = obj # farmi.constraints["IK"].pole_subtarget = farm.name @@ -475,22 +458,6 @@ def ik2fk_leg(obj, fk, ik): # Rotation Correction correct_rotation(thighi,thigh) - #Correct matrix if footi has IK_follow property - if 'IK_follow' in footi.keys(): - - cns = footi.constraints[0] - parent = obj.pose.bones[cns.subtarget] - cns1 = footi.constraints[1] - parent1 = obj.pose.bones[cns1.subtarget] - infl = cns.influence - - C = parent.matrix.inverted() - F=parent1.matrix_channel.inverted() - - C=C*C - F=F*F - G = C.lerp(F,1-infl) - footi.matrix = G*footi.matrix # shini.constraints["IK"].pole_target = obj # shini.constraints["IK"].pole_subtarget = shin.name diff --git a/rigify/rigs/pitchipoy/limbs/super_arm.py b/rigify/rigs/pitchipoy/limbs/super_arm.py index cddf59c8..684241ee 100644 --- a/rigify/rigs/pitchipoy/limbs/super_arm.py +++ b/rigify/rigs/pitchipoy/limbs/super_arm.py @@ -512,32 +512,56 @@ class Rig: eb[ bones['ik']['mch_target'] ].parent = eb[ ctrl ] eb[ bones['ik']['mch_target'] ].use_connect = False - + # MCH for ik control + ctrl_socket = copy_bone(self.obj, org_bones[2], get_bone_name( org_bones[2], 'mch', 'ik_socket')) + eb[ctrl_socket].tail = eb[ctrl_socket].head + 0.8*(eb[ctrl_socket].tail-eb[ctrl_socket].head) + eb[ctrl_socket].parent = None + eb[ctrl].parent = eb[ctrl_socket] + + ctrl_root = copy_bone(self.obj, org_bones[2], get_bone_name( org_bones[2], 'mch', 'ik_root')) + eb[ctrl_root].tail = eb[ctrl_root].head + 0.7*(eb[ctrl_root].tail-eb[ctrl_root].head) + eb[ctrl_root].use_connect = False + eb[ctrl_root].parent = eb['root'] + + ctrl_parent = copy_bone(self.obj, org_bones[2], get_bone_name( org_bones[2], 'mch', 'ik_parent')) + eb[ctrl_parent].tail = eb[ctrl_parent].head + 0.6*(eb[ctrl_parent].tail-eb[ctrl_parent].head) + eb[ctrl_parent].use_connect = False + eb[ctrl_parent].parent = eb[org_bones[0]].parent # Set up constraints # Constrain ik ctrl to root / parent # Todo this should be better : target = strip_org(eb[org_bones[0]].parent.name) - target = eb[org_bones[0]].parent.name + #target = eb[org_bones[0]].parent.name - make_constraint( self, ctrl, { - 'constraint' : 'CHILD_OF', - 'subtarget' : 'root', + make_constraint( self, ctrl_socket, { + 'constraint' : 'COPY_TRANSFORMS', + 'subtarget' : ctrl_root, }) - - make_constraint( self, ctrl, { - 'constraint' : 'CHILD_OF', - 'subtarget' : target, - 'influence' : 0.0, + make_constraint( self, ctrl_socket, { + 'constraint' : 'COPY_TRANSFORMS', + 'subtarget' : ctrl_parent, }) + # make_constraint( self, ctrl, { + # 'constraint' : 'CHILD_OF', + # 'subtarget' : 'root', + # }) + # + # + # make_constraint( self, ctrl, { + # 'constraint' : 'CHILD_OF', + # 'subtarget' : target, + # 'influence' : 0.0, + # }) - pbone = self.obj.pose.bones[target] - const = self.obj.pose.bones[ctrl].constraints[1] - const.inverse_matrix = (self.obj.matrix_world*pbone.matrix).inverted() + # pbone = self.obj.pose.bones[target] #SET INVERSE EMULATION + # + # const = self.obj.pose.bones[ctrl].constraints[1] + # const.inverse_matrix = (self.obj.matrix_world*pbone.matrix).inverted() # Constrain mch target bone to the ik control and mch stretch @@ -606,6 +630,7 @@ class Rig: create_hand_widget(self.obj, ctrl, bone_transform_name=None) bones['ik']['ctrl']['terminal'] = [ ctrl ] + bones['ik']['mch_hand'] = [ctrl_socket, ctrl_root, ctrl_parent] return bones @@ -623,7 +648,7 @@ class Rig: bpy.ops.object.mode_set(mode ='OBJECT') pb = self.obj.pose.bones - ctrl = pb[bones['ik']['ctrl']['terminal'][0]] + ctrl = pb[bones['ik']['mch_hand'][0]] props = [ "IK_follow", "root/parent" ] @@ -739,7 +764,7 @@ class Rig: controls_string = ", ".join(["'" + x + "'" for x in controls]) script = create_script( bones, 'arm' ) - script += extra_script % (controls_string, bones['ik']['ctrl']['terminal'][0], 'IK_follow', 'root/parent') + script += extra_script % (controls_string, bones['ik']['mch_hand'][0], 'IK_follow', 'root/parent') return [ script ] diff --git a/rigify/rigs/pitchipoy/limbs/super_leg.py b/rigify/rigs/pitchipoy/limbs/super_leg.py index 8a61bb4d..2bc206a9 100644 --- a/rigify/rigs/pitchipoy/limbs/super_leg.py +++ b/rigify/rigs/pitchipoy/limbs/super_leg.py @@ -524,6 +524,22 @@ class Rig: eb[ ctrl ].parent = None eb[ ctrl ].use_connect = False + # MCH for ik control + ctrl_socket = copy_bone(self.obj, org_bones[2], get_bone_name( org_bones[2], 'mch', 'ik_socket')) + eb[ctrl_socket].tail = eb[ctrl_socket].head + 0.8*(eb[ctrl_socket].tail-eb[ctrl_socket].head) + eb[ctrl_socket].parent = None + eb[ctrl].parent = eb[ctrl_socket] + + ctrl_root = copy_bone(self.obj, org_bones[2], get_bone_name( org_bones[2], 'mch', 'ik_root')) + eb[ctrl_root].tail = eb[ctrl_root].head + 0.7*(eb[ctrl_root].tail-eb[ctrl_root].head) + eb[ctrl_root].use_connect = False + eb[ctrl_root].parent = eb['root'] + + ctrl_parent = copy_bone(self.obj, org_bones[2], get_bone_name( org_bones[2], 'mch', 'ik_parent')) + eb[ctrl_parent].tail = eb[ctrl_parent].head + 0.6*(eb[ctrl_parent].tail-eb[ctrl_parent].head) + eb[ctrl_parent].use_connect = False + eb[ctrl_parent].parent = eb[org_bones[0]].parent + # Create heel ctrl bone heel = get_bone_name( org_bones[2], 'ctrl', 'heel_ik' ) heel = copy_bone( self.obj, org_bones[2], heel ) @@ -602,7 +618,7 @@ class Rig: # Get target for ctrl constraints # Todo this should be better : target = strip_org(eb[org_bones[0]].parent.name) - target = eb[org_bones[0]].parent.name + #target = eb[org_bones[0]].parent.name # Constrain rock and roll MCH bones make_constraint( self, roll1_mch, { @@ -678,23 +694,23 @@ class Rig: # Constrain ik ctrl to root / parent - make_constraint( self, ctrl, { - 'constraint' : 'CHILD_OF', - 'subtarget' : 'root', + make_constraint( self, ctrl_socket, { + 'constraint' : 'COPY_TRANSFORMS', + 'subtarget' : ctrl_root, }) - make_constraint( self, ctrl, { - 'constraint' : 'CHILD_OF', - 'subtarget' : target, + make_constraint( self, ctrl_socket, { + 'constraint' : 'COPY_TRANSFORMS', + 'subtarget' : ctrl_parent, 'influence' : 0.0, }) - pbone = self.obj.pose.bones[target] - - const = self.obj.pose.bones[ctrl].constraints[1] - const.inverse_matrix = (self.obj.matrix_world*pbone.matrix).inverted() + # pbone = self.obj.pose.bones[target] + # + # const = self.obj.pose.bones[ctrl].constraints[1] + # const.inverse_matrix = (self.obj.matrix_world*pbone.matrix).inverted() # Constrain mch target bone to the ik control and mch stretch @@ -825,6 +841,7 @@ class Rig: bones['ik']['ctrl']['terminal'] += [ toes ] bones['ik']['ctrl']['terminal'] += [ heel, ctrl ] + bones['ik']['mch_foot'] = [ctrl_socket, ctrl_root, ctrl_parent] return bones @@ -842,7 +859,7 @@ class Rig: bpy.ops.object.mode_set(mode ='OBJECT') pb = self.obj.pose.bones - ctrl = pb[bones['ik']['ctrl']['terminal'][-1]] + ctrl = pb[bones['ik']['mch_foot'][0]] props = [ "IK_follow", "root/parent" ] @@ -957,7 +974,7 @@ class Rig: controls_string = ", ".join(["'" + x + "'" for x in controls]) script = create_script( bones, 'leg' ) - script += extra_script % (controls_string, bones['ik']['ctrl']['terminal'][-1], 'IK_follow', 'root/parent') + script += extra_script % (controls_string, bones['ik']['mch_foot'][0], 'IK_follow', 'root/parent') return [ script ] @@ -1081,18 +1098,21 @@ def get_future_names(bone): name = bone[:-2] suffix = bone[-2:] - list.append(org(name) + suffix) - list.append(make_mechanism_name(name) + 'ik_stretch' + suffix) - list.append(make_deformer_name(name) + suffix) - list.append(name + '_fk' + suffix) - list.append(name + '_tweak' + suffix) + list.append(org(name) + suffix) + list.append(make_mechanism_name(name) + 'ik_stretch' + suffix) + list.append(make_deformer_name(name) + suffix) + list.append(name + '_fk' + suffix) + list.append(name + '_tweak' + suffix) - list.append(name + '_tweak' + suffix + '.001') - list.append(name + '_ik' + suffix) + list.append(name + '_tweak' + suffix + '.001') + list.append(name + '_ik' + suffix) return list + return ['prova', 'prova2'] + + def create_sample(obj): # generated by rigify.utils.write_metarig bpy.ops.object.mode_set(mode='EDIT') |