View Full Version : camera

07-15-2000, 01:24 PM
does anybody know some good docs about cameras ? (or does anybody have some code i could rip ? http://www.opengl.org/discussion_boards/ubb/smile.gif)

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.


07-15-2000, 01:58 PM
Have you tried gluLookAt?... Does all you want but the roll angle is specified as an up vector..

07-15-2000, 08:16 PM
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] );

07-16-2000, 01:48 AM
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)

07-16-2000, 06:47 AM
Sorry I should have explained the code but as in a rush http://www.opengl.org/discussion_boards/ubb/smile.gif

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.

Glenn Upton
07-18-2000, 10:01 PM
Hi Ann
OpenGl Superbible has the camera routine that you want (I think!).

07-19-2000, 12:07 AM
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?


07-28-2000, 07:27 PM
Hehe http://www.opengl.org/discussion_boards/ubb/smile.gif. 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).]