Sign in to follow this  
staticVoid2

calculating face normals

Recommended Posts

staticVoid2    381
hi, how would you normally calculate face normals when you have the vertex normals the make up the face, I've tried adding them together and dividing by the number of vertices but it's not working, I have these unit normals: 0.577349; 0.577349; -0.577349;, 0.577349; -0.577349; -0.577349;, -0.577349; -0.577349; -0.577349;, -0.577349; 0.577349; -0.577349;, and the result is: 0.000000, 0.000000, -0.577349 but should it not be (0, 0, -1)? how would I do this

Share this post


Link to post
Share on other sites
deadstar    536
How did you calculate the vertex normals without a face normal in the first place?

I'm unsure if you can 'revert back' to a face normal from a set of vertex normals.

But then again, I'm not the world's best mathematician.

Share this post


Link to post
Share on other sites
staticVoid2    381
Quote:
Original post by deadstar
How did you calculate the vertex normals without a face normal in the first place?

I'm unsure if you can 'revert back' to a face normal from a set of vertex normals.

But then again, I'm not the world's best mathematician.


there pre-calculated in .x files for each vertex but not for faces.


Quote:

Just normalize your result vector.


thanx.

Share this post


Link to post
Share on other sites
haegarr    7372
A vertex normal is computed by the normalized sum of the normals of surrounding faces if the corners are smoothed. They are identical to the face normal for sharp corners. Perhaps, before summed up, they are weighted with the enclosed angle with which the face participates on the vertex (other weighting schemes exist as well).

Summing up the normals of all verices of a face definitely considers the orientations of neighbouring faces, too. Therefore, it will definitely not yield in the original normal for the general case. If you want to yield in the correct normal, compute and re-normalize the cross-product of the difference vectors between vertices. I.e. for a face with at least 3 vertex positions p1, p2, p3 use
normalize( ( p2 - p1 ) x ( p3 - p1) )
(For quads and faces with even more vertices some possibilities exist to suffer as least as possible from numeric inaccuraries.) You can, of course, look at the vertex normals to determine whether the direction of the cross-product is correct or has to be inverted.


EDIT: Okay, jezham has mentioned it already :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this