i have a Quaternion, based on a coordinate system where the Y axis is up, the X axis is to the right and the Z axis looks towards me.
Now i want to move a character in another application(C++) based on this quaternion. This would be no problem if the coordinate systems where identical, but this application uses a different coordinate system. Z is up, X is to the right and Y is trough the monitor(inwards).
I tried to simply rotate the quaternion to adjust the coordinate system, but every rotation i tried, it didnt look even close to be correct.
My Thought is that i need some kind of base transformation, but i have no idea how to do this with a quaternion, does any one know how to perform a base transformation on a quaternion?
EDIT
I use the Eigen C++ lib for Quaternions. Here are the Quaternions i used:
Quaternion<float> QX90( Eigen::AngleAxisf( M_PI /2.0, Eigen::Vector3f::UnitX() ) );
Quaternion<float> nQX90( Eigen::AngleAxisf( -M_PI /2.0, Eigen::Vector3f::UnitX() ) );
Quaternion<float> Qrshoulder = .... //the Quaternion in the Y up coordinate system
i tried with rotating the X axis :
Qrshoulder=Qrshoulder*QX90;
Qrshoulder=QX90*Qrshoulder;
Qrshoulder=Qrshoulder*nQX90;
Qrshoulder=nQX90*Qrshoulder;
This didnt work. I also tried several other multiplications, i nearly tried every rotation that seems logical. I am confused..it seems this cannot be done with Quaternion multiplication
EDIT 2
I have absolute and hierarchical quaternions. Hierarchical Quaternions provides the amount of rotation in 3D space from the parent bone to the child..the absolute quaternions are the multiplied hierarchical bone orientations.
On the other hand, the character i want to animate has an engine behind, which already multiplies the bones, so i definitely need to use the hierarchical rotations. But the problem is, when i use hierarchical rotations, the Y axis always lies on the direction of the bone.
What i tried from Nolnoch's answer :
Quaternion<float> QNX( Eigen::AngleAxisf( 0, Eigen::Vector3f(1,0,0) ) );
rot=(QNX*QX90*Qrshoulder).toRotationMatrix();
targetNode->setRotation( Eigen::Transform3f( rot ) );
This didnt work either with hierarchcal nor with absolute orientations. Here is the article that describes what quaternions i get : http://msdn.microsoft.com/en-us/library/hh973073.aspx
What i think i miss, is when using the hierarchical orientations, i get the correct amount of rotation i need, but then the coordinate system is completly messed up because the Y axis is along the bone, and in my collada the coordinate system is always Z up. I have no clue how i can change this, i am not even sure if that is my problem.
boost::mathhas quaternion support.