Hi !
Here come some previews of the fractal painter. As shown before in this thread, it creates a little height map to modify a region of the g_Map. This region is defined by a pair of coordinates array, i.e. something like {x:some_value,y:some_value}. So it can be anything including Vector2D, cell objects and even PointXZ (converted on the fly). In the former version, the painter replaced indistinctly all the heights of the regions, which gives this:
The result is not great, because it's possible to have chiasms at the border of the region. This mode is still available but the default is now to modify only the parts where the computed height is higher than original terrain:
The merge is now much better. What if we want not a mountains patch but a depression ? There is a new painter for that:
It creates a bumped hole in the map, but the default here modifies only the parts lower than the original map and it merges better:
Now another painter. Mesas or cliffs:
The top of the mesa (deep green) is perfectly flat, but this can be changed easily: at the end of the painting, the painter stores into a member array all the top points. The top of the mesa is painted using this region. A new fractal painter (or anything else) can be applied to modify this part if something less plain is desired. The counterpart of this painter obviously creates holes whose bottom is flat:
In the same way, the flat part is available after painting, for morphing, painting or populating. Just put an Orthanc tower here, some Fangorn forests around and you've got Isenguard ring
Please note the painter can be applied on any kind of regions, not only the rather round one I use here.
More of it, everyone can define easily a new fractal painter because they all inherit from an abstract object holding all the code complexity. The child painters hold only the part where the two maps are mixed. Here is an example:
function MyNewFractalPainter(area,centerHeight,bump,rough,progress, your_parameters_if_needed) {
AbstractFractalPainter.call(this,area,centerHeight,bump,rough,progress);
this.param1 = your_parameters_if_needed;
}
MyNewFractalPainter.prototype = Object.create(AbstractFractalPainter.prototype);
MyNewFractalPainter.prototype.paint = function() {
let res = this.maps(); // this computes the temporary fractal map
let depx = res[0]; // these are the offsets of the fractal map in the main map. No need to change them.
let depy = res[1];
for (let pt of this.region)
{
// melting the g_Map and the temporary map. This is the only part to modify.
let xg = pt.x - depx;
let yg = pt.y - depy;
if(g_Map.height[pt.x][pt.y] < this.tMap[xg][yg])
continue; // we skip this value
g_Map.height[pt.x][pt.y] = this.tMap[xg][yg]; // we keep this one
}
}
Not in Github for now. The reason is I don't know yet in which format the flat regions created by the two last painters should be created.
Friendly,