In Blender 2.6 API, PoseBone is used for animating a bone. PoseBone.matrix is one way to do that. API says PoseBone.matrix is in "object space".
PoseBone.matrix is nothing I've seen at all. I still can't get my animation importer working. What's the deal with PoseBone.matrix? In Blender 2.4 API there were two matrices: one in local space, one in armature space.
But the new PoseBone.matrix is neither! It's not a local matrix:
Position isn't local, it's global.
But rotation
<Euler (x=1.5708, y=-0.7854, z=-0.0000), order='XYZ'>
is.
So what is this "object space" that the API says PoseBone.matrix is in?
I'm trying to assign my armature-space matrices to a hierarchial armature and I can't get them right.
I tried decomposing the matrices I have, undoing parent rotations then recomposing the matrix again before setting it as "PoseBone.matrix". It just doesn't work.
oldmatrix = myMatrix
loc, rot, scale = oldmatrix.decompose()
#rot = rot * pose.bones[bonename].parent.rotation_quaternion.conjugated()
for i in pose.bones[bonename].parent_recursive:
rot = rot * i.conjugated()
newmatrix = rot.to_matrix().to_4x4()
newmatrix[0][3] = loc.x
newmatrix[1][3] = loc.y
newmatrix[2][3] = loc.z
pose.bones[bonename].matrix = newmatrix