Jump to content
  • Advertisement

Archived

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

InsanE

Camera movement

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

Getting lots of trouble with the camera movement. I have a model that can walk around in my little engine. Now the camera should follow the player like in e.g. Tomb Raider. I have the orientation of the model and it''s position. But the transformation for the camera is far from being correct. Is there any tutorial out there or can anybody give me an advice?

Share this post


Link to post
Share on other sites
Advertisement
I''m a weenie when it comes to doing the camera. Most people suggest using quarternions, but I use normal rotation matrices AND manage to avoid the gimbal lock.

Basically, a camera consists of three pts: the camera, an up vector, and the look at vector. Rotating the camera invovles rotating these points locally. So to rotate the camera to the right, you simply rotate the look at vector around the up vector. To roll the camera, you simple rotate the up vector around the look at vector. Just make sure to rotate the correct vectors when rotating.

So to have the camera track the player, simple link the look at vector to the player. WHenever the player moves, move the lookat, up, and camera vectors with the player.

To orbit the camera around the player, simply translate the up vector to the look at position (remmeber the look at position is on the player) then rotate the camera around the up vector.

DX has a function that creates a view matrix from an up, lookat, and camera vectors. . .

Hope that makes sense.

Share this post


Link to post
Share on other sites

  • 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!