Archived

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

Alan Kemp

3rd Person Camera Math

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 this post


Link to post
Share on other sites
Guest Anonymous Poster
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.

Share this post


Link to post
Share on other sites