Skip to main content
GameDev.net gamedev.net
🔒 Locked

C# Face Normal Calculations

Started by awood969 Mar 29, 2011 at 2:47 PM 3 replies 2.3k views
Original Post
awood969
awood969
Hi there,

Question is the title, how do you calculate face normals? I'm doing a little project in C# without using any graphics API (DirectX, OpenGL etc) so I need a way calculate face normals, I don't fully understand the theory im afraid :-(

Any help would be very appreciated!

Thanks
Andrew
Buckeye
Buckeye
A face normal is calculated using the cross-product of vectors forming two sides of the triangle, and sharing the same origin.

I.e., given a triangle with 3 vertices v0, v1, v2:

normal = cross( (v2-v0), (v1-v0) )

Depending on the winding order of the vertices and how you calculate the cross product, you may have to flip the normal. You may also want to normalize the result.
Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly. You don't forget how to play when you grow old; you grow old when you forget how to play.
awood969
awood969
Aha, thank you :-D Per chance BuckEye you don't happen to have a handy dandy tutorial that explains how to create a Phong lighting model in c#?

Thanks
Andrew
Krypt0n
Krypt0n

Aha, thank you :-D Per chance BuckEye you don't happen to have a handy dandy tutorial that explains how to create a Phong lighting model in c#?

it's done in c# like probably in any other language. looking that up at google will give you tons of tutorials.
awood969
awood969
That was my first second and third stab before coming on here to post.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.