PDA

View Full Version : Quadrics and Lighting



DragonMage3000
11-30-2002, 09:11 AM
I have put many quadrics into my code but after I put one of them at the end of the program, one part of my scene had the lighting somehow removed so that one of the 'rooms' was dark. This was at the beginning of my program. But then another part was ligheted correctly and that part was also done before the quadric was drawn. Most of the polygons are correct except for a few ones and at first I thought that OpenGL wasn't lighting it correctly because I was looking at the back of many but then I realized that the floor wasn't lighted correctly and the floor was a face-up polygon and another 'room' was lighted correctly and all the polygons were set up almost the same way. All but one of the quadrics was lighted correctly and the one that wasn't I think had the light hit it in a way that wouldn't light part of it. One of my biggest problems was that I made a polygon and I called glColor3f(0, 1, 0); and moved the polygon all around to make sure that the light should hit it correctly, I reapplied the light but the polygon, no matter where I put it and no matter what color I made it, kept being black. Is there something that I should be doing differently? Thanks in advance.

Music_Man
11-30-2002, 09:47 AM
This may be a silly question, but have u set the normal of the polygon? If u have set lights and you dont set the normal of the faces (gl.glNormal(x,y,z)) (Java) then I think that this may cause the polygon to just show up as black.
Alternatively, disable lighting (gl.glDisable(GL_LIGHTING)) (in Java) before you draw the polygon and then enable it again after. (gl.glEnable(GL_LIGHTING))

Hope this helps

Music_Man :-)

[This message has been edited by Music_Man (edited 11-30-2002).]

KenR7A
11-30-2002, 11:56 AM
yeah, in order for my lighting to work corectly I had to specify the normal for each polygon. check this sample out:




glBegin(GL_POLYGON);
glNormal3d( 1.0, 0.0, 0.0);
glVertex3d( 1.0, 1.0, 1.0);
glVertex3d( 1.0, -1.0, 1.0);
glVertex3d( 1.0, -1.0, -1.0);
glVertex3d( 1.0, 1.0, -1.0);
glEnd();