DirectX 11 Orbit Camera

Started by
4 comments, last by Gamer5 9 years, 9 months ago

Does anyone know how to create an orbit camera?? Using dx11.

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(...).

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

You don't forget how to play when you grow old; you grow old when you forget how to play.

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.

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.

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

You don't forget how to play when you grow old; you grow old when you forget how to play.

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.

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.

This topic is closed to new replies.

Advertisement