• Advertisement

Archived

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

Convex polygon to triangle strip

This topic is 5129 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

Has anyone got any idea on how to generate a triangle strip from a convex polygon, while preserving clockwise vertex order, for backface culling?

Looking for a serious game project?
www.xgameproject.com

Share this post


Link to post
Share on other sites
Advertisement
Then explain your idea :D

How do you convert an n-sided convex polygon with the vertices ordered clockwise to a triangle strip with the first triangle ordered clockwise.



Looking for a serious game project?
www.xgameproject.com

Share this post


Link to post
Share on other sites
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
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

  • Advertisement