Jump to content
  • Advertisement


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


Convex polygon to triangle strip

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

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?

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
add v[j] to your list
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

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!