Can see inside box faces, not outside

Started by
11 comments, last by chbfiv 20 years, 6 months ago
quote:Original post by chbfiv
Do you mean when I fill them into a face struct, or when I render them? And Why? Clockwise? I really dont understand that, this is a 3D space, that could be any direction in my eyes.


The order in which they get sent to GL is the important one. This may or may not be the same as your face struct.

The vertex winding order defines which is the front face of your polys. If you look at the front of your poly, the vertices will go either clockwise or anti-clockwise. You need to make sure that all of your faces are defined correctly to face outwards.

The order you choose to represent the front face doesn''t matter, as long as you''re consistant. You then set that with:
glFrontFace(GL_CW);
glFrontFace(GL_CCW); // Counter/Anti clockwise

Then, assuming thats all correct you typically do
glEnable(GL_CULL_FACE);
glCullFace(GL_BACK); // Remove back facing (invisible) polys

The other two options for glCullFace are rarely used so don''t worry about them. Also you may need to remember that using a mirror transformation (like a negative scale for a mirror) will mean you need to flip the front face from one to the other.
Advertisement
Oh, and looking from your arrays and such (ugh, bad variable names and too much indirection ) your first two faces are defined anti-clockwise (assuming a right handed coord system, I think it flips if you''re using a left handed).

Right handed system:
   y   |   |   0---x  / /z 


I didn''t check any further though, so I don''t know if they''re consistant.
ok, this is what I did now.

I turned on CW

and I filled in each triangle in a CW manner.
then I left them in the CW manner and turned on CCW, with the same result. On top of that, after I turned on glEnable(GL_CULL_FACE) and glCullFace(GL_BACK) and I still see both sides of each triangle.


Edit:

I even cut and pasted a Nehe demo code that creates a pyramid. Still the same problem, it cant be my vertex order, or my draw order because Its from a nehe! gerrr.

not that you need to see the pyramid code, maybe someone will get it.
	glBegin(GL_TRIANGLES);					// Start Drawing The Pyramid		glColor3f(15.0f,0.0f,0.0f);			// Red		glVertex3f( 0.0f, 15.0f, 0.0f);			// Top Of Triangle (Front)		glColor3f(0.0f,15.0f,0.0f);			// Green		glVertex3f(-15.0f,-15.0f, 15.0f);			// Left Of Triangle (Front)		glColor3f(0.0f,0.0f,15.0f);			// Blue		glVertex3f( 15.0f,-15.0f, 15.0f);			// Right Of Triangle (Front)		glColor3f(15.0f,0.0f,0.0f);			// Red		glVertex3f( 0.0f, 15.0f, 0.0f);			// Top Of Triangle (Right)		glColor3f(0.0f,0.0f,15.0f);			// Blue		glVertex3f( 15.0f,-15.0f, 15.0f);			// Left Of Triangle (Right)		glColor3f(0.0f,15.0f,0.0f);			// Green		glVertex3f( 15.0f,-15.0f, -15.0f);			// Right Of Triangle (Right)		glColor3f(15.0f,0.0f,0.0f);			// Red		glVertex3f( 0.0f, 15.0f, 0.0f);			// Top Of Triangle (Back)		glColor3f(0.0f,15.0f,0.0f);			// Green		glVertex3f( 15.0f,-15.0f, -15.0f);			// Left Of Triangle (Back)		glColor3f(0.0f,0.0f,15.0f);			// Blue		glVertex3f(-15.0f,-15.0f, -15.0f);			// Right Of Triangle (Back)		glColor3f(15.0f,0.0f,0.0f);			// Red		glVertex3f( 0.0f, 15.0f, 0.0f);			// Top Of Triangle (Left)		glColor3f(0.0f,0.0f,15.0f);			// Blue		glVertex3f(-15.0f,-15.0f,-15.0f);			// Left Of Triangle (Left)		glColor3f(0.0f,15.0f,0.0f);			// Green		glVertex3f(-15.0f,-15.0f, 15.0f);			// Right Of Triangle (Left)	glEnd();						// Done Drawing The Pyramid 


[edited by - chbfiv on October 7, 2003 8:46:03 PM]
-BourkeIV

This topic is closed to new replies.

Advertisement