I'm using anim8or as my 3D modeller and am writing the code to import the models into my OpenGL project. I've run into a problem, as I had intended to use vertex arrays to store the mesh data. However anim8or store objects as the highest n-gons available, and the number of points may vary thruought the mesh. The data stored looks like this:

5 4 0 -1 ( (2 0) (7 1) (4 2) (1 3) (0 4) ) 5 4 0 -1 ( (3 5) (9 6) (6 7) (2 0) (0 4) ) 5 4 0 -1 ( (1 3) (5 8) (8 9) (3 5) (0 4) ) 5 4 0 -1 ( (4 2) (10 10) (11 11) (5 8) (1 3) ) 5 4 0 -1 ( (6 7) (12 12) (13 13) (7 1) (2 0) ) 5 4 0 -1 ( (8 9) (14 14) (15 15) (9 6) (3 5) ) 5 4 0 -1 ( (7 1) (13 13) (16 16) (10 10) (4 2) ) 5 4 0 -1 ( (11 11) (17 17) (14 14) (8 9) (5 8) ) 5 4 0 -1 ( (9 6) (15 15) (18 18) (12 12) (6 7) ) 5 4 0 -1 ( (16 16) (19 19) (17 17) (11 11) (10 10) ) 5 4 0 -1 ( (18 18) (19 19) (16 16) (13 13) (12 12) ) 5 4 0 -1 ( (17 17) (19 19) (18 18) (15 15) (14 14) )

That first number (a 5 in all of the cases in this example) is the number of sides the polygon will have. The next 3 numbers don't matter for this discussion. The following list is made up of n groupings, where the first one is the index into an array of vertices. So the first polygon in the mesh is a pentagon made up of the vertices 2, 7, 4, 1, and 0. Simple enough, right? Well, certainly not for using vertex arrays. I originally thought I could just split the mesh up into all triangles, but that appears to be complicated for anything more complex than a square. Does anyone know a simple algorithm to do this? Thanks in advance!