PDA

View Full Version : glulookat not working :-(



laeuchli
12-27-2000, 01:38 PM
Could someone please please please tell me what in the world is wrong with this????
Thanks,
Jesse www.laeuchli.com/jesse/ (http://www.laeuchli.com/jesse/)

void GLEngine::turn(float x)
{
float tempx=lookDir.x-eye.x;
float tempz=lookDir.z-eye.z;
float rad=x*0.01745f;
float newx=tempx*cos(rad) - tempz*sin(rad);
float newz=tempz*cos(rad) + tempx*sin(rad);
lookDir.x=newx+eye.x;
lookDir.z=newz+eye.z;
gluLookAt(lookDir.x, lookDir.y, lookDir.z,
eye.x, eye.y, eye.z,
0.0, 1.0, 0.0);
}
void GLEngine::move(float x)
{
lookDir.z+=x;
gluLookAt(lookDir.x, lookDir.y, lookDir.z,
eye.x, eye.y, eye.z,
0.0, 1.0, 0.0);
}

Igor
12-27-2000, 03:00 PM
I think the first 3 parameters are the coords of the eye, the next 3 ones the reference point and than there comes the up vector...

Bob
12-28-2000, 04:25 AM
You don't load the identity matrix before each call to gluLookAt. gluLookAt doesn't load the matrix stack with the generated matrix, it multiplies it, and therefore you need to reset the matrix each time you generate a new look-at matrix.

rIO
12-28-2000, 07:51 AM
gluLookAt( eye.x, eye.y,eye.z, target.x,target.y,target.z, vect.x,vect.y,vect.z);

that's the way lookat works....

C U

rIO

laeuchli
12-28-2000, 08:35 AM
so my code should look like this?
void GLEngine::turn(float x)
{
float tempx=lookDir.x-eye.x;
float tempz=lookDir.z-eye.z;
float rad=x*0.01745f;
float newx=tempx*cos(rad) - tempz*sin(rad);
float newz=tempz*cos(rad) + tempx*sin(rad);
lookDir.x=newx+eye.x;
lookDir.z=newz+eye.z;
gluLookAt(eye.x, eye.y, eye.z,
lookDir.x, lookDir.y, lookDir.z,
0.0, 1.0, 0.0);
}
void GLEngine::move(float x)
{
lookDir.z+=x;
gluLookAt(eye.x, eye.y, eye.z,
lookDir.x, lookDir.y, lookDir.z,
0.0, 1.0, 0.0);
}
I tried that, but it still didn't work right....

Bob
12-29-2000, 03:08 AM
Still can't see any glLoadIdentity() before gluLookAt().

laeuchli
12-29-2000, 08:52 AM
sorry, I forgot to post them. I did put them in.