14

I have legitimately done every research possible for this, and it all just says to simply calculate the surface normals of each adjacent face. Calculating surface normals is easy, but how the heck do you find the adjacent faces for each vertex? What kind of storage do you use? Am I missing something? Why is it so easy for everyone.

Any guidance would be greatly appreciated.

Nicol Bolas
  • 449,505
  • 63
  • 781
  • 982
Jimmy Dean
  • 147
  • 1
  • 1
  • 7

1 Answers1

16

but how the heck do you find the adjacent faces for each vertex?

Think it otherway round: Iterate over the faces and add to the normal of the vertex. Once you processed all faces, normalize the vertex normal to unit length. I described it in detail here

Calculating normals in a triangle mesh

If you really want to find the faces for a vertex, the naive approach is to perform (linear) search for the vertex in the list of faces. A better approach is to maintain an adjancy list.

Community
  • 1
  • 1
datenwolf
  • 159,371
  • 13
  • 185
  • 298
  • 2
    Damn that makes a lot of sense thanks alot. I tried to make an adjacency list, but had no idea where to even begin because I couldn't visualize how to store what data for which data, when where how. Your first solution makes a lot more sense thanks. I also found an easier solution for what I'm doing, since I'm trying to shade a sphere, I found that the normal is just the normalized vertex minus the center of the sphere... which would've saved me hours upon hours. Thanks again – Jimmy Dean May 02 '13 at 15:05
  • 1
    @JimmyDean: If you search StackOverflow for "datenwolf sphere rendering" you'll find an answer by me, that also describes that relationship between a sphere's surface points and its normals. – datenwolf May 02 '13 at 15:07