Hi,
gluLookAt will set up a transformation to take the camera from it defined location at the origin looking down -z axis to some point you specifiy. You’re “effectively” moving the camera, but you’re not, really. Hold this thought; next train of thought: if you’re in a train and look out the window and see the neighbouring train move, are YOU moving, or is the other train moving? OK, it might be important to know this if you’re on the train (because they TAKE you places, you know <nods wisely> ), but the visual effect is the same. Anyway, back to the previous train of thought… you’re not really moving the observer to the new place, but rather moving the WORLD around the observer. (so, the camera is sitting in a stationary train, and the neighbour train is the thing that’s moving, but its still giving the camera the impression of being moved around).
The trick behind the glLookAt, then, is to initialise the modelview matrix stack with the camera transform first… so the entire world is moved after its been set up to accomdoate moving the observer around the place. So, in answer to your first question: your gluLookAt isn’t moving the camera, anyway; and it will only affect the modelling coordinates, because that’s what it does.
In reference to yoru second questrion, then… it… really doesn’t matter (?!) how you set up the modelview matrix. gluLookAt() will post multiply the current matrix (whcih should, after all, be the modelview matrix (c.f. some posts on this topic)). but you can just as well do the same transform yourself with the corresponding glTranslate yadda yadda. an example!!
glLoadIdentity();
gluLookAt(0.0, 0.0, 10.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);
glTranslatef(1.0, 2.0, 3.0);
glRotatef(4.0, 5.0, 6.0, 7.0);
glutSolidTeapot(1.0);
is JUST the same as:
glPushMatrix();
glLoadIdentity();
glTranslatef(0.0, 0.0, -10.0); /* same thing as the lookat above, in this SIMPLE case /
glPushMatrix(); / just for the hell of it /
glTranslatef(1.0, 2.0, 3.0);
glPushMatrix(); / to emphasise a point =) */
glRotatef(4.0, 5.0, 6.0, 7.0);
glutSolidTeapot(1.0);
glPopMatrix();
glPopMatrix();
glPopMatrix();
this works because the gluLookAT is effectively moving the observer back, right? Well, we can get the same effect by explicility putting a translate to do that, anyway. (but, what transform do you want for some more complicated gluLookAt()?! that’s why the function exists, after all=)
in summary: gluLookAt() is a substitute for a set of transformations. but its just that: an easy alias for a set of translates/rotates, and not something magical.
- er, this isn’t a question =) but i hope this info helps!!
cheers,
John