I’m playing around with an idea for a 2D fractal terrain engine. My current methodology, is to do standard fractal subdivision to generate a heightfield, and then generate a mesh using different layers. This works great for stacked terrain featuring underground layers of dirt and rock, and differing layers of stone, etc. However, there is a bit of a problem with how I plan to handle a dirt layer.
The dirt layer itself, is generated at a certain thickness, and then dropped onto the terrain. It prefers to flow downwards, and any slope greater than 1/2 (22.5 degrees) will attempt to smooth itself. This is done by continually finding slopes in the dirt layer that are greater than the specified degrees, and flowing the dirt “downhill” until it is smoothed. I then take the height data and convert it into a mesh.
The problem is, if there is a rock spire, I will not have a continuous heightmap for the dirt layer. It will actually split into multiple triangle regions, having a big gaping hole where the rock pokes through it. I am looking for clever ways to handle this behavior. I realize that I can just skip creating any vertices/faces that have a depth of zero, and generate a new mesh region, and that will work fine, but I’m also curious about a few other approaches.
I also looking at ideas for generating resources within the rock layers that wouldn’t be terribly cumbersome. Veins of ore will have to be textured meshes, given the system’s implementation, but I’m unsure how to proceed with creating ore veins within the terrain. These are going to be generated in lines and patches using a limited cellular automata.
Currently, I store terrain data by storing two numbers (in some cases) the height of the terrain from the base point (a float value, which I multiply by the size of the world “grid”, and the depth, which stores how thick this bit of terrain is. My rock layers actually connect themselves to whatever is below them using their height values, and the depth value of the entire terrain to determine where the layer floor is, but for ore, I wouldn’t have a method of calculating this without storing it explicitly.
Ore veins would store their areas as perimeters, and then generate faces to connect the hulls using a simple algorithm, but essentially, the way this would be stored, would be the top of the ore vein, followed by the thickness of the ore vein at the given point. The only problem with this, is that it would not allow an ore vein to have any concave regions. Can someone point me to a method for generating convex and concave shaped meshes using only their perimeters?