Sign in to follow this  
SuperNerd

Normal Calculation

Recommended Posts

How would I calculate a normal for a triagle. All I need is calculation for a flat shaded triangle or the normal being perendicualar to the triangle face.

Share this post


Link to post
Share on other sites
You would take the three points of the triangle, then use those to find two vectors composing the triangle (for example, if you have a triangle consisting of points A, B and C, AB, AC and BC would be the vectors composing the triangle). Then take the cross product of the two vectors to get a vector orthogonal to the triangle. Normalize it and there you have it, a normal.

To make sure you're getting the correct normal (each triangle can have two normals - one coming out of each side of the triangle's surface), I believe you have to perform cross multiplication on your vectors using the proper winding order of your vertices.

I don't know if I can explain that any better, but, here's a link to an article you can read: Clickity!

-Auron

Edit: Also, if you need the normals at the vertices, then you can use the same normal as the rest of the triangle, or you can choose to interpolate that triangle's normal with the normals of all other triangles sharing that vertex.

Share this post


Link to post
Share on other sites
Auron:

Nicely put. Rating++.

SuperNerd:

I'm posting a thread this weekend in the Beginners or DirectX forum on computing efficient normals for a regular heightfield. Its probably the next step if you're just learning normal calculations, but I thought I'd let you know. You can follow the existing discussion of the article HERE.

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