3

I'm trying to save transform matrices of objects into a text file using python. These objects are animated using armatures. I tried to use the "matrix_world" field but that only contains the base value. It's possible to do similar to a mesh which gives a transformed mesh (using the animations and modifiers, etc) but that does not contain the transformation matrix that I need.

Is is possible to get that transformation matrix which is used to render the mesh in the view (basically that matrix which is created using the base matrix plus the animations)?

David
  • 49,291
  • 38
  • 159
  • 317
robot9706
  • 33
  • 5

1 Answers1

1

As your mesh is composed of multiple pieces that are posed with armature, the mesh itself has only 1 origin and 1 matrix transform.

To get the transformation of pieces you need to extract transformation of those pose bones.

You can use bpy.data.objects["Armature"].pose.bones["Bone"].matrix added to your armature global transform matrix or also you can use this answer:

How can I manually calculate bpy.types.PoseBone.matrix

Jaroslav Jerryno Novotny
  • 51,077
  • 7
  • 129
  • 218
  • Thanks for your answer! I tried that too, it turned out that I need both of the matrices and I need to multiply them to get the correct result (because the bone matrix contains rotation and position and the object matrix contains scale and base position). – robot9706 Apr 02 '16 at 07:53