Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'rigify/rigs/pitchipoy/limbs/super_front_paw.py')
-rw-r--r--rigify/rigs/pitchipoy/limbs/super_front_paw.py211
1 files changed, 171 insertions, 40 deletions
diff --git a/rigify/rigs/pitchipoy/limbs/super_front_paw.py b/rigify/rigs/pitchipoy/limbs/super_front_paw.py
index 936395ca..04e6280f 100644
--- a/rigify/rigs/pitchipoy/limbs/super_front_paw.py
+++ b/rigify/rigs/pitchipoy/limbs/super_front_paw.py
@@ -15,6 +15,17 @@ from ..super_widgets import create_ikarrow_widget
from ..super_widgets import create_foot_widget, create_ballsocket_widget
from math import trunc
+
+extra_script = """
+controls = [%s]
+ctrl = '%s'
+
+if is_selected( controls ):
+ layout.prop( pose_bones[ ctrl ], '["%s"]')
+ if '%s' in pose_bones[ctrl].keys():
+ layout.prop( pose_bones[ ctrl ], '["%s"]', slider = True )
+"""
+
class Rig:
def __init__(self, obj, bone_name, params):
""" Initialize torso rig and key rig properties """
@@ -41,8 +52,7 @@ class Rig:
else:
self.fk_layers = None
-
- def create_parent( self ):
+ def create_parent(self):
org_bones = self.org_bones
@@ -96,8 +106,7 @@ class Rig:
return mch
-
- def create_tweak( self ):
+ def create_tweak(self):
org_bones = self.org_bones
bpy.ops.object.mode_set(mode ='EDIT')
@@ -235,8 +244,7 @@ class Rig:
return tweaks
-
- def create_def( self, tweaks ):
+ def create_def(self, tweaks ):
org_bones = self.org_bones
bpy.ops.object.mode_set(mode ='EDIT')
@@ -342,8 +350,7 @@ class Rig:
return def_bones
-
- def create_ik( self, parent ):
+ def create_ik(self, parent ):
org_bones = self.org_bones
bpy.ops.object.mode_set(mode ='EDIT')
@@ -400,8 +407,7 @@ class Rig:
'mch_str' : mch_str
}
-
- def create_fk( self, parent ):
+ def create_fk(self, parent ):
org_bones = self.org_bones.copy()
@@ -452,8 +458,7 @@ class Rig:
return { 'ctrl' : ctrls, 'mch' : mch }
-
- def org_parenting_and_switch( self, org, ik, fk, parent ):
+ def org_parenting_and_switch(self, org, ik, fk, parent):
bpy.ops.object.mode_set(mode ='EDIT')
eb = self.obj.data.edit_bones
# re-parent ORGs in a connected chain
@@ -501,13 +506,12 @@ class Rig:
var.targets[0].data_path = \
pb_parent.path_from_id() + '['+ '"' + prop.name + '"' + ']'
-
def create_paw( self, bones ):
+
org_bones = list(
[self.org_bones[0]] + connected_children_names(self.obj, self.org_bones[0])
)
-
bones['ik']['ctrl']['terminal'] = []
bpy.ops.object.mode_set(mode='EDIT')
@@ -521,6 +525,26 @@ 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']
+
+ if eb[org_bones[0]].parent:
+ paw_parent = eb[org_bones[0]].parent
+ 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
+ else:
+ paw_parent = None
+
# Create heel control bone
heel = get_bone_name( org_bones[2], 'ctrl', 'heel_ik' )
heel = copy_bone( self.obj, org_bones[2], heel )
@@ -544,9 +568,22 @@ class Rig:
eb[ ctrl ].length = l
# Set up constraints
- # Constrain mch target bone to the ik control and mch stretch
+ # Constrain ik ctrl to root / parent
+ make_constraint( self, ctrl_socket, {
+ 'constraint' : 'COPY_TRANSFORMS',
+ 'subtarget' : ctrl_root,
+ })
+
+ if paw_parent:
+ make_constraint( self, ctrl_socket, {
+ 'constraint' : 'COPY_TRANSFORMS',
+ 'subtarget' : ctrl_parent,
+ 'influence' : 0.0,
+ })
+
+ # Constrain mch target bone to the ik control and mch stretch
make_constraint( self, bones['ik']['mch_target'], {
'constraint' : 'COPY_LOCATION',
'subtarget' : bones['ik']['mch_str'],
@@ -680,42 +717,136 @@ class Rig:
bones['ik']['ctrl']['terminal'] += [ heel, ctrl ]
+ if paw_parent:
+ bones['ik']['mch_foot'] = [ctrl_socket, ctrl_root, ctrl_parent]
+ else:
+ bones['ik']['mch_foot'] = [ctrl_socket, ctrl_root]
+
return bones
- # def create_terminal( self, limb_type, bones ):
- # if limb_type == 'arm':
- # return create_arm( self, bones )
- # elif limb_type == 'leg':
- # return create_leg( self, bones )
- # elif limb_type == 'paw':
- # return create_paw( self, bones )
+ def create_drivers(self, bones):
+ bpy.ops.object.mode_set(mode ='OBJECT')
+ pb = self.obj.pose.bones
+
+ ctrl = pb[bones['ik']['mch_foot'][0]]
+
+ props = [ "IK_follow", "root/parent" ]
+
+ for prop in props:
+ if prop == 'IK_follow':
+
+ ctrl[prop] = True
+ rna_prop = rna_idprop_ui_prop_get( ctrl, prop, create=True )
+ rna_prop["min"] = False
+ rna_prop["max"] = True
+ rna_prop["description"] = prop
+
+ drv = ctrl.constraints[ 0 ].driver_add("mute").driver
+ drv.type = 'AVERAGE'
+
+ var = drv.variables.new()
+ var.name = prop
+ var.type = "SINGLE_PROP"
+ var.targets[0].id = self.obj
+ var.targets[0].data_path = \
+ ctrl.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
+
+ if len(ctrl.constraints) > 1:
+ drv = ctrl.constraints[ 1 ].driver_add("mute").driver
+ drv.type = 'AVERAGE'
+
+ var = drv.variables.new()
+ var.name = prop
+ var.type = "SINGLE_PROP"
+ var.targets[0].id = self.obj
+ var.targets[0].data_path = \
+ ctrl.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
+
+ elif len(ctrl.constraints) > 1:
+ ctrl[prop]=0.0
+ rna_prop = rna_idprop_ui_prop_get( ctrl, prop, create=True )
+ rna_prop["min"] = 0.0
+ rna_prop["max"] = 1.0
+ rna_prop["soft_min"] = 0.0
+ rna_prop["soft_max"] = 1.0
+ rna_prop["description"] = prop
+
+ # drv = ctrl.constraints[ 0 ].driver_add("influence").driver
+ # drv.type = 'AVERAGE'
+ #
+ # var = drv.variables.new()
+ # var.name = prop
+ # var.type = "SINGLE_PROP"
+ # var.targets[0].id = self.obj
+ # var.targets[0].data_path = \
+ # ctrl.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
+
+ drv = ctrl.constraints[ 1 ].driver_add("influence").driver
+ drv.type = 'AVERAGE'
+
+ var = drv.variables.new()
+ var.name = prop
+ var.type = "SINGLE_PROP"
+ var.targets[0].id = self.obj
+ var.targets[0].data_path = \
+ ctrl.path_from_id() + '['+ '"' + prop + '"' + ']'
def generate( self ):
- bpy.ops.object.mode_set(mode ='EDIT')
- eb = self.obj.data.edit_bones
+ bpy.ops.object.mode_set(mode ='EDIT')
+ eb = self.obj.data.edit_bones
+
+ # Clear parents for org bones
+ for bone in self.org_bones[1:]:
+ eb[bone].use_connect = False
+ eb[bone].parent = None
+
+ bones = {}
- # Clear parents for org bones
- for bone in self.org_bones[1:]:
- eb[bone].use_connect = False
- eb[bone].parent = None
+ # Create mch limb parent
+ bones['parent'] = self.create_parent()
+ 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']
+ )
- bones = {}
+ bones = self.create_paw( bones )
+ self.create_drivers( bones )
- # Create mch limb parent
- bones['parent'] = self.create_parent()
- 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'] )
+ controls = [ bones['ik']['ctrl']['limb'], bones['ik']['ctrl']['terminal'][-1], bones['ik']['ctrl']['terminal'][-2] ]
- self.org_parenting_and_switch(
- self.org_bones, bones['ik'], bones['fk']['ctrl'], bones['parent']
- )
+ # Create UI
+ controls_string = ", ".join(["'" + x + "'" for x in controls])
- bones = self.create_paw( bones )
+ script = create_script( bones, 'paw' )
+ script += extra_script % (controls_string, bones['ik']['mch_foot'][0], 'IK_follow', 'root/parent','root/parent')
- return [ create_script( bones, 'paw' ) ]
+ return [ script ]
def add_parameters( params ):