3
$\begingroup$

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)?

$\endgroup$

1 Answer 1

1
$\begingroup$

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

$\endgroup$
1
  • $\begingroup$ 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). $\endgroup$
    – robot9706
    Commented Apr 2, 2016 at 7:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .