Sign in to follow this  
arbin

Vertex winding order (counter clockwise oder vertex) - algorithm

Recommended Posts

I can think of a way:
You can set the winding to the same to triangles that share an edge. So in most cases, it will be okay. And you need to find a well winded triangle first.

image

Red is the first triangle.
You have to find its edge neighbors.
Lets say the shared edge has vertex indices a,b in the correct, CCW order.
The index of the neighbor's other vertex is k

if its edge neighbor has indices b,a,k or k,b,a or a,k,b, its winding is the same as the first. If not, rewind.
If you have all neighbor triangles done, go the the next triangle, and do the stuff with its neighbors. You can traverse through the whole mesh with some flood-fill algorithm.

I hope that works, it's early, and haven't slept too much.

But the other method that presented in the other thread works well too (but I'm not sure about non-closed meshes), don't expect that you will get a pseudo, or complete code.
Work!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this