For the problem I have: a) An ordered list of points b) A list of points that make up each polygon
For example
point1 = (1, 2, 2)
point2 = (1, 2, 3)
point3 = (1, 3, 3)
polygon1 = [ point1, point2, point3 ]
=> polygon1 is a triangle which could be part of the outside of the model.
I need to calculate the correct normals for lighting in OpenGL.
I know that I can calculate vectors on the plane from the points given, and cross-product to get A normal to the plane, but OpenGL requires the normals to be pointing in the correct direction (ie outward).
The process needs to be automated because I have LOTS of polygons.
If I pick two vectors on the plane I can't tell how I can be sure the normal I have calculated points in the correct direction for lighting (ie is on the outside of the model.)
I figured I could add the calculated normal to a point on the plane and see if its further from the origin to see if its correct, but the model is quite complex and some normals may need to point towards the origin(ish)
If it helps, it turns out all the polygons are triangles (dont see how it helps though, should be able to abstract for any polygon)