PDA

View Full Version : camera rotation



dan-leech
02-25-2001, 12:34 PM
Could you help me? I got a camera and I want to rotate it around a point(model) with radius, which I want. Help me, please!

And one more do you know where I can find any car physics tutorial or demos!

Thanx.

RandyU
02-25-2001, 07:53 PM
glTranslatef(mx,my,mz);//translate to the center of model
glRotatef(a,1,0,0);//rotate camera
glTranslatef(0,0,r);//translate on a radius in direction, orthogonal to rotation axis

Hope this works.
Randy, http://www.geocities.com/udodenko

Cardinal
02-25-2001, 10:09 PM
I am not sure whether the code above works or not, but it should be as simple as translate radius out from the origin, rotate by a clock variable, then translate by the central position of the model, leaving the camera radius away, rotated around the model.

Be careful to implement your camera correctly, by making inverse motion changes to the modelview matrix to give the impression a camera. You may want to use an external matrix class to model the motion, then pass it into OpenGL using glLoadMatrix(), this will be much faster than using opengl as a mathlib, and easier to work with.

If you can get your hands on a high school physics book, you should be able to get the kinematics out of it.