More black surfaces

Hello,

So I’ve expanded my program a little. The plane has 3 objects sitting on it and I allow the user to select from various viewing angles such as top, bottom, left, right, front, back. The usual stuff. All viewing angle are represented by quaternions. All viewing angles work except for the bottom view. In the bottom view the plane appears black. The quaternion for the bottom view is defined as a 180 degree rotation around the x axis. The call to set the material for the plane is glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, white) where white is defined as (1.0,1.0,1.0,1.0). The viewing volume and model translation are the same as used for the top view. The near and far values for glOrtho() are -1 and 4, and the position is set by glTranslatef(0,0,-2). Again, why would bottom surface be black? If I use a perspective view and rotate the same model around, the bottom surface is white, so what gives.

I’m not sure you’ve setup everything as required.

// If you have any scaling in the matrix:
glEnable(GL_NORMALIZE);
// If you want the back faces to be lit:
glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, 1);
// Default light 0 is directional light down the negative z axis, (all other lights must be specified):
glEnable(GL_LIGHT0)
glEnable(GL_LIGHTING);
// Set white material for front and back:
glMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, white);
// A simple plane facing the viewer is
glNormal3f(0.0f, 0.0f, 1.0f); // Right handed coordinate system pointing directly to the viewer.
glBegin(GL_QUADS); // counter-clockwise is default front
glVertex3f(-0.5f, -0.5f, 0.0f);
glVertex3f( 0.5f, -0.5f, 0.0f);
glVertex3f( 0.5f, 0.5f, 0.0f);
glVertex3f(-0.5f, 0.5f, 0.0f);
glEnd();

Whatever you’re matrix and projection is (except if it turns things inside out or moves the light) should render the back face white now.

Be sure you understand when to send a light’s position. The light stays fixed if you do it outside your transformation and moves with the object if it’s specified within your object transformation’s scope. If you did that latter, the light moved with your rotation and of course the back is black then.
It’s actually a good idea to set front and back faces to different materials while debugging, like blue for front and red for back.

[This message has been edited by Relic (edited 09-30-2003).]

Originally posted by Relic:
[b]I’m not sure you’ve setup everything as required.

[quote]

// If you have any scaling in the matrix:
glEnable(GL_NORMALIZE);
// If you want the back faces to be lit:
glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, 1);
// Default light 0 is directional light down the negative z axis, (all other lights must be specified):
glEnable(GL_LIGHT0)
glEnable(GL_LIGHTING);
// Set white material for front and back:
glMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, white);
// A simple plane facing the viewer is
glNormal3f(0.0f, 0.0f, 1.0f); // Right handed coordinate system pointing directly to the viewer.
glBegin(GL_QUADS); // counter-clockwise is default front
glVertex3f(-0.5f, -0.5f, 0.0f);
glVertex3f( 0.5f, -0.5f, 0.0f);
glVertex3f( 0.5f, 0.5f, 0.0f);
glVertex3f(-0.5f, 0.5f, 0.0f);
glEnd();

Whatever you’re matrix and projection is (except if it turns things inside out or moves the light) should render the back face white now.

Be sure you understand when to send a light’s position. The light stays fixed if you do it outside your transformation and moves with the object if it’s specified within your object transformation’s scope. If you did that latter, the light moved with your rotation and of course the back is black then.
It’s actually a good idea to set front and back faces to different materials while debugging, like blue for front and red for back.

[This message has been edited by Relic (edited 09-30-2003).][/b][/QUOTE]

Thanks. At first I thought it was rotating the light around like you’ve stated, but I do all the context setup before any model matrix changes so I didn’t think it was that. My code does everything your code was doing except for the glEnable(GL_NORMALIZE) and glLightModeli() calls. Turning on GL_NORMALIZE didn’t change anything, but adding the glLightModeli() call fixed it.