Terra 1.0
TerraField Class Reference

A virtual class for coding nodes whoses material functions are coded as an elevation map. More...

#include <archestree.h>

Inheritance diagram for TerraField:
TerraPrimitive TerraNode TerraBoxImage TerraCubicImage TerraQuadrangleImage TerraVertexImage

Public Member Functions

 TerraField (const QString &)
 Create the node.
 
 TerraField (const QString &, const QString &)
 Create an image primitive.
 
- Public Member Functions inherited from TerraPrimitive
 TerraPrimitive (const double &=1.0, const double &=1.0)
 Create a primitive.
 
 ~TerraPrimitive ()
 Recusively destroy the sub-trees.
 
int Traversal (const Vector2 &) const
 Compute the number of nodes that are traversed when evaluating the tree.
 
double Alpha (const double &) const
 Compute the falloff function.
 
- Public Member Functions inherited from TerraNode
 TerraNode (const Box2 &=Box2::Infinity)
 Create a node.
 
virtual Box2 GetBox () const
 Returns the bouding box of a node.
 
virtual ScalarAlpha ElevationAlpha (const Vector2 &) const
 Compute the elevation and weight.
 
virtual double Elevation (const Vector2 &) const
 Compute the elevation at a given position.
 
virtual double Alpha (const Vector2 &) const
 Compute the alpha mask at a given position.
 
virtual Vector2 Gradient (const Vector2 &) const
 Compute the gradient at a given position.
 
virtual Vector Normal (const Vector2 &) const
 Compute the normal at a given position.
 
virtual void writeJson (QJsonObject &)
 Compute the Json Document of the subtree.
 
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.
 
ScalarField2 Alpha (const Array2 &) const
 Create a discrete scalar field by sampling the elevation over a given domain.
 
void Blend (HeightField &) const
 Blend a given node with an existing terrain over an input heightfield.
 
void Add (HeightField &) const
 Add a given node with an existing heightfield.
 
virtual void Draw (QGraphicsScene &) const
 Renders the node into a QGraphicsScene.
 

Static Public Member Functions

static void Store (const ScalarField2 &, const QString &)
 Store an image in the set of image instances.
 
static void Store (const QImage &, const QString &)
 Store an image in the set of image instances.
 
static void Store (const QString &, const QString &)
 Store an image in the set of image instances.
 

Protected Member Functions

const ScalarField2GetImage (int) const
 Get the reference to the k-th image in the atlas.
 

Static Protected Member Functions

static bool ExistsInStorage (const QString &)
 Checks if an image exists in the atlas.
 
static int IndexInStorage (const QString &)
 Checks if an image exists in the atlas, and returns its index.
 

Protected Attributes

int alf = -1
 Indexes storing the reference to the field and the alpha mask.
 
- Protected Attributes inherited from TerraPrimitive
double alpha = 1.0
 Weight.
 
- Protected Attributes inherited from TerraNode
Box2 box = Box2::Infinity
 Bounding box.
 

Static Protected Attributes

static QVector< ScalarField2images
 Set of images that will be shared by the instances of TerraField.
 
static QVector< QString > aliases
 Identifier as names of the images.
 
- Static Protected Attributes inherited from TerraNode
static const double epsilon = 1e-2
 Epsilon value for gradient computations.
 

Detailed Description

A virtual class for coding nodes whoses material functions are coded as an elevation map.

Constructor & Destructor Documentation

◆ TerraField() [1/2]

TerraField::TerraField ( const QString & alias)

◆ TerraField() [2/2]

TerraField::TerraField ( const QString & h,
const QString & a )

Create an image primitive.

Parameters
imageThe image.
aliasAlias.

References alf, and IndexInStorage().

Member Function Documentation

◆ ExistsInStorage()

bool TerraField::ExistsInStorage ( const QString & alias)
staticprotected

Checks if an image exists in the atlas.

Parameters
aliasName.

References aliases.

Referenced by Store(), Store(), and Store().

◆ GetImage()

const ScalarField2 & TerraField::GetImage ( int k) const
inlineprotected

Get the reference to the k-th image in the atlas.

This internal function is only provided to simplifiy notations in the code.

Parameters
kIndex.

References images.

Referenced by TerraBoxImage::ElevationAlpha(), TerraQuadrangleImage::ElevationAlpha(), and TerraVertexImage::ElevationAlpha().

◆ IndexInStorage()

int TerraField::IndexInStorage ( const QString & alias)
staticprotected

Checks if an image exists in the atlas, and returns its index.

Parameters
aliasName.

References aliases.

Referenced by TerraField(), and TerraField().

◆ Store() [1/3]

void TerraField::Store ( const QImage & image,
const QString & alias )
static

Store an image in the set of image instances.

Parameters
imageThe image.
aliasAlias.

References aliases, ExistsInStorage(), images, and Box2::Unit.

◆ Store() [2/3]

void TerraField::Store ( const QString & image,
const QString & alias )
static

Store an image in the set of image instances.

Parameters
imageThe image.
aliasAlias.

References ExistsInStorage(), and Store().

◆ Store() [3/3]

void TerraField::Store ( const ScalarField2 & image,
const QString & alias )
static

Store an image in the set of image instances.

Parameters
imageThe image.
aliasAlias.

References aliases, ExistsInStorage(), and images.

Referenced by Store().