[Bf-python] getRestMatrix() "fix"? (Was: Python -- Orientationproblems.)

Nick Lawson vektuz at cox.net
Wed Jun 8 23:00:09 CEST 2005


I'd be willing to test this, but the below link doesn't seem to work for me.

Anyways, I originally created bonebug.blend, and the python program in it
does the following:

	For each bone, it gets the rest matrix in 'bone space'
	Then, it uses blenders math library to decompose the matrix into a
rotation and a translation.
	All it does is print out the rotation and translations.

	The blendfile has just a long, straight, string of bones in it, so
in the initial pose, frame zero, the root bone should have a rotation (to
get it pointing in the right direction), and then every other bone should
have no rotation, because they're all just straight along that same axis.
Each bone is a few units above each other, in a straight line, so each bone
(Except the root) should show a constant translation of a few units along a
single axis.  

	The initial pose outputs -correctly-.  The bug is when you rotate
bones.

	On frame 10, bone three has been rotated by 90 degrees.  The
matrices, when decomposed should show that bone 3 has been rotated by 90
degrees in its parents space.  

	The bug is that even in 'bonespace', the rotation doesn't show up,
and instead it shows up as a translation.  If it were true parent-space
bones, the translations would never change, since no bones are being moved
relative to their parents spaces, they are only being rotated.

	The bug is 'fixed' when rotations show up as rotations and
translations show up as translations.  Currently everything shows up as a
translation, even rotations.

Perhaps it should be called 'parentspace' instead.  The matrix should be
each rotation relative to the parent's coordinate system, and its
translation in that same coordinate system.  

	The expected output of bonebug.blend on frame 10 is the same exact
translations as frame 1, but the bone that has been rotated should show up
as having been rotated.  Translations shouldn't ever change (it should stay
that constant value), since nothing was translated any differently.

	Some exporters use 'bonespace' already, as far as I know.  I'm not
sure they work correctly - I looked through the export of the .X file format
exporter, which uses 'bonespace' and I'm sure that animations will not work
correctly, because of the bug.  It does the same decomposition, and that
means anyone using the .X file exporter will probably start to notice all
their articulated models stretching apart instead of rotating their limbs.

	The .X file format, like many game export formats, expects bones to
be listed relative to their parents spaces, as it's the best format to use
for matrix palette skinning in a shader.

	If you need a more clear script to test the bug with, please let me
know.  I can also currently compile the blender CVS build, albeit with lots
and lots of warnings.  
	
	few months ago someone mentioned they had a patch for this bug that
added 'parentspace' in addition to 'bonespace' and 'worldspace', just in
case people used 'bonespace' somehow in their current exporters.  I believe
that kind of non-destructive fix would be best.  
-Nick Lawson




-----Original Message-----
From: bf-python-bounces at projects.blender.org
[mailto:bf-python-bounces at projects.blender.org] On Behalf Of Ken Hughes
Sent: Tuesday, June 07, 2005 11:03 PM
To: Blender Foundation Python list
Subject: [Bf-python] getRestMatrix() "fix"? (Was: Python --
Orientationproblems.)


I spent some time today trying to see if I could understand what's
happening here and how to fix it.  This is pretty difficult when
you (or at least I) can't find any documentation on how armatures
work and the Bone.py doc is ambiguous.  So here's how I interpret
the getRestMatrix('bonespace') should work:
    * the translation is the offset between a bone's head and its
      parent's head, relative to the parent's coordinate system
    * the rotation is the rotation relative to the parent

So for the bonebug.blend file in bug tracker #2230, I made a
patch which works, based on the above interpretation.  I uploaded
for testing to http://projects.blender.org/sharea/index.php?
(see patch-Bone.c)

Could someone try this, or if I interpreted what it should do
wrong, at least give me some examples of what the output SHOULD
be so I know what to look for?

Ken

_______________________________________________
Bf-python mailing list
Bf-python at projects.blender.org
http://projects.blender.org/mailman/listinfo/bf-python




More information about the Bf-python mailing list