Jump to content
  • Advertisement
Sign in to follow this  
Rhiakath

OpenGL Convert quaternions from D3D to OpenGL

This topic is 3244 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi there. I'm reading the model files from Dawn of war, and i've come into a bit of trouble. All the quaternions stored there are assuming an axis orientation of Direct3D. (Z axis coming toward the user), while I'm using OpenGL (Z axis going away from the user). So, the models appear somewhat "reflected". It appears correctly if i just invert the Z coordinate, but then I don't know how to invert the rotation quaternions of the animations. How can i do it? Basically, it's just inverting the Z axis (I think).

Share this post


Link to post
Share on other sites
Advertisement
To invert the rotation represented by a quaternion, invert the quaternion (which, for unit-length quaternions, is equivalent to conjugation). Or, you can just negate the 'w' component (which will give you the negative of the conjugate, and since q and -q represent the same rotation, the result will still be correct).

Share this post


Link to post
Share on other sites
Hmm, but won't that negate the whole rotation? I just want to negate the Z axis.

So, for example, if the rotation means 30 degrees clockwise, i want it to remain exactly the same, but with negative Z.


But, again, I don't know what i want so surely, anymore. been fighting with this for a few months, now. I'll try your sugestion.

Share this post


Link to post
Share on other sites
Hmm, but won't that negate the whole rotation? I just want to negate the Z axis.

So, for example, if the rotation means 30 degrees clockwise, i want it to remain exactly the same, but with negative Z.


But, again, I don't know what i want so surely, anymore. been fighting with this for a few months, now. I'll try your sugestion.

Share this post


Link to post
Share on other sites
A quaternion cannot represent a flip in a coordinate. What you need to do is flip the z coordinate of the points as you load your model.

Share this post


Link to post
Share on other sites
Fliping the Z coordinate of the model displays the model correctly, yes.
All the vertices of the model are relative to (0,0,0), with no transformations or rotations.

The problem is the skeleton. If I just flip the Z coordinate of the bones do you imagine what happens? Mayhem.

So, that should not be the solution.

I'm gonna try inverting w later today, when i get home.
And then, invert x and y, as suggested. Let's see what comes from that...


Share this post


Link to post
Share on other sites
For the quaternions, try negating the z and w elements (no guarantee that'll work, but it seems that reflecting the axis across the xy plane and reversing the direction of rotation might have the desired effect).

Share this post


Link to post
Share on other sites
Ok, negate W on the quaternion.
or X and Y.
or X and Z.

AAAAAAAAAHHHHHHHHHHHHHHHHHH

(bangs head on wall)

or just leave programming and open a bakery

Share this post


Link to post
Share on other sites
Ok, negate W on the quaternion.
or X and Y.
or X and Z.

AAAAAAAAAHHHHHHHHHHHHHHHHHH

(bangs head on wall)

or just leave programming and open a bakery

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!