View Full Version : How to triangulate.

08-08-2002, 08:19 AM

I'm having polygon with > 3 vertexes, How could i make it bunch of triangles?

08-08-2002, 08:26 AM
I have had great luck with the GPC (Generic Polygon Clipping) library. I believe it also does triangulation. Why code something like this when you can just use the code?

08-08-2002, 10:45 AM
You need help drawning more then one triangle?
Not sure what you are asking for.

Originally posted by runggu:

I'm having polygon with > 3 vertexes, How could i make it bunch of triangles?

08-08-2002, 11:39 AM
One (not optimal) way which always works:
Create a new vertex in the middle of all vertices. Draw all triangles using 2 neighbouring vertices and the middle vertex.

What you can also do is choose one vertex of the polygon as the *central* vertex, and draw using 2 adjacent vertices and the chosen vertex

08-09-2002, 12:30 AM
I know how to draw more than one triangle, i just want to know how to complex polygon to bunch of simple ones.

edotorpedo: That doesn't work with reaally complex polygons(like shape of G)

08-09-2002, 02:31 AM
Use a tesselation object. It's made for just that cause: tesselation is triangulation.
Go look for gluNewTess() in the SDK



08-09-2002, 04:10 AM
this is a classical computational geometry problem. look for "polygon triangulation" on google.
The basic idea of the common algorithm is to make trapezoids with your polygon, then cuting trapezoids accordingly (cut it in half anywhere if all its vertices are convex, otherwise cut it at the non-convex vertex). This works, providing your polygon is "simple" enougth (the G shape is).