I'm trying to update a script from blender 2.55 to 2.7 which was supposed to work, but here I have an issue, to get the bone matrices I take the armature world_matrix and multiply by the bone local_matrix but all my bone seems to be at 0,0,0. I need to obtain the world matrix of each bone in object mode.

my test code:

import bpy
from bpy.props import *


for bone in ob.modifiers[0].object.pose.bones:
    print("matrix channel",bone.matrix_channel)
for bone in ob.modifiers[0].object.data.bones:

For both I have 0,0,0 for location (last line 0 0 0 1)


  • $\begingroup$ can you post how you are getting 0,0,0 , and did you try armature.pose.bones[0].matrix_channel $\endgroup$ – Chebhou Mar 14 '15 at 23:32
  • $\begingroup$ A pose bones location is relative to it's rest position, it will be 0,0,0 unless you have moved it in pose mode. $\endgroup$ – sambler Mar 15 '15 at 6:20
  • $\begingroup$ @Chebhou I added the code to my post, I have the same with matrix_channel $\endgroup$ – Entretoize Mar 15 '15 at 9:12
  • $\begingroup$ @sambler I don't find where to get the rest matrix.. $\endgroup$ – Entretoize Mar 15 '15 at 9:52
  • $\begingroup$ OK I finally found the error, it seems that rows and columns have been switched from blender 2.5 to 2.7 or my script was already buggy... Then matrix_local is the one to use. $\endgroup$ – Entretoize Mar 15 '15 at 13:12

this is not official but after inspection :

  • the last line is not for location in 4*4 matrix

enter image description here

  • matrix_local is the rest matrix in the armature space

  • matrix_channel is the pose matrix according to the rest state

  • i think the last line is there to make a square matrix

  • 1
    $\begingroup$ FYI the last line is used for non-uniform transformation (IE used in perspective matrix) and is known as the "w" component of the matrix. Should always be (0,0,0,1) unless you want strange things to happen :) $\endgroup$ – beiller Mar 16 '15 at 19:11
  • $\begingroup$ @beiller thanks for the info, feel free to edit and add more $\endgroup$ – Chebhou Mar 16 '15 at 19:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.