PDA

View Full Version : Changing gluLookAt () several times-- what happens?



03-28-2003, 04:15 PM
Imagine someone running from location to location in a scene, with a camera in hand as they create cubes, triangles, etc.

Something like this:

/*****************/
glLoadIdentity();
gluLookAt(/*some location*/);

//glVertex calls here

glLoadIdentity();
gluLookAt(/*another location*/);

//more glVertex calls go here

/*******etc****************/


When I do this, what happens onscreen?

Does the cube I place, say, three units in front of me at the first camera position wind up "interfering" with a another cube I may put three units in front of me at the second camera position?

In other words, is the first cube immediately transformed and projected into screen coordinates when it's created, and would these screen coordinates overlap with the second cube's?

I understand things fairly well when gluLookAt(...) is called at the start of a modeling scene, but when it's called multiple times, after primitives have been created, I get a little confused.

shinpaughp
03-28-2003, 05:06 PM
Yes, they both show up as if they were in the same place to begin with.

nexusone
03-28-2003, 06:23 PM
I think it best to think of your world of object like a map and you move your camera around that map.

// Camera

gluLookAt ( camera_pos )


// Draw cubes

// Draw first cube 3 units out from camera
Draw_cube_1();

// Draw second cube 6 units out and units over

Draw_cube_2();

By using variables you guide your camera through your world and around each object.

HalcyonBlaze
03-28-2003, 07:02 PM
Also, if you are trying to move your objects independently from each other, gluLookAt(...) is not what you want.