Advertisement

Help with Polygons

Started by February 20, 2002 08:33 PM
2 comments, last by cb007sax 23 years ago
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?
...

umm...maybe im just not understanding it correctly...
Advertisement
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
for two sided lighting the command is:
glLightModeli (GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);

This topic is closed to new replies.

Advertisement