I'm having trouble replicating Blender bone animation in my game.

Bones that have a vertical rest position (Euler(PI / 2, 0, 0)) are animated correctly (e.g. head, neck, torso, legs, shins), however bones that have horizontal rest positions (e.g. hips, shoulders, arms) appear slightly off.

I export each bone's rotation Euler value at each frame and reconstruct the rotation matrices in game. (exporting matrix values at each frame results in a larger file size)

I tried exporting quaternion values instead, but the resulting animation looked exactly the same.

I have successfully imported the model's resting mesh position and resting bone position. The issues happen during animation.

In Blender, the model's rest position is:

Model Rest Position

At a certain frame in Blender the model looks like this:

Model Animated

At the same frame in-game, the model looks like this:

Model Animated In-Game

As you can see, the hip bones are at more of a downward angle, and the "L.Shoulder" bone is at more of a downward angle.

The matrix I use to rotate each bone in-game is:

Matrix4.CreateTranslation(-bone.head) * Matrix4.CreateXYZRotation(-bone.restingRotation) * Matrix4.CreateXYZRotation(bone rotation at frame X) * Matrix4.CreateTranslation(bone.parent.tail)

I obtain each bone's resting Euler rotation by decomposing PoseBone.bone.matrix_local, and obtain each bone's animated Euler rotation by decomposing PoseBone.matrix:

Blender Python Data

The commands above were run at the same frame as the images of the animated model. The resting Euler rotation of the right shoulder is similar to that of the left shoulder, however the animated Euler rotations are quite different.

The roll of the L.Shoulder bone is -14 degrees, and the roll of the R.Shoulder bone is 14 degrees.

Any help with this would be greatly appreciated.

  • \$\begingroup\$ Perhaps use quaternion rotations instead? There's a game developer I track on Youtube and he realized that Euler rotations aren't good for animation, particularly because interpolation doesn't work as expected. I am not nearly qualified to teach game animation--in fact, I'm still trying to work out the bugs of my own animation system--but I can direct you to some tutorials, including the tutorial of the aforemetioned game developer: youtube.com/playlist?list=PLRIWtICgwaX2tKWCxdeB7Wv_rTET9JtWW ephenationopengl.blogspot.com/2012/06/… \$\endgroup\$ – Hylian Pikachu Oct 13 '18 at 3:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.