Representing a grid and rotating around it

Hi,

I’ve implemented an A* pathfinder in C++ and would like to display the grid (which can be 3d) and the route it’s found in OpenGL. I’ve created an application using GLUT which sets the coordinate system to <-1, -1, gridWidth+1, gridHeight+1, -1, gridDepth+1> and creates a number of cubes which represent obstacles and cubes which represent nodes on the grid that contribute to the route found.

I’ve come somewhat unstuck however when it comes to implementing a way of rotating the scene. I’ve read and tried to follow a number of tutorials but feel as if I’ve missed something somewhat significant. For example, when I follow them I can’t seem to find the right values to start off with for gluLookAt.

Do the parameters of of gluLookAt work like this:
eyeX, eyeY, eyeZ: The location of the camera? Where is this set to by default? I guess that this, along with the angle specified in gluPerspective, determines what ‘quantity’ of the grid we can see?
centerX, centerY, centerZ: A point in the coordinate system where the camera focuses? So I’d want this to intially be <gridWidth/2, gridHeight/2, 0> initially?
upX, upY, upZ This is the same as ‘yaw’?

The relevant code I have currently looks like this:


void display(void){
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

//Make cubes for every obstacle in the 3d world.
	for(int y=m.height()-1; y>=0; y--){
		for(int x=0; x<m.width(); x++){
			for(int z=0; z<m.depth(); z++){
				if(!m.at(x, y, z)->obstacle) continue;
				glPushMatrix();
				glTranslatef(x+0.5, y+0.5, z+0.5); //Move this cube to its coordinates in the map (and align to the window).
				glutSolidCube(1);
				glPopMatrix();
			}
		}
	}

	for(int n=0; n<route.size(); n++){
		glPushMatrix();
		glTranslatef(route.at(n)->x+0.5, route.at(n)->y+0.5, route.at(n)->z+0.5);
		glutSolidCube(0.5);
		glPopMatrix();
	}

	glutSwapBuffers();
}
void reshape(int width, int height){
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	glViewport(0, 0, width, height);
    
	glOrtho(-1, w+1, -1, h+1,-1,d+1); // Set the coordinate system's units in scale with our own map.
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();
}

http://www.lighthouse3d.com/opengl/glut/index.php?6 was a good tutorial but I think I need to change the initial values it sets because of my change in coordinate system? Preemptive thanks to anyone who can help me.

I solved my problems by inverting transformations from the camera’s perspective (hopefully that’s the correct terminology) though I’d still like an explanation of gluLookAt possible use in this context as I’m sure it would have been easier!