Camera calculations


I have a game “engine” :stuck_out_tongue: that uses “camera” movement with gluLookAt and I’ve got it work perfectly with the X and Z plane, but I don’t know how to implant the Y axis, because I recently wanted an observer/ghost/spectator and I have to get it to work, I also need it if I want to be able to shoot…

As U all see in the code below I calculate the X and Z plane with the variable ang, but for the Y axis I use another variable that’s called angy, cause I cant use the same and there’s where all the problems begin… Or???

Here’s how I calculate the gluLookAt on the X and Z axis:

// px = point x
// pz = point x
// ex = eye x
// ez = eye z

// pmx = point movement x
// pmz = point movement z

pmx = pmx - (sin(pi*(ang/180))1.8);
pmz = pmz - (cos(pi
ex = ex - (sin(pi
ez = ez - (cos(pi
px = pmx + sin(deg * pi / 180) * -rad;
py = cos(degy * pi / 180) * -rad;
pz = pmz + cos(deg * pi / 180) * -rad;

gluLookAt(ex, ey, ez, px, py, pz, 0, 1, 0);

At last the question: How do I do to calculate the pmy (point movement y) point…?

Need help plz…

[This message has been edited by CyBBe (edited 09-12-2000).]

Please there must be someone here that have done this kinda thingie and got it to work, or???

I don’t know the answer, but that’s something I’m interested in learning, too, and at least my post will bump it up near the top again.

The only thing I might recommend you look into is source code and tutorials for using quaternions with OpenGL for camera movement. You can translate back and forth between a quaternion and a matrix.

I’ve solved it, my camera works perfectly, mail me if ya need code…

Have you tried Polar Coordinates?

I have done an example that provides a Quake type camera movement. You can find it at


I do not know what you exactly mean, but usually the problem with gluLookAt is, that the vector from the eye to position is parralel to the upvector.p.e:

gluLookAt 0,2,0,0,-1,0,0,1,0 is WRONG !!

In this example you must change the upvector to 1,0,0 or 0.001,1,0. For more questions mail