# polygons to triangles

this might be a little offtopic:

how can I convert a N-Vertex polygon to a triangle list?

I tried to iterate the different vertices of te polygon, and generate triangles like this:

Triangle Vertex0 - Polygon Vertex 0
Triangle Vertex1 - Polygon Vertex N+1
Triangle Vertex2 - Polygon Vertex N+2

But a lot of times it just makes a mess, with a lot of garbage triangles, so I figure I have something missing.

so, which is the correct algorythm?

The easiest thing to do is make a triangle fan.
triangle 0 vert 0 = polygon vert 0
traingle 0 vert 1 = polygon vert 1
triangle 0 vert 2 = polygon vert 2
triangle 1 vert 0 = polygon vert 0
triangle 1 vert 1 = polygon vert 2
triangle 1 vert 2 = polygon vert 3
triangle 2 vert 0 = polygon vert 0
triangle 2 vert 1 = polygon vert 3
triangle 2 vert 2 = polygon vert 4

-Andy

this is exactly what I’m doing…

I’m trying to convert polygons to triangles, in collada documents exported with the 3dsmax plugin… it is possible that the 3dsmax plugin exports polygons incorrectly? (still experimental…)