Problem of triangle mesh normal caculating.

Started by
1 comment, last by SaltyGoodness 15 years, 3 months ago
Hi, all: I have wrote a program, which will parse *.3ds file, and display 3d object using opengl. I save 3ds object in triangle mesh, according 3ds format. My algorithm of caculating normal vector is : 1. Calculating every triangle surface normal. 2. Averaging triangle normals to compute vertex normals Ok, diplay some box object like blow. You can see obviously black line at top of box.
"Averaging normal not work very well." Now what can I do?
Advertisement
I cant see your images.

Are you normalizing the normals? You should normalize the normals of each triangle before averaging and also normalize the normals of each vertex.
.
Quote:Original post by xissburg
Are you normalizing the normals? You should normalize the normals of each triangle before averaging and also normalize the normals of each vertex.


Actually it's often considered better not to normalize your face normals before averaging. That way faces with a larger surface area contribute more to a vertex's normal. It also has the added bonus of simplifying your code:
Set all vertex normals to (0,0,0)For each face (a, b, c){   face_normal = Cross(b-a, c-a)   vertex[a].normal += face_normal   vertex.normal += face_normal   vertex[c].normal += face_normal}For each vertex v   v.normal = Normalize(v.normal)


Here's another explanation, because I tend to suck at explaining things

This topic is closed to new replies.

Advertisement