Jump to content
  • Advertisement
Sign in to follow this  
BlackJoker

Auto-level feature for quaternion based camera

This topic is 1426 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

I have 6DOF camera based on quaternions and I have accumulated roll. I wanted to get rid of it, but cant find the solution.

I know this was discussed much times, but I didnt find any working code for doing this.

For now i have the following code to get rid from unwanted roll rotation:

qRotation *= Quaternion.RotationAxis(Vector3.ForwardLH,
                Vector3.Dot(Vector3.Transform(Vector3.Right, qRotation), Vector3.Up) * 0.04f);
            qRotation = Quaternion.Normalize(qRotation);

But this code leads to unexpected results. First, Camera rotate to 180 degrees on z axis and I cannot rotate it back. 

Second - during rotation along X axis, camera start rotating and I change its orientation.

 

Does someone know how to fix that and do correct auto-leveling?

Share this post


Link to post
Share on other sites
Advertisement
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!