In this case, you do not care about angles.

What you want to do is basically why gluLookAt was created for, but suposing you want to do it by hand :

Lets call D the direction (capitals are for vectors) :

X,Y,Z are the camera’s axis.

Z = - D;

normilize(Z); // you got Z

Y = (0,1,0); // if you want a vertical Y axis for the camera (in case of Z is also (0,1,0), you got a problem.

s = Y.Z;

Y -= sZ;

normilize(Y); // you got Y

X = Y*Z; // (cross product)

you are done.

try to follow these steps geometrically, its simple.

Then of course add the position of you camera (“transposed”, ie not the camera’s position in respect to the center of the scene, but the position of the center of the scene in respect to the camera), and you got your camera matrices to push at first onto your model view matrix :

GLfloat cam_pos_transp = {

Xx, Yx, Zx, 0,

Xy, Yy, Zy, 0,

Xz, Yz, Zz, 0,

Tx, Ty, Tz, 1

};

where Xx is the x coordinate of the X axis, etc, and T is the position of center in respect to camera’s position, that is, if you have the position of camera in respect to center (let’s call it t) :

[Tx,Ty,Tz] = - [ [Xx,Yx,Zx] [Xy,Yy,Zy] [Xz,Yz,Zz] ] * [tx,ty,tz]

(in standard matricial notations).

got it ?

(sorry but im not used to do maths in english - Im preparing an article about this kind of calculus but in french)

[This message has been edited by rixed (edited 12-13-2001).]