diff options
author | Nathan Vegdahl <cessen@cessen.com> | 2011-03-13 22:02:15 +0300 |
---|---|---|
committer | Nathan Vegdahl <cessen@cessen.com> | 2011-03-13 22:02:15 +0300 |
commit | 3636e3dfbac30dc44903e9dbbb7c19d81a03f6cf (patch) | |
tree | cfb42abc7c255161178632e70b3d8b994a589b43 /rigify | |
parent | 3964a4f5f6e99fdc9a2b548862b6e94b511dd15c (diff) |
Rigify:
- Flipped the roll values on the default human metarig spine and neck. This
makes bending the rig forward have a positive rotation value, and bending
back have a negative one. More in line with user expectations.
- Improved get_pose_matrix_in_other_space() to account for bones with
"inherit rotation" and/or "inherit scale" turned off.
- Added a text file giving credit to people who have contributed to Rigify
financially or otherwise.
Diffstat (limited to 'rigify')
-rw-r--r-- | rigify/CREDITS | 15 | ||||
-rw-r--r-- | rigify/metarigs/human.py | 10 | ||||
-rw-r--r-- | rigify/rig_ui_template.py | 52 |
3 files changed, 67 insertions, 10 deletions
diff --git a/rigify/CREDITS b/rigify/CREDITS new file mode 100644 index 00000000..804a6057 --- /dev/null +++ b/rigify/CREDITS @@ -0,0 +1,15 @@ +A big thank you to all the people listed here for supporting Rigify. + +Original prototyping and development, and Python API support: +- Campbell Barton + +General financial support: +- Benjamin Tolputt +- Nesterenko Viktoriya + +IK/FK snapping financial support: +- Benjamin Tolputt +- Nesterenko Viktoriya +- Leslie Chih +- Isaac Ah-Loe + diff --git a/rigify/metarigs/human.py b/rigify/metarigs/human.py index 082c5ef3..9a67504a 100644 --- a/rigify/metarigs/human.py +++ b/rigify/metarigs/human.py @@ -29,13 +29,13 @@ def create(obj): bone = arm.edit_bones.new('hips') bone.head[:] = 0.0000, 0.0552, 1.0099 bone.tail[:] = 0.0000, 0.0172, 1.1837 - bone.roll = -3.1416 + bone.roll = 0.0000 bone.use_connect = False bones['hips'] = bone.name bone = arm.edit_bones.new('spine') bone.head[:] = 0.0000, 0.0172, 1.1837 bone.tail[:] = 0.0000, 0.0004, 1.3418 - bone.roll = -3.1416 + bone.roll = 0.0000 bone.use_connect = True bone.parent = arm.edit_bones[bones['hips']] bones['spine'] = bone.name @@ -56,7 +56,7 @@ def create(obj): bone = arm.edit_bones.new('ribs') bone.head[:] = 0.0000, 0.0004, 1.3418 bone.tail[:] = 0.0000, 0.0114, 1.6582 - bone.roll = -3.1416 + bone.roll = 0.0000 bone.use_connect = True bone.parent = arm.edit_bones[bones['spine']] bones['ribs'] = bone.name @@ -77,7 +77,7 @@ def create(obj): bone = arm.edit_bones.new('neck') bone.head[:] = 0.0000, 0.0114, 1.6582 bone.tail[:] = 0.0000, -0.0247, 1.7813 - bone.roll = 3.1416 + bone.roll = 0.0000 bone.use_connect = False bone.parent = arm.edit_bones[bones['ribs']] bones['neck'] = bone.name @@ -140,7 +140,7 @@ def create(obj): bone = arm.edit_bones.new('head') bone.head[:] = 0.0000, -0.0247, 1.7813 bone.tail[:] = 0.0000, -0.0247, 1.9347 - bone.roll = 3.1416 + bone.roll = 0.0000 bone.use_connect = True bone.parent = arm.edit_bones[bones['neck']] bones['head'] = bone.name diff --git a/rigify/rig_ui_template.py b/rigify/rig_ui_template.py index 08e40f2f..136cb44b 100644 --- a/rigify/rig_ui_template.py +++ b/rigify/rig_ui_template.py @@ -33,16 +33,58 @@ def get_pose_matrix_in_other_space(mat, pose_bone): transform space. In other words, presuming that mat is in armature space, slapping the returned matrix onto pose_bone should give it the armature-space transforms of mat. + TODO: try to handle cases with axis-scaled parents better. """ - rest_inv = pose_bone.bone.matrix_local.inverted() - + rest = pose_bone.bone.matrix_local.copy() + rest_inv = rest.inverted() if pose_bone.parent: + par_mat = pose_bone.parent.matrix.copy() par_inv = pose_bone.parent.matrix.inverted() par_rest = pose_bone.parent.bone.matrix_local.copy() - - smat = rest_inv * (par_rest * (par_inv * mat)) else: - smat = rest_inv * mat + par_mat = Matrix() + par_inv = Matrix() + par_rest = Matrix() + + # Get matrix in bone's current transform space + smat = rest_inv * (par_rest * (par_inv * mat)) + + # Compensate for non-inherited rotation/scale + if not pose_bone.bone.use_inherit_rotation: + loc = mat.to_translation() + loc -= (par_mat*(par_rest.inverted() * rest)).to_translation() + loc *= rest.inverted().to_quaternion() + if pose_bone.bone.use_inherit_scale: + t = par_mat.to_scale() + par_scale = Matrix().Scale(t[0], 4, Vector((1,0,0))) + par_scale *= Matrix().Scale(t[1], 4, Vector((0,1,0))) + par_scale *= Matrix().Scale(t[2], 4, Vector((0,0,1))) + else: + par_scale = Matrix() + + smat = rest_inv * mat * par_scale.inverted() + smat[3][0] = loc[0] + smat[3][1] = loc[1] + smat[3][2] = loc[2] + elif not pose_bone.bone.use_inherit_scale: + loc = smat.to_translation() + rot = smat.to_quaternion() + scl = mat.to_scale() + + smat = Matrix().Scale(scl[0], 4, Vector((1,0,0))) + smat *= Matrix().Scale(scl[1], 4, Vector((0,1,0))) + smat *= Matrix().Scale(scl[2], 4, Vector((0,0,1))) + smat *= Matrix.Rotation(rot.angle, 4, rot.axis) + smat[3][0] = loc[0] + smat[3][1] = loc[1] + smat[3][2] = loc[2] + + # Compensate for non-local location + if not pose_bone.bone.use_local_location: + loc = smat.to_translation() * (par_rest.inverted() * rest).to_quaternion() + smat[3][0] = loc[0] + smat[3][1] = loc[1] + smat[3][2] = loc[2] return smat |