Could someone please please please tell me what in the world is wrong with this???
Thanks,
Jesse www.laeuchli.com/jesse/
void GLEngine::turn(float x)
{
float tempx=lookDir.x-eye.x;
float tempz=lookDir.z-eye.z;
float rad=x0.01745f;
float newx=tempx cos(rad) - tempzsin(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
December 27, 2000, 2:00pm
2
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
December 28, 2000, 3:25am
3
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
December 28, 2000, 6:51am
4
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
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=x0.01745f;
float newx=tempx cos(rad) - tempzsin(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
December 29, 2000, 2:08am
6
Still can’t see any glLoadIdentity() before gluLookAt().
sorry, I forgot to post them. I did put them in.