I have written scripts that take as input the joint-local rotations (in quaternions) of an armature. All works as expected when extracting these rotations directly from a .bvh file and converting them to quaternions manually, but I am trying to obtain the same rotations from an armature inside of a scene and failing to do so.

Currently I am importing a single-frame .bvh file into a scene and then I try to obtain the exact joint_local Euler rotations stored in that file with the following function (with order ZYX as it is the specified order in the .bvh file) so that I can later manually convert the rotations to quaternions:

def get_local_rotations_in_degrees(armature, euler_order='ZYX'):
    rotations = []
    for pose_bone in armature.pose.bones:
        local_rotation_matrix = pose_bone.matrix_basis
        local_rotation_euler = local_rotation_matrix.to_euler(euler_order)
        local_rotation_degrees = [math.degrees(angle) for angle in local_rotation_euler]

    return rotations

This function however returns very different floats than are stored in the original file.

How do I obtain the exact floats (joint-local rotations) that are stored in a .bvh file from an armature in a scene?

  • $\begingroup$ Can you share your Blender project file? Instructions for sharing. $\endgroup$
    – Jakemoyo
    Commented Jun 27 at 14:30
  • 1
    $\begingroup$ Yes! .blend: <img src="https://blend-exchange.com/embedImage.png?bid=N0aXV5rk" />. It should contain the imported armature called "sample" and a script that when ran prints the rotations as obtained with the above function. In that script I also put the original line from the single-frame .bvh file for reference(these are the rotations I'm looking for). $\endgroup$
    – wolfg269
    Commented Jun 27 at 15:25


You must log in to answer this question.

Browse other questions tagged .