# Generate Triangle List

This topic is 4840 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Trying not to re-invent the wheel, could someone point me towards an algorithm/function to generate a triangle list (or strip) from a series of points. The points are in series and all points are co-planar (2d). They form the outline of polygon (convex or nonconvex but do not contain 'holes'). Currently I am using Direct3D but would like a generic implementation, and would like to stay away from Direct3D meshes. A web resource would be good. Something outside of any library. Really just looking for an algorithm. Any help would be aprreciated.

##### Share on other sites
Anyway basically, just start looping the points (asuming that they represent triangles and are in order) :

int vertex = 0for i < numtris   // a corner   trianglelist.index[0] = vertex;   vertex++;   // b corner   trianglelist.index[1] = vertex;   vertex++;   // c corner   trianglelist.index[2] = vertex;   vertex++;end

Now the vertices must be in triangle order, like 0, 1, 2 - vertices creates the first triangle and so on. Anyway that is the basic code.. :)

##### Share on other sites
Arex's method works only with convex polygons. If you want more general solution, here (PDF warning) is a paper describing an algorithm that works with arbitrary shaped polygons. Also, try googling for "polygon triangulation".

##### Share on other sites
gnu triangulated surface library does delaunay triangulation. any good?

edit: whoops. didn't see you didn't want a lib... googling delaunay triangulation gives some good descriptions (even a few applets demonstrating it)

##### Share on other sites
From the time I posted this I ended up going with the whole ear clipping idea.

Whcih pretty much looks like what you guys pointed to, so I suppose I'm on the right track.

Thanks for the resources.

1. 1
Rutin
37
2. 2
3. 3
4. 4
5. 5

• 11
• 12
• 14
• 9
• 9
• ### Forum Statistics

• Total Topics
633348
• Total Posts
3011462

×