Jump to content
  • Advertisement
Sign in to follow this  
Burnhard

Quaternion - restricting movement.

This topic is 2988 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, I'm using the Virtual Trackball class that comes with the SDK to express the orientation of an object on screen (a graph). I'd like to restrict the movement of this object, preventing the user from tilting it by more than, say, 45 degrees on any axis. I can't work out how to do it. The trackball uses a D3DXQUATERNION internally of course. Do I just need to break the quat into x, y, z angles and test those? There's a method to compose a quat from x, y, z with D3D, but there isn't one to break it down into them. Thanks for any assistance you can give me.

Share this post


Link to post
Share on other sites
Advertisement
The best way would probably to keep track of the angles separately from the quaternion. So have your yaw, pitch and roll as separate floats, adjust them however you want, test them to make sure they don't go over the value you want and then create a quaternion with them.

The angle floats have to be retained in the object for use in the next frame of course. This is what I do for my camera anyway whose pitch I stop from going too far up or down.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!