TerrainRoetger Class Reference

Simple LOD terrain implementation. Level Of Detail - Roetger. More...

#include <terrain_roetger.h>

Inherits TerrainClient.

Inheritance diagram for TerrainRoetger:

Inheritance graph
[legend]
Collaboration diagram for TerrainRoetger:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 TerrainRoetger ()
 ~TerrainRoetger ()
virtual void render (void)
 Performs rendering. [CLIENT].
virtual void update (const class Camera *camera)
 Data update (LOD-related things). [CLIENT].
virtual void init (void)
 preprocessing step - offline calculations for LOD
void set_minimum_quality (float minimum_global_res)
void set_desired_quality (float desired_global_res)
float get_minimum_quality (void)
float get_desired_quality (void)
void calculate_roughness (void)
void build_quadtree (const Quadtree::QuadtreeNode &node)
void build_quadtree (void)
void render_quadtree (const Quadtree::QuadtreeNode &node)
void render_quadtree (void)
bool subdivision_criterium (const Quadtree::QuadtreeNode &node)
void init_faces_counter (void)
int faces_counter (void)
void set_location (GLVector3d loc)

Protected Member Functions

virtual bool allocateHeightmap (int sizeX, int sizeY)
 allocates memory and sets the heightmap pointer.

Private Member Functions

double metricsL1 (GLVector3d a, GLVector3d b)
int index (int x, int y)
void add_height_error (int x1, int y1, int x2, int y2, float *max_error)
void emit_vertices (const GLVector3d &v1, const GLVector3d &v2, const GLVector3d &v3)

Private Attributes

Quadtree m_qt
 Quad tree over this terrain, root node size is m_size.
float m_minimum_global_res
float m_desired_global_res
GLVector3d m_location
int m_faces_rendered
 the number of faces rendered
float * m_roughness
Frustum mFrustum

Detailed Description

Simple LOD terrain implementation. Level Of Detail - Roetger.

Note:
This is the specific terrain implementation (where some LOD could be implemented). Implements TerrainClient::render() and possibly TerrainClient::update() methods.

Definition at line 17 of file terrain_roetger.h.


Constructor & Destructor Documentation

TerrainRoetger::TerrainRoetger  ) 
 

Definition at line 6 of file terrain_roetger.cpp.

TerrainRoetger::~TerrainRoetger  ) 
 

Definition at line 14 of file terrain_roetger.cpp.

References m_roughness.


Member Function Documentation

void TerrainRoetger::add_height_error int  x1,
int  y1,
int  x2,
int  y2,
float *  max_error
[private]
 

Definition at line 118 of file terrain_roetger.cpp.

References TerrainBase::getScaledHeight().

Referenced by calculate_roughness().

Here is the call graph for this function:

bool TerrainRoetger::allocateHeightmap int  sizeX,
int  sizeY
[protected, virtual]
 

allocates memory and sets the heightmap pointer.

Parameters:
sizeX the size of the heightmap in x axis
sizeY the size of the heightmap in y axis
Returns:
false, if there is not enough memory ;-)
Note:
If the heightmap was already allocated, it is deleted.

Reimplemented from TerrainBase.

Definition at line 24 of file terrain_roetger.cpp.

References Quadtree::Alloc(), TerrainBase::allocateHeightmap(), m_qt, and m_roughness.

Here is the call graph for this function:

void TerrainRoetger::build_quadtree void   )  [inline]
 

Recursively builds the quadtree of this terrain.

See also:
build_quadtree(node)

Definition at line 43 of file terrain_roetger.h.

References Quadtree::get_root(), and m_qt.

Referenced by build_quadtree(), set_minimum_quality(), and update().

Here is the call graph for this function:

void TerrainRoetger::build_quadtree const Quadtree::QuadtreeNode node  ) 
 

Recursively builds the quadtree of this terrain. Works top-down, uses subdivision_criterium(node) to determine whether to subdivide quadtree node or not. Possibly stops building the tree-branch at node of width 1.

Parameters:
node Starting node, root at startup.

Definition at line 190 of file terrain_roetger.cpp.

References build_quadtree(), Frustum::classifyPoint(), Quadtree::get_subnodes(), Frustum::getPlane(), m_qt, mFrustum, Frustum::NEGATIVE, Frustum::PL_BOTTOM, Frustum::PL_TOP, Quadtree::set_leaf(), Quadtree::set_node(), subdivision_criterium(), Quadtree::QuadtreeNode::width, Quadtree::QuadtreeNode::x, and Quadtree::QuadtreeNode::y.

Here is the call graph for this function:

void TerrainRoetger::calculate_roughness void   ) 
 

Definition at line 130 of file terrain_roetger.cpp.

References add_height_error(), TerrainBase::getExtents(), index(), m_minimum_global_res, and m_roughness.

Referenced by init(), and set_minimum_quality().

Here is the call graph for this function:

void TerrainRoetger::emit_vertices const GLVector3d &  v1,
const GLVector3d &  v2,
const GLVector3d &  v3
[private]
 

Definition at line 235 of file terrain_roetger.cpp.

References m_faces_rendered.

Referenced by render_quadtree().

int TerrainRoetger::faces_counter void   )  [inline]
 

Definition at line 61 of file terrain_roetger.h.

References m_faces_rendered.

float TerrainRoetger::get_desired_quality void   )  [inline]
 

Definition at line 30 of file terrain_roetger.h.

References m_desired_global_res.

float TerrainRoetger::get_minimum_quality void   )  [inline]
 

Definition at line 29 of file terrain_roetger.h.

References m_minimum_global_res.

int TerrainRoetger::index int  x,
int  y
[inline, private]
 

Definition at line 73 of file terrain_roetger.h.

References TerrainBase::getExtents().

Referenced by calculate_roughness(), and subdivision_criterium().

Here is the call graph for this function:

void TerrainRoetger::init void   )  [virtual]
 

preprocessing step - offline calculations for LOD

Reimplemented from TerrainClient.

Definition at line 19 of file terrain_roetger.cpp.

References calculate_roughness().

Here is the call graph for this function:

void TerrainRoetger::init_faces_counter void   )  [inline]
 

Definition at line 60 of file terrain_roetger.h.

References m_faces_rendered.

double TerrainRoetger::metricsL1 GLVector3d  a,
GLVector3d  b
[inline, private]
 

Definition at line 70 of file terrain_roetger.h.

Referenced by subdivision_criterium().

void TerrainRoetger::render void   )  [virtual]
 

Performs rendering. [CLIENT].

Possibly "only" sends data to OpenGL API.

Implements TerrainClient.

Definition at line 51 of file terrain_roetger.cpp.

References TerrainBase::getExtents(), TerrainBase::getRealScale(), TerrainClient::mGlobalTexture, and render_quadtree().

Here is the call graph for this function:

void TerrainRoetger::render_quadtree void   )  [inline]
 

Definition at line 47 of file terrain_roetger.h.

References Quadtree::get_root(), and m_qt.

Referenced by render(), and render_quadtree().

Here is the call graph for this function:

void TerrainRoetger::render_quadtree const Quadtree::QuadtreeNode node  ) 
 

Definition at line 243 of file terrain_roetger.cpp.

References emit_vertices(), Quadtree::get_neighbor(), Quadtree::get_subnodes(), TerrainBase::getTrueHeight(), Quadtree::is_subdivided(), m_qt, Quadtree::n_left, Quadtree::n_up, render_quadtree(), Quadtree::QuadtreeNode::width, Quadtree::QuadtreeNode::x, and Quadtree::QuadtreeNode::y.

Here is the call graph for this function:

void TerrainRoetger::set_desired_quality float  desired_global_res  ) 
 

Definition at line 113 of file terrain_roetger.cpp.

References m_desired_global_res.

void TerrainRoetger::set_location GLVector3d  loc  )  [inline]
 

Definition at line 63 of file terrain_roetger.h.

References m_location.

void TerrainRoetger::set_minimum_quality float  minimum_global_res  ) 
 

Definition at line 102 of file terrain_roetger.cpp.

References build_quadtree(), calculate_roughness(), and m_minimum_global_res.

Here is the call graph for this function:

bool TerrainRoetger::subdivision_criterium const Quadtree::QuadtreeNode node  )  [inline]
 

Computes subdivision criterium of the given node.

Returns:
True for subdivide, otherwise false.

Definition at line 53 of file terrain_roetger.h.

References index(), m_desired_global_res, m_location, m_minimum_global_res, m_roughness, metricsL1(), Quadtree::QuadtreeNode::width, Quadtree::QuadtreeNode::x, and Quadtree::QuadtreeNode::y.

Referenced by build_quadtree().

Here is the call graph for this function:

void TerrainRoetger::update const class Camera camera  )  [virtual]
 

Data update (LOD-related things). [CLIENT].

This is usually a *very* time consuming task. However, it should be performed once a frame, because it takes care about LOD. In good implementation, it should be time-constrained, for example by the maximal number of used triangles.

Reimplemented from TerrainClient.

Definition at line 32 of file terrain_roetger.cpp.

References build_quadtree(), TerrainBase::getRealScale(), TerrainBase::getRealScaleInv(), m_location, mFrustum, and Frustum::transform().

Here is the call graph for this function:


Member Data Documentation

float TerrainRoetger::m_desired_global_res [private]
 

Definition at line 84 of file terrain_roetger.h.

Referenced by get_desired_quality(), set_desired_quality(), and subdivision_criterium().

int TerrainRoetger::m_faces_rendered [private]
 

the number of faces rendered

Definition at line 87 of file terrain_roetger.h.

Referenced by emit_vertices(), faces_counter(), and init_faces_counter().

GLVector3d TerrainRoetger::m_location [private]
 

Definition at line 85 of file terrain_roetger.h.

Referenced by set_location(), subdivision_criterium(), and update().

float TerrainRoetger::m_minimum_global_res [private]
 

Definition at line 83 of file terrain_roetger.h.

Referenced by calculate_roughness(), get_minimum_quality(), set_minimum_quality(), and subdivision_criterium().

Quadtree TerrainRoetger::m_qt [private]
 

Quad tree over this terrain, root node size is m_size.

Definition at line 81 of file terrain_roetger.h.

Referenced by allocateHeightmap(), build_quadtree(), and render_quadtree().

float* TerrainRoetger::m_roughness [private]
 

Definition at line 88 of file terrain_roetger.h.

Referenced by allocateHeightmap(), calculate_roughness(), subdivision_criterium(), and ~TerrainRoetger().

Frustum TerrainRoetger::mFrustum [private]
 

Definition at line 90 of file terrain_roetger.h.

Referenced by build_quadtree(), and update().


The documentation for this class was generated from the following files:
Generated on Wed Apr 12 14:30:40 2006 for bjs by  doxygen 1.4.5