Page 1 of 1

Setting a bone's restmatrix

Posted: Fri Sep 10, 2004 1:59 pm
by der_ton
There's a .getRestMatrix() method for bones, but no .setRestMatrix(). I'm working on a script that imports a skeleton, and the generated bones in Blender must have the same transformation matrix as the imported skeleton (because of animation file compatibility when the skeleton is exported again).
How do I use setHead(), setTail() and setRoll() so that the resulting transformation matrix of the bone is the one I want it to have?

A convenient alternative would be if there was a setRestMatrix(). :)

Posted: Sat Sep 11, 2004 8:55 pm
by ascotan
SetRestMatrix was the idea but the math was a bit complex. There is no easy way to do what you want. A guess would be: You would need to deconstruct the 'worldspace' matrix from every bone in your armature based on the parenting structure. ie. matrixC = (local)matrixC /((world)matrixA * (world)matrixB) or something. Once you have the world matrix for every bone in the armature, You could then import everybone using setHead/setTail. Then you would need to apply the parent matrix for everybone in the armature using setMatrix(). This is an idea but clearly not a simple one.
Obviously the ability to use setrestmatrix would be better :)