- Home /
What's the right way of generating a procedural mesh from an known outline?
I want to generate a procedural terrain in a 2D game, and I'm thinking that this can be achieved with a meshFilter component. Think worms, scorched earth, desert golfing, etc.
I'm not interested in generating the shape of the level in itself, but generating the mesh (vertices and triangles) from an already existing and known outline for the terrain, as a set of coordinates. Either if there is a builtin way of doing this or some pointers to existing algorithms to achieve what I want.
Maybe a mesh is not the right way, I'd like to hear what's a better way of achieving this in that case.
Answer by tanoshimi · Mar 06, 2015 at 06:50 AM
There are plenty of examples of procedural mesh generation; try this for starters: http://u3d.as/content/unity-technologies/procedural-examples/3zu
Sorry for not having followed up on this before, was on a trip. I had in fact tried this asset but it didn't give me the answers I needed. I'm not having a problem generating the meshes, my problem lies more into what kind of algorithm can be used to create a surface of triangles given a known outline (described as a List for example) For example, right now to generate a procedural terrain that doesn't have "caves" or overhangs, something like this:
https://sketch.io/render/sketch550d99b2a87a5.png
But I'd like to solve the more generic problem of being able to fill up a generic terrain, something like this:
Answer by Chiroculon · Apr 06, 2017 at 10:03 PM
@kkxzd You could use Constrained Delaunay triangulation to create the optimal triangle net, and then loop through the triangles to remove the ones that should not be filled.