Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I use this simple python script to export bones transformation:

bones = armature.pose.bones
# for eaach bone in bones
SystemMatrix = Matrix.Scale(-1, 4, Vector((0, 0, 1))) * Matrix.Rotation(radians(-90), 4, 'X')
if (bone.parent):
  Export_babylon.write_matrix4(file_handler, "matrix", bone.parent.matrix.inverted() * bone.matrix)
else:
  Export_babylon.write_matrix4(file_handler, "matrix", SystemMatrix * bone.matrix)

I'm using a left handed Y up system but I should forget something about rotation because the result is not correct :(

enter image description here

Original (under Blender): enter image description here

share|improve this question
    
It's bit unclear what you are asking? –  Katu Sep 7 '13 at 17:02
    
I would like to know how to get the value of a bone transform from blender to apply it to my meshes Inside my engine –  David Catuhe Sep 8 '13 at 6:42
add comment

1 Answer

up vote 0 down vote accepted

OK I found the solution :)

It was related to the inversion of the parent bone. For those who have the same question, here is the final exportation code:

def export_bone_matrix(armature, bone, label, file_handler):
  SystemMatrix = Matrix.Scale(-1, 4, Vector((0, 0, 1))) * Matrix.Rotation(radians(-90), 4, 'X')

    if (bone.parent):
        Export_babylon.write_matrix4(file_handler, label, (SystemMatrix * armature.matrix_world * bone.parent.matrix).inverted() * (SystemMatrix * armature.matrix_world * bone.matrix))
    else:
        Export_babylon.write_matrix4(file_handler, label, SystemMatrix * armature.matrix_world * bone.matrix)
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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