Mar 17, 2011 at 2:23 AM
Edited Mar 17, 2011 at 2:24 AM
I'm creating a rendering system for my game terrain and would like an opinion on the best approach for breaking down polygon's to triangles (which can then be used in a trianglelist via vertex buffer). I understand the whole process as I've done it
many times without FPE, but I'm having difficulties in triangulating.
My approach at a high level:
1. Generate a random level saving all the information to texture.
2. Process the texture on level load, at which point we are left with a simple transparent and black image (with the smallest shape being 2x2 pixels)
3. Run it through the Earclip Decomposer
4. Create a polygon body for each of the decomposed polygons and add them to the world.
At this point I know I need to use the decomposed polygons to create triangles for my vertex buffer, but the triangulation methods I've found don't seem to work. Particularly I've used EarclipDecomposer.TriangulatePolygon and Triangulator, but
both have the main problem of being unable to triangulate all of my those decomposed polygons. From what I can tell they are all simple polygons... talking 4 or 5 sided convex polygons at the most complex. The Triangulator can triangulate the best
but its output is random, and even crashes sometimes.
Is there a better approach? Should I go with one triangulation function over the other for my situation? What are some of the caveats or best approaches when using these functions that may be causing me these problems?
EDIT: using latest source