apply non-hierarchial transforms to hierarchial skeleton?
Posted
by
user975135
on Game Development
See other posts from Game Development
or by user975135
Published on 2012-07-30T08:13:43Z
Indexed on
2012/09/04
3:49 UTC
Read the original article
Hit count: 401
I use Blender3D, but the answer might not API-exclusive.
I have some matrices I need to assign to PoseBones. The resulting pose looks fine when there is no bone hierarchy (parenting) and messed up when there is.
I've uploaded an archive with sample blend of the rigged models, text animation importer and a test animation file here:
http://www.2shared.com/file/5qUjmnIs/sample_files.html
Import the animation by selecting an Armature and running the importer on "sba" file.
Do this for both Armatures.
This is how I assign the poses in the real (complex) importer:
matrix_bases = ... # matrix from file
animation_matrix = matrix_basis * pose.bones['mybone'].matrix.copy()
pose.bones[bonename].matrix = animation_matrix
If I go to edit mode, select all bones and press Alt+P to undo parenting, the Pose looks fine again.
The API documentation says the PoseBone.matrix is in "object space", but it seems clear to me from these tests that they are relative to parent bones.
Final 4x4 matrix after constraints and drivers are applied (object space)
I tried doing something like this:
matrix_basis = ... # matrix from file
animation_matrix = matrix_basis * (pose.bones['mybone'].matrix.copy() * pose.bones[bonename].bone.parent.matrix_local.copy().inverted())
pose.bones[bonename].matrix = animation_matrix
But it looks worse. Experimented with order of operations, no luck with all.
For the record, in the old 2.4 API this worked like a charm:
matrix_basis = ... # matrix from file
animation_matrix = armature.bones['mybone'].matrix['ARMATURESPACE'].copy() * matrix_basis
pose.bones[bonename].poseMatrix = animation_matrix
pose.update()
Link to Blender API ref:
© Game Development or respective owner