PDA

View Full Version : Camera calculations



CyBBe
09-12-2000, 05:09 AM
Hi!

I have a game "engine" :P 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*(ang/180))*1.8);
ex = ex - (sin(pi*(ang/180))*1.8);
ez = ez - (cos(pi*(ang/180))*1.8);
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).]

CyBBe
09-13-2000, 04:39 AM
Please there must be someone here that have done this kinda thingie and got it to work, or???

09-15-2000, 01:10 PM
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.

CyBBe
09-17-2000, 08:31 AM
I've solved it, my camera works perfectly, mail me if ya need code...

Antonio
09-18-2000, 08:05 AM
Have you tried Polar Coordinates?

I have done an example that provides a Quake type camera movement. You can find it at http://www.fatech.com/tech/opengl/displaylists.glut2.zip

Antonio www.fatech.com/tech (http://www.fatech.com/tech)

edotorpedo
09-20-2000, 02:36 AM
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 fredo@studenten.net