Converting Unreal quaternions to Babylon.js

I need to convert some position and rotation data of skeleton nodes (in actor space) from Unreal to Babylon.js.

Unreal Has Z-axis as the UP vector as opposed to Babylon.js, which has Y-axis for the UP vector. I’m not super knowledgeable about quaternion math, so how would I go about converting the quaternion properly, given the quaternion X, Y, Z, and W values from Unreal?

Thanks in advance!

is y forward negative or positive? (right handed?)

In Unreal, Y forward is positive.

if you dont need to switch coordinates system (just z-to-y), switch between y and z, just like you would do for position.

This was the first thing I tried, but the resulting rotation is incorrect, where the rotation is pointed in the wrong direction. After swapping the Y and Z, I also tried multiplying the X and the new Z by -1, which gets me closer, but it still doesn’t look correct when comparing it against Unreal.

Y - positive = forward
Z positive = upwards
X positive = right?

I usually answer longer sentences. No idea why I come to the point so quick now :slight_smile:

In Unreal, X positive is forward, Y positive is right, and Z positive is up.

Ah :slight_smile: so switching them won’t do no good. Need to think a bit

Any new thoughts? I’ve tried everything I can think of but haven’t been able to find any conversion that works.

Hmm, I can only think in euler angles for this one:

Unreal is Z+Up, X+Forward, Y+Right
We want to convert to Y+Up, Z+Forward, X+Right

Isn’t that -90deg Z, then -90degY (in Unreal’s coordinate space)? These are both left handed coordinate spaces, so I don’t know if we should be flipping or swapping anything…

Mind you this was done using my hand in front of me haha, so I might have the directions flipped

To switch position information you simply change X to Z, Y to X and Z to Y, right? If you convert everything to this order, including VertexData, you should be able to change them in the quaternion (or better yet - in the rotation matrix) as well and not have any consequences. But this is an uneducated and untested guess.

Want to share a model in the playground and explain how it needs to be positioned?

Thanks for the help, but I managed to figure it out myself. In my case, the way to do this was to keep the order the same (x, y, z, and w), then multiplying x and w by -1.