Jump to content
  • Advertisement


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


Camera Rotation~

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

Hi, does anyone know how to rotate a camera around a specific object? I tried to use the matrix transformation, but the result was not what I wanted. Any algorithm or? Thank you~

Share this post

Link to post
Share on other sites
if you apply a rotation matrix to the camera matrix it will always rotate around the world origin. so it should be enough to translate the camera along the negative position of the object, rotate, and then translate back.
another way would be storing two angles (relative to the object), set cam to identity, rotate around them, translate backwards (in cams local space) and translate along objects position (in world space).
or of course your cam matrix is always relativ to the object. in that case, set it to identity when its attachted to the object, translate it back as much as it should be away from the object and apply all rotations as usual. just dont forget to create the final matrix by multiplying the cams matrix with the objects matrix. that way all transformations to the object will automatically be applied to the cam.

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!