Calculating Normals
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?
I assume you are working with triangles:
Assume that v0, v1 and v2 are the three vertices of a triangle
This is pseudo-code
Hope that helps
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
-->
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
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement