1
\$\begingroup\$

Mesh Image

I'd like to learn a good algorithm to generate a 2d mesh made out only of triangles to be used as a terrain.

Its not important to get a high detail terrain. It should just have a triangle looking style.

Also the mesh should be extendable endlessly in all directions because the map will be endless. I thought about to having chunks of meshes saved in a file so they can be loaded during the execution.

Something like this (from Chasing Aurora): Chasing Aurora screenshot

\$\endgroup\$
  • \$\begingroup\$ What is your data source? How should the terrain look like? Should it be just random or follow specific rules? Please specify what you want to know, currently we can't really help you as the possibilities are endless. \$\endgroup\$ – LukeG Nov 3 '15 at 21:06
  • \$\begingroup\$ I should be able to create paths where the player can move. Or add some predefined structures like a vertical wall but with triangles and not staight. Or make a flatterd land. \$\endgroup\$ – Dario Kowalski Nov 3 '15 at 21:12
  • \$\begingroup\$ Please add the image to which you refer directly to the question, it's hard to know what exactly you're referring to in the link you added. \$\endgroup\$ – Vaillancourt Nov 3 '15 at 21:26
  • \$\begingroup\$ link \$\endgroup\$ – Dario Kowalski Nov 3 '15 at 21:28
  • \$\begingroup\$ If you want to use a voxel field as data source, you could search for the Marching Cubes algorithm. voxels have the benefit that you can have caves, what isn't possible with simple height fields. But pathfinding could be a little bit more difficult \$\endgroup\$ – Tobias B Nov 5 '15 at 9:17
4
\$\begingroup\$

Try this:

  1. Generate random points
  2. Compute delaunay triangulation of those points
  3. Use those delaunay triangles as your mesh

By restricting the domain and distribution of the random points, you can control the height of your terrain more carefully.

If you want to go beyond this and generate consistent terrain, or geometries that aren't just random mess, you will want to try some kind of procedural terrain generation. A great write-up about this can be found on NVIDIA's GPU-Gems site. The NVIDIA write-ups are really good disregarding your implementation tool, you don't have to actually implement it on the GPU.

\$\endgroup\$

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.