Thank for all your help. I'm very rusty on my maths. My previous job is embedded design engineer. We just used tools & libraries. I will go digest all your explanation tomorrow.
What I'm trying to do is to check whether the shape that has being created by my staff through programming sequence conforms to the winding rule. Its difficult to visualize in details to check their work. So I decided to write a program to examine every triangles that froms the object. Previously I have being clicking each triangle to check visually.
To keep it simple, I will know the center point of the shape at point ( 0, 0, 0 ). I will also know any points that are inside the shape. The shape could be any form like sphere, cylinder, torus and etc.
Can anybody help me on this ? Once again thank you for all your help. I hope my standard can come to par with you guys one day.
I think you need to do something like this. Start at your point (0,0,0) and draw a vector from it extending in though the middle of any triangle. Now you have to count all the intersections with the object (i.e. all other triangles including the one you stated with). If there is an odd number you stated inside the object. If there is an even number you started outside. You can also determine if for the triangle you picked, you are entering or leaving the object. You probably need some special cases to make this work perfectly. For instance if you pass directly though an edge you might end up counting intersections for both polygons on either side of it, however you really only want one intersection. Passing though a point is likewise situation. For each triangle I would check points first, then edges and then the face. That way you can branch off into your special case code properly.
In any case now you have all the information to determine if your winding is correct by taking the dot product of the vector and the normal of the triangle. If your object has adjacency information you can then walk from your triangle and visit all triangles in the object to check their winding. Alternatively you can test each polygon separately with the above method.