[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [1704] trunk/py/scripts/addons/rigify: Rigify:

Nathan Vegdahl cessen at cessen.com
Sun Mar 13 20:02:16 CET 2011


Revision: 1704
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=1704
Author:   cessen
Date:     2011-03-13 19:02:15 +0000 (Sun, 13 Mar 2011)
Log Message:
-----------
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.

Modified Paths:
--------------
    trunk/py/scripts/addons/rigify/metarigs/human.py
    trunk/py/scripts/addons/rigify/rig_ui_template.py

Added Paths:
-----------
    trunk/py/scripts/addons/rigify/CREDITS

Added: trunk/py/scripts/addons/rigify/CREDITS
===================================================================
--- trunk/py/scripts/addons/rigify/CREDITS	                        (rev 0)
+++ trunk/py/scripts/addons/rigify/CREDITS	2011-03-13 19:02:15 UTC (rev 1704)
@@ -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
+

Modified: trunk/py/scripts/addons/rigify/metarigs/human.py
===================================================================
--- trunk/py/scripts/addons/rigify/metarigs/human.py	2011-03-13 06:51:07 UTC (rev 1703)
+++ trunk/py/scripts/addons/rigify/metarigs/human.py	2011-03-13 19:02:15 UTC (rev 1704)
@@ -29,13 +29,13 @@
     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 @@
     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 @@
     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 @@
     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

Modified: trunk/py/scripts/addons/rigify/rig_ui_template.py
===================================================================
--- trunk/py/scripts/addons/rigify/rig_ui_template.py	2011-03-13 06:51:07 UTC (rev 1703)
+++ trunk/py/scripts/addons/rigify/rig_ui_template.py	2011-03-13 19:02:15 UTC (rev 1704)
@@ -33,17 +33,59 @@
         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
 
 



More information about the Bf-extensions-cvs mailing list