Notice: this is for the Blender 2.5/2.6 API.

Back in the old days in the Blender 2.4 API, you could easily create a bone from a transform matrix in your 3d file as EditBones had an attribute named "matrix", which was an armature-space matrix you could access and modify.

The new 2.5+ API still has the "matrix" attribute for EditBones, but for some unknown reason it is now read-only.

So how to create EditBones from transform matrices? I could only find one thing: a new "transform()" function, which takes a Matrix too.

Transform the the bones head, tail, roll and envelope (when the matrix has a scale component).

Perfect, but you already need to have some values (loc/rot/scale) for your bone, otherwise transforming with a matrix like this will give you nothing, your bone will be a zero-sized bone which will be deleted by Blender.

if you create default bone values first, like this:

bone.tail = mathutils.Vector([0,1,0])

Then transform() will work on your bone and it might seem to create correct bones, but setting a tail position actually generates a matrix itself, use transform() and you don't get the matrix from your model file on your EditBone, but the multiplication of your matrix with the bone's existing one. This can be easily proven by comparing the matrices read from the file with EditBone.matrix.

Again it might seem correct in Blender, but now export your model and you see your animations are messed up, as the bind pose rotations of the bones are wrong.

I've tried to find an alternative way to assign the transformation matrix from my file to my EditBone with no luck.

  • \$\begingroup\$ this is exact duplicate of gamedev.stackexchange.com/questions/31959/… \$\endgroup\$ – theli Jul 17 '12 at 8:06
  • \$\begingroup\$ This question appears to be off-topic because it is about Blender, not game development. Blender questions should be asked on the Blender stack exchange. \$\endgroup\$ – MichaelHouse Dec 19 '13 at 17:00
  • \$\begingroup\$ This is currently my problem too. You can't set matrix property, and I only have a transform matrix. \$\endgroup\$ – majidarif Sep 16 '16 at 20:26