#### Archived

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

# Help with Polygons

This topic is 6019 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

glBegin (GL_TRIANGLES); // Begin Drawing Triangles Point3 help; Point3 help2; Point3 help3; help.x = -1.0f; help.y = -1.0f; help.z = 0.0f; help2.x = 1.0f; help2.y = 1.0f; help2.z = 0.0f; help3.x = -1.0f; help3.y = 1.0f; help3.z = 0.0f; tempNormal = normal(help, help2, help3); glNormal3f(tempNormal.x,tempNormal.y,tempNormal.z); glVertex3f(-1.0f, -1.0f, 0.0f); glVertex3f(1.0f, 1.0f, 0.0f); glVertex3f(-1.0f,1.0f,0.0f); glEnd(); Ok heres code, this draws a triangle, this makes 1 side shaded, and the other side adjusts with light. How do i make both sides adjusting with light?

##### Share on other sites
...

umm...maybe im just not understanding it correctly...

##### Share on other sites
Im sure there''s a command to light up both sides of the polygon no matter which side the light is pointing at, but i dont know it

so why not use the normal to determine if the light is behind the object or not, and if it is, just make the normal negative?

ie:

result = (normal.x * lightpos.x) + (normal.y * lightpos.y) + (normal.z * lightpos.z) + normal.d

if (result < 0)
{
normal.x = -normal.x;
normal.y = -normal.y;
normal.z = -normal.z;
}

that should do what you want

##### Share on other sites
for two sided lighting the command is:
glLightModeli (GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);

1. 1
2. 2
frob
16
3. 3
4. 4
Rutin
11
5. 5

• 13
• 13
• 61
• 14
• 15
• ### Forum Statistics

• Total Topics
632125
• Total Posts
3004250

×