Archived

This topic is now archived and is closed to further replies.

apatequil

Frustum clipping problem

Recommended Posts

Hey everyone. I'm writing a 3d maze generator where the user can walk through the maze in first person. Everything is working properly, except the the "cell" or wall in front of the user isn't being included in the clipping plain. I'm using glFrustum for this. Here's my reshape and draw function: Reshape:
  
void myReshape(int w, int h)  
{  
    glViewport(0, 0, w, h);  
    glMatrixMode(GL_PROJECTION);  
    glLoadIdentity(); 
	if(firstPerson == 1)
	{
		if(w<=h)
			glFrustum(-1.0, 1.0, -1.0*(GLfloat)h/(GLfloat)w, 1.0*(GLfloat)h/(GLfloat)w, 0.01, 20.0);
		else
			glFrustum(-1.0, 1.0, -1.0*(GLfloat)w/(GLfloat)h, 1.0*(GLfloat)w/(GLfloat)h, 0.01, 20.0);
	}
	else if(firstPerson == 0)
	{
		if(w<=h)
			glFrustum(-2.0, 2.0, -2.0*(GLfloat)h/(GLfloat)w, 2.0*(GLfloat)h/(GLfloat)w, 2.0, 20.0);
		else
			glFrustum(-2.0, 2.0, -2.0*(GLfloat)w/(GLfloat)h, 2.0*(GLfloat)w/(GLfloat)h, 2.0, 20.0);
	}
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();
}
   
Display
  
void display(void)
{
	//clear the background

	glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
	glLoadIdentity();
	//translate so the maze is in front of the camera

	glTranslatef(0.0, 0.0, -1.0);
	if(firstPerson == 1)
	{
		//if the eye is looking north

		if(pV[9] == 0)
			gluLookAt(camPos[0], camPos[1], camPos[2], camPos[0], camPos[1]+0.5, camPos[2], 0.0, 0.0, 1.0);
		//if the eye is looking east

		else if(pV[9] == 1)
			gluLookAt(camPos[0], camPos[1], camPos[2], camPos[0]+0.5, camPos[1], camPos[2], 0.0, 0.0, 1.0);
		//if the eye is looking south

		else if(pV[9] == 2)
			gluLookAt(camPos[0], camPos[1], camPos[2], camPos[0], camPos[1]-0.5, camPos[2], 0.0, 0.0, 1.0);
		//if the eye is looking west

		else
			gluLookAt(camPos[0], camPos[1], camPos[2], camPos[0]-0.5, camPos[1], camPos[2], 0.0, 0.0, 1.0);
	}
	else
		gluLookAt(currentPos[0], currentPos[1], zoomAmt, currentPos[0], currentPos[1], currentPos[2], 0.0, 1.0, 0.0); 
	//display the grid

	drawMaze();
	//display the cursor

	createCursor();
	//flush the buffer

	glutSwapBuffers();
}//end display

   
Any help with this would be most appreciated. Thanks in advance. oh yeah, i'm using vc++ 6.0....if that matters "Flies are born the size they are" -- Undisclosed Person [edited by - apatequil on March 2, 2003 12:58:56 AM]

Share this post


Link to post
Share on other sites