diff options
author | Nathan Vegdahl <cessen@cessen.com> | 2013-02-16 22:22:20 +0400 |
---|---|---|
committer | Nathan Vegdahl <cessen@cessen.com> | 2013-02-16 22:22:20 +0400 |
commit | 21e99d0bd6b6a71cbf871cc4aaf6f2b744cd3d14 (patch) | |
tree | a9e1ee9327533ef7018dd08272dd54cd231e6534 /rigify/rigs | |
parent | 3d5172cf6bc017f929818725ccb890084617c519 (diff) |
Rigify: updated naming schemes for control bones.
This required changes to both the default human metarig and some of
the rig types. This updates the naming scheme to match new
best-practices, as per the CGCookie Flexrig.
Diffstat (limited to 'rigify/rigs')
-rw-r--r-- | rigify/rigs/biped/arm/__init__.py | 4 | ||||
-rw-r--r-- | rigify/rigs/biped/arm/fk.py | 8 | ||||
-rw-r--r-- | rigify/rigs/biped/arm/ik.py | 13 | ||||
-rw-r--r-- | rigify/rigs/biped/leg/__init__.py | 5 | ||||
-rw-r--r-- | rigify/rigs/biped/leg/fk.py | 8 | ||||
-rw-r--r-- | rigify/rigs/biped/leg/ik.py | 15 | ||||
-rw-r--r-- | rigify/rigs/spine.py | 48 |
7 files changed, 36 insertions, 65 deletions
diff --git a/rigify/rigs/biped/arm/__init__.py b/rigify/rigs/biped/arm/__init__.py index 41fe1f71..9cdf31ab 100644 --- a/rigify/rigs/biped/arm/__init__.py +++ b/rigify/rigs/biped/arm/__init__.py @@ -98,6 +98,7 @@ class Rig: 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.elbow_target_base_name = bpy.props.StringProperty(name="Elbow Target Name", default="elbow_target", description="Base name for the generated elbow 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") @@ -113,6 +114,9 @@ class Rig: 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() diff --git a/rigify/rigs/biped/arm/fk.py b/rigify/rigs/biped/arm/fk.py index e27e8541..54b1a459 100644 --- a/rigify/rigs/biped/arm/fk.py +++ b/rigify/rigs/biped/arm/fk.py @@ -24,7 +24,7 @@ from rna_prop_ui import rna_idprop_ui_prop_get from ....utils import MetarigError from ....utils import copy_bone from ....utils import connected_children_names -from ....utils import strip_org, make_mechanism_name +from ....utils import strip_org, make_mechanism_name, insert_before_lr from ....utils import get_layers from ....utils import create_widget, create_limb_widget @@ -73,9 +73,9 @@ class Rig: bpy.ops.object.mode_set(mode='EDIT') # Create the control bones - uarm = copy_bone(self.obj, self.org_bones[0], strip_org(self.org_bones[0])) - farm = copy_bone(self.obj, self.org_bones[1], strip_org(self.org_bones[1])) - hand = copy_bone(self.obj, self.org_bones[2], strip_org(self.org_bones[2])) + uarm = copy_bone(self.obj, self.org_bones[0], strip_org(insert_before_lr(self.org_bones[0], ".fk"))) + farm = copy_bone(self.obj, self.org_bones[1], strip_org(insert_before_lr(self.org_bones[1], ".fk"))) + hand = copy_bone(self.obj, self.org_bones[2], strip_org(insert_before_lr(self.org_bones[2], ".fk"))) # Create the hinge bones if self.org_parent != None: diff --git a/rigify/rigs/biped/arm/ik.py b/rigify/rigs/biped/arm/ik.py index 50ae72a9..8f288601 100644 --- a/rigify/rigs/biped/arm/ik.py +++ b/rigify/rigs/biped/arm/ik.py @@ -100,14 +100,15 @@ class Rig: bpy.ops.object.mode_set(mode='EDIT') # Create the bones - uarm = copy_bone(self.obj, self.org_bones[0], make_mechanism_name(strip_org(insert_before_lr(self.org_bones[0], "_ik")))) - farm = copy_bone(self.obj, self.org_bones[1], make_mechanism_name(strip_org(insert_before_lr(self.org_bones[1], "_ik")))) + uarm = copy_bone(self.obj, self.org_bones[0], make_mechanism_name(strip_org(insert_before_lr(self.org_bones[0], ".ik")))) + farm = copy_bone(self.obj, self.org_bones[1], make_mechanism_name(strip_org(insert_before_lr(self.org_bones[1], ".ik")))) - hand = copy_bone(self.obj, self.org_bones[2], strip_org(insert_before_lr(self.org_bones[2], "_ik"))) - pole = copy_bone(self.obj, self.org_bones[0], strip_org(insert_before_lr(self.org_bones[0], "_pole"))) + hand = copy_bone(self.obj, self.org_bones[2], strip_org(insert_before_lr(self.org_bones[2], ".ik"))) + pole_target_name = self.params.elbow_target_base_name + "." + insert_before_lr(self.org_bones[0], ".ik").split(".", 1)[1] + pole = copy_bone(self.obj, self.org_bones[0], pole_target_name) - vishand = copy_bone(self.obj, self.org_bones[2], "VIS-" + strip_org(insert_before_lr(self.org_bones[2], "_ik"))) - vispole = copy_bone(self.obj, self.org_bones[1], "VIS-" + strip_org(insert_before_lr(self.org_bones[0], "_pole"))) + vishand = copy_bone(self.obj, self.org_bones[2], "VIS-" + strip_org(insert_before_lr(self.org_bones[2], ".ik"))) + vispole = copy_bone(self.obj, self.org_bones[1], "VIS-" + strip_org(insert_before_lr(self.org_bones[0], "_pole.ik"))) # Get edit bones eb = self.obj.data.edit_bones diff --git a/rigify/rigs/biped/leg/__init__.py b/rigify/rigs/biped/leg/__init__.py index dbeeb0ef..a3c71627 100644 --- a/rigify/rigs/biped/leg/__init__.py +++ b/rigify/rigs/biped/leg/__init__.py @@ -100,6 +100,8 @@ class Rig: 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") @@ -115,6 +117,9 @@ class Rig: 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() diff --git a/rigify/rigs/biped/leg/fk.py b/rigify/rigs/biped/leg/fk.py index 497c110d..4e224ceb 100644 --- a/rigify/rigs/biped/leg/fk.py +++ b/rigify/rigs/biped/leg/fk.py @@ -25,7 +25,7 @@ from mathutils import Vector from ....utils import MetarigError from ....utils import copy_bone from ....utils import connected_children_names, has_connected_children -from ....utils import strip_org, make_mechanism_name +from ....utils import strip_org, make_mechanism_name, insert_before_lr from ....utils import get_layers from ....utils import create_widget, create_limb_widget @@ -99,9 +99,9 @@ class Rig: bpy.ops.object.mode_set(mode='EDIT') # Create the control bones - thigh = copy_bone(self.obj, self.org_bones[0], strip_org(self.org_bones[0])) - shin = copy_bone(self.obj, self.org_bones[1], strip_org(self.org_bones[1])) - foot = copy_bone(self.obj, self.org_bones[2], strip_org(self.org_bones[2])) + thigh = copy_bone(self.obj, self.org_bones[0], strip_org(insert_before_lr(self.org_bones[0], ".fk"))) + shin = copy_bone(self.obj, self.org_bones[1], strip_org(insert_before_lr(self.org_bones[1], ".fk"))) + foot = copy_bone(self.obj, self.org_bones[2], strip_org(insert_before_lr(self.org_bones[2], ".fk"))) # Create the foot mechanism bone foot_mch = copy_bone(self.obj, self.org_bones[2], make_mechanism_name(strip_org(self.org_bones[2]))) diff --git a/rigify/rigs/biped/leg/ik.py b/rigify/rigs/biped/leg/ik.py index 98f4a3eb..52eae332 100644 --- a/rigify/rigs/biped/leg/ik.py +++ b/rigify/rigs/biped/leg/ik.py @@ -154,19 +154,20 @@ class Rig: make_rocker = True # Create the bones - thigh = copy_bone(self.obj, self.org_bones[0], make_mechanism_name(strip_org(insert_before_lr(self.org_bones[0], "_ik")))) - shin = copy_bone(self.obj, self.org_bones[1], make_mechanism_name(strip_org(insert_before_lr(self.org_bones[1], "_ik")))) + thigh = copy_bone(self.obj, self.org_bones[0], make_mechanism_name(strip_org(insert_before_lr(self.org_bones[0], ".ik")))) + shin = copy_bone(self.obj, self.org_bones[1], make_mechanism_name(strip_org(insert_before_lr(self.org_bones[1], ".ik")))) - foot = copy_bone(self.obj, self.org_bones[2], strip_org(insert_before_lr(self.org_bones[2], "_ik"))) + foot = copy_bone(self.obj, self.org_bones[2], strip_org(insert_before_lr(self.org_bones[2], ".ik"))) foot_ik_target = copy_bone(self.obj, self.org_bones[2], make_mechanism_name(strip_org(insert_before_lr(self.org_bones[2], "_ik_target")))) - pole = copy_bone(self.obj, self.org_bones[0], strip_org(insert_before_lr(self.org_bones[0], "_pole"))) + pole_target_name = self.params.knee_target_base_name + "." + insert_before_lr(self.org_bones[0], ".ik").split(".", 1)[1] + pole = copy_bone(self.obj, self.org_bones[0], pole_target_name) toe = copy_bone(self.obj, self.org_bones[3], strip_org(self.org_bones[3])) toe_parent = copy_bone(self.obj, self.org_bones[2], make_mechanism_name(strip_org(self.org_bones[3] + ".parent"))) toe_parent_socket1 = copy_bone(self.obj, self.org_bones[2], make_mechanism_name(strip_org(self.org_bones[3] + ".socket1"))) toe_parent_socket2 = copy_bone(self.obj, self.org_bones[2], make_mechanism_name(strip_org(self.org_bones[3] + ".socket2"))) - foot_roll = copy_bone(self.obj, self.org_bones[4], strip_org(insert_before_lr(self.org_bones[2], "_roll"))) + foot_roll = copy_bone(self.obj, self.org_bones[4], strip_org(insert_before_lr(self.org_bones[2], "_roll.ik"))) roll1 = copy_bone(self.obj, self.org_bones[4], make_mechanism_name(strip_org(self.org_bones[2] + ".roll.01"))) roll2 = copy_bone(self.obj, self.org_bones[4], make_mechanism_name(strip_org(self.org_bones[2] + ".roll.02"))) @@ -174,8 +175,8 @@ class Rig: rocker1 = copy_bone(self.obj, self.org_bones[5], make_mechanism_name(strip_org(self.org_bones[2] + ".rocker.01"))) rocker2 = copy_bone(self.obj, self.org_bones[5], make_mechanism_name(strip_org(self.org_bones[2] + ".rocker.02"))) - visfoot = copy_bone(self.obj, self.org_bones[2], "VIS-" + strip_org(insert_before_lr(self.org_bones[2], "_ik"))) - vispole = copy_bone(self.obj, self.org_bones[1], "VIS-" + strip_org(insert_before_lr(self.org_bones[0], "_pole"))) + visfoot = copy_bone(self.obj, self.org_bones[2], "VIS-" + strip_org(insert_before_lr(self.org_bones[2], ".ik"))) + vispole = copy_bone(self.obj, self.org_bones[1], "VIS-" + strip_org(insert_before_lr(self.org_bones[0], "_pole.ik"))) # Get edit bones eb = self.obj.data.edit_bones diff --git a/rigify/rigs/spine.py b/rigify/rigs/spine.py index 332c6f43..29ad1729 100644 --- a/rigify/rigs/spine.py +++ b/rigify/rigs/spine.py @@ -20,6 +20,7 @@ """ TODO: - Add parameters for bone transform alphas. + - Add IK spine controls """ from math import floor @@ -32,7 +33,7 @@ from ..utils import MetarigError from ..utils import copy_bone, new_bone, flip_bone, put_bone from ..utils import connected_children_names from ..utils import strip_org, make_mechanism_name, make_deformer_name -from ..utils import obj_to_bone, create_circle_widget, create_compass_widget +from ..utils import obj_to_bone, create_circle_widget, create_cube_widget script = """ main = "%s" @@ -73,6 +74,7 @@ class Rig: self.control_indices.sort() self.pivot_rest = self.params.rest_pivot_slide + # Clamp pivot_rest to within the middle bones of the spine self.pivot_rest = max(self.pivot_rest, 1.0 / len(self.org_bones)) self.pivot_rest = min(self.pivot_rest, 1.0 - (1.0 / len(self.org_bones))) @@ -148,22 +150,12 @@ class Rig: # Create main control bone main_control = new_bone(self.obj, self.params.spine_main_control_name) - # Create main control WGT bones - main_wgt1 = new_bone(self.obj, make_mechanism_name(self.params.spine_main_control_name + ".01")) - main_wgt2 = new_bone(self.obj, make_mechanism_name(self.params.spine_main_control_name + ".02")) - eb = self.obj.data.edit_bones # Parent the main control eb[main_control].use_connect = False eb[main_control].parent = eb[self.org_bones[0]].parent - # Parent the main WGTs - eb[main_wgt1].use_connect = False - eb[main_wgt1].parent = eb[main_control] - eb[main_wgt2].use_connect = False - eb[main_wgt2].parent = eb[main_wgt1] - # Parent the controls and sub-controls for name, subname in zip(controls, subcontrols): eb[name].use_connect = False @@ -181,12 +173,6 @@ class Rig: put_bone(self.obj, main_control, pivot_rest_pos) eb[main_control].length = sum([eb[b].length for b in self.org_bones]) / 2 - # Position the main WGTs - eb[main_wgt1].tail = (0.0, 0.0, sum([eb[b].length for b in self.org_bones]) / 4) - eb[main_wgt2].length = sum([eb[b].length for b in self.org_bones]) / 4 - put_bone(self.obj, main_wgt1, pivot_rest_pos) - put_bone(self.obj, main_wgt2, pivot_rest_pos) - # Position the controls and sub-controls pos = eb[controls[0]].head.copy() for name, subname in zip(controls, subcontrols): @@ -379,11 +365,6 @@ class Rig: con.target = self.obj con.subtarget = rev_bones[0] - con = pb[main_wgt1].constraints.new('COPY_ROTATION') - con.name = "copy_rotation" - con.target = self.obj - con.subtarget = rev_bones[0] - # Slide constraints i = 1 tot = len(rev_bones) @@ -408,26 +389,6 @@ class Rig: mod.coefficients[0] = 1 - i mod.coefficients[1] = tot - # Main WGT - con = pb[main_wgt1].constraints.new('COPY_ROTATION') - con.name = "slide." + str(i) - con.target = self.obj - con.subtarget = rb - - # Driver - fcurve = con.driver_add("influence") - driver = fcurve.driver - var = driver.variables.new() - driver.type = 'AVERAGE' - var.name = "slide" - var.targets[0].id_type = 'OBJECT' - var.targets[0].id = self.obj - var.targets[0].data_path = main_control_p.path_from_id() + '["pivot_slide"]' - mod = fcurve.modifiers[0] - mod.poly_order = 1 - mod.coefficients[0] = 1.5 - i - mod.coefficients[1] = tot - i += 1 #---------------------------------- @@ -482,8 +443,7 @@ class Rig: # Control appearance # Main - pb[main_control].custom_shape_transform = pb[main_wgt2] - w = create_compass_widget(self.obj, main_control, bone_transform_name=main_wgt2) + w = create_cube_widget(self.obj, main_control) # Spines for name, i in zip(controls[1:-1], self.control_indices[1:-1]): |