#### Archived

This topic is now archived and is closed to further replies.

# 3rd Person Camera Math

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

## Recommended Posts

Hi, I am trying to get a sort of third-person camera working. The exact effect I am try to achive is like the camera in Neverwinter Nights, or Warcraft 3. Basically my world is aligned to the x/z axis (and is pretty much flat). I have a point on that axis which I want to look at. I also have a distance value (the distance back I want the camera to be from the target coordinate), a pitch angle (the angle, from verticle (pointing down the y-axis) to flat (looking along the x/z plane), and a rotation value (the rotation around the y-axis). The problem I am having is forming the required view matrix in direct3d. To calculate the cameras location I belive I can just: - Translate up the y-axis by the distance. - Rotate around the x-axis by the pitch angle. - Rotate around the y-axis by the rotation angle. - Translate by the objects offset from the origin. This gives me the camera position, and I have the look at point (the object on the x/z axis). To use the D3DXMatrixLookAtLH function I still need an up vector, and this is where I am stuck. How do I calulate the up vector from the information I have available? And have I made any assumption errors in my basic methodology? Thanks for your time, Alan

##### Share on other sites
if you never look striaght down, just use the y-axis vector.
cross it with your lookat to get the true left right vector.
cross this new vector with the lookat to get you true up vector.
make sure to do your crossproducts in the correct order..right or left hand rules apply..just be consistent.

1. 1
Rutin
27
2. 2
3. 3
4. 4
5. 5

• 11
• 9
• 9
• 9
• 14
• ### Forum Statistics

• Total Topics
633313
• Total Posts
3011319
• ### Who's Online (See full list)

There are no registered users currently online

×