Jump to content
  • Advertisement


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


rotating a model about the cameras location in 3D space

This topic is 5990 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'm having a problem rotating a model around a point which represents the position of the camera. I have a model with vertices defined in a local coordinate space and a camera represented by 3 euler angles and a location in 3d space. I need to rotate all points in the model around the cameras position so that they are always "in front" of the camera. I think this is similar to the technique of having the gun follow the mouse/view in a First Person Shooter type game. Any help would be appreciated. [edited by - juicemaster23 on June 24, 2002 10:52:52 AM]

Share this post

Link to post
Share on other sites
Two ways to do this: Either exactly what you described or something to the same effect

1. Your thing
-substract the camera position C from the object position O, and call that dO
-rotate dO with the same parameters like the view matrix
-add C to dO

this should do

2. If you only want to have the object in front of the camera, no matter what you could also do the following
- set the view matrix to identity
- place the object on the base coordinate system, (x -> right, y->up, z -> away from the cam)

note that you lighting context that way if you don''t move the lights too

You might want to do this either first or last thing in the scene because then you only need to set the view matrix once and not reset it. I propose first, because I assume whatever you render hides part of the screen. So objects hidden by your HUD, gun, whatever don''t have to be shaded

If the thingy is not animated you might even want to render it only once, store the image and copy it onto your surface first (remember the depth buffer!) or last (overhead!).
Swinging right and left can also be done, but no rotation and scaling probably looks crappy

I may be getting older, but I refuse to grow up

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!