Terra 1.0
|
This class implements a generic node in the ArchesTree model. More...
#include <archestree.h>
Public Member Functions | |
TerraNode (const Box2 &=Box2::Infinity) | |
Create a node. More... | |
virtual Box2 | GetBox () const |
Returns the bouding box of a node. | |
virtual ScalarAlpha | ElevationAlpha (const Vector2 &) const |
Compute the elevation and weight. More... | |
virtual double | Elevation (const Vector2 &) const |
Compute the elevation at a given position. More... | |
virtual double | Alpha (const Vector2 &) const |
Compute the alpha mask at a given position. More... | |
virtual Vector2 | Gradient (const Vector2 &) const |
Compute the gradient at a given position. More... | |
virtual Vector | Normal (const Vector2 &) const |
Compute the normal at a given position. More... | |
virtual void | writeJson (QJsonObject &) |
Compute the Json Document of the subtree. | |
virtual int | Traversal (const Vector2 &) const |
Compute the number of nodes that are traversed when evaluating the tree. More... | |
virtual int | Memory () const |
Compute the size of a node. | |
ScalarField2 | Sample (const Array2 &) const |
Create a discrete scalar field by sampling the elevation over a given domain. More... | |
ScalarField2 | Alpha (const Array2 &) const |
Create a discrete scalar field by sampling the elevation over a given domain. More... | |
void | Blend (HeightField &) const |
Blend a given node with an existing terrain over an input heightfield. More... | |
void | Add (HeightField &) const |
Add a given node with an existing heightfield. More... | |
virtual void | Draw (QGraphicsScene &) const |
Renders the node into a QGraphicsScene. More... | |
Protected Attributes | |
Box2 | box = Box2::Infinity |
Bounding box. | |
Static Protected Attributes | |
static const double | epsilon = 1e-2 |
Epsilon value for gradient computations. | |
This class implements a generic node in the ArchesTree model.
The default elevation function is set to 0 and the weight to 1.
|
explicit |
void TerraNode::Add | ( | HeightField & | h | ) | const |
Add a given node with an existing heightfield.
h | HeighfField. |
References ScalarAlpha::Alpha(), box, ElevationAlpha(), and ScalarAlpha::Value().
ScalarField2 TerraNode::Alpha | ( | const Array2 & | a | ) | const |
Create a discrete scalar field by sampling the elevation over a given domain.
a | Domain. |
References Alpha(), Array2::ArrayVertex(), Array2::GetSizeX(), and Array2::GetSizeY().
|
virtual |
Compute the alpha mask at a given position.
p | Point. |
References ScalarAlpha::Alpha(), and ElevationAlpha().
Referenced by Alpha().
void TerraNode::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).
h | HeighfField. |
References ScalarAlpha::Alpha(), box, ElevationAlpha(), Math::Lerp(), and ScalarAlpha::Value().
|
virtual |
Renders the node into a QGraphicsScene.
Draws the box.
scene | The scene. |
Reimplemented in TerraBinary, TerraBlend, TerraPlateau, TerraVertex, TerraDisc, TerraCurveThick, TerraAddMusgrave, and TerraOcean.
References box, and Box2::Draw().
Referenced by TerraBinary::Draw(), and TerraAddMusgrave::Draw().
|
virtual |
Compute the elevation at a given position.
This is a shortcut for:
p | Point. |
References ElevationAlpha(), and ScalarAlpha::Value().
Referenced by Gradient(), ArchesTree::Intersect(), and Sample().
|
virtual |
Compute the elevation and weight.
p | Point. |
Reimplemented in TerraRotate, TerraTransform, TerraDunes, TerraGrid, TerraBlend, TerraBlendGrid, TerraUnion, TerraLowest, TerraAdd, TerraSub, TerraReplace, TerraBinaryBlend, Terra2015Replace, TerraPlateau, TerraVertex, TerraDisc, TerraVertexSlope, Terra2013VertexSlopeNoise, TerraVertexNoise, TerraDiscNoise, TerraVertexNoiseRydge, TerraVertexFractal, TerraBox, TerraBoxImage, TerraVertexImage, TerraQuadrangleImage, TerraCubic, TerraCrater, TerraCubicImage, TerraScale, TerraDiscCut, TerraClampWeight, TerraTranslate, TerraWarpNoise, TerraTwist, TerraCircleWarp, Terra2015ReplaceAlpha, Terra2015ReplaceMaxAlpha, TerraSmooth, TerraCurveThick, TerraAddMusgrave, TerraOcean, TerraUnary, TerraOperator, and TerraImages.
Referenced by Add(), Alpha(), Blend(), ArchesTree::CreateLayerStack(), ArchesTree::dichotomie(), Elevation(), TerraRotate::ElevationAlpha(), TerraTransform::ElevationAlpha(), TerraGrid::ElevationAlpha(), TerraLowest::ElevationAlpha(), TerraAdd::ElevationAlpha(), TerraSub::ElevationAlpha(), TerraReplace::ElevationAlpha(), TerraBinaryBlend::ElevationAlpha(), Terra2015Replace::ElevationAlpha(), TerraPlateau::ElevationAlpha(), TerraScale::ElevationAlpha(), TerraDiscCut::ElevationAlpha(), TerraClampWeight::ElevationAlpha(), TerraTranslate::ElevationAlpha(), TerraWarpNoise::ElevationAlpha(), TerraTwist::ElevationAlpha(), TerraCircleWarp::ElevationAlpha(), Terra2015ReplaceAlpha::ElevationAlpha(), Terra2015ReplaceMaxAlpha::ElevationAlpha(), TerraSmooth::ElevationAlpha(), TerraAddMusgrave::ElevationAlpha(), ArchesTree::GetBedrock(), ArchesTree::GetFoam(), ArchesTree::GetSand(), ArchesTree::GetTriangles(), and ArchesTree::GetWater().
Compute the gradient at a given position.
p | Point. |
References Elevation(), and epsilon.
Referenced by Normal().
Compute the normal at a given position.
p | Point. |
References Gradient().
Referenced by ArchesTree::CreateMesh().
ScalarField2 TerraNode::Sample | ( | const Array2 & | a | ) | const |
Create a discrete scalar field by sampling the elevation over a given domain.
a | Domain. |
References Array2::ArrayVertex(), Elevation(), Array2::GetSizeX(), and Array2::GetSizeY().
Referenced by ArchesTree::HeightFieldRock(), ArchesTree::HeightFieldSand(), and ArchesTree::HeightFieldWater().
|
virtual |
Compute the number of nodes that are traversed when evaluating the tree.
p | Point. |
Reimplemented in TerraBinary, TerraUnary, TerraPrimitive, TerraBlend, and TerraAddMusgrave.
Referenced by ArchesTree::Traversal(), TerraBinary::Traversal(), TerraUnary::Traversal(), and TerraAddMusgrave::Traversal().