Archived

This topic is now archived and is closed to further replies.

Max_Payne

Convex polygon to triangle strip

Recommended Posts

FReY    424
assume your vertices are numbered v[0] ... v[n-1],



int i = 1;
int j = n-1;
bool left = false;

add v[0] to your list

while (i < j)
{
if (left)
{
add v[i] to your list
i++
}
else
{
add v[j] to your list
j--;
}
left = !left;
}


haven''t tested it, but the idea is that you keep 2 running indices i and j. i increases and j decreases and you always alternate between i and j.

This should work with both clockwise and counterclockwise ordered vertices.

Share this post


Link to post
Share on other sites
technobot    238
For CW, the idea is like this, according to how OpenGL draws its tri-strips. For CCW, mirror the drawing:

2-----3 2-----4
/ \ /| /|\
/ \ / | / | \
1 4 ---> 1 | / | 6
\ / \ | / | /
\ / \|/ |/
6-----5 3-----5


Michael K.,
Co-designer and Graphics Programmer of "The Keepers"



We come in peace... surrender or die!

Share this post


Link to post
Share on other sites