Jump to content
  • Advertisement
Sign in to follow this  
MisterHeadache

Rotate model to align to third person camera vectors

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

I have a space flight simulator that I'm working on where the camera is always orbiting at a fixed radius about (0,0,0), where the model of the ship is located. I've got my third person camera working satisfactorily, but now my problem is I need to rotate the 3D model of the ship to match the view and orientation of the camera. From the viewmatrix, I can get the look, right, and up vectors for the camera, but how can I translate that information into a 3D rotation for the ship model so that the Z axis of the ship is aligned with the look vector and the X axis of the ship is aligned with the camera right vector? It seems that if I had roll, pitch, and yaw angles for the camera then I could just build a rotation Quaternion for the ship and apply it, but converting camera look, right, and up vectors into roll, pitch, and yaw angles is not obvious nor is it a standard matrix or Quaternion built-in calculation in DirectX. How should I go about rotating my model? Thanks!

Share this post


Link to post
Share on other sites
Advertisement
Ah, by trial & error I figured it out!

All that was necessary was to transform world space by the INVERSE of the view matrix and then draw the ship mesh. No need for messy Euler angles or tangled vector multiplication.

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!