# Make a triangular mesh from of a map defined by points that follow the coast lines

I have a set of points which follow the coast lines of a world map. I would like to triangulate it so that I can render the continents filled in. The points seem to be in order so that if you render as lines, the only issue is when a land mass starts and ends you get lines you shouldn't have between them.

Does anyone know of a good way to go about making a triangular mesh out of this data?

• Does this have to be dynamically generated? You could use the current output to generate stencils in Paint (flood fill). Then, just draw big textured/colored quads with the stencil active. Then, draw thick lines for borders. – Jon Apr 4 '15 at 20:39
• What do you mean with "the only issue is when a land mass starts and ends you get lines you shouldn't have between them"? – Daniel Carlsson Apr 4 '15 at 20:57
• @DanielCarlsson, he hasn't figured out which way to go yet and seems to be rendering it all as one long linestrip, currently. Probably has connections where strip-cuts should occur. – Jon Apr 4 '15 at 20:59
• @Jon But rendering any country or landmass would give you a closed area (not counting the few countries that reside inside another country), perhaps its besides the point though – Daniel Carlsson Apr 4 '15 at 21:03
• @DanielCarlsson, would you basically recommend a "flood-fill shader"? – Jon Apr 4 '15 at 21:09

## 1 Answer

If this is dynamic, a radial sweep algorithm to collect the points into clumps of non-overlapping triangles. A geometry shader would generate a triangle fan from the clumps using the calculated radial point for each.

If this is static, I'd render it as a LINESTRIP, save the rendertarget to disk, and flood-filling the shape in Paint. You can use the result as a stencil and draw the LINESTRIP for borders.

Here is an image of a big red quad drawn with a stencil of Texas. The right-most portion of the stencil was erased to reveal the quad.

• Try and make your answer stand on its own as much as possible, refer to your answer from your comment rather than the other way around – Daniel Carlsson Apr 4 '15 at 20:56