does anybody know some good docs about cameras ? (or does anybody have some code i could rip ? )

i’m searching for some camera model where you have a location (where the eye is), a point were the camera looks at and a roll angle.


Have you tried gluLookAt?.. Does all you want but the roll angle is specified as an up vector…

Using a roll angle is much better gluLookat sucks!!! Use something like this:

void cam_glview( camera_t* cam ) {
float M[16];
float a,b,c;

memset( M, 0, 16*sizeof(float) );

a = cam->vn[0];
b = cam->vn[1];
c = cam->vn[2];

M[0] = -c;
M[8] = a;
M[1] = -a*b;
M[5] = a*a+c*c;
M[9] = -b*c;
M[2] = -a;
M[6] = -b;
M[10] = -c;
M[15] = 1.0f;

glRotatef( cam->angle, 0.0f,0.0f,1.0f );
glTranslatef(-cam->pos[0],-cam->pos[1],-cam->pos[2] );


well, gluLookAt isn’t that bad…but how can i rotate the camera ? you know, for example if you’re writing a flight simulator, and you want to turn left, the camera should rotate about it’s own Y axis (and not about the world’s Y axis)

Sorry I should have explained the code but as in a rush

The vector cam->vn[] is the normal in the viewing direction so this specifies where the camera is pointing like in gluLookat.

cam->angle is the angle the camera is rotated about its own z-axis: ie the axis coming straight out of the lens. (you said y-axis but I think you meant z). If you want to rotate the camera about its y-axis just change the glrotate*() call but this wouldn’t make much sense.

Hi Ann
OpenGl Superbible has the camera routine that you want (I think!).

What’s your problem with gluLookAt? it’s a function to calculate the transform between two completely-arbitary points. <shakes head in confusion> how can you say it sucks?


Hehe . I just find a roll angle more intuitive. Plus, since the up vector should always form a right angle with the view vector so why specify redundant information and allow the chance of an error.

[This message has been edited by foobar (edited 07-28-2000).]