Vertex Normals

Post: #1
There is a way to calculate the vertex normals of a triangle? Like Meshwork? GL_NORMALIZE seems to not work... I need them for my little modelling app. Thanks
Quote this message in a reply
Posts: 5,143
Joined: 2002.04
Post: #2
Face normals are easy:

If the vertices of your triangle are A, B, C, the face normal is something like (A - B) x (C - B). (That might be back-to-front, should be easy to fix by changing the order of the subtractions).

For vertex normals, average the face normals of the surrounding triangles.

This has all been discussed before, search the forum and you shall find Wink
Quote this message in a reply
Post: #3
FAQ that sucker!!
Quote this message in a reply
Posts: 142
Joined: 2002.11
Post: #4
I had the very same problem, and being a beginner at OpenGL I looked it up. I hope this helps:

<code snippet>

triNormal[0] = vec1[1] * vec2[2] - vec1[2] * vec2[1];
triNormal[1] = vec1[2] * vec2[0] - vec1[0] * vec2[2];
triNormal[2] = vec1[0] * vec2[1] - vec1[1] * vec2[0];


</code snippet>

vec1[0] would be the x difference between a first point and a second.
vec1[1] would be the y difference for the same thing
vec1[2] would be the z difference

vec2[0] would be the x difference between the same first point and another point on the triangle
vec2[1] would be the y diff...ect.

This normal that results isn't the correct length, however (it must be 1), but theres a few ways to fix this like dividing each component by the total length or using OpenGL's normalize functions.

Now I'm a beginner, and I'm trying to help, so if I'm wrong (talking to you advanced people!), correct me.

The original document I found this at is here:
Quote this message in a reply
Posts: 164
Joined: 2002.04
Post: #5
I'm not sure if this is what you're doing, but if you loop through all your faces and calculate their normals you can just add each face normal to its component vertices' normals and then go through all the vertices and normalise their normals.

That sounds kinda confusing now that I read through it but should work.
Quote this message in a reply
Posts: 177
Joined: 2002.08
Post: #6
What GL_NORMALIZE really does is it scales all the normals you send with the glNormal commands such that they are 1 unit long (some transformations will change their length). But if you aren't sending normals at all or the normals you send are incorrect, GL_NORMALIZE won't help you.
Quote this message in a reply
Post: #7
Try to avoid GL_NORMALIZE if you can help by normalising your normals yourself. It is really slow, mainly because it will kick you off the fast path.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  glNormal - Surface/Vertex normals Jones 19 20,318 Jul 18, 2006 12:45 PM
Last Post: imikedaman
  Normals Nick 20 12,691 Mar 25, 2005 09:31 AM
Last Post: tigakub
  Normals? Quicksilver 3 4,162 Jan 13, 2003 05:31 PM
Last Post: henryj