Jump to content
  • Advertisement
Sign in to follow this  
dxdotnet1

Rotate the camera around an Vector, how?

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

how can i rotate the camera around an vector? i have an FPS camera and i want to add rotation not just by yaw and pitch but arround a certain object, for example i want to rotate around my Lookat vector how? i just have this formula but it only rotates the x and z position D3DXVECTOR3 vVector = m_vPos - vView; m_vPos.z = (float)(vView.z + sin(speed)*vVector.x + cos(speed)*vVector.z); m_vPos.x = (float)(vView.x + cos(speed)*vVector.x - sin(speed)*vVector.z); m_vForward = vView - m_vPos; D3DXVec3Normalize(&m_vForward,&m_vForward); pls help

Share this post


Link to post
Share on other sites
Advertisement
Hey,

It looks like you're on the right track, though I think you may be over complicating things.

For example, to get a bunch of points in a circle (around 0,0,0) over time you would have something like this:

float p1 = sin(cur_time) * offset;
float p2 = cos(cur_time) * offset;

// Note: offset is just allows you to change how far the camera is out from your target

Now you can really use p1 and p2 for anything you want: x and y, x and z, y and x, etc...

Then you just keep setting p1 and p2 as your camera's location, and set the look at vector to 0,0,0.

If you want to look somewhere else, you just add that position to p1 and p2.

As I said before that is basically what you are doing, you just need to recognize that you can use those values for Y as well.

Matt Hughson

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!