Reputation: 904
I have a two dimensional polygon mesh made of connected triangles represented like this:
V = A, B, C, D, E, ...
I = 0, 4, 3,
...
V[0], V[4], V[3]
which is A-E-D
forms a triangle)http://img694.imageshack.us/img694/8968/meshg.png Example mesh
Now i want to traverse the boundary points in counter-clockwise-order, the starting vertex doesn't matter:
G, H, A, D, C, F
The reason for this is that i want to compute dynamic 2D shadows like in this article: http://www.gamedev.net/reference/programming/features/2dsoftshadow/page3.asp
Whats the best way to do this? I thought about computing a convex hull, but this seems too expensive because it's not using the triangle vertex indices, there has to be a better way.
Is there a way to make it work even for several polygons in one representation so that i get a list of boundary point lists for every connected polygon?
Thanks, abenthy
Upvotes: 1
Views: 2134
Reputation: 52519
Here's one way:
(A, B)
is the same edge as (B, A)
).Since the triangles are counter clockwise the computed boundary will also be counter clockwise. This method is good because it doesn't need the actual positions of the vertices, it only uses the topology specified by the indices.
Upvotes: 4