Jump to content
  • Advertisement
Sign in to follow this  

Free-Space-Camera rotation

This topic is 3983 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 want to create a camera like in the games "Descent" or "Forsaken". You can rotate freely in every direction. But each rotation is depending on the current camera state. Which means, it is not the same if you first rotate 90 degrees up and then 90 degrees to the left or if you first rotate left and then up. After the first way of rotating the camera would face to the left, but the floor of the world is to the viewers left on the screen. After the second way of rotating the camera would face upwards. It's like rotating your head to the left and then looking up instead of first looking upwards and then just rotate it to the left. It's not easy to describe what exactly I mean, but I hope you can imagine what I want. Hope you understand it or someone can describe it better than me :(

Share this post

Link to post
Share on other sites
So you got 3 vectors:

(doesnt have to start like this, dont matter at all)
_right (1,0,0)
_up (0,1,0)
_look (0,0,1)

You look left, you rotate around the y-angle then D3DXVec3Cross() the other two angles

D3DXVec3TransformCoord(&_right, &_right, &mRotation);
D3DXVec3TransformCoord(&_look , &_look , &mRotation);
// ... normalize etc ...

Assuming you rotated 90 degrees on the y-axis, your _right vector should now be on the z-axis instead of the x-axis.

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!