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:
At a certain frame in Blender the model looks like this:
At the same frame in-game, the model looks like this:
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.CreateXYZRotation(bone rotation at frame X) *
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:
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.