Armature Export: find armature matrix

I’ve been trying way too long to get the proper transformation of my armature to export. I’ve searched all the forums and documentation, unfortunately most of the information is outdated for 2.65, and I’m hoping there is someone out there that has figured this out.

So, my problem: I am skinning a mesh in my program, and to do so must export the armature transforms as a matrix. I’ve got it exporting, the armature transforms the model, but some of the bone transformations are rotating about the wrong axis. I have a suspicion that it has to do with bone.matrix_local, and i’ve tried multiplying the results by matrix_local.inverted() and many other permutations of matrix multiplication, but I cant quite figure it out.

So, I require transformation of bones in matrix form, with the proper axis, where each transformation is relative to it’s parent. Has anyone done this before in 2.6x?

Thanks for the help.

Are you talking about doing skeletal animations where you deform the mesh in realtime with the bones?

If so, the points in the mesh are in Object space. The following matrix will transform a point in Object space to a Pose space.

Given pBone is a PoseBone:

  # Get the matrix that maps Obj->rest space
  obj2Rest = pBone.bone.matrix_local.copy().inverted()
  # compose the matrix that maps obj->pose space
  obj2Pose = pBone.matrix * obj2Rest