Help with Polygons
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?
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
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
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement