diff options
author | Nathan Vegdahl <cessen@cessen.com> | 2013-02-16 23:35:26 +0400 |
---|---|---|
committer | Nathan Vegdahl <cessen@cessen.com> | 2013-02-16 23:35:26 +0400 |
commit | 47b467eb42d4a8ec7041c98e13653f481cf56597 (patch) | |
tree | 6cae6dbdca8e562aca1d0aae9620b03597c6ce6b /rigify/rigs | |
parent | 21e99d0bd6b6a71cbf871cc4aaf6f2b744cd3d14 (diff) |
Rigify: changed rig type API. Disabled delta rig type.
I have updated the rig type API to be a bit clearer based on my
interactions with Kfir from PitchiPoy.
I've also disabled the "delta" rig type, as it is very obscure and
mostly just confuses people.
Diffstat (limited to 'rigify/rigs')
-rw-r--r-- | rigify/rigs/basic/copy.py | 101 | ||||
-rw-r--r-- | rigify/rigs/basic/copy_chain.py | 157 | ||||
-rw-r--r-- | rigify/rigs/biped/arm/__init__.py | 282 | ||||
-rw-r--r-- | rigify/rigs/biped/leg/__init__.py | 352 | ||||
-rw-r--r-- | rigify/rigs/finger.py | 258 | ||||
-rw-r--r-- | rigify/rigs/misc/delta.py | 144 | ||||
-rw-r--r-- | rigify/rigs/neck_short.py | 96 | ||||
-rw-r--r-- | rigify/rigs/palm.py | 210 | ||||
-rw-r--r-- | rigify/rigs/spine.py | 172 |
9 files changed, 880 insertions, 892 deletions
diff --git a/rigify/rigs/basic/copy.py b/rigify/rigs/basic/copy.py index 9deb0e11..50a25767 100644 --- a/rigify/rigs/basic/copy.py +++ b/rigify/rigs/basic/copy.py @@ -83,60 +83,57 @@ class Rig: # Create control widget create_bone_widget(self.obj, bone) - @classmethod - def add_parameters(self, 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_deform = bpy.props.BoolProperty(name="Deform", default=True, description="Create a deform bone for the copy") - - @classmethod - def parameters_ui(self, layout, obj, bone): - """ Create the ui for the rig parameters. - """ - params = obj.pose.bones[bone].rigify_parameters - r = layout.row() - r.prop(params, "make_control") - r = layout.row() - r.prop(params, "make_deform") - - @classmethod - def create_sample(self, obj): - """ Create a sample metarig for this rig type. - - """ - # generated by rigify.utils.write_metarig - bpy.ops.object.mode_set(mode='EDIT') - arm = obj.data +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_deform = bpy.props.BoolProperty(name="Deform", default=True, description="Create a deform bone for the copy") - bones = {} - bone = arm.edit_bones.new('Bone') - bone.head[:] = 0.0000, 0.0000, 0.0000 - bone.tail[:] = 0.0000, 0.0000, 0.2000 - bone.roll = 0.0000 - bone.use_connect = False - bones['Bone'] = bone.name +def parameters_ui(layout, params): + """ Create the ui for the rig parameters. + """ + r = layout.row() + r.prop(params, "make_control") + r = layout.row() + r.prop(params, "make_deform") - bpy.ops.object.mode_set(mode='OBJECT') - pbone = obj.pose.bones[bones['Bone']] - pbone.rigify_type = 'basic.copy' - pbone.lock_location = (False, False, False) - pbone.lock_rotation = (False, False, False) - pbone.lock_rotation_w = False - pbone.lock_scale = (False, False, False) - pbone.rotation_mode = 'QUATERNION' - bpy.ops.object.mode_set(mode='EDIT') - for bone in arm.edit_bones: - bone.select = False - bone.select_head = False - bone.select_tail = False - for b in bones: - bone = arm.edit_bones[bones[b]] - bone.select = True - bone.select_head = True - bone.select_tail = True - arm.edit_bones.active = bone +def create_sample(obj): + """ Create a sample metarig for this rig type. + """ + # generated by rigify.utils.write_metarig + bpy.ops.object.mode_set(mode='EDIT') + arm = obj.data + + bones = {} + + bone = arm.edit_bones.new('Bone') + bone.head[:] = 0.0000, 0.0000, 0.0000 + bone.tail[:] = 0.0000, 0.0000, 0.2000 + bone.roll = 0.0000 + bone.use_connect = False + bones['Bone'] = bone.name + + bpy.ops.object.mode_set(mode='OBJECT') + pbone = obj.pose.bones[bones['Bone']] + pbone.rigify_type = 'basic.copy' + pbone.lock_location = (False, False, False) + pbone.lock_rotation = (False, False, False) + pbone.lock_rotation_w = False + pbone.lock_scale = (False, False, False) + pbone.rotation_mode = 'QUATERNION' + + bpy.ops.object.mode_set(mode='EDIT') + for bone in arm.edit_bones: + bone.select = False + bone.select_head = False + bone.select_tail = False + for b in bones: + bone = arm.edit_bones[bones[b]] + bone.select = True + bone.select_head = True + bone.select_tail = True + arm.edit_bones.active = bone diff --git a/rigify/rigs/basic/copy_chain.py b/rigify/rigs/basic/copy_chain.py index a56e65c3..4e426284 100644 --- a/rigify/rigs/basic/copy_chain.py +++ b/rigify/rigs/basic/copy_chain.py @@ -122,88 +122,85 @@ class Rig: for bone in ctrl_chain: create_bone_widget(self.obj, bone) - @classmethod - def add_parameters(self, params): - """ Add the parameters of this rig type to the - RigifyParameters PropertyGroup - """ - params.make_controls = bpy.props.BoolProperty(name="Controls", default=True, description="Create control bones for the copy") - params.make_deforms = bpy.props.BoolProperty(name="Deform", default=True, description="Create deform bones for the copy") - - @classmethod - def parameters_ui(self, layout, obj, bone): - """ Create the ui for the rig parameters. - """ - params = obj.pose.bones[bone].rigify_parameters - r = layout.row() - r.prop(params, "make_controls") - r = layout.row() - r.prop(params, "make_deforms") +def add_parameters(params): + """ Add the parameters of this rig type to the + RigifyParameters PropertyGroup + """ + params.make_controls = bpy.props.BoolProperty(name="Controls", default=True, description="Create control bones for the copy") + params.make_deforms = bpy.props.BoolProperty(name="Deform", default=True, description="Create deform bones for the copy") - @classmethod - def create_sample(self, obj): - """ Create a sample metarig for this rig type. - """ - # generated by rigify.utils.write_metarig - bpy.ops.object.mode_set(mode='EDIT') - arm = obj.data - - bones = {} - - bone = arm.edit_bones.new('bone.01') - bone.head[:] = 0.0000, 0.0000, 0.0000 - bone.tail[:] = 0.0000, 0.0000, 0.3333 - bone.roll = 0.0000 - bone.use_connect = False - bones['bone.01'] = bone.name - bone = arm.edit_bones.new('bone.02') - bone.head[:] = 0.0000, 0.0000, 0.3333 - bone.tail[:] = 0.0000, 0.0000, 0.6667 - bone.roll = 3.1416 - bone.use_connect = True - bone.parent = arm.edit_bones[bones['bone.01']] - bones['bone.02'] = bone.name - bone = arm.edit_bones.new('bone.03') - bone.head[:] = 0.0000, 0.0000, 0.6667 - bone.tail[:] = 0.0000, 0.0000, 1.0000 - bone.roll = 3.1416 - bone.use_connect = True - bone.parent = arm.edit_bones[bones['bone.02']] - bones['bone.03'] = bone.name +def parameters_ui(layout, params): + """ Create the ui for the rig parameters. + """ + r = layout.row() + r.prop(params, "make_controls") + r = layout.row() + r.prop(params, "make_deforms") - bpy.ops.object.mode_set(mode='OBJECT') - pbone = obj.pose.bones[bones['bone.01']] - pbone.rigify_type = 'basic.copy_chain' - pbone.lock_location = (False, False, False) - pbone.lock_rotation = (False, False, False) - pbone.lock_rotation_w = False - pbone.lock_scale = (False, False, False) - pbone.rotation_mode = 'QUATERNION' - pbone = obj.pose.bones[bones['bone.02']] - pbone.rigify_type = '' - pbone.lock_location = (False, False, False) - pbone.lock_rotation = (False, False, False) - pbone.lock_rotation_w = False - pbone.lock_scale = (False, False, False) - pbone.rotation_mode = 'QUATERNION' - pbone = obj.pose.bones[bones['bone.03']] - pbone.rigify_type = '' - pbone.lock_location = (False, False, False) - pbone.lock_rotation = (False, False, False) - pbone.lock_rotation_w = False - pbone.lock_scale = (False, False, False) - pbone.rotation_mode = 'QUATERNION' - bpy.ops.object.mode_set(mode='EDIT') - for bone in arm.edit_bones: - bone.select = False - bone.select_head = False - bone.select_tail = False - for b in bones: - bone = arm.edit_bones[bones[b]] - bone.select = True - bone.select_head = True - bone.select_tail = True - arm.edit_bones.active = bone +def create_sample(obj): + """ Create a sample metarig for this rig type. + """ + # generated by rigify.utils.write_metarig + bpy.ops.object.mode_set(mode='EDIT') + arm = obj.data + + bones = {} + + bone = arm.edit_bones.new('bone.01') + bone.head[:] = 0.0000, 0.0000, 0.0000 + bone.tail[:] = 0.0000, 0.0000, 0.3333 + bone.roll = 0.0000 + bone.use_connect = False + bones['bone.01'] = bone.name + bone = arm.edit_bones.new('bone.02') + bone.head[:] = 0.0000, 0.0000, 0.3333 + bone.tail[:] = 0.0000, 0.0000, 0.6667 + bone.roll = 3.1416 + bone.use_connect = True + bone.parent = arm.edit_bones[bones['bone.01']] + bones['bone.02'] = bone.name + bone = arm.edit_bones.new('bone.03') + bone.head[:] = 0.0000, 0.0000, 0.6667 + bone.tail[:] = 0.0000, 0.0000, 1.0000 + bone.roll = 3.1416 + bone.use_connect = True + bone.parent = arm.edit_bones[bones['bone.02']] + bones['bone.03'] = bone.name + + bpy.ops.object.mode_set(mode='OBJECT') + pbone = obj.pose.bones[bones['bone.01']] + pbone.rigify_type = 'basic.copy_chain' + pbone.lock_location = (False, False, False) + pbone.lock_rotation = (False, False, False) + pbone.lock_rotation_w = False + pbone.lock_scale = (False, False, False) + pbone.rotation_mode = 'QUATERNION' + pbone = obj.pose.bones[bones['bone.02']] + pbone.rigify_type = '' + pbone.lock_location = (False, False, False) + pbone.lock_rotation = (False, False, False) + pbone.lock_rotation_w = False + pbone.lock_scale = (False, False, False) + pbone.rotation_mode = 'QUATERNION' + pbone = obj.pose.bones[bones['bone.03']] + pbone.rigify_type = '' + pbone.lock_location = (False, False, False) + pbone.lock_rotation = (False, False, False) + pbone.lock_rotation_w = False + pbone.lock_scale = (False, False, False) + pbone.rotation_mode = 'QUATERNION' + + bpy.ops.object.mode_set(mode='EDIT') + for bone in arm.edit_bones: + bone.select = False + bone.select_head = False + bone.select_tail = False + for b in bones: + bone = arm.edit_bones[bones[b]] + bone.select = True + bone.select_head = True + bone.select_tail = True + arm.edit_bones.active = bone diff --git a/rigify/rigs/biped/arm/__init__.py b/rigify/rigs/biped/arm/__init__.py index 9cdf31ab..2d2d6beb 100644 --- a/rigify/rigs/biped/arm/__init__.py +++ b/rigify/rigs/biped/arm/__init__.py @@ -88,151 +88,149 @@ class Rig: ik_controls = self.ik_rig.generate() return [script % (fk_controls[0], fk_controls[1], fk_controls[2], ik_controls[0], ik_controls[1], ik_controls[2], ik_controls[3])] - @classmethod - def add_parameters(self, params): - """ Add the parameters of this rig type to the - RigifyParameters PropertyGroup - """ - items = [('X', 'X', ''), ('Y', 'Y', ''), ('Z', 'Z', ''), ('-X', '-X', ''), ('-Y', '-Y', ''), ('-Z', '-Z', '')] - params.primary_rotation_axis = bpy.props.EnumProperty(items=items, name="Primary Rotation Axis", default='X') +def add_parameters(params): + """ Add the parameters of this rig type to the + RigifyParameters PropertyGroup - params.bend_hint = bpy.props.BoolProperty(name="Bend Hint", default=True, description="Give IK chain a hint about which way to bend. Useful for perfectly straight chains") - params.elbow_target_base_name = bpy.props.StringProperty(name="Elbow Target Name", default="elbow_target", description="Base name for the generated elbow target.") + """ + items = [('X', 'X', ''), ('Y', 'Y', ''), ('Z', 'Z', ''), ('-X', '-X', ''), ('-Y', '-Y', ''), ('-Z', '-Z', '')] + params.primary_rotation_axis = bpy.props.EnumProperty(items=items, name="Primary Rotation Axis", default='X') - params.separate_ik_layers = bpy.props.BoolProperty(name="Separate IK Control Layers:", default=False, description="Enable putting the ik controls on a separate layer from the fk controls") - params.ik_layers = bpy.props.BoolVectorProperty(size=32, description="Layers for the ik controls to be on") + params.bend_hint = bpy.props.BoolProperty(name="Bend Hint", default=True, description="Give IK chain a hint about which way to bend. Useful for perfectly straight chains") + params.elbow_target_base_name = bpy.props.StringProperty(name="Elbow Target Name", default="elbow_target", description="Base name for the generated elbow target.") - params.use_upper_arm_twist = bpy.props.BoolProperty(name="Upper Arm Twist", default=True, description="Generate the dual-bone twist setup for the upper arm") - params.use_forearm_twist = bpy.props.BoolProperty(name="Forearm Twist", default=True, description="Generate the dual-bone twist setup for the forearm") + params.separate_ik_layers = bpy.props.BoolProperty(name="Separate IK Control Layers:", default=False, description="Enable putting the ik controls on a separate layer from the fk controls") + params.ik_layers = bpy.props.BoolVectorProperty(size=32, description="Layers for the ik controls to be on") - @classmethod - def parameters_ui(self, layout, obj, bone): - """ Create the ui for the rig parameters. + params.use_upper_arm_twist = bpy.props.BoolProperty(name="Upper Arm Twist", default=True, description="Generate the dual-bone twist setup for the upper arm") + params.use_forearm_twist = bpy.props.BoolProperty(name="Forearm Twist", default=True, description="Generate the dual-bone twist setup for the forearm") - """ - params = obj.pose.bones[bone].rigify_parameters - - r = layout.row() - r.prop(params, "elbow_target_base_name") - - r = layout.row() - r.prop(params, "separate_ik_layers") - - r = layout.row() - r.active = params.separate_ik_layers - - col = r.column(align=True) - row = col.row(align=True) - row.prop(params, "ik_layers", index=0, toggle=True, text="") - row.prop(params, "ik_layers", index=1, toggle=True, text="") - row.prop(params, "ik_layers", index=2, toggle=True, text="") - row.prop(params, "ik_layers", index=3, toggle=True, text="") - row.prop(params, "ik_layers", index=4, toggle=True, text="") - row.prop(params, "ik_layers", index=5, toggle=True, text="") - row.prop(params, "ik_layers", index=6, toggle=True, text="") - row.prop(params, "ik_layers", index=7, toggle=True, text="") - row = col.row(align=True) - row.prop(params, "ik_layers", index=16, toggle=True, text="") - row.prop(params, "ik_layers", index=17, toggle=True, text="") - row.prop(params, "ik_layers", index=18, toggle=True, text="") - row.prop(params, "ik_layers", index=19, toggle=True, text="") - row.prop(params, "ik_layers", index=20, toggle=True, text="") - row.prop(params, "ik_layers", index=21, toggle=True, text="") - row.prop(params, "ik_layers", index=22, toggle=True, text="") - row.prop(params, "ik_layers", index=23, toggle=True, text="") - - col = r.column(align=True) - row = col.row(align=True) - row.prop(params, "ik_layers", index=8, toggle=True, text="") - row.prop(params, "ik_layers", index=9, toggle=True, text="") - row.prop(params, "ik_layers", index=10, toggle=True, text="") - row.prop(params, "ik_layers", index=11, toggle=True, text="") - row.prop(params, "ik_layers", index=12, toggle=True, text="") - row.prop(params, "ik_layers", index=13, toggle=True, text="") - row.prop(params, "ik_layers", index=14, toggle=True, text="") - row.prop(params, "ik_layers", index=15, toggle=True, text="") - row = col.row(align=True) - row.prop(params, "ik_layers", index=24, toggle=True, text="") - row.prop(params, "ik_layers", index=25, toggle=True, text="") - row.prop(params, "ik_layers", index=26, toggle=True, text="") - row.prop(params, "ik_layers", index=27, toggle=True, text="") - row.prop(params, "ik_layers", index=28, toggle=True, text="") - row.prop(params, "ik_layers", index=29, toggle=True, text="") - row.prop(params, "ik_layers", index=30, toggle=True, text="") - row.prop(params, "ik_layers", index=31, toggle=True, text="") - - r = layout.row() - r.label(text="Elbow rotation axis:") - r.prop(params, "primary_rotation_axis", text="") - - r = layout.row() - r.prop(params, "bend_hint") - - col = layout.column() - col.prop(params, "use_upper_arm_twist") - col.prop(params, "use_forearm_twist") - - @classmethod - def create_sample(self, obj): - # generated by rigify.utils.write_meta_rig - bpy.ops.object.mode_set(mode='EDIT') - arm = obj.data - - bones = {} - - bone = arm.edit_bones.new('upper_arm') - bone.head[:] = 0.0000, 0.0000, 0.0000 - bone.tail[:] = 0.3000, 0.0300, 0.0000 - bone.roll = 1.5708 - bone.use_connect = False - bones['upper_arm'] = bone.name - bone = arm.edit_bones.new('forearm') - bone.head[:] = 0.3000, 0.0300, 0.0000 - bone.tail[:] = 0.6000, 0.0000, 0.0000 - bone.roll = 1.5708 - bone.use_connect = True - bone.parent = arm.edit_bones[bones['upper_arm']] - bones['forearm'] = bone.name - bone = arm.edit_bones.new('hand') - bone.head[:] = 0.6000, 0.0000, 0.0000 - bone.tail[:] = 0.7000, 0.0000, 0.0000 - bone.roll = 3.1416 - bone.use_connect = True - bone.parent = arm.edit_bones[bones['forearm']] - bones['hand'] = bone.name - - bpy.ops.object.mode_set(mode='OBJECT') - pbone = obj.pose.bones[bones['upper_arm']] - pbone.rigify_type = 'biped.arm' - pbone.lock_location = (True, True, True) - pbone.lock_rotation = (False, False, False) - pbone.lock_rotation_w = False - pbone.lock_scale = (False, False, False) - pbone.rotation_mode = 'QUATERNION' - pbone = obj.pose.bones[bones['forearm']] - pbone.rigify_type = '' - pbone.lock_location = (False, False, False) - pbone.lock_rotation = (False, False, False) - pbone.lock_rotation_w = False - pbone.lock_scale = (False, False, False) - pbone.rotation_mode = 'QUATERNION' - pbone = obj.pose.bones[bones['hand']] - pbone.rigify_type = '' - pbone.lock_location = (False, False, False) - pbone.lock_rotation = (False, False, False) - pbone.lock_rotation_w = False - pbone.lock_scale = (False, False, False) - pbone.rotation_mode = 'QUATERNION' - - bpy.ops.object.mode_set(mode='EDIT') - for bone in arm.edit_bones: - bone.select = False - bone.select_head = False - bone.select_tail = False - for b in bones: - bone = arm.edit_bones[bones[b]] - bone.select = True - bone.select_head = True - bone.select_tail = True - arm.edit_bones.active = bone + +def parameters_ui(layout, params): + """ Create the ui for the rig parameters. + + """ + r = layout.row() + r.prop(params, "elbow_target_base_name") + + r = layout.row() + r.prop(params, "separate_ik_layers") + + r = layout.row() + r.active = params.separate_ik_layers + + col = r.column(align=True) + row = col.row(align=True) + row.prop(params, "ik_layers", index=0, toggle=True, text="") + row.prop(params, "ik_layers", index=1, toggle=True, text="") + row.prop(params, "ik_layers", index=2, toggle=True, text="") + row.prop(params, "ik_layers", index=3, toggle=True, text="") + row.prop(params, "ik_layers", index=4, toggle=True, text="") + row.prop(params, "ik_layers", index=5, toggle=True, text="") + row.prop(params, "ik_layers", index=6, toggle=True, text="") + row.prop(params, "ik_layers", index=7, toggle=True, text="") + row = col.row(align=True) + row.prop(params, "ik_layers", index=16, toggle=True, text="") + row.prop(params, "ik_layers", index=17, toggle=True, text="") + row.prop(params, "ik_layers", index=18, toggle=True, text="") + row.prop(params, "ik_layers", index=19, toggle=True, text="") + row.prop(params, "ik_layers", index=20, toggle=True, text="") + row.prop(params, "ik_layers", index=21, toggle=True, text="") + row.prop(params, "ik_layers", index=22, toggle=True, text="") + row.prop(params, "ik_layers", index=23, toggle=True, text="") + + col = r.column(align=True) + row = col.row(align=True) + row.prop(params, "ik_layers", index=8, toggle=True, text="") + row.prop(params, "ik_layers", index=9, toggle=True, text="") + row.prop(params, "ik_layers", index=10, toggle=True, text="") + row.prop(params, "ik_layers", index=11, toggle=True, text="") + row.prop(params, "ik_layers", index=12, toggle=True, text="") + row.prop(params, "ik_layers", index=13, toggle=True, text="") + row.prop(params, "ik_layers", index=14, toggle=True, text="") + row.prop(params, "ik_layers", index=15, toggle=True, text="") + row = col.row(align=True) + row.prop(params, "ik_layers", index=24, toggle=True, text="") + row.prop(params, "ik_layers", index=25, toggle=True, text="") + row.prop(params, "ik_layers", index=26, toggle=True, text="") + row.prop(params, "ik_layers", index=27, toggle=True, text="") + row.prop(params, "ik_layers", index=28, toggle=True, text="") + row.prop(params, "ik_layers", index=29, toggle=True, text="") + row.prop(params, "ik_layers", index=30, toggle=True, text="") + row.prop(params, "ik_layers", index=31, toggle=True, text="") + + r = layout.row() + r.label(text="Elbow rotation axis:") + r.prop(params, "primary_rotation_axis", text="") + + r = layout.row() + r.prop(params, "bend_hint") + + col = layout.column() + col.prop(params, "use_upper_arm_twist") + col.prop(params, "use_forearm_twist") + + +def create_sample(obj): + # generated by rigify.utils.write_meta_rig + bpy.ops.object.mode_set(mode='EDIT') + arm = obj.data + + bones = {} + + bone = arm.edit_bones.new('upper_arm') + bone.head[:] = 0.0000, 0.0000, 0.0000 + bone.tail[:] = 0.3000, 0.0300, 0.0000 + bone.roll = 1.5708 + bone.use_connect = False + bones['upper_arm'] = bone.name + bone = arm.edit_bones.new('forearm') + bone.head[:] = 0.3000, 0.0300, 0.0000 + bone.tail[:] = 0.6000, 0.0000, 0.0000 + bone.roll = 1.5708 + bone.use_connect = True + bone.parent = arm.edit_bones[bones['upper_arm']] + bones['forearm'] = bone.name + bone = arm.edit_bones.new('hand') + bone.head[:] = 0.6000, 0.0000, 0.0000 + bone.tail[:] = 0.7000, 0.0000, 0.0000 + bone.roll = 3.1416 + bone.use_connect = True + bone.parent = arm.edit_bones[bones['forearm']] + bones['hand'] = bone.name + + bpy.ops.object.mode_set(mode='OBJECT') + pbone = obj.pose.bones[bones['upper_arm']] + pbone.rigify_type = 'biped.arm' + pbone.lock_location = (True, True, True) + pbone.lock_rotation = (False, False, False) + pbone.lock_rotation_w = False + pbone.lock_scale = (False, False, False) + pbone.rotation_mode = 'QUATERNION' + pbone = obj.pose.bones[bones['forearm']] + pbone.rigify_type = '' + pbone.lock_location = (False, False, False) + pbone.lock_rotation = (False, False, False) + pbone.lock_rotation_w = False + pbone.lock_scale = (False, False, False) + pbone.rotation_mode = 'QUATERNION' + pbone = obj.pose.bones[bones['hand']] + pbone.rigify_type = '' + pbone.lock_location = (False, False, False) + pbone.lock_rotation = (False, False, False) + pbone.lock_rotation_w = False + pbone.lock_scale = (False, False, False) + pbone.rotation_mode = 'QUATERNION' + + bpy.ops.object.mode_set(mode='EDIT') + for bone in arm.edit_bones: + bone.select = False + bone.select_head = False + bone.select_tail = False + for b in bones: + bone = arm.edit_bones[bones[b]] + bone.select = True + bone.select_head = True + bone.select_tail = True + arm.edit_bones.active = bone diff --git a/rigify/rigs/biped/leg/__init__.py b/rigify/rigs/biped/leg/__init__.py index a3c71627..85c5840b 100644 --- a/rigify/rigs/biped/leg/__init__.py +++ b/rigify/rigs/biped/leg/__init__.py @@ -90,187 +90,185 @@ class Rig: ik_controls = self.ik_rig.generate() return [script % (fk_controls[0], fk_controls[1], fk_controls[2], fk_controls[3], ik_controls[0], ik_controls[1], ik_controls[2], ik_controls[3], ik_controls[4], ik_controls[5])] - @classmethod - def add_parameters(self, params): - """ Add the parameters of this rig type to the - RigifyParameters PropertyGroup - """ - items = [('X', 'X', ''), ('Y', 'Y', ''), ('Z', 'Z', ''), ('-X', '-X', ''), ('-Y', '-Y', ''), ('-Z', '-Z', '')] - params.primary_rotation_axis = bpy.props.EnumProperty(items=items, name="Primary Rotation Axis", default='X') +def add_parameters(params): + """ Add the parameters of this rig type to the + RigifyParameters PropertyGroup - params.bend_hint = bpy.props.BoolProperty(name="Bend Hint", default=True, description="Give IK chain a hint about which way to bend (useful for perfectly straight chains)") - params.knee_target_base_name = bpy.props.StringProperty(name="Knee Target Name", default="knee_target", description="Base name for the generated knee target.") + """ + items = [('X', 'X', ''), ('Y', 'Y', ''), ('Z', 'Z', ''), ('-X', '-X', ''), ('-Y', '-Y', ''), ('-Z', '-Z', '')] + params.primary_rotation_axis = bpy.props.EnumProperty(items=items, name="Primary Rotation Axis", default='X') + params.bend_hint = bpy.props.BoolProperty(name="Bend Hint", default=True, description="Give IK chain a hint about which way to bend (useful for perfectly straight chains)") + params.knee_target_base_name = bpy.props.StringProperty(name="Knee Target Name", default="knee_target", description="Base name for the generated knee target.") - params.separate_ik_layers = bpy.props.BoolProperty(name="Separate IK Control Layers:", default=False, description="Enable putting the ik controls on a separate layer from the fk controls") - params.ik_layers = bpy.props.BoolVectorProperty(size=32, description="Layers for the ik controls to be on") - params.use_thigh_twist = bpy.props.BoolProperty(name="Thigh Twist", default=True, description="Generate the dual-bone twist setup for the thigh") - params.use_shin_twist = bpy.props.BoolProperty(name="Shin Twist", default=True, description="Generate the dual-bone twist setup for the shin") + params.separate_ik_layers = bpy.props.BoolProperty(name="Separate IK Control Layers:", default=False, description="Enable putting the ik controls on a separate layer from the fk controls") + params.ik_layers = bpy.props.BoolVectorProperty(size=32, description="Layers for the ik controls to be on") - @classmethod - def parameters_ui(self, layout, obj, bone): - """ Create the ui for the rig parameters. + params.use_thigh_twist = bpy.props.BoolProperty(name="Thigh Twist", default=True, description="Generate the dual-bone twist setup for the thigh") + params.use_shin_twist = bpy.props.BoolProperty(name="Shin Twist", default=True, description="Generate the dual-bone twist setup for the shin") - """ - params = obj.pose.bones[bone].rigify_parameters - - r = layout.row() - r.prop(params, "knee_target_base_name") - - r = layout.row() - r.prop(params, "separate_ik_layers") - - r = layout.row() - r.active = params.separate_ik_layers - - col = r.column(align=True) - row = col.row(align=True) - row.prop(params, "ik_layers", index=0, toggle=True, text="") - row.prop(params, "ik_layers", index=1, toggle=True, text="") - row.prop(params, "ik_layers", index=2, toggle=True, text="") - row.prop(params, "ik_layers", index=3, toggle=True, text="") - row.prop(params, "ik_layers", index=4, toggle=True, text="") - row.prop(params, "ik_layers", index=5, toggle=True, text="") - row.prop(params, "ik_layers", index=6, toggle=True, text="") - row.prop(params, "ik_layers", index=7, toggle=True, text="") - row = col.row(align=True) - row.prop(params, "ik_layers", index=16, toggle=True, text="") - row.prop(params, "ik_layers", index=17, toggle=True, text="") - row.prop(params, "ik_layers", index=18, toggle=True, text="") - row.prop(params, "ik_layers", index=19, toggle=True, text="") - row.prop(params, "ik_layers", index=20, toggle=True, text="") - row.prop(params, "ik_layers", index=21, toggle=True, text="") - row.prop(params, "ik_layers", index=22, toggle=True, text="") - row.prop(params, "ik_layers", index=23, toggle=True, text="") - - col = r.column(align=True) - row = col.row(align=True) - row.prop(params, "ik_layers", index=8, toggle=True, text="") - row.prop(params, "ik_layers", index=9, toggle=True, text="") - row.prop(params, "ik_layers", index=10, toggle=True, text="") - row.prop(params, "ik_layers", index=11, toggle=True, text="") - row.prop(params, "ik_layers", index=12, toggle=True, text="") - row.prop(params, "ik_layers", index=13, toggle=True, text="") - row.prop(params, "ik_layers", index=14, toggle=True, text="") - row.prop(params, "ik_layers", index=15, toggle=True, text="") - row = col.row(align=True) - row.prop(params, "ik_layers", index=24, toggle=True, text="") - row.prop(params, "ik_layers", index=25, toggle=True, text="") - row.prop(params, "ik_layers", index=26, toggle=True, text="") - row.prop(params, "ik_layers", index=27, toggle=True, text="") - row.prop(params, "ik_layers", index=28, toggle=True, text="") - row.prop(params, "ik_layers", index=29, toggle=True, text="") - row.prop(params, "ik_layers", index=30, toggle=True, text="") - row.prop(params, "ik_layers", index=31, toggle=True, text="") - - r = layout.row() - r.label(text="Knee rotation axis:") - r.prop(params, "primary_rotation_axis", text="") - - r = layout.row() - r.prop(params, "bend_hint") - - col = layout.column() - col.prop(params, "use_thigh_twist") - col.prop(params, "use_shin_twist") - - @classmethod - def create_sample(self, obj): - # generated by rigify.utils.write_meta_rig - bpy.ops.object.mode_set(mode='EDIT') - arm = obj.data - - bones = {} - - bone = arm.edit_bones.new('thigh') - bone.head[:] = -0.0000, 0.0000, 1.0000 - bone.tail[:] = -0.0000, -0.0500, 0.5000 - bone.roll = -0.0000 - bone.use_connect = False - bones['thigh'] = bone.name - bone = arm.edit_bones.new('shin') - bone.head[:] = -0.0000, -0.0500, 0.5000 - bone.tail[:] = -0.0000, 0.0000, 0.1000 - bone.roll = -0.0000 - bone.use_connect = True - bone.parent = arm.edit_bones[bones['thigh']] - bones['shin'] = bone.name - bone = arm.edit_bones.new('foot') - bone.head[:] = -0.0000, 0.0000, 0.1000 - bone.tail[:] = 0.0000, -0.1200, 0.0300 - bone.roll = 0.0000 - bone.use_connect = True - bone.parent = arm.edit_bones[bones['shin']] - bones['foot'] = bone.name - bone = arm.edit_bones.new('heel') - bone.head[:] = -0.0000, 0.0000, 0.1000 - bone.tail[:] = -0.0000, 0.0600, 0.0000 - bone.roll = -0.0000 - bone.use_connect = True - bone.parent = arm.edit_bones[bones['shin']] - bones['heel'] = bone.name - bone = arm.edit_bones.new('heel.02') - bone.head[:] = -0.0500, -0.0200, 0.0000 - bone.tail[:] = 0.0500, -0.0200, 0.0000 - bone.roll = 0.0000 - bone.use_connect = False - bone.parent = arm.edit_bones[bones['heel']] - bones['heel.02'] = bone.name - bone = arm.edit_bones.new('toe') - bone.head[:] = 0.0000, -0.1200, 0.0300 - bone.tail[:] = 0.0000, -0.2000, 0.0300 - bone.roll = 3.1416 - bone.use_connect = True - bone.parent = arm.edit_bones[bones['foot']] - bones['toe'] = bone.name - - bpy.ops.object.mode_set(mode='OBJECT') - pbone = obj.pose.bones[bones['thigh']] - pbone.rigify_type = 'biped.leg' - pbone.lock_location = (True, True, True) - pbone.lock_rotation = (False, False, False) - pbone.lock_rotation_w = False - pbone.lock_scale = (False, False, False) - pbone.rotation_mode = 'QUATERNION' - pbone = obj.pose.bones[bones['shin']] - pbone.rigify_type = '' - pbone.lock_location = (False, False, False) - pbone.lock_rotation = (False, False, False) - pbone.lock_rotation_w = False - pbone.lock_scale = (False, False, False) - pbone.rotation_mode = 'QUATERNION' - pbone = obj.pose.bones[bones['foot']] - pbone.rigify_type = '' - pbone.lock_location = (False, False, False) - pbone.lock_rotation = (False, False, False) - pbone.lock_rotation_w = False - pbone.lock_scale = (False, False, False) - pbone.rotation_mode = 'QUATERNION' - pbone = obj.pose.bones[bones['heel']] - pbone.rigify_type = '' - pbone.lock_location = (False, False, False) - pbone.lock_rotation = (False, False, False) - pbone.lock_rotation_w = False - pbone.lock_scale = (False, False, False) - pbone.rotation_mode = 'QUATERNION' - pbone = obj.pose.bones[bones['toe']] - pbone.rigify_type = '' - pbone.lock_location = (False, False, False) - pbone.lock_rotation = (False, False, False) - pbone.lock_rotation_w = False - pbone.lock_scale = (False, False, False) - pbone.rotation_mode = 'QUATERNION' - - bpy.ops.object.mode_set(mode='EDIT') - for bone in arm.edit_bones: - bone.select = False - bone.select_head = False - bone.select_tail = False - for b in bones: - bone = arm.edit_bones[bones[b]] - bone.select = True - bone.select_head = True - bone.select_tail = True - arm.edit_bones.active = bone + +def parameters_ui(layout, params): + """ Create the ui for the rig parameters. + + """ + r = layout.row() + r.prop(params, "knee_target_base_name") + + r = layout.row() + r.prop(params, "separate_ik_layers") + + r = layout.row() + r.active = params.separate_ik_layers + + col = r.column(align=True) + row = col.row(align=True) + row.prop(params, "ik_layers", index=0, toggle=True, text="") + row.prop(params, "ik_layers", index=1, toggle=True, text="") + row.prop(params, "ik_layers", index=2, toggle=True, text="") + row.prop(params, "ik_layers", index=3, toggle=True, text="") + row.prop(params, "ik_layers", index=4, toggle=True, text="") + row.prop(params, "ik_layers", index=5, toggle=True, text="") + row.prop(params, "ik_layers", index=6, toggle=True, text="") + row.prop(params, "ik_layers", index=7, toggle=True, text="") + row = col.row(align=True) + row.prop(params, "ik_layers", index=16, toggle=True, text="") + row.prop(params, "ik_layers", index=17, toggle=True, text="") + row.prop(params, "ik_layers", index=18, toggle=True, text="") + row.prop(params, "ik_layers", index=19, toggle=True, text="") + row.prop(params, "ik_layers", index=20, toggle=True, text="") + row.prop(params, "ik_layers", index=21, toggle=True, text="") + row.prop(params, "ik_layers", index=22, toggle=True, text="") + row.prop(params, "ik_layers", index=23, toggle=True, text="") + + col = r.column(align=True) + row = col.row(align=True) + row.prop(params, "ik_layers", index=8, toggle=True, text="") + row.prop(params, "ik_layers", index=9, toggle=True, text="") + row.prop(params, "ik_layers", index=10, toggle=True, text="") + row.prop(params, "ik_layers", index=11, toggle=True, text="") + row.prop(params, "ik_layers", index=12, toggle=True, text="") + row.prop(params, "ik_layers", index=13, toggle=True, text="") + row.prop(params, "ik_layers", index=14, toggle=True, text="") + row.prop(params, "ik_layers", index=15, toggle=True, text="") + row = col.row(align=True) + row.prop(params, "ik_layers", index=24, toggle=True, text="") + row.prop(params, "ik_layers", index=25, toggle=True, text="") + row.prop(params, "ik_layers", index=26, toggle=True, text="") + row.prop(params, "ik_layers", index=27, toggle=True, text="") + row.prop(params, "ik_layers", index=28, toggle=True, text="") + row.prop(params, "ik_layers", index=29, toggle=True, text="") + row.prop(params, "ik_layers", index=30, toggle=True, text="") + row.prop(params, "ik_layers", index=31, toggle=True, text="") + + r = layout.row() + r.label(text="Knee rotation axis:") + r.prop(params, "primary_rotation_axis", text="") + + r = layout.row() + r.prop(params, "bend_hint") + + col = layout.column() + col.prop(params, "use_thigh_twist") + col.prop(params, "use_shin_twist") + + +def create_sample(obj): + # generated by rigify.utils.write_meta_rig + bpy.ops.object.mode_set(mode='EDIT') + arm = obj.data + + bones = {} + + bone = arm.edit_bones.new('thigh') + bone.head[:] = -0.0000, 0.0000, 1.0000 + bone.tail[:] = -0.0000, -0.0500, 0.5000 + bone.roll = -0.0000 + bone.use_connect = False + bones['thigh'] = bone.name + bone = arm.edit_bones.new('shin') + bone.head[:] = -0.0000, -0.0500, 0.5000 + bone.tail[:] = -0.0000, 0.0000, 0.1000 + bone.roll = -0.0000 + bone.use_connect = True + bone.parent = arm.edit_bones[bones['thigh']] + bones['shin'] = bone.name + bone = arm.edit_bones.new('foot') + bone.head[:] = -0.0000, 0.0000, 0.1000 + bone.tail[:] = 0.0000, -0.1200, 0.0300 + bone.roll = 0.0000 + bone.use_connect = True + bone.parent = arm.edit_bones[bones['shin']] + bones['foot'] = bone.name + bone = arm.edit_bones.new('heel') + bone.head[:] = -0.0000, 0.0000, 0.1000 + bone.tail[:] = -0.0000, 0.0600, 0.0000 + bone.roll = -0.0000 + bone.use_connect = True + bone.parent = arm.edit_bones[bones['shin']] + bones['heel'] = bone.name + bone = arm.edit_bones.new('heel.02') + bone.head[:] = -0.0500, -0.0200, 0.0000 + bone.tail[:] = 0.0500, -0.0200, 0.0000 + bone.roll = 0.0000 + bone.use_connect = False + bone.parent = arm.edit_bones[bones['heel']] + bones['heel.02'] = bone.name + bone = arm.edit_bones.new('toe') + bone.head[:] = 0.0000, -0.1200, 0.0300 + bone.tail[:] = 0.0000, -0.2000, 0.0300 + bone.roll = 3.1416 + bone.use_connect = True + bone.parent = arm.edit_bones[bones['foot']] + bones['toe'] = bone.name + + bpy.ops.object.mode_set(mode='OBJECT') + pbone = obj.pose.bones[bones['thigh']] + pbone.rigify_type = 'biped.leg' + pbone.lock_location = (True, True, True) + pbone.lock_rotation = (False, False, False) + pbone.lock_rotation_w = False + pbone.lock_scale = (False, False, False) + pbone.rotation_mode = 'QUATERNION' + pbone = obj.pose.bones[bones['shin']] + pbone.rigify_type = '' + pbone.lock_location = (False, False, False) + pbone.lock_rotation = (False, False, False) + pbone.lock_rotation_w = False + pbone.lock_scale = (False, False, False) + pbone.rotation_mode = 'QUATERNION' + pbone = obj.pose.bones[bones['foot']] + pbone.rigify_type = '' + pbone.lock_location = (False, False, False) + pbone.lock_rotation = (False, False, False) + pbone.lock_rotation_w = False + pbone.lock_scale = (False, False, False) + pbone.rotation_mode = 'QUATERNION' + pbone = obj.pose.bones[bones['heel']] + pbone.rigify_type = '' + pbone.lock_location = (False, False, False) + pbone.lock_rotation = (False, False, False) + pbone.lock_rotation_w = False + pbone.lock_scale = (False, False, False) + pbone.rotation_mode = 'QUATERNION' + pbone = obj.pose.bones[bones['toe']] + pbone.rigify_type = '' + pbone.lock_location = (False, False, False) + pbone.lock_rotation = (False, False, False) + pbone.lock_rotation_w = False + pbone.lock_scale = (False, False, False) + pbone.rotation_mode = 'QUATERNION' + + bpy.ops.object.mode_set(mode='EDIT') + for bone in arm.edit_bones: + bone.select = False + bone.select_head = False + bone.select_tail = False + for b in bones: + bone = arm.edit_bones[bones[b]] + bone.select = True + bone.select_head = True + bone.select_tail = True + arm.edit_bones.active = bone diff --git a/rigify/rigs/finger.py b/rigify/rigs/finger.py index ff2fc560..9ecaac32 100644 --- a/rigify/rigs/finger.py +++ b/rigify/rigs/finger.py @@ -276,138 +276,136 @@ class Rig: self.deform() self.control() - @classmethod - def add_parameters(self, params): - """ Add the parameters of this rig type to the - RigifyParameters PropertyGroup - """ - items = [('X', 'X', ''), ('Y', 'Y', ''), ('Z', 'Z', ''), ('-X', '-X', ''), ('-Y', '-Y', ''), ('-Z', '-Z', '')] - params.primary_rotation_axis = bpy.props.EnumProperty(items=items, name="Primary Rotation Axis", default='X') - params.separate_extra_layers = bpy.props.BoolProperty(name="Separate Secondary Control Layers:", default=False, description="Enable putting the secondary controls on a separate layer from the primary controls") - params.extra_layers = bpy.props.BoolVectorProperty(size=32, description="Layers for the secondary controls to be on") +def add_parameters(params): + """ Add the parameters of this rig type to the + RigifyParameters PropertyGroup + """ + items = [('X', 'X', ''), ('Y', 'Y', ''), ('Z', 'Z', ''), ('-X', '-X', ''), ('-Y', '-Y', ''), ('-Z', '-Z', '')] + params.primary_rotation_axis = bpy.props.EnumProperty(items=items, name="Primary Rotation Axis", default='X') - params.use_digit_twist = bpy.props.BoolProperty(name="Digit Twist", default=True, description="Generate the dual-bone twist setup for the first finger digit") + params.separate_extra_layers = bpy.props.BoolProperty(name="Separate Secondary Control Layers:", default=False, description="Enable putting the secondary controls on a separate layer from the primary controls") + params.extra_layers = bpy.props.BoolVectorProperty(size=32, description="Layers for the secondary controls to be on") - @classmethod - def parameters_ui(self, layout, obj, bone): - """ Create the ui for the rig parameters. - """ - params = obj.pose.bones[bone].rigify_parameters - - r = layout.row() - r.prop(params, "separate_extra_layers") - - r = layout.row() - r.active = params.separate_extra_layers - - col = r.column(align=True) - row = col.row(align=True) - row.prop(params, "extra_layers", index=0, toggle=True, text="") - row.prop(params, "extra_layers", index=1, toggle=True, text="") - row.prop(params, "extra_layers", index=2, toggle=True, text="") - row.prop(params, "extra_layers", index=3, toggle=True, text="") - row.prop(params, "extra_layers", index=4, toggle=True, text="") - row.prop(params, "extra_layers", index=5, toggle=True, text="") - row.prop(params, "extra_layers", index=6, toggle=True, text="") - row.prop(params, "extra_layers", index=7, toggle=True, text="") - row = col.row(align=True) - row.prop(params, "extra_layers", index=16, toggle=True, text="") - row.prop(params, "extra_layers", index=17, toggle=True, text="") - row.prop(params, "extra_layers", index=18, toggle=True, text="") - row.prop(params, "extra_layers", index=19, toggle=True, text="") - row.prop(params, "extra_layers", index=20, toggle=True, text="") - row.prop(params, "extra_layers", index=21, toggle=True, text="") - row.prop(params, "extra_layers", index=22, toggle=True, text="") - row.prop(params, "extra_layers", index=23, toggle=True, text="") - - col = r.column(align=True) - row = col.row(align=True) - row.prop(params, "ik_layers", index=8, toggle=True, text="") - row.prop(params, "ik_layers", index=9, toggle=True, text="") - row.prop(params, "ik_layers", index=10, toggle=True, text="") - row.prop(params, "ik_layers", index=11, toggle=True, text="") - row.prop(params, "ik_layers", index=12, toggle=True, text="") - row.prop(params, "ik_layers", index=13, toggle=True, text="") - row.prop(params, "ik_layers", index=14, toggle=True, text="") - row.prop(params, "ik_layers", index=15, toggle=True, text="") - row = col.row(align=True) - row.prop(params, "ik_layers", index=24, toggle=True, text="") - row.prop(params, "ik_layers", index=25, toggle=True, text="") - row.prop(params, "ik_layers", index=26, toggle=True, text="") - row.prop(params, "ik_layers", index=27, toggle=True, text="") - row.prop(params, "ik_layers", index=28, toggle=True, text="") - row.prop(params, "ik_layers", index=29, toggle=True, text="") - row.prop(params, "ik_layers", index=30, toggle=True, text="") - row.prop(params, "ik_layers", index=31, toggle=True, text="") - - r = layout.row() - r.label(text="Bend rotation axis:") - r.prop(params, "primary_rotation_axis", text="") - - col = layout.column() - col.prop(params, "use_digit_twist") - - @classmethod - def create_sample(self, obj): - # generated by rigify.utils.write_metarig - bpy.ops.object.mode_set(mode='EDIT') - arm = obj.data - - bones = {} - - bone = arm.edit_bones.new('finger.01') - bone.head[:] = 0.0000, 0.0000, 0.0000 - bone.tail[:] = 0.2529, 0.0000, 0.0000 - bone.roll = 3.1416 - bone.use_connect = False - bones['finger.01'] = bone.name - bone = arm.edit_bones.new('finger.02') - bone.head[:] = 0.2529, 0.0000, 0.0000 - bone.tail[:] = 0.4024, 0.0000, -0.0264 - bone.roll = -2.9671 - bone.use_connect = True - bone.parent = arm.edit_bones[bones['finger.01']] - bones['finger.02'] = bone.name - bone = arm.edit_bones.new('finger.03') - bone.head[:] = 0.4024, 0.0000, -0.0264 - bone.tail[:] = 0.4975, -0.0000, -0.0610 - bone.roll = -2.7925 - bone.use_connect = True - bone.parent = arm.edit_bones[bones['finger.02']] - bones['finger.03'] = bone.name + params.use_digit_twist = bpy.props.BoolProperty(name="Digit Twist", default=True, description="Generate the dual-bone twist setup for the first finger digit") - bpy.ops.object.mode_set(mode='OBJECT') - pbone = obj.pose.bones[bones['finger.01']] - pbone.rigify_type = 'finger' - pbone.lock_location = (True, True, True) - pbone.lock_rotation = (False, False, False) - pbone.lock_rotation_w = False - pbone.lock_scale = (False, False, False) - pbone.rotation_mode = 'YZX' - pbone = obj.pose.bones[bones['finger.02']] - pbone.rigify_type = '' - pbone.lock_location = (False, False, False) - pbone.lock_rotation = (False, False, False) - pbone.lock_rotation_w = False - pbone.lock_scale = (False, False, False) - pbone.rotation_mode = 'YZX' - pbone = obj.pose.bones[bones['finger.03']] - pbone.rigify_type = '' - pbone.lock_location = (False, False, False) - pbone.lock_rotation = (False, False, False) - pbone.lock_rotation_w = False - pbone.lock_scale = (False, False, False) - pbone.rotation_mode = 'YZX' - bpy.ops.object.mode_set(mode='EDIT') - for bone in arm.edit_bones: - bone.select = False - bone.select_head = False - bone.select_tail = False - for b in bones: - bone = arm.edit_bones[bones[b]] - bone.select = True - bone.select_head = True - bone.select_tail = True - arm.edit_bones.active = bone +def parameters_ui(layout, params): + """ Create the ui for the rig parameters. + """ + r = layout.row() + r.prop(params, "separate_extra_layers") + + r = layout.row() + r.active = params.separate_extra_layers + + col = r.column(align=True) + row = col.row(align=True) + row.prop(params, "extra_layers", index=0, toggle=True, text="") + row.prop(params, "extra_layers", index=1, toggle=True, text="") + row.prop(params, "extra_layers", index=2, toggle=True, text="") + row.prop(params, "extra_layers", index=3, toggle=True, text="") + row.prop(params, "extra_layers", index=4, toggle=True, text="") + row.prop(params, "extra_layers", index=5, toggle=True, text="") + row.prop(params, "extra_layers", index=6, toggle=True, text="") + row.prop(params, "extra_layers", index=7, toggle=True, text="") + row = col.row(align=True) + row.prop(params, "extra_layers", index=16, toggle=True, text="") + row.prop(params, "extra_layers", index=17, toggle=True, text="") + row.prop(params, "extra_layers", index=18, toggle=True, text="") + row.prop(params, "extra_layers", index=19, toggle=True, text="") + row.prop(params, "extra_layers", index=20, toggle=True, text="") + row.prop(params, "extra_layers", index=21, toggle=True, text="") + row.prop(params, "extra_layers", index=22, toggle=True, text="") + row.prop(params, "extra_layers", index=23, toggle=True, text="") + + col = r.column(align=True) + row = col.row(align=True) + row.prop(params, "ik_layers", index=8, toggle=True, text="") + row.prop(params, "ik_layers", index=9, toggle=True, text="") + row.prop(params, "ik_layers", index=10, toggle=True, text="") + row.prop(params, "ik_layers", index=11, toggle=True, text="") + row.prop(params, "ik_layers", index=12, toggle=True, text="") + row.prop(params, "ik_layers", index=13, toggle=True, text="") + row.prop(params, "ik_layers", index=14, toggle=True, text="") + row.prop(params, "ik_layers", index=15, toggle=True, text="") + row = col.row(align=True) + row.prop(params, "ik_layers", index=24, toggle=True, text="") + row.prop(params, "ik_layers", index=25, toggle=True, text="") + row.prop(params, "ik_layers", index=26, toggle=True, text="") + row.prop(params, "ik_layers", index=27, toggle=True, text="") + row.prop(params, "ik_layers", index=28, toggle=True, text="") + row.prop(params, "ik_layers", index=29, toggle=True, text="") + row.prop(params, "ik_layers", index=30, toggle=True, text="") + row.prop(params, "ik_layers", index=31, toggle=True, text="") + + r = layout.row() + r.label(text="Bend rotation axis:") + r.prop(params, "primary_rotation_axis", text="") + + col = layout.column() + col.prop(params, "use_digit_twist") + + +def create_sample(obj): + # generated by rigify.utils.write_metarig + bpy.ops.object.mode_set(mode='EDIT') + arm = obj.data + + bones = {} + + bone = arm.edit_bones.new('finger.01') + bone.head[:] = 0.0000, 0.0000, 0.0000 + bone.tail[:] = 0.2529, 0.0000, 0.0000 + bone.roll = 3.1416 + bone.use_connect = False + bones['finger.01'] = bone.name + bone = arm.edit_bones.new('finger.02') + bone.head[:] = 0.2529, 0.0000, 0.0000 + bone.tail[:] = 0.4024, 0.0000, -0.0264 + bone.roll = -2.9671 + bone.use_connect = True + bone.parent = arm.edit_bones[bones['finger.01']] + bones['finger.02'] = bone.name + bone = arm.edit_bones.new('finger.03') + bone.head[:] = 0.4024, 0.0000, -0.0264 + bone.tail[:] = 0.4975, -0.0000, -0.0610 + bone.roll = -2.7925 + bone.use_connect = True + bone.parent = arm.edit_bones[bones['finger.02']] + bones['finger.03'] = bone.name + + bpy.ops.object.mode_set(mode='OBJECT') + pbone = obj.pose.bones[bones['finger.01']] + pbone.rigify_type = 'finger' + pbone.lock_location = (True, True, True) + pbone.lock_rotation = (False, False, False) + pbone.lock_rotation_w = False + pbone.lock_scale = (False, False, False) + pbone.rotation_mode = 'YZX' + pbone = obj.pose.bones[bones['finger.02']] + pbone.rigify_type = '' + pbone.lock_location = (False, False, False) + pbone.lock_rotation = (False, False, False) + pbone.lock_rotation_w = False + pbone.lock_scale = (False, False, False) + pbone.rotation_mode = 'YZX' + pbone = obj.pose.bones[bones['finger.03']] + pbone.rigify_type = '' + pbone.lock_location = (False, False, False) + pbone.lock_rotation = (False, False, False) + pbone.lock_rotation_w = False + pbone.lock_scale = (False, False, False) + pbone.rotation_mode = 'YZX' + + bpy.ops.object.mode_set(mode='EDIT') + for bone in arm.edit_bones: + bone.select = False + bone.select_head = False + bone.select_tail = False + for b in bones: + bone = arm.edit_bones[bones[b]] + bone.select = True + bone.select_head = True + bone.select_tail = True + arm.edit_bones.active = bone diff --git a/rigify/rigs/misc/delta.py b/rigify/rigs/misc/delta.py index 873515d8..a005fb61 100644 --- a/rigify/rigs/misc/delta.py +++ b/rigify/rigs/misc/delta.py @@ -18,76 +18,80 @@ # <pep8 compliant> -from math import acos +if False: + # This rig type is disabled due to its obscurity. + # However, some of the code may be useful in the future, so + # I'm leaving it here. + from math import acos -import bpy + import bpy -from ...utils import MetarigError -from ...utils import copy_bone -from ...utils import org_name, make_mechanism_name + from ...utils import MetarigError + from ...utils import copy_bone + from ...utils import org_name, make_mechanism_name -class Rig: - """ A delta rig. - Creates a setup that will place its child at its position in pose mode, - but will not modifying its child's position in edit mode. - This is a mechanism-only rig (no control or deformation bones). - - """ - def __init__(self, obj, bone, params): - """ Gather and validate data about the rig. - Store any data or references to data that will be needed later on. - In particular, store references to bones that will be needed. - Do NOT change any data in the scene. This is a gathering phase only. + class Rig: + """ A delta rig. + Creates a setup that will place its child at its position in pose mode, + but will not modifying its child's position in edit mode. + This is a mechanism-only rig (no control or deformation bones). """ - bb = obj.data.bones + def __init__(self, obj, bone, params): + """ Gather and validate data about the rig. + Store any data or references to data that will be needed later on. + In particular, store references to bones that will be needed. + Do NOT change any data in the scene. This is a gathering phase only. - if bb[bone].children is None: - raise MetarigError("RIGIFY ERROR: bone '%s': rig type requires one child" % org_name(bone.name)) - if bb[bone].use_connect is True: - raise MetarigError("RIGIFY ERROR: bone '%s': rig type cannot be connected to parent" % org_name(bone.name)) + """ + bb = obj.data.bones - self.obj = obj - self.org_bones = {"delta": bone, "child": bb[bone].children[0].name} - self.org_names = [org_name(bone), org_name(bb[bone].children[0].name)] + if bb[bone].children is None: + raise MetarigError("RIGIFY ERROR: bone '%s': rig type requires one child" % org_name(bone.name)) + if bb[bone].use_connect is True: + raise MetarigError("RIGIFY ERROR: bone '%s': rig type cannot be connected to parent" % org_name(bone.name)) - def generate(self): - """ Generate the rig. - Do NOT modify any of the original bones, except for adding constraints. - The main armature should be selected and active before this is called. + self.obj = obj + self.org_bones = {"delta": bone, "child": bb[bone].children[0].name} + self.org_names = [org_name(bone), org_name(bb[bone].children[0].name)] - """ - bpy.ops.object.mode_set(mode='EDIT') - eb = self.obj.data.edit_bones + def generate(self): + """ Generate the rig. + Do NOT modify any of the original bones, except for adding constraints. + The main armature should be selected and active before this is called. - org_delta = self.org_bones["delta"] - org_delta_e = eb[self.org_bones["delta"]] - # org_child = self.org_bones["child"] # UNUSED - org_child_e = eb[self.org_bones["child"]] + """ + bpy.ops.object.mode_set(mode='EDIT') + eb = self.obj.data.edit_bones - # Calculate the matrix for achieving the delta - child_mat = org_delta_e.matrix.invert() * org_child_e.matrix - mat = org_delta_e.matrix * child_mat.invert() + org_delta = self.org_bones["delta"] + org_delta_e = eb[self.org_bones["delta"]] + # org_child = self.org_bones["child"] # UNUSED + org_child_e = eb[self.org_bones["child"]] - # Create the delta bones. - delta_e = eb[copy_bone(self.obj, self.org_bones["delta"])] - delta_e.name = make_mechanism_name(self.org_names[0]) - delta = delta_e.name + # Calculate the matrix for achieving the delta + child_mat = org_delta_e.matrix.invert() * org_child_e.matrix + mat = org_delta_e.matrix * child_mat.invert() - # Set the delta to the matrix's transforms - set_mat(self.obj, delta, mat) + # Create the delta bones. + delta_e = eb[copy_bone(self.obj, self.org_bones["delta"])] + delta_e.name = make_mechanism_name(self.org_names[0]) + delta = delta_e.name - bpy.ops.object.mode_set(mode='OBJECT') + # Set the delta to the matrix's transforms + set_mat(self.obj, delta, mat) + + bpy.ops.object.mode_set(mode='OBJECT') - # Constrain org_delta to delta - con = self.obj.pose.bones[org_delta].constraints.new('COPY_TRANSFORMS') - con.name = "delta" - con.target = self.obj - con.subtarget = delta + # Constrain org_delta to delta + con = self.obj.pose.bones[org_delta].constraints.new('COPY_TRANSFORMS') + con.name = "delta" + con.target = self.obj + con.subtarget = delta - @classmethod - def create_sample(self, obj): + + def create_sample(obj): # generated by rigify.utils.write_metarig bpy.ops.object.mode_set(mode='EDIT') arm = obj.data @@ -137,27 +141,27 @@ class Rig: arm.edit_bones.active = bone -def set_mat(obj, bone_name, matrix): - """ Sets the bone to have the given transform matrix. - """ - a = obj.data.edit_bones[bone_name] - - a.head = (0, 0, 0) - a.tail = (0, 1, 0) + def set_mat(obj, bone_name, matrix): + """ Sets the bone to have the given transform matrix. + """ + a = obj.data.edit_bones[bone_name] - a.transform(matrix) + a.head = (0, 0, 0) + a.tail = (0, 1, 0) - d = acos(a.matrix.to_quaternion().dot(matrix.to_quaternion())) * 2.0 + a.transform(matrix) - roll_1 = a.roll + d - roll_2 = a.roll - d + d = acos(a.matrix.to_quaternion().dot(matrix.to_quaternion())) * 2.0 - a.roll = roll_1 - d1 = a.matrix.to_quaternion().dot(matrix.to_quaternion()) - a.roll = roll_2 - d2 = a.matrix.to_quaternion().dot(matrix.to_quaternion()) + roll_1 = a.roll + d + roll_2 = a.roll - d - if d1 > d2: a.roll = roll_1 - else: + d1 = a.matrix.to_quaternion().dot(matrix.to_quaternion()) a.roll = roll_2 + d2 = a.matrix.to_quaternion().dot(matrix.to_quaternion()) + + if d1 > d2: + a.roll = roll_1 + else: + a.roll = roll_2 diff --git a/rigify/rigs/neck_short.py b/rigify/rigs/neck_short.py index f7814a0c..9c24832a 100644 --- a/rigify/rigs/neck_short.py +++ b/rigify/rigs/neck_short.py @@ -337,52 +337,52 @@ class Rig: return [script] - @classmethod - def create_sample(self, obj): - # generated by rigify.utils.write_metarig - bpy.ops.object.mode_set(mode='EDIT') - arm = obj.data - - bones = {} - - bone = arm.edit_bones.new('neck') - bone.head[:] = 0.0000, 0.0000, 0.0000 - bone.tail[:] = 0.0000, -0.0500, 0.1500 - bone.roll = 0.0000 - bone.use_connect = False - bones['neck'] = bone.name - bone = arm.edit_bones.new('head') - bone.head[:] = 0.0000, -0.0500, 0.1500 - bone.tail[:] = 0.0000, -0.0500, 0.4000 - bone.roll = 3.1416 - bone.use_connect = True - bone.parent = arm.edit_bones[bones['neck']] - bones['head'] = bone.name - - bpy.ops.object.mode_set(mode='OBJECT') - pbone = obj.pose.bones[bones['neck']] - pbone.rigify_type = 'neck_short' - pbone.lock_location = (True, True, True) - pbone.lock_rotation = (False, False, False) - pbone.lock_rotation_w = False - pbone.lock_scale = (False, False, False) - pbone.rotation_mode = 'QUATERNION' - pbone = obj.pose.bones[bones['head']] - pbone.rigify_type = '' - pbone.lock_location = (False, False, False) - pbone.lock_rotation = (False, False, False) - pbone.lock_rotation_w = False - pbone.lock_scale = (False, False, False) - pbone.rotation_mode = 'QUATERNION' - bpy.ops.object.mode_set(mode='EDIT') - for bone in arm.edit_bones: - bone.select = False - bone.select_head = False - bone.select_tail = False - for b in bones: - bone = arm.edit_bones[bones[b]] - bone.select = True - bone.select_head = True - bone.select_tail = True - arm.edit_bones.active = bone +def create_sample(obj): + # generated by rigify.utils.write_metarig + bpy.ops.object.mode_set(mode='EDIT') + arm = obj.data + + bones = {} + + bone = arm.edit_bones.new('neck') + bone.head[:] = 0.0000, 0.0000, 0.0000 + bone.tail[:] = 0.0000, -0.0500, 0.1500 + bone.roll = 0.0000 + bone.use_connect = False + bones['neck'] = bone.name + bone = arm.edit_bones.new('head') + bone.head[:] = 0.0000, -0.0500, 0.1500 + bone.tail[:] = 0.0000, -0.0500, 0.4000 + bone.roll = 3.1416 + bone.use_connect = True + bone.parent = arm.edit_bones[bones['neck']] + bones['head'] = bone.name + + bpy.ops.object.mode_set(mode='OBJECT') + pbone = obj.pose.bones[bones['neck']] + pbone.rigify_type = 'neck_short' + pbone.lock_location = (True, True, True) + pbone.lock_rotation = (False, False, False) + pbone.lock_rotation_w = False + pbone.lock_scale = (False, False, False) + pbone.rotation_mode = 'QUATERNION' + pbone = obj.pose.bones[bones['head']] + pbone.rigify_type = '' + pbone.lock_location = (False, False, False) + pbone.lock_rotation = (False, False, False) + pbone.lock_rotation_w = False + pbone.lock_scale = (False, False, False) + pbone.rotation_mode = 'QUATERNION' + + bpy.ops.object.mode_set(mode='EDIT') + for bone in arm.edit_bones: + bone.select = False + bone.select_head = False + bone.select_tail = False + for b in bones: + bone = arm.edit_bones[bones[b]] + bone.select = True + bone.select_head = True + bone.select_tail = True + arm.edit_bones.active = bone diff --git a/rigify/rigs/palm.py b/rigify/rigs/palm.py index acef0529..f5568210 100644 --- a/rigify/rigs/palm.py +++ b/rigify/rigs/palm.py @@ -162,114 +162,112 @@ class Rig: mod = w.modifiers.new("subsurf", 'SUBSURF') mod.levels = 2 - @classmethod - def add_parameters(self, params): - """ Add the parameters of this rig type to the - RigifyParameters PropertyGroup - """ - items = [('X', 'X', ''), ('Z', 'Z', '')] - params.palm_rotation_axis = bpy.props.EnumProperty(items=items, name="Palm Rotation Axis", default='X') - - @classmethod - def parameters_ui(self, layout, obj, bone): - """ Create the ui for the rig parameters. +def add_parameters(params): + """ Add the parameters of this rig type to the + RigifyParameters PropertyGroup - """ - params = obj.pose.bones[bone].rigify_parameters + """ + items = [('X', 'X', ''), ('Z', 'Z', '')] + params.palm_rotation_axis = bpy.props.EnumProperty(items=items, name="Palm Rotation Axis", default='X') - r = layout.row() - r.label(text="Primary rotation axis:") - r.prop(params, "palm_rotation_axis", text="") - @classmethod - def create_sample(self, obj): - # generated by rigify.utils.write_metarig - bpy.ops.object.mode_set(mode='EDIT') - arm = obj.data - - bones = {} - - bone = arm.edit_bones.new('palm.parent') - bone.head[:] = 0.0000, 0.0000, 0.0000 - bone.tail[:] = 0.0577, 0.0000, -0.0000 - bone.roll = 3.1416 - bone.use_connect = False - bones['palm.parent'] = bone.name - bone = arm.edit_bones.new('palm.04') - bone.head[:] = 0.0577, 0.0315, -0.0000 - bone.tail[:] = 0.1627, 0.0315, -0.0000 - bone.roll = 3.1416 - bone.use_connect = False - bone.parent = arm.edit_bones[bones['palm.parent']] - bones['palm.04'] = bone.name - bone = arm.edit_bones.new('palm.03') - bone.head[:] = 0.0577, 0.0105, -0.0000 - bone.tail[:] = 0.1627, 0.0105, -0.0000 - bone.roll = 3.1416 - bone.use_connect = False - bone.parent = arm.edit_bones[bones['palm.parent']] - bones['palm.03'] = bone.name - bone = arm.edit_bones.new('palm.02') - bone.head[:] = 0.0577, -0.0105, -0.0000 - bone.tail[:] = 0.1627, -0.0105, -0.0000 - bone.roll = 3.1416 - bone.use_connect = False - bone.parent = arm.edit_bones[bones['palm.parent']] - bones['palm.02'] = bone.name - bone = arm.edit_bones.new('palm.01') - bone.head[:] = 0.0577, -0.0315, -0.0000 - bone.tail[:] = 0.1627, -0.0315, -0.0000 - bone.roll = 3.1416 - bone.use_connect = False - bone.parent = arm.edit_bones[bones['palm.parent']] - bones['palm.01'] = bone.name +def parameters_ui(layout, params): + """ Create the ui for the rig parameters. - bpy.ops.object.mode_set(mode='OBJECT') - pbone = obj.pose.bones[bones['palm.parent']] - pbone.rigify_type = '' - pbone.lock_location = (False, False, False) - pbone.lock_rotation = (False, False, False) - pbone.lock_rotation_w = False - pbone.lock_scale = (False, False, False) - pbone.rotation_mode = 'QUATERNION' - pbone = obj.pose.bones[bones['palm.04']] - pbone.rigify_type = '' - pbone.lock_location = (False, False, False) - pbone.lock_rotation = (False, True, True) - pbone.lock_rotation_w = False - pbone.lock_scale = (False, False, False) - pbone.rotation_mode = 'YXZ' - pbone = obj.pose.bones[bones['palm.03']] - pbone.rigify_type = '' - pbone.lock_location = (False, False, False) - pbone.lock_rotation = (False, True, True) - pbone.lock_rotation_w = False - pbone.lock_scale = (False, False, False) - pbone.rotation_mode = 'YXZ' - pbone = obj.pose.bones[bones['palm.02']] - pbone.rigify_type = '' - pbone.lock_location = (False, False, False) - pbone.lock_rotation = (False, True, True) - pbone.lock_rotation_w = False - pbone.lock_scale = (False, False, False) - pbone.rotation_mode = 'YXZ' - pbone = obj.pose.bones[bones['palm.01']] - pbone.rigify_type = 'palm' - pbone.lock_location = (False, False, False) - pbone.lock_rotation = (False, True, True) - pbone.lock_rotation_w = False - pbone.lock_scale = (False, False, False) - pbone.rotation_mode = 'YXZ' - - bpy.ops.object.mode_set(mode='EDIT') - for bone in arm.edit_bones: - bone.select = False - bone.select_head = False - bone.select_tail = False - for b in bones: - bone = arm.edit_bones[bones[b]] - bone.select = True - bone.select_head = True - bone.select_tail = True - arm.edit_bones.active = bone + """ + r = layout.row() + r.label(text="Primary rotation axis:") + r.prop(params, "palm_rotation_axis", text="") + + +def create_sample(obj): + # generated by rigify.utils.write_metarig + bpy.ops.object.mode_set(mode='EDIT') + arm = obj.data + + bones = {} + + bone = arm.edit_bones.new('palm.parent') + bone.head[:] = 0.0000, 0.0000, 0.0000 + bone.tail[:] = 0.0577, 0.0000, -0.0000 + bone.roll = 3.1416 + bone.use_connect = False + bones['palm.parent'] = bone.name + bone = arm.edit_bones.new('palm.04') + bone.head[:] = 0.0577, 0.0315, -0.0000 + bone.tail[:] = 0.1627, 0.0315, -0.0000 + bone.roll = 3.1416 + bone.use_connect = False + bone.parent = arm.edit_bones[bones['palm.parent']] + bones['palm.04'] = bone.name + bone = arm.edit_bones.new('palm.03') + bone.head[:] = 0.0577, 0.0105, -0.0000 + bone.tail[:] = 0.1627, 0.0105, -0.0000 + bone.roll = 3.1416 + bone.use_connect = False + bone.parent = arm.edit_bones[bones['palm.parent']] + bones['palm.03'] = bone.name + bone = arm.edit_bones.new('palm.02') + bone.head[:] = 0.0577, -0.0105, -0.0000 + bone.tail[:] = 0.1627, -0.0105, -0.0000 + bone.roll = 3.1416 + bone.use_connect = False + bone.parent = arm.edit_bones[bones['palm.parent']] + bones['palm.02'] = bone.name + bone = arm.edit_bones.new('palm.01') + bone.head[:] = 0.0577, -0.0315, -0.0000 + bone.tail[:] = 0.1627, -0.0315, -0.0000 + bone.roll = 3.1416 + bone.use_connect = False + bone.parent = arm.edit_bones[bones['palm.parent']] + bones['palm.01'] = bone.name + + bpy.ops.object.mode_set(mode='OBJECT') + pbone = obj.pose.bones[bones['palm.parent']] + pbone.rigify_type = '' + pbone.lock_location = (False, False, False) + pbone.lock_rotation = (False, False, False) + pbone.lock_rotation_w = False + pbone.lock_scale = (False, False, False) + pbone.rotation_mode = 'QUATERNION' + pbone = obj.pose.bones[bones['palm.04']] + pbone.rigify_type = '' + pbone.lock_location = (False, False, False) + pbone.lock_rotation = (False, True, True) + pbone.lock_rotation_w = False + pbone.lock_scale = (False, False, False) + pbone.rotation_mode = 'YXZ' + pbone = obj.pose.bones[bones['palm.03']] + pbone.rigify_type = '' + pbone.lock_location = (False, False, False) + pbone.lock_rotation = (False, True, True) + pbone.lock_rotation_w = False + pbone.lock_scale = (False, False, False) + pbone.rotation_mode = 'YXZ' + pbone = obj.pose.bones[bones['palm.02']] + pbone.rigify_type = '' + pbone.lock_location = (False, False, False) + pbone.lock_rotation = (False, True, True) + pbone.lock_rotation_w = False + pbone.lock_scale = (False, False, False) + pbone.rotation_mode = 'YXZ' + pbone = obj.pose.bones[bones['palm.01']] + pbone.rigify_type = 'palm' + pbone.lock_location = (False, False, False) + pbone.lock_rotation = (False, True, True) + pbone.lock_rotation_w = False + pbone.lock_scale = (False, False, False) + pbone.rotation_mode = 'YXZ' + + bpy.ops.object.mode_set(mode='EDIT') + for bone in arm.edit_bones: + bone.select = False + bone.select_head = False + bone.select_tail = False + for b in bones: + bone = arm.edit_bones[bones[b]] + bone.select = True + bone.select_head = True + bone.select_tail = True + arm.edit_bones.active = bone diff --git a/rigify/rigs/spine.py b/rigify/rigs/spine.py index 29ad1729..0983e83e 100644 --- a/rigify/rigs/spine.py +++ b/rigify/rigs/spine.py @@ -478,93 +478,91 @@ class Rig: controls_string = ", ".join(["'" + x + "'" for x in controls[1:]]) return [script % (controls[0], controls_string)] - @classmethod - def add_parameters(self, params): - """ Add the parameters of this rig type to the - RigifyParameters PropertyGroup - """ - params.spine_main_control_name = bpy.props.StringProperty(name="Main control name", default="torso", description="Name that the main control bone should be given") - params.rest_pivot_slide = bpy.props.FloatProperty(name="Rest Pivot Slide", default=0.0, min=0.0, max=1.0, soft_min=0.0, soft_max=1.0, description="The pivot slide value in the rest pose") - params.chain_bone_controls = bpy.props.StringProperty(name="Control bone list", default="", description="Define which bones have controls") - - @classmethod - def parameters_ui(self, layout, obj, bone): - """ Create the ui for the rig parameters. - """ - params = obj.pose.bones[bone].rigify_parameters - - r = layout.row() - r.prop(params, "spine_main_control_name") - - r = layout.row() - r.prop(params, "rest_pivot_slide", slider=True) - - r = layout.row() - r.prop(params, "chain_bone_controls") - @classmethod - def create_sample(self, obj): - # generated by rigify.utils.write_metarig - bpy.ops.object.mode_set(mode='EDIT') - arm = obj.data - - bones = {} - - bone = arm.edit_bones.new('hips') - bone.head[:] = 0.0000, 0.0000, 0.0000 - bone.tail[:] = -0.0000, -0.0590, 0.2804 - bone.roll = -0.0000 - bone.use_connect = False - bones['hips'] = bone.name - bone = arm.edit_bones.new('spine') - bone.head[:] = -0.0000, -0.0590, 0.2804 - bone.tail[:] = 0.0000, 0.0291, 0.5324 - bone.roll = 0.0000 - bone.use_connect = True - bone.parent = arm.edit_bones[bones['hips']] - bones['spine'] = bone.name - bone = arm.edit_bones.new('ribs') - bone.head[:] = 0.0000, 0.0291, 0.5324 - bone.tail[:] = -0.0000, 0.0000, 1.0000 - bone.roll = -0.0000 - bone.use_connect = True - bone.parent = arm.edit_bones[bones['spine']] - bones['ribs'] = bone.name +def add_parameters(params): + """ Add the parameters of this rig type to the + RigifyParameters PropertyGroup + """ + params.spine_main_control_name = bpy.props.StringProperty(name="Main control name", default="torso", description="Name that the main control bone should be given") + params.rest_pivot_slide = bpy.props.FloatProperty(name="Rest Pivot Slide", default=0.0, min=0.0, max=1.0, soft_min=0.0, soft_max=1.0, description="The pivot slide value in the rest pose") + params.chain_bone_controls = bpy.props.StringProperty(name="Control bone list", default="", description="Define which bones have controls") - bpy.ops.object.mode_set(mode='OBJECT') - pbone = obj.pose.bones[bones['hips']] - pbone.rigify_type = 'spine' - pbone.lock_location = (False, False, False) - pbone.lock_rotation = (False, False, False) - pbone.lock_rotation_w = False - pbone.lock_scale = (False, False, False) - pbone.rotation_mode = 'QUATERNION' - pbone = obj.pose.bones[bones['spine']] - pbone.rigify_type = '' - pbone.lock_location = (False, False, False) - pbone.lock_rotation = (False, False, False) - pbone.lock_rotation_w = False - pbone.lock_scale = (False, False, False) - pbone.rotation_mode = 'QUATERNION' - pbone = obj.pose.bones[bones['ribs']] - pbone.rigify_type = '' - pbone.lock_location = (False, False, False) - pbone.lock_rotation = (False, False, False) - pbone.lock_rotation_w = False - pbone.lock_scale = (False, False, False) - pbone.rotation_mode = 'QUATERNION' - pbone = obj.pose.bones[bones['hips']] - pbone['rigify_type'] = 'spine' - pbone.rigify_parameters.chain_bone_controls = "1, 2, 3" - bpy.ops.object.mode_set(mode='EDIT') - for bone in arm.edit_bones: - bone.select = False - bone.select_head = False - bone.select_tail = False - for b in bones: - bone = arm.edit_bones[bones[b]] - bone.select = True - bone.select_head = True - bone.select_tail = True - arm.edit_bones.active = bone +def parameters_ui(layout, params): + """ Create the ui for the rig parameters. + """ + r = layout.row() + r.prop(params, "spine_main_control_name") + + r = layout.row() + r.prop(params, "rest_pivot_slide", slider=True) + + r = layout.row() + r.prop(params, "chain_bone_controls") + + +def create_sample(obj): + # generated by rigify.utils.write_metarig + bpy.ops.object.mode_set(mode='EDIT') + arm = obj.data + + bones = {} + + bone = arm.edit_bones.new('hips') + bone.head[:] = 0.0000, 0.0000, 0.0000 + bone.tail[:] = -0.0000, -0.0590, 0.2804 + bone.roll = -0.0000 + bone.use_connect = False + bones['hips'] = bone.name + bone = arm.edit_bones.new('spine') + bone.head[:] = -0.0000, -0.0590, 0.2804 + bone.tail[:] = 0.0000, 0.0291, 0.5324 + bone.roll = 0.0000 + bone.use_connect = True + bone.parent = arm.edit_bones[bones['hips']] + bones['spine'] = bone.name + bone = arm.edit_bones.new('ribs') + bone.head[:] = 0.0000, 0.0291, 0.5324 + bone.tail[:] = -0.0000, 0.0000, 1.0000 + bone.roll = -0.0000 + bone.use_connect = True + bone.parent = arm.edit_bones[bones['spine']] + bones['ribs'] = bone.name + + bpy.ops.object.mode_set(mode='OBJECT') + pbone = obj.pose.bones[bones['hips']] + pbone.rigify_type = 'spine' + pbone.lock_location = (False, False, False) + pbone.lock_rotation = (False, False, False) + pbone.lock_rotation_w = False + pbone.lock_scale = (False, False, False) + pbone.rotation_mode = 'QUATERNION' + pbone = obj.pose.bones[bones['spine']] + pbone.rigify_type = '' + pbone.lock_location = (False, False, False) + pbone.lock_rotation = (False, False, False) + pbone.lock_rotation_w = False + pbone.lock_scale = (False, False, False) + pbone.rotation_mode = 'QUATERNION' + pbone = obj.pose.bones[bones['ribs']] + pbone.rigify_type = '' + pbone.lock_location = (False, False, False) + pbone.lock_rotation = (False, False, False) + pbone.lock_rotation_w = False + pbone.lock_scale = (False, False, False) + pbone.rotation_mode = 'QUATERNION' + pbone = obj.pose.bones[bones['hips']] + pbone['rigify_type'] = 'spine' + pbone.rigify_parameters.chain_bone_controls = "1, 2, 3" + + bpy.ops.object.mode_set(mode='EDIT') + for bone in arm.edit_bones: + bone.select = False + bone.select_head = False + bone.select_tail = False + for b in bones: + bone = arm.edit_bones[bones[b]] + bone.select = True + bone.select_head = True + bone.select_tail = True + arm.edit_bones.active = bone |