Skip to main content
gamedev.net
🔒 Locked

[solved] glNormal

Started by Phille 3 replies 1.4k views
Original Post
Phille
Phille
I am trying to put some light on my square. But I don't know how to use glNormal. I found this: http://www.gamedev.net/community/forums/topic.asp?topic_id=513422 Now I know why. But not how. How do I use it when I want sharp edges? Here is my square:
  // Front
  glVertex3f(-1.0f,-1.0f, 1.0f);
  glVertex3f(-1.0f, 1.0f, 1.0f);
  glVertex3f( 1.0f, 1.0f, 1.0f);
  glVertex3f( 1.0f,-1.0f, 1.0f);


  // Left
  glVertex3f(-1.0f,-1.0f,-1.0f);
  glVertex3f(-1.0f, 1.0f,-1.0f);
  glVertex3f(-1.0f, 1.0f, 1.0f);
  glVertex3f(-1.0f,-1.0f, 1.0f);


  // Back
  glVertex3f( 1.0f,-1.0f,-1.0f);
  glVertex3f( 1.0f, 1.0f,-1.0f);
  glVertex3f(-1.0f, 1.0f,-1.0f);
  glVertex3f(-1.0f,-1.0f,-1.0f);


  // Right
  glVertex3f( 1.0f,-1.0f, 1.0f);
  glVertex3f( 1.0f, 1.0f, 1.0f);
  glVertex3f( 1.0f, 1.0f,-1.0f);
  glVertex3f( 1.0f,-1.0f,-1.0f);


  // Top
  glVertex3f(-1.0f, 1.0f, 1.0f);
  glVertex3f(-1.0f, 1.0f,-1.0f);
  glVertex3f( 1.0f, 1.0f,-1.0f);
  glVertex3f( 1.0f, 1.0f, 1.0f);


  // Bottom
  glVertex3f(-1.0f,-1.0f,-1.0f);
  glVertex3f(-1.0f,-1.0f, 1.0f);
  glVertex3f( 1.0f,-1.0f, 1.0f);
  glVertex3f( 1.0f,-1.0f,-1.0f);
Could somebody please tell me how I use glNormal() on that? [Edited by - Phille on January 6, 2009 9:18:53 AM]
scwizzo
scwizzo
Normals are the vectors perpendicular to the faces, typically pointing out (versus in). So figure out what the vector would be pointing perpendicular to each face.
/ Visual Studios 2010 / Codeblocks 10.05 / Windows 7 / Ubuntu 10.10 / - I might be wrong
fcoelho
fcoelho
After you figured the normal vector, just use the same vector for all vertexes in the same face.
glNormal.. //normal for faceglVertex.. //vertexesglVertex....
kittycat768
kittycat768
It's a cube so you want your normals to be 90 degrees apart. Try this

// Front
glNormal3f( 0.0f, 0.0f, 1.0f);
glVertex3f(-1.0f,-1.0f, 1.0f);
glVertex3f(-1.0f, 1.0f, 1.0f);
glVertex3f( 1.0f, 1.0f, 1.0f);
glVertex3f( 1.0f,-1.0f, 1.0f);
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------I once read that World of Warcraft is poor fishing simulator. I don't know about you but I catch a lot more fish in World of Warcraft than I do in real life.
Phille
Phille
Thanks a lot!!

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.