Heightfield 1.0
LayerFieldErosion Class Reference

A multi-layered height field with complex erosion algorithms. More...

#include <layersfielderosion.h>

Inheritance diagram for LayerFieldErosion:
LayerStack HeightFieldSediment Array2 Box2

Public Member Functions

 LayerFieldErosion ()
 Empty.
 
 LayerFieldErosion (const Box2 &, int, int)
 Create a terrain adapted to erosion simulations.
 
 LayerFieldErosion (const HeightField &)
 Create a terrain adapted to erosion simulations.
 
 LayerFieldErosion (const ScalarField2 &, const ScalarField2 &)
 Create a terrain adapted to erosion simulations.
 
 ~LayerFieldErosion ()
 Empty.
 
void SetEvaporation (const double &)
 Set the constant of evaporation.
 
void SetBordersFlow (const double &)
 Set the percentage of sand that would flow out of the domain when flow reaches border cells.
 
void ThermalImpactSlope (const double &)
 Globally transform a thin layer of bedrock into rocks.
 
bool StabilizeStep (const double &, int, int, ScalarField2 &, ScalarField2 &, ScalarField2 &)
 
bool FlowOneStep (const double &)
 One flow step.
 
bool FlowStep (const double &, int)
 Perform a set of flow.
 
bool WorldmachineStep (const double &)
 
bool WorldmachineSeveralStep (const double &)
 
void HydraulicImpact (const double &)
 Add water all over the terrain.
 
void HydraulicEvaporate ()
 Evaporation.
 
void VegetationDestruction ()
 Destroys the vegetation layer.
 
void GrassSeed ()
 Seed grass on a terrain.
 
void ProceduralVegetation ()
 Create vegetation.
 
void GrassOverall (const double &=0.5)
 Add grass over the entire terrain, regardless of the conditions of the environment.
 
Mesh CreateGeometry () const
 Create geometry.
 
void Droplet (const Vector2 &, const double &)
 Erode the terrain using a single droplet.
 
void GlobalDropletErosion (const double &)
 Erode the terrain by distributing droplets all over the terrain.
 
void RandomDropletErosion (int, const double &)
 Erode the terrain using randomly distributed droplets.
 
void PointDropletErosion (const Vector2 &, int, const double &)
 Erode the terrain using a point source for generating droplets.
 
void Lightning (const Vector2 &, const double &)
 Lightning strike.
 
void LightningErosion (int, const double &)
 Erode the terrain using randomly distributed droplets.
 
void ThermalGlobalDropletErosion ()
 Erode the terrain by distributing droplet all over the terrain.
 
void ThermalDropletErosion (int)
 Erode the terrain using randomly distributed droplets.
 
void ThermalDropletErosion (const Vector2 &, int)
 Erode the terrain using a point source for generating droplets.
 
- Public Member Functions inherited from LayerStack
 LayerStack ()
 Create an empty terrain.
 
 LayerStack (const Box2 &, int, int)
 Create a terrain with different material layers.
 
 LayerStack (const ScalarField2 &)
 Create terrain.
 
 LayerStack (const ScalarField2 &, const ScalarField2 &)
 Create terrain.
 
 LayerStack (const ScalarField2 &, const ScalarField2 &, const ScalarField2 &, const ScalarField2 &, const ScalarField2 &, const ScalarField2 &, const ScalarField2 &, const ScalarField2 &)
 Create a layered terrain model.
 
 ~LayerStack ()
 Empty.
 
void Subdivide ()
 Double the resolution of the terrain.
 
Box GetBox () const
 Compute the bounding box of the terrain.
 
double Vegetation (const Vector2 &) const
 Return the vegetation density.
 
double Vegetation (int, int) const
 Return the vegetation density.
 
double Grass (const Vector2 &) const
 Return the grass elevation.
 
double Grass (int, int) const
 Return the grass elevation.
 
double Water (const Vector2 &) const
 Return the water elevation.
 
double Water (int, int) const
 Return the water elevation.
 
double Rocks (const Vector2 &) const
 Return the rocks elevation.
 
double Rocks (int, int) const
 Return the rocks elevation.
 
ScalarField2GetRock ()
 Access to the rock scalar field.
 
ScalarField2GetWater ()
 Access to the water scalar field.
 
ScalarField2GetSnow ()
 Access to the snow scalar field.
 
ScalarField2GetGrass ()
 Access to the grass scalar field.
 
ScalarField2GetVegetation ()
 Access to the vegetation scalar field.
 
ScalarField2GetAlpha ()
 Access to the alpha scalar field.
 
HeightField GetHeightField (bool=true, bool=true) const
 Convert the layered model into a simple heightfield.
 
void UpdateHeightField (HeightField &, const QRect &=QRect(), bool=true, bool=true) const
 Convert the layer model into a simple heightfield.
 
bool Intersect (const Ray &, double &, Vector &) const
 Compute the intersection between a ray and the surface of the terrain.
 
LayerStack Crop (const QPoint &, const QPoint &) const
 Crops a rectangular region in the terrain.
 
void WaterFlood (const double &)
 Fill the terrain with a water body.
 
void WaterFlood (const Vector2 &, const double &)
 Flood fills a region with water.
 
void WaterDry (const Vector2 &)
 Dries a connex region, removing water using a flood fill algorithm.
 
void SandOverall (const double &)
 Add sand over the terrain.
 
void RockOverall (const double &)
 Add rock over the terrain.
 
QVector< VectorGetTrees () const
  <FONT COLOR="AA2222"><B>Warning</B></FONT>
 
Vector Vertex (int, int) const
 Compute the vertex corresponding to a given sample.
 
Vector Vertex (const Vector2 &) const
 Compute the elevation of a point, which is the sum of the bedrock, sand and rocks layers.
 
Vector Normal (int, int) const
 Compute the normal at a given sample.
 
Color GetColorVector (int, int) const
 Compute the vertex corresponding to a given sample.
 
double Height (const Vector2 &) const
 Compute the elevation of a point, which is the sum of the bedrock, sand and rocks layers.
 
Vector Normal (const Vector2 &, bool=false) const
 Compute the normal for a given position on the terrain.
 
void Scale (const double &)
 Scale the layer-field.
 
void Translate (const Vector2 &)
 Translate the layer-field.
 
void Save (const QString &) const
 Save structure as a set of images.
 
Mesh CreateWaterGeometry () const
 Create the geometry of the water on the terrain.
 
void CreateCubes (Box &, QVector< FrameScaled > &, QVector< FrameScaled > &, QVector< FrameScaled > &, QVector< FrameScaled > &, QVector< FrameScaled > &, QVector< FrameScaled > &, bool=true, bool=true, bool=true, bool=true, bool=true, bool=true) const
 Create a material stack representation of the model.
 
- Public Member Functions inherited from HeightFieldSediment
 HeightFieldSediment ()
 Create an empty terrain.
 
 HeightFieldSediment (const Box2 &, int, int)
 Create a flat terrain with no sediments.
 
 HeightFieldSediment (const ScalarField2 &)
 Create a terrain with no sediments from an elevation field.
 
 HeightFieldSediment (const ScalarField2 &, const ScalarField2 &)
 Create a terrain with sediments.
 
 ~HeightFieldSediment ()
 Empty.
 
Array2 GetArray () const
 Return the array representing the grid domain.
 
ScalarField2 AlphaBlend () const
 Compute the alpha blending between sand and bedrock.
 
HeightField GetHeightField () const
 Convert the layered model into a simple heightfield.
 
bool Intersect (const Ray &, double &, Vector &) const
 Compute the intersection between a ray and the surface of the terrain.
 
void SmoothRock (int=1)
 Smoothes the bedrock layer.
 
HeightFieldGetBedrock ()
 Access to the bedrock scalar field.
 
ScalarField2GetSand ()
 Access to the sand scalar field.
 
double Bedrock (const Vector2 &) const
 Compute the bedrock elevation.
 
double Bedrock (int, int) const
 Return the bedrock elevation.
 
double Sand (const Vector2 &) const
 Compute the sand thickness.
 
double Sand (int, int) const
 Return the sand thickness.
 
void Subdivide ()
 Double the resolution of the terrain.
 
void BedrockFlatten (const Vector2 &, const double &, const double &=0.25)
 Flatten the bedrock around the target point.
 
void BedrockLevel (const Vector2 &, const double &, const double &)
 Level the bedrock to the target elevation.
 
void BedrockUplift (const double &)
 Modify the bedrock using a uniform uplift.
 
void BedrockUplift (const ScalarField2 &)
 Uplift.
 
void ThermalImpact (const double &)
 Globally transform a thin layer of bedrock into sediments.
 
void ThermalImpactSlope (const double &)
 Globally transform a thin layer of bedrock into sediments.
 
void Stabilize (const double &, const double &=0.84)
 Stabilizes sediments over the entire terrain.
 
bool StabilizeStep (int, int, const double &, ScalarField2 &)
 Perform a stabilization step on the given layered cell.
 
int CheckFlowSlope (const QPoint &, FlowStruct &) const
 Compute the flow directions at a given point.
 
int CheckFlowDirectionsAngle (const QPoint &, const double &, QPoint *, double *, double *, double *) const
 Compute the flow directions at a given point.
 
bool SelectFlowDirection (const QPoint &, QPoint &, double &) const
 Select flow direction.
 
void TRUC (const QPoint &q, const double &slope, const double &V_T, double &V_T_S, double &V_E_R, double &V_E_S, double &V_D_S)
 Compute eroded material.
 

Protected Attributes

ScalarField2 bedrockflow
 Flowing sediments.
 
ScalarField2 sandflow
 Flowing sediments.
 
ScalarField2 waterflow
 Flowing water.
 
ScalarField2 suspended
 Suspended material.
 
double evaporation = 0.0
 Evaporation rate.
 
double flowouside = 0.0
 Percentage of sediment flowing outside of boundary.
 
- Protected Attributes inherited from LayerStack
ScalarField2 rocks
 Rocks.
 
ScalarField2 water
 Water.
 
ScalarField2 grass
 Grass.
 
ScalarField2 vegetation
 Vegetation.
 
ScalarField2 snow
 Snow.
 
ScalarField2 alpha
 Alpha.
 
- Protected Attributes inherited from HeightFieldSediment
HeightField bedrock
 Bedrock.
 
ScalarField2 sand
 Sand, i.e., sediments.
 

Additional Inherited Members

- Protected Member Functions inherited from HeightFieldSediment
void Evaporate (const double &, const double &, double &, double &, double &)
 Evaporate some water from the droplet.
 

Detailed Description

A multi-layered height field with complex erosion algorithms.

Constructor & Destructor Documentation

◆ LayerFieldErosion() [1/3]

LayerFieldErosion::LayerFieldErosion ( const Box2 & box,
int nx,
int ny )
explicit

Create a terrain adapted to erosion simulations.

Parameters
boxThe box.
nx,nyResolution.

◆ LayerFieldErosion() [2/3]

LayerFieldErosion::LayerFieldErosion ( const HeightField & t)

Create a terrain adapted to erosion simulations.

Parameters
tHeightfield.

◆ LayerFieldErosion() [3/3]

LayerFieldErosion::LayerFieldErosion ( const ScalarField2 & t,
const ScalarField2 & s )
explicit

Create a terrain adapted to erosion simulations.

Parameters
tBedrock.
sSediment layer.

Member Function Documentation

◆ Droplet()

void LayerFieldErosion::Droplet ( const Vector2 & p,
const double & e )

Erode the terrain using a single droplet.

Same as:

layered.Droplet(layered.VertexInteger(p), e);
void VertexInteger(const Vector2 &, int &, int &) const
void Droplet(const Vector2 &, const double &)
Erode the terrain using a single droplet.
Definition terrain-droplet.cpp:26
LayerFieldErosion()
Empty.
Definition terrain.cpp:15
Parameters
pPosition of the drop.
eWater elevation (in meters).

◆ FlowOneStep()

bool LayerFieldErosion::FlowOneStep ( const double & e)

One flow step.

Parameters
eAmount of material.

◆ FlowStep()

bool LayerFieldErosion::FlowStep ( const double & e,
int n )

Perform a set of flow.

Parameters
eAmount of material.
nNumber of steps.

◆ GlobalDropletErosion()

void LayerFieldErosion::GlobalDropletErosion ( const double & e)

Erode the terrain by distributing droplets all over the terrain.

Parameters
eWater elevation (in meters).

◆ GrassOverall()

void LayerFieldErosion::GrassOverall ( const double & s = 0.5)

Add grass over the entire terrain, regardless of the conditions of the environment.

Parameters
sGrass density.

◆ HydraulicImpact()

void LayerFieldErosion::HydraulicImpact ( const double & r)

Add water all over the terrain.

Parameters
rWater elevation.

◆ Lightning()

void LayerFieldErosion::Lightning ( const Vector2 & p,
const double & e )

Lightning strike.

Parameters
pPoint.
eStrength of the lightning.

◆ LightningErosion()

void LayerFieldErosion::LightningErosion ( int n,
const double & e )

Erode the terrain using randomly distributed droplets.

Parameters
nNumber of droplets.
eWater elevation (in meters).

◆ PointDropletErosion()

void LayerFieldErosion::PointDropletErosion ( const Vector2 & p,
int n,
const double & e )

Erode the terrain using a point source for generating droplets.

Parameters
pSource.
nNumber of droplets.
eWater elevation (in meters).

◆ RandomDropletErosion()

void LayerFieldErosion::RandomDropletErosion ( int n,
const double & e )

Erode the terrain using randomly distributed droplets.

Parameters
nNumber of droplets.
eWater elevation (in meters).

◆ SetBordersFlow()

void LayerFieldErosion::SetBordersFlow ( const double & b)

Set the percentage of sand that would flow out of the domain when flow reaches border cells.

Parameters
bOut flow rate.

◆ SetEvaporation()

void LayerFieldErosion::SetEvaporation ( const double & v)

Set the constant of evaporation.

Parameters
vEvaporation volume.

◆ StabilizeStep()

bool LayerFieldErosion::StabilizeStep ( const double & ae,
int x,
int y,
ScalarField2 & deltaRock,
ScalarField2 & deltaSand,
ScalarField2 & deltaeboul )
Returns
true if the x y pile was stable, false otherwise

◆ ThermalDropletErosion() [1/2]

void LayerFieldErosion::ThermalDropletErosion ( const Vector2 & p,
int n )

Erode the terrain using a point source for generating droplets.

Parameters
pSource.
nNumber of droplets.

◆ ThermalDropletErosion() [2/2]

void LayerFieldErosion::ThermalDropletErosion ( int n)

Erode the terrain using randomly distributed droplets.

Parameters
nNumber of droplets.

◆ ThermalImpactSlope()

void LayerFieldErosion::ThermalImpactSlope ( const double & s)

Globally transform a thin layer of bedrock into rocks.

This function takes into account the slope, vegetation and sand layers.

Parameters
sThickness (in meters)

◆ WorldmachineSeveralStep()

bool LayerFieldErosion::WorldmachineSeveralStep ( const double & e)
Parameters
eAmount of material.

◆ WorldmachineStep()

bool LayerFieldErosion::WorldmachineStep ( const double & e)
Parameters
eAmount of material.