Vertex winding order (counter clockwise oder vertex) - algorithm
Hello I am facing the same problem like in the thread
http://www.gamedev.net/community/forums/topic.asp?topic_id=550481
Does any one have any solution to this problem.
Thank you in advance
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.
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!
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.
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!
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement