• Advertisement
Sign in to follow this  

Vertex winding order (counter clockwise oder vertex) - algorithm

This topic is 2995 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Advertisement
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
Sign in to follow this  

  • Advertisement