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/super_torso_turbo.py')
-rw-r--r--rigify/rigs/pitchipoy/super_torso_turbo.py212
1 files changed, 106 insertions, 106 deletions
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']]