1. ## Normal Vector problem

Hello, I want to make a pyramid and light it properly. I use this code for the pyramid:
void drawUnitPyramid()
{
glBegin(GL_POLYGON);
glNormal3f(0,0,-1);
glVertex3f(-0.5, -0.5,0);
glVertex3f(-0.5, 0.5,0);
glVertex3f( 0.5, 0.5,0);
glVertex3f( 0.5, -0.5,0);
glEnd();

glBegin(GL_POLYGON);
glNormal3f(2,0,-1);
glVertex3f(-0.5, -0.5,0);
glVertex3f(-0.5, 0.5,0);
glVertex3f( 0, 0, 1);
glEnd();

glBegin(GL_POLYGON);
glNormal3f(-2, 0, -1);
glVertex3f( 0.5, 0.5,0);
glVertex3f( 0.5, -0.5,0);
glVertex3f( 0, 0, 1);
glEnd();

glBegin(GL_POLYGON);
glNormal3f(0,-2,-1);
glVertex3f(-0.5, 0.5,0);
glVertex3f( 0.5, 0.5,0);
glVertex3f( 0, 0, 1);
glEnd();

glBegin(GL_POLYGON);
glNormal3f(0,2,-1);
glVertex3f( 0.5, -0.5,0);
glVertex3f( -0.5, -0.5,0);
glVertex3f( 0, 0, 1);
glEnd();
}
I use glEnable( GL_LIGHTING );
glEnable( GL_COLOR_MATERIAL );
glEnable( GL_LIGHT0 ); to enable the light but I doesn't light it good. I guess I have problem with the normal vectors but I made the math like 100 times and I think they are right. With other object like a cube it works properly. Could you help me please ?

2. It's hard to help you without seeing all of your code, particularly the code that sets up the lighting. I notice that your normal vectors are not unit vectors. This is o.k. if you do a 'glEnable (GL_NORMALIZE)' before calling the 'draw' routine. Also, it would help if you posted picture(s) of the problem.

3. Yes the problem looks like was in this "normalize". Thank you very much.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•