PDA

View Full Version : Rotating a third person camera



Psiborg
05-08-2006, 08:13 PM
I am making a third-person shooting game, and basically i want the camera to rotate around an object (sorta like they way a planet revolves around the sun). How would i be able to accomplish this?

AUGH why cant opengl make it as easy as drawing a sphere rotating around another sphere.

Thanks alot guys,
Psiborg

k_szczech
05-08-2006, 08:45 PM
It's not up to OpenGL to provide such functionality. OpenGL's main purpose is to let you use your GPU.

Basically you need to compute camera position, and then look at player from that position (gluLookAt does the second part).
Or you could just do something like this:

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glFrustum(....);
glTranslatef(0.0f, 0.0f, -distance);
glRotatef(cameraAngleX, 1, 0, 0);
glRotatef(cameraAngleY, 0, 1, 0);