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?

  • \$\begingroup\$ 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. \$\endgroup\$ – Jon Apr 4 '15 at 20:39
  • 1
    \$\begingroup\$ 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"? \$\endgroup\$ – Daniel Carlsson Apr 4 '15 at 20:57
  • \$\begingroup\$ @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. \$\endgroup\$ – Jon Apr 4 '15 at 20:59
  • \$\begingroup\$ @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 \$\endgroup\$ – Daniel Carlsson Apr 4 '15 at 21:03
  • \$\begingroup\$ @DanielCarlsson, would you basically recommend a "flood-fill shader"? \$\endgroup\$ – Jon Apr 4 '15 at 21:09

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.

texas stencil

  • \$\begingroup\$ 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 \$\endgroup\$ – Daniel Carlsson Apr 4 '15 at 20:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.