Jump to content
  • Advertisement

Archived

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

cb007sax

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.

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
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

Share this post


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

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!