Trying to export bones, please save me from asylum...

Scripting in Blender with Python, and working on the API

Moderators: jesterKing, stiv

Deltakosh
Posts: 3
Joined: Sun Sep 08, 2013 9:56 am
Location: Paris

Trying to export bones, please save me from asylum...

Postby Deltakosh » Sun Sep 08, 2013 10:03 am

Hello all,

I would like to export bones. According to the doc, if I use this code, I should get the absolute transformation matrix for a bone:

Code: Select all

           
SystemMatrix = Matrix.Rotation(radians(-90), 4, 'X')
Export_babylon.write_matrix4(file_handler, "matrix", SystemMatrix * armature.matrix_world * bone.matrix)


But it seems to be more complex because the result is not good (scaling is not good).

What have I to do to export a bone absolute matrix then ?

Thanks a lot for any appreciated help!
Creator of babylon.js - www.babylonjs.com

Deltakosh
Posts: 3
Joined: Sun Sep 08, 2013 9:56 am
Location: Paris

Re: Trying to export bones, please save me from asylum...

Postby Deltakosh » Sun Sep 08, 2013 8:18 pm

Ok I found:)
For those who have the same question here is the final code!

Code: Select all

    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)


Deltakosh wrote:Hello all,

I would like to export bones. According to the doc, if I use this code, I should get the absolute transformation matrix for a bone:

Code: Select all

           
SystemMatrix = Matrix.Rotation(radians(-90), 4, 'X')
Export_babylon.write_matrix4(file_handler, "matrix", SystemMatrix * armature.matrix_world * bone.matrix)


But it seems to be more complex because the result is not good (scaling is not good).

What have I to do to export a bone absolute matrix then ?

Thanks a lot for any appreciated help!
Creator of babylon.js - www.babylonjs.com


Return to “Python”

Who is online

Users browsing this forum: No registered users and 0 guests