proland::TerrainNode Class Reference
[terrain]

A view dependent, quadtree based terrain. More...

#include <TerrainNode.h>

List of all members.

Public Member Functions

 TerrainNode (ptr< Deformation > deform, ptr< TerrainQuad > root, float splitFactor, int maxLevel)
 Creates a new TerrainNode.
virtual ~TerrainNode ()
 Deletes this TerrainNode.
vec3d getDeformedCamera () const
 Returns the current viewer position in the deformed terrain space (see deform).
const vec4d * getDeformedFrustumPlanes () const
 Returns the current viewer frustum planes in the deformed terrain space (see deform).
vec3d getLocalCamera () const
 Returns the current viewer position in the local terrain space (see deform).
float getCameraDist (const box3d &localBox) const
 Returns the distance between the current viewer position and the given bounding box.
SceneManager::visibility getVisibility (const box3d &localBox) const
 Returns the visibility of the given bounding box from the current viewer position.
float getSplitDistance () const
 Returns the viewer distance at which a quad is subdivided, relatively to the quad size.
float getDistFactor () const
 Returns the ratio between local and deformed lengths at getLocalCamera().
void update (ptr< SceneNode > owner)
 Updates the terrain quadtree based on the current viewer position.
bool addOccluder (const box3d &occluder)
 Adds the given bounding box as an occluder.
bool isOccluded (const box3d &box)
 Returns true if the given bounding box is occluded by the bounding boxes previously added by addOccluder().

Public Attributes

ptr< Deformationdeform
 The deformation of this terrain.
ptr< TerrainQuadroot
 The root of the terrain quadtree.
float splitFactor
 Describes how the terrain quadtree must be subdivided based on the viewer distance.
bool splitInvisibleQuads
 True to subdivide invisible quads based on distance, like visible ones.
bool horizonCulling
 True to perform horizon occlusion culling tests.
int maxLevel
 The maximum level at which the terrain quadtree must be subdivided (inclusive).

Static Public Attributes

static float groundHeightAtCamera
 The terrain elevation below the current viewer position.
static float nextGroundHeightAtCamera
 The value groundHeightAtCamera will have at the next frame.

Protected Member Functions

 TerrainNode ()
 Creates an uninitialized TerrainNode.
void init (ptr< Deformation > deform, ptr< TerrainQuad > root, float splitFactor, int maxLevel)
 Initializes this TerrainNode.

Private Attributes

vec3d deformedCameraPos
 The current viewer position in the deformed terrain space (see deform).
vec4d deformedFrustumPlanes [6]
 The current viewer frustum planes in the deformed terrain space (see deform).
vec3d localCameraPos
 The current viewer position in the local terrain space (see deform).
float splitDist
 The viewer distance at which a quad is subdivided, relatively to the quad size.
float distFactor
 The ratio between local and deformed lengths at localCameraPos.
mat2f localCameraDir
 Local reference frame used to compute horizon occlusion culling.
float * horizon
 Rasterized horizon elevation angle for each azimuth angle.

Detailed Description

A view dependent, quadtree based terrain.

This class provides access to the terrain quadtree, defines the terrain deformation (can be used to get planet sized terrains), and defines how the terrain quadtree must be subdivided based on the viewer position. This class does not give any direct or indirect access to the terrain data (elevations, normals, texture, etc). The terrain data must be managed by proland::TileProducer, and stored in proland::TileStorage. The link between with the terrain quadtree is provided by the TileSampler class.

Authors:
Eric Bruneton, Antoine Begault, Guillaume Piolat

Constructor & Destructor Documentation

proland::TerrainNode::TerrainNode ( ptr< Deformation deform,
ptr< TerrainQuad root,
float  splitFactor,
int  maxLevel 
)

Creates a new TerrainNode.

Parameters:
deform the terrain deformation.
root the root of the terrain quadtree.
splitFactor how the terrain quadtree must be subdivided (see splitFactor).
maxLevel the maximum level at which the terrain quadtree must be subdivided (inclusive).
virtual proland::TerrainNode::~TerrainNode (  )  [virtual]

Deletes this TerrainNode.

proland::TerrainNode::TerrainNode (  )  [protected]

Creates an uninitialized TerrainNode.


Member Function Documentation

bool proland::TerrainNode::addOccluder ( const box3d &  occluder  ) 

Adds the given bounding box as an occluder.

The bounding boxes must be added in front to back order.

Parameters:
occluder a bounding box in local (i.e. non deformed) coordinates.
Returns:
true is the given bounding box is occluded by the bounding boxes previously added as occluders by this method.
float proland::TerrainNode::getCameraDist ( const box3d &  localBox  )  const

Returns the distance between the current viewer position and the given bounding box.

This distance is measured in the local terrain space (with Deformation::getLocalDist), with altitudes divided by getDistFactor() to take deformations into account.

vec3d proland::TerrainNode::getDeformedCamera (  )  const

Returns the current viewer position in the deformed terrain space (see deform).

This position is updated by the update method.

const vec4d* proland::TerrainNode::getDeformedFrustumPlanes (  )  const

Returns the current viewer frustum planes in the deformed terrain space (see deform).

These planes are updated by the update method.

float proland::TerrainNode::getDistFactor (  )  const

Returns the ratio between local and deformed lengths at getLocalCamera().

vec3d proland::TerrainNode::getLocalCamera (  )  const

Returns the current viewer position in the local terrain space (see deform).

This position is updated by the update method.

float proland::TerrainNode::getSplitDistance (  )  const

Returns the viewer distance at which a quad is subdivided, relatively to the quad size.

This relative distance is equal to splitFactor for a field of view of 80 degrees and a viewport width of 1024 pixels. It is larger for smaller field of view angles and/or larger viewports.

SceneManager::visibility proland::TerrainNode::getVisibility ( const box3d &  localBox  )  const

Returns the visibility of the given bounding box from the current viewer position.

This visibility is computed with Deformation::getVisbility.

void proland::TerrainNode::init ( ptr< Deformation deform,
ptr< TerrainQuad root,
float  splitFactor,
int  maxLevel 
) [protected]

Initializes this TerrainNode.

Parameters:
deform the terrain deformation.
root the root of the terrain quadtree.
splitFactor how the terrain quadtree must be subdivided (see splitFactor).
maxLevel the maximum level at which the terrain quadtree must be subdivided (inclusive).
bool proland::TerrainNode::isOccluded ( const box3d &  box  ) 

Returns true if the given bounding box is occluded by the bounding boxes previously added by addOccluder().

Parameters:
box a bounding box in local (i.e. non deformed) coordinates.
Returns:
true is the given bounding box is occluded by the bounding boxes previously added as occluders by addOccluder.
void proland::TerrainNode::update ( ptr< SceneNode >  owner  ) 

Updates the terrain quadtree based on the current viewer position.

The viewer position relatively to the local and deformed terrain spaces is computed based on the given SceneNode, which represents the terrain position in the scene graph (which also contains the current viewer position).

Parameters:
owner the SceneNode representing the terrain position in the global scene graph.

Member Data Documentation

The deformation of this terrain.

In the terrain local space the terrain sea level surface is flat. In the terrain deformed space the sea level surface can be spherical or cylindrical (or flat if the identity deformation is used).

The current viewer position in the deformed terrain space (see deform).

The current viewer frustum planes in the deformed terrain space (see deform).

The ratio between local and deformed lengths at localCameraPos.

The terrain elevation below the current viewer position.

This field must be updated manually by users (the TileSamplerZ class can do this for you). It is used to compute the 3D distance between the viewer and a quad, to decide whether this quad must be subdivided or not.

Rasterized horizon elevation angle for each azimuth angle.

True to perform horizon occlusion culling tests.

Local reference frame used to compute horizon occlusion culling.

The current viewer position in the local terrain space (see deform).

The maximum level at which the terrain quadtree must be subdivided (inclusive).

The terrain quadtree will never be subdivided beyond this level, even if the viewer comes very close to the terrain.

The value groundHeightAtCamera will have at the next frame.

The root of the terrain quadtree.

This quadtree is subdivided based on the current viewer position by the update method.

The viewer distance at which a quad is subdivided, relatively to the quad size.

Describes how the terrain quadtree must be subdivided based on the viewer distance.

For a field of view of 80 degrees, and a viewport width of 1024 pixels, a quad of size L will be subdivided into subquads if the viewer distance is less than splitFactor * L. For a smaller field of view and/or a larger viewport, the quad will be subdivided at a larger distance, so that its size in pixels stays more or less the same. This number must be strictly larger than 1.

True to subdivide invisible quads based on distance, like visible ones.

The default value of this flag is false.


Generated on Sat May 12 09:41:38 2012 for proland by  doxygen 1.6.1