# Bone Matrix??

-I’m having some trouble on getting the exact matrix
of a bone.I have to set up the pose mode and I need
the exact local matrix of every bone.I’ve studied the
blender2cal3d code but without results.It gives me
strange rotations(maybe i’m using it in the wrong way)
Any help would be aprecciated!!!Thanx in advance.

…I’m wondering why API gives acces to the matrices
for every object but not for the bones…???

Ben

I´ve written an exporter script based on blender2cal3d, and maybe I can help you understand what´s going on there. But your question is kinda unspecific.

The part where the bone-objects get set up in blender2cal3d is where the rest-pose gets extracted. The blender_bone2matrix(head, tail, b.getRoll()) function gives you the local matrix of the rest pose (in the parent´s coordinate space).

For the animations, the animated matrix of a bone is the result of the multiplication of the rest pose matrix and the matrix resulting from the ipo´s quaternion values:

``````          # We need to blend the rotation from the bone rest state (=bone.rot) with
# ipo_rot.
rot = quaternion_multiply(ipo_rot, bone.rot)
``````

-I’m trying to export the rest pose of an armature.
I need all their (bones) local matrices.I tried the
bone_matrix function but it doesn’t give me good
results…??
I’m building a 4x4 local matrix, from the 3x3 matrix
got with bone_matrix and the positon vector (tail-head)
of the parent…What I’m doing wrong?

Ben

It´s difficult to tell what you´re doing wrong since you didn´t post any code. But anyway, I´m absolutely sure that jiba´s code in blend2cal3d works correctly. The relevant portions are the “treat_bone” function and the “blender_bone2matrix” function.

Are you using row-major matrix notation instead of column-major?

This code snippet is from the “treat_bone” function, maybe that helps you:

``````        if parent:
# Compute the translation from the parent bone's head to the child
# bone's head, in the parent bone coordinate system.