Export bone poses differently

Hello,
I am currently in the middle of writing an export script in Blender 2.63 and successfully exported armature bone poses so that I can animate a rigged model in an external program. I have achieved this, by exporting the bone’s localmatrix=Armature.bones[‘bonename’].matrix_local.copy().inverted() matrix and a pose matrix of: matrix=Armatureobject.pose.bones[‘bonename’].matrix .

In my program I modify the assigned vertices by those matrices, like: matrixlocalmatrixweight*vertex . The final result is correct on my model in Blender and in my program as well.

I would like to modify this, by exporting only a pose bone’s rotation_quaternion and location to reduce the output file’s size and also integrate intepolation to my external program (game), and create the tranformation matrices there. However I am quite a bit stuck for some days with that. I thought I would read the rotation_quaternion and location vectors, create the transformation matrices and loop back recursively on a bones parents to create the final transformation matrix for a bone. I also thought that this way I would not need the local matrix of a bone, because the rotation and translation are this way relative to the bone. The final result showed me that I am wrong, because it differs significantly in my game compared to in Blender. (But the model is still recognizable, so I think I might not be far from the answer)

Did you solve your issues finally?

I am trying to do something similar at the moment but am struggling to read the “location” and “rotation_quaternion” of a mesh based on frames. At the moment I can only access the initial position but not the adjusted one in the single frames…

Update: For the quaternion-rotation I have found something in another thread which seems to work.

bpy.context.scene.frame_set(x)
obj.rotation_mode=“QUATERNION”
obj.rotation_quaternion