Swapping axes in skeletons & animations.

Started by
3 comments, last by GameDev.net 19 years, 7 months ago
Hello, I'm implementing an skeletal animation system, and in order to convert from my model's file coodinate system to my engine coordinate system I have to swap the y & z components of the vertices. However it isn't as simple as that for the bones (I'm defining the bone transform as a rotation stored in a quaternion, followed by a translation stored as a 3d vector), and I'm having a hard time wrapping my head around how to do the conversion between coordinate systems for them. So if any of you has faced this problem before & can shed some light in the subject I'd be grateful. Thanks.
Advertisement
My advice is to google for the "matrix and quaternion FAQ", which used to be called the hexapod faq or something.

Use conversion to eulers to swap axes at load time, then back to quats for runtime.

There may well be a smarter way to do this using just quaternions, but I'm not 100% sure. Postmultiply your quaternion with another quat representing the rotation (90 degrees in the correct axis) into the 'correct' frame of reference.
[size="1"]
Something like this?


Q = Build quaternion that rotates -PI/2 radians around x-axis.

If joint is root in the hierarchy (origin):
Joint.Rotation = Q * Joint.Rotation
Joint.Position = Q * Joint.Position
[size="1"]Perl - Made by Idiots, Java - Made for Idiots, C++ - Envied by Idiots | http://sunray.cplusplus.se
Would just transforming the root bones work??
Quote:Original post by raydog
Would just transforming the root bones work??


good one. Yes, I think it would.

This topic is closed to new replies.

Advertisement