• Advertisement

Archived

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

Camera Rotation~

This topic is 5499 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
Advertisement
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