diff options
author | Nathan Vegdahl <cessen@cessen.com> | 2011-06-18 11:04:53 +0400 |
---|---|---|
committer | Nathan Vegdahl <cessen@cessen.com> | 2011-06-18 11:04:53 +0400 |
commit | 83840e5713eaeaf3b8ec0c779d0dffe8666cd85c (patch) | |
tree | dd94cfae0a9c028aed22e740df08c74a6e86f34d /rigify/rigs | |
parent | 6f3d2c4932d9af407fa8bdf9317ccaed5e993dcd (diff) |
Rigify: added bend hinting to the arm and leg rigs.
This allows IK arms and legs to still function properly even when they
start with an entirely straight chain.
Diffstat (limited to 'rigify/rigs')
-rw-r--r-- | rigify/rigs/biped/arm/__init__.py | 5 | ||||
-rw-r--r-- | rigify/rigs/biped/arm/ik.py | 32 | ||||
-rw-r--r-- | rigify/rigs/biped/leg/__init__.py | 5 | ||||
-rw-r--r-- | rigify/rigs/biped/leg/ik.py | 32 |
4 files changed, 74 insertions, 0 deletions
diff --git a/rigify/rigs/biped/arm/__init__.py b/rigify/rigs/biped/arm/__init__.py index c09b39f4..93e757f4 100644 --- a/rigify/rigs/biped/arm/__init__.py +++ b/rigify/rigs/biped/arm/__init__.py @@ -96,6 +96,8 @@ class Rig: items = [('X', 'X', ''), ('Y', 'Y', ''), ('Z', 'Z', ''), ('-X', '-X', ''), ('-Y', '-Y', ''), ('-Z', '-Z', '')] group.primary_rotation_axis = bpy.props.EnumProperty(items=items, name="Primary Rotation Axis", default='X') + group.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.") + group.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.") group.ik_layers = bpy.props.BoolVectorProperty(size=32, description="Layers for the ik controls to be on.") @@ -159,6 +161,9 @@ class Rig: 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") diff --git a/rigify/rigs/biped/arm/ik.py b/rigify/rigs/biped/arm/ik.py index b16221d8..0ecf70e7 100644 --- a/rigify/rigs/biped/arm/ik.py +++ b/rigify/rigs/biped/arm/ik.py @@ -84,6 +84,8 @@ class Rig: else: self.layers = None + self.bend_hint = params.bend_hint + self.primary_rotation_axis = params.primary_rotation_axis def generate(self): @@ -198,6 +200,36 @@ class Rig: prop["soft_min"] = prop["min"] = 0.0 prop["soft_max"] = prop["max"] = 1.0 + # Bend direction hint + if self.bend_hint: + con = farm_p.constraints.new('LIMIT_ROTATION') + con.name = "bend_hint" + con.owner_space = 'LOCAL' + if self.primary_rotation_axis == 'X': + con.use_limit_x = True + con.min_x = pi / 10 + con.max_x = pi / 10 + elif self.primary_rotation_axis == '-X': + con.use_limit_x = True + con.min_x = -pi / 10 + con.max_x = -pi / 10 + elif self.primary_rotation_axis == 'Y': + con.use_limit_y = True + con.min_y = pi / 10 + con.max_y = pi / 10 + elif self.primary_rotation_axis == '-Y': + con.use_limit_y = True + con.min_y = -pi / 10 + con.max_y = -pi / 10 + elif self.primary_rotation_axis == 'Z': + con.use_limit_z = True + con.min_z = pi / 10 + con.max_z = pi / 10 + elif self.primary_rotation_axis == '-Z': + con.use_limit_z = True + con.min_z = -pi / 10 + con.max_z = -pi / 10 + # IK Constraint con = farm_p.constraints.new('IK') con.name = "ik" diff --git a/rigify/rigs/biped/leg/__init__.py b/rigify/rigs/biped/leg/__init__.py index f2ea2e51..8f9286c7 100644 --- a/rigify/rigs/biped/leg/__init__.py +++ b/rigify/rigs/biped/leg/__init__.py @@ -98,6 +98,8 @@ class Rig: items = [('X', 'X', ''), ('Y', 'Y', ''), ('Z', 'Z', ''), ('-X', '-X', ''), ('-Y', '-Y', ''), ('-Z', '-Z', '')] group.primary_rotation_axis = bpy.props.EnumProperty(items=items, name="Primary Rotation Axis", default='X') + group.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.") + group.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.") group.ik_layers = bpy.props.BoolVectorProperty(size=32, description="Layers for the ik controls to be on.") @@ -161,6 +163,9 @@ class Rig: 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") diff --git a/rigify/rigs/biped/leg/ik.py b/rigify/rigs/biped/leg/ik.py index 265b4e32..54869b8e 100644 --- a/rigify/rigs/biped/leg/ik.py +++ b/rigify/rigs/biped/leg/ik.py @@ -134,6 +134,8 @@ class Rig: else: self.layers = None + self.bend_hint = params.bend_hint + self.primary_rotation_axis = params.primary_rotation_axis def generate(self): @@ -376,6 +378,36 @@ class Rig: prop["soft_min"] = prop["min"] = 0.0 prop["soft_max"] = prop["max"] = 1.0 + # Bend direction hint + if self.bend_hint: + con = shin_p.constraints.new('LIMIT_ROTATION') + con.name = "bend_hint" + con.owner_space = 'LOCAL' + if self.primary_rotation_axis == 'X': + con.use_limit_x = True + con.min_x = pi / 10 + con.max_x = pi / 10 + elif self.primary_rotation_axis == '-X': + con.use_limit_x = True + con.min_x = -pi / 10 + con.max_x = -pi / 10 + elif self.primary_rotation_axis == 'Y': + con.use_limit_y = True + con.min_y = pi / 10 + con.max_y = pi / 10 + elif self.primary_rotation_axis == '-Y': + con.use_limit_y = True + con.min_y = -pi / 10 + con.max_y = -pi / 10 + elif self.primary_rotation_axis == 'Z': + con.use_limit_z = True + con.min_z = pi / 10 + con.max_z = pi / 10 + elif self.primary_rotation_axis == '-Z': + con.use_limit_z = True + con.min_z = -pi / 10 + con.max_z = -pi / 10 + # IK Constraint con = shin_p.constraints.new('IK') con.name = "ik" |