Hello,
I've written a tool that converts rotations from Right Handed (Blender) to Left Handed (Unity 3D). The tool runs in Unity 3D. I'm given a quaternion with the original rotation, and I calculate the quaternion with equivalent rotation as output. The only way I've found so far requires to extract and operate the Euler angles.
Actually this code runs fine:
// "rot" contains the input Quaternion with the original rotation
rot = Quaternion.Inverse(rot);
// Rename and invert the axes via Euler.
Vector3 euler = rot.eulerAngles;
float eulerY = euler.y;
euler.x = -euler.x;
euler.y = -euler.z;
euler.z = eulerY;
// If the model has been turned around (180º) then invert the rotations around the Y axis
if (m_zReverse)
{
euler.x = -euler.x;
euler.z = -euler.z;
}
// Convert the Euler angles back to Quaternion
rot = Quaternion.Euler(euler);
This converts the rotations properly on static objects. The problem is that this breaks the quaternion continuity when applied to rotation keys in animations. I suspect that the conversion back and forth Euler is the cause.
The question is: Could the above conversion be done without actually using Euler angles?
If you want to take a look at the tool itself, it's hosted at GitHub here.
Thank you!