I'm trying to implement volume (or stencil) shadows at the moment and have come to a stand-still.
In order to run the algorithm efficiently, you need to have a orientations of all the edges in a mesh consistent. What I need is an algorithm for determining if a triangle is wound correctly and otherwise fixing it.
So for example, the following tri would be fine:
3
/ / 1-----2
Assuming the face normal points toward you, the vertices are ordered correctly around the normal (anti-clockwise).
This is not good however:
2
/ / 1-----3
The vertices are number around the wrong way.
Is there a way of testing which way around the vertices are given I have the vertex positions and the face normal??? I realise that if I have a test for it then the simple solution is to swap verts 2 and 3, but how do I test that this is the case?