🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Calculating Normals

Started by
3 comments, last by Marc 23 years, 10 months ago
I''m just starting to learn OpenGL, and was wondering if there are any procedures available for calculating normals? All the OpenGL source I''ve found uses simple shapes, and the normals have been set manually, but I''m trying to import 3D Studio files, with complex objects, and so I need something to take the XYZ coordinates of the points each polygon in a model and calculate the two possible normals for that polygon - anyone got any ideas where I could find such a procedure, or if there''s an easier way to do this?
Advertisement
Try this or download this.
I assume you are working with triangles:

Assume that v0, v1 and v2 are the three vertices of a triangle

This is pseudo-code

vett0 = v1 - v0vett1 = v2 - v0normal = CrossProduct(vett0, vett1)Normalize(normal) 


Hope that helps

v'' = CrossProduct(v1,v2)

-->
v''.x = v1.y*v2.z - v1.z*v2.y
v''.y = v1.z*v2.x - v1.x*v2.z
v''.z = v1.x*v2.y - v1.y*v2.x


GA
Visit our homepage: www.rarebyte.de.stGA
Thanks for all the help, guys.

This topic is closed to new replies.

Advertisement