# DX11 DirectX 11 Orbit Camera

This topic is 1664 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

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

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

##### 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 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 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 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.

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 9
• 31
• 16
• 11
• 10
• ### Forum Statistics

• Total Topics
634121
• Total Posts
3015613
×