Jump to content
  • Advertisement

Archived

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

El_Bosso

VertexArrays and Normals

This topic is 6081 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

Hi, assume I''ve got an array of 8 Vertices, and an Array with the data of the polys, forming a cube. (sorry sad English). OpenGL gets an index out of the polys array and sets the Vertex like glVertex3fv (Vertices[Polys]) and if I want to use a normal array Normals [Polys[i]]. And now my problem. I have to calculate a normal for every Vertex, but one vertex builds more than one poly, so it has (e.g. in the cube) 3 Normals. How can I calculate them? I thought I add the 3 Vectors and normalize the sum of the 3 Polynormals, but that sems for me not right. Any suggestions out there? Bosso

Share this post


Link to post
Share on other sites
Advertisement
There is no one way to calculate normals -- you can do it however you want (of course you will get strange results if you do something that makes no sense). If you have a procedural shape, such as a cyclinder, you could calculate the normals from the equation of a cylinder. Usually if you have a mesh with no normal information and you want it to look smooth, you calculate the vertex normals by averaging the surrounding face normals. However, if you want a faceted shape, such as a cube you set the vertex normal to the face normal -- THIS MEANS THAT IN SUCH A CUBE THE FACES WILL NOT SHARE THE SAME VERTICES, because even though the faces have vertices with the same position, they require different normals. You can also just change the shade mode to flat to draw faceted objects.

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!