Terra 1.0
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.
 
 ~ArchesTree ()
 Deletes the tree structure.
 
ScalarAlpha GetBedrock (const Vector2 &) const
 Compute the bedrock height of a given input point.
 
ScalarAlpha GetWater (const Vector2 &) const
 Compute the height of a given input point.
 
ScalarAlpha GetFoam (const Vector2 &) const
 Compute the height of a given input point.
 
ScalarAlpha GetSand (const Vector2 &) const
 Compute the height of a given input point.
 
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.
 
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.
 
bool Intersect (const Ray &, double &) const
 Compute the intersection between the surface and a ray.
 
Mesh CreateMesh (const Circle2 &, int) const
 Create a mesh over a disc support.
 
Mesh CreateMeshBorder (const Circle2 &, int) const
 Create a mesh over a disc support.
 
void HeightFieldRock (HeightField &) const
 Create a Rock Heightfield.
 
void HeightFieldWater (HeightField &) const
 Create a Water Heightfield.
 
void HeightFieldSand (HeightField &) const
 Create a Sand Heightfield.
 
LayerStack CreateLayerStack (const Array2 &) const
 Create a LayerStack.
 
void Blend (HeightField &) const
 Blend a given node with an existing terrain over an input heightfield.
 

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

Create a LayerStack.

Parameters
aThe grid array.

References ScalarAlpha::Alpha(), bedrock, Array2::GetBox(), Array2::GetSizeX(), Array2::GetSizeY(), ScalarAlpha::Value(), and water.

◆ CreateMesh()

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

Create a mesh over a disc support.

Parameters
circleThe disc.
nSubdivision.

References bedrock, Mesh2::Indexes(), Vector2::ToVector(), 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, 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.

Referenced by Blend(), and CreateMeshBorder().

◆ GetFoam()

ScalarAlpha ArchesTree::GetFoam ( const Vector2 & p) const

Compute the height of a given input point.

Parameters
pPoint.

◆ GetSand()

ScalarAlpha ArchesTree::GetSand ( const Vector2 & p) const

Compute the height of a given input point.

Parameters
pPoint.

◆ GetWater()

ScalarAlpha ArchesTree::GetWater ( const Vector2 & p) const

Compute the height of a given input point.

Parameters
pPoint.

References water.

◆ HeightFieldRock()

void ArchesTree::HeightFieldRock ( HeightField & hf) const

Create a Rock Heightfield.

Parameters
hfHeightfield.

References bedrock.

◆ HeightFieldSand()

void ArchesTree::HeightFieldSand ( HeightField & hf) const

Create a Sand Heightfield.

Parameters
hfHeightfield.

◆ HeightFieldWater()

void ArchesTree::HeightFieldWater ( HeightField & hf) const

Create a Water Heightfield.

Parameters
hfHeightfield.

References 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.

◆ Traversal()

int ArchesTree::Traversal ( const Vector2 & p) const

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

Parameters
pPoint.

References bedrock, and water.