Jump to content
  • Advertisement
Sign in to follow this  
n0ob

Which up vector to use for D3DXMatrixLookAtLH?

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

When I call D3DXMatrixLookAtLH, should I pass in the camera's up vector transformed to world coordinates, or should I pass in the world's up vector? They both seem to and should work because it's a cross product operation between the up vector and z vector, but, are there any possible bugs that could arise from just using the world's up vector (and saving a transformation)? Thanks for your time!

Share this post


Link to post
Share on other sites
Advertisement
You should use the camera's up vector in world space. If you use the world's up vector, you will have problems when the camera is looking in that direction.

Share this post


Link to post
Share on other sites
Quote:
Original post by Aldenar
You should use the camera's up vector in world space. If you use the world's up vector, you will have problems when the camera is looking in that direction.


That is going to cause problems if you want to keep the camera upright. Imagine that the camera is pointing up at something at about a 45 degree angle. Now, you want it to point to something directly to the side of it. If you use it's previous up vector, then it is going to be tilted over to its side.

The solution is to use the world's "up" vector. That will keep the camera always upright. The restriction is that you cannot allow the camera to look straight up or straight down.

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!