Terra 1.0
Public Member Functions | Protected Attributes | Static Protected Attributes | List of all members
ArchesTree Class Reference

This class implements complex terrains created by combining elements. More...

#include <archestree.h>

Public Member Functions

 ArchesTree (TerraNode *, TerraNode *=nullptr, TerraNode *=nullptr, TerraNode *=nullptr)
 Create terrain structure from an input TerraNode element with Vegetation. More...
 
 ~ArchesTree ()
 Deletes the tree structure.
 
ScalarAlpha GetBedrock (const Vector2 &) const
 Compute the bedrock height of a given input point. More...
 
ScalarAlpha GetWater (const Vector2 &) const
 Compute the height of a given input point. More...
 
ScalarAlpha GetFoam (const Vector2 &) const
 Compute the height of a given input point. More...
 
ScalarAlpha GetSand (const Vector2 &) const
 Compute the height of a given input point. More...
 
Box2 GetBox () const
 Return the bounding box of the tree.
 
int Traversal (const Vector2 &) const
 Compute the number of nodes that are traversed when evaluating the tree. More...
 
void GetTriangles (const Triangle2 &, QVector< Vector > &, QVector< Vector > &) const
 Get triangles of terrain and water using the Archestree.
 
Vector dichotomie (Vector, Vector, double, double) const
 Find the intersection between the terrain and a segment. More...
 
bool Intersect (const Ray &, double &) const
 Compute the intersection between the surface and a ray. More...
 
Mesh CreateMesh (const Circle2 &, int) const
 Create a mesh over a disc support. More...
 
Mesh CreateMeshBorder (const Circle2 &, int) const
 Create a mesh over a disc support. More...
 
void HeightFieldRock (HeightField &) const
 Create a Rock Heightfield. More...
 
void HeightFieldWater (HeightField &) const
 Create a Water Heightfield. More...
 
void HeightFieldSand (HeightField &) const
 Create a Sand Heightfield. More...
 
LayerStack CreateLayerStack (const Array2 &) const
 Create a LayerStack. More...
 
void Blend (HeightField &) const
 Blend a given node with an existing terrain over an input heightfield. More...
 

Protected Attributes

TerraNodebedrock
 Bedrock tree.
 
TerraNodewater
 Water.
 

Static Protected Attributes

static const double epsilon = 1e-6
 Epsilon value for gradient computations.
 

Detailed Description

This class implements complex terrains created by combining elements.

Constructor & Destructor Documentation

◆ ArchesTree()

ArchesTree::ArchesTree ( TerraNode r,
TerraNode w = nullptr,
TerraNode s = nullptr,
TerraNode f = nullptr 
)
explicit

Create terrain structure from an input TerraNode element with Vegetation.

Parameters
rBedrock node.
wWater node.
sSand node.
fFoam node.

References bedrock, and water.

Member Function Documentation

◆ Blend()

void ArchesTree::Blend ( HeightField &  h) const

Blend a given node with an existing terrain over an input heightfield.

Let a the mask of the node, the mask of the heightfield is implicitly defined as (1-a).

Parameters
hHeighfField.
See also
TreeNode::Blend(HeightField&) const

References ScalarAlpha::Alpha(), GetBedrock(), GetBox(), Math::Lerp(), and ScalarAlpha::Value().

◆ CreateLayerStack()

LayerStack ArchesTree::CreateLayerStack ( const Array2 a) const

◆ CreateMesh()

Mesh ArchesTree::CreateMesh ( const Circle2 circle,
int  n 
) const

Create a mesh over a disc support.

Parameters
circleThe disc.
nSubdivision.

References bedrock, GetBedrock(), Mesh2::Indexes(), TerraNode::Normal(), Vector2::ToVector(), ScalarAlpha::Value(), Mesh2::Vertex(), and Mesh2::VertexSize().

◆ CreateMeshBorder()

Mesh ArchesTree::CreateMeshBorder ( const Circle2 circle,
int  n 
) const

Create a mesh over a disc support.

Parameters
circleThe disc.
nSubdivision.

References Circle2::Center(), GetBedrock(), Circle2::Radius(), Vector2::ToVector(), ScalarAlpha::Value(), and Mesh::Vertex().

◆ dichotomie()

Vector ArchesTree::dichotomie ( Vector  a,
Vector  b,
double  va,
double  vb 
) const

Find the intersection between the terrain and a segment.

Parameters
a,bSegment.
va,vbValues at vertexes.

References bedrock, TerraNode::ElevationAlpha(), epsilon, ScalarAlpha::Value(), and water.

Referenced by GetTriangles().

◆ GetBedrock()

ScalarAlpha ArchesTree::GetBedrock ( const Vector2 p) const

Compute the bedrock height of a given input point.

Parameters
pPoint.

References bedrock, and TerraNode::ElevationAlpha().

Referenced by Blend(), CreateMesh(), and CreateMeshBorder().

◆ GetFoam()

ScalarAlpha ArchesTree::GetFoam ( const Vector2 p) const

Compute the height of a given input point.

Parameters
pPoint.

References TerraNode::ElevationAlpha().

◆ GetSand()

ScalarAlpha ArchesTree::GetSand ( const Vector2 p) const

Compute the height of a given input point.

Parameters
pPoint.

References TerraNode::ElevationAlpha().

◆ GetWater()

ScalarAlpha ArchesTree::GetWater ( const Vector2 p) const

Compute the height of a given input point.

Parameters
pPoint.

References TerraNode::ElevationAlpha(), and water.

◆ HeightFieldRock()

void ArchesTree::HeightFieldRock ( HeightField &  hf) const

Create a Rock Heightfield.

Parameters
hfHeightfield.

References bedrock, and TerraNode::Sample().

◆ HeightFieldSand()

void ArchesTree::HeightFieldSand ( HeightField &  hf) const

Create a Sand Heightfield.

Parameters
hfHeightfield.

References TerraNode::Sample().

◆ HeightFieldWater()

void ArchesTree::HeightFieldWater ( HeightField &  hf) const

Create a Water Heightfield.

Parameters
hfHeightfield.

References TerraNode::Sample(), and water.

◆ Intersect()

bool ArchesTree::Intersect ( const Ray ray,
double &  t 
) const

Compute the intersection between the surface and a ray.

Parameters
rayThe ray.
tIntersection depth.

References bedrock, and TerraNode::Elevation().

◆ Traversal()

int ArchesTree::Traversal ( const Vector2 p) const

Compute the number of nodes that are traversed when evaluating the tree.

Parameters
pPoint.

References bedrock, TerraNode::Traversal(), and water.