Setting a bone's restmatrix

Scripting in Blender with Python, and working on the API

Moderators: jesterKing, stiv

Post Reply
Posts: 0
Joined: Mon Oct 20, 2003 1:02 am

Setting a bone's restmatrix

Post 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(). :)

Posts: 0
Joined: Thu May 29, 2003 10:32 pm
Location: Maryland, U.S.

Post 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 :)

Post Reply