Jump to content
  • Advertisement
Sign in to follow this  
Gamer5

DX11 DirectX 11 Orbit Camera

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

Advertisement

I assume by "camera" you mean data which will be used to set the view matrix for rendering. Is that correct?

 

If so, can you describe in a bit more detail how you want the camera to behave? I.e., what do you mean by "orbit?" Orbit the world origin? Orbit an object?

 

Commonly, one defines a camera position, up and look-at vectors. The view matrix is then constructed with (something equivalent to) XMMatrixLookAtLH(...).

Share this post


Link to post
Share on other sites

I assume by "camera" you mean data which will be used to set the view matrix for rendering. Is that correct?

 

If so, can you describe in a bit more detail how you want the camera to behave? I.e., what do you mean by "orbit?" Orbit the world origin? Orbit an object?

 

Commonly, one defines a camera position, up and look-at vectors. The view matrix is then constructed with (something equivalent to) XMMatrixLookAtLH(...).

Yeah like I'm currently rendering a cube but I want the camera to rotate around the cube.

Share this post


Link to post
Share on other sites

One approach would be to calculate the camera's position from the object's position, given a changing value.

 

E.g., assuming Y is the up-axis, calculate a vector based on time - vector.x = sin(time); vector.z = cos(time); let vector.y remain the same (however "high" above the object you want it to be.)

 

The camera's position = object position + some_scale_distance*vector. Keep the camera's up vector (0,1,0) and look-at vector (the object's position) the same. Create the view matrix as mentioned above.

Share this post


Link to post
Share on other sites

You can use your current view matrix functions, and just modify their input to an appropriate new model.  For example, if you want the camera view to rotate around an object, your look at point would be the center of the object.   Then the location for your 'look from' point can be calculated with spherical coordinates each frame.  This lets you easily increment the values of the spherical coordinates, which then get translated into a position.

 

Like Buckeye said, there are lots of ways to do it.  If you provide a little more detail about what you are currently using for your view matrix generation, we can probably give you a more specific answer.

Share this post


Link to post
Share on other sites

You can use your current view matrix functions, and just modify their input to an appropriate new model. For example, if you want the camera view to rotate around an object, your look at point would be the center of the object. Then the location for your 'look from' point can be calculated with spherical coordinates each frame. This lets you easily increment the values of the spherical coordinates, which then get translated into a position.

Like Buckeye said, there are lots of ways to do it. If you provide a little more detail about what you are currently using for your view matrix generation, we can probably give you a more specific answer.


Already figured it out. Lol usin both of your advice.

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!