• ### Announcements

#### Archived

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

# Convex polygon to triangle strip

## Recommended Posts

Max_Payne    757
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 on other sites
alvaro    21246
Isn''t this absolutely straight-forward?

##### Share on other sites
Max_Payne    757

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 on other sites
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 listwhile (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 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!