Jump to content
  • Advertisement
Sign in to follow this  
tinu

camera

This topic is 4196 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, To orbit around an object in y direction, how should I modify my up vector. [Edited by - tinu on March 26, 2007 1:28:53 AM]

Share this post


Link to post
Share on other sites
Advertisement
You don't. If you use a look-at matrix, set the look-at vector to your object, and move your camera in a circle around the object.

Share this post


Link to post
Share on other sites
You google for some basic matrix mathematics. Are you sure you want to rotate the camera around the object, and not rotate the object on the spot?

Share this post


Link to post
Share on other sites
D3DXMatrixLookAtLH() will do the job then, and you can just have the camera position move in a circle as:
D3DXVECTOR3 vPos(sin(angle), 0.0f, cos(angle)); where angle is the angle you want to use, which will be incrementing each frame.

Share this post


Link to post
Share on other sites
Given an angle and a radius, you can use some simple trig to determine the X and Y position.


Camera
+
/|
/ |
radius / |
/ |
/ | Y
/ |
/ _|
/ theta | |
+---------------+
Object X


SOHCAHTOA

X = cos(theta) * radius
Y = sin(theta) * radius

You'll need to modify the axes to rotate on the Y axis (for simplicity this is an example of rotating on the Z axis).

EDIT: Yeah, what Evil Steve said.

Share this post


Link to post
Share on other sites
Yes.
This is true in orbiting in x-direction
But to orbit in y direction what should i do?

z = Radius * cos( Angle );
y = Radius * sin( Angle );

Is this correct?

If I do this,At particular angles my object disappears.

To avoid this, should I modify my up vector also?



Share this post


Link to post
Share on other sites
Quote:
Original post by tinu
Yes.
This is true in orbiting in x-direction
But to orbit in y direction what should i do?

z = Radius * cos( Angle );
y = Radius * sin( Angle );

Is this correct?

If I do this,At particular angles my object disappears.

To avoid this, should I modify my up vector also?
To orbit around the Y axis, you modify X and Z. You only change the up vector if the "up" direction has changed - which is if you rotate the camera around either X (Pitch) or Z (roll).

Share this post


Link to post
Share on other sites
To rotate the camera around X axis (pitch as mentioned)
how should i modify my up vector

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!