dtTerrain::SoarXTerrainRenderer Class Reference

This renderer is an integration/implementation of the SoarX terrain rendering algorithm. More...

#include <soarxterrainrenderer.h>

Inheritance diagram for dtTerrain::SoarXTerrainRenderer:

dtTerrain::TerrainDataRenderer dtCore::Base

List of all members.

Public Types

typedef std::map
< dtCore::RefPtr
< PagedTerrainTile >,
DrawableEntry
DrawableMap
 Help minimize some typing...

Public Member Functions

 SoarXTerrainRenderer (const std::string &name="SoarXRenderer")
 Constructs the SoarX renderer.
void OnLoadTerrainTile (PagedTerrainTile &tile)
 This method constructs a SoarXDrawable for the new terrain tile that needs to be loaded.
void OnUnloadTerrainTile (PagedTerrainTile &tile)
 This method updates an internal map of tiles and drawables based on what tiles were unloaded from the terrain.
float GetHeight (float x, float y)
 Gets the height of the terrain at the specified (x,y) coordinates.
osg::Vec3 GetNormal (float x, float y)
 Gets the normal vector at the specified point.
osg::Group * GetRootDrawable ()
 Returns a scene node that encapsulates the renderable terrain.
void SetDetailMultiplier (float value)
 Sets the detail multiplier on the SoarX drawable.
float GetDetailMultiplier () const
 Gets the current detail multiplier.
void SetThreshold (float value)
 Sets the threshold value of the SoarXDrawable.
float GetThreshold () const
 Gets the threshold value of the SoarXDrawable.
void SetTerrainFragmentShader (const std::string &filePath)
 Sets the file containing the fragment shader to use when rendering the terrain.
const std::string & GetTerrainFragmentShader () const
 Gets the file name containing the fragment shader currently in use by the terrain renderer.
void SetEnableFog (bool pEnableFog)
 Tells the terrain whether or not to use the fog variables when rendering the terrain by default there is no fog.

Static Public Attributes

static const float GRADIENT_SCALE = 32.0f
 Used to scale the precalculated gradient values used to render the terrain.

Protected Member Functions

virtual ~SoarXTerrainRenderer ()
 Destroy the renderer.
void InitializeRenderer ()
 This method initializes data for this renderer that is shared amoungst the terrain tiles.
void CreateFragmentShader ()
 Creates the GLSL program object.
void SetupRenderState (PagedTerrainTile &tile, DrawableEntry &entry, osg::StateSet &ss)
 Configures the specified drawable and stateset to use the proper textures and render state for SoarX terrain renderering.
void CheckDetailNoiseCache ()
 Attempts to load the detail noise data from the terrain cache.
void CheckDetailGradientCache ()
 Checks the cache for a detail gradient texture.
void CheckDetailScaleCache ()
 Checks the cache for a detail scale map.
void CheckBaseGradientCache (const PagedTerrainTile &tile, DrawableEntry &entry)
 This method is called for each tile that is loaded.
void CalculateDetailNoise ()
 Builds an array of noise values used to dynamically add more detail to the terrain.

Classes

struct  DrawableEntry
 This structure represents a drawable tile. More...


Detailed Description

This renderer is an integration/implementation of the SoarX terrain rendering algorithm.

The SoarX algorithm is an extension of the original SOAR (Stateless One-pass Adaptive Refinement) algorithm developed by Peter Lindstrom and Valerio Pascucci. The SOAR algorithm itself has several components and features including adaptive refinement, on-the-fly triangle stripping and smooth geomorphing based on projected error. The SoarX implementation extends and improves on some of the shortcomings of the original SOAR terrain rendering solution. The original SoarX algorithm and demo application developed by Andras Balogh can be found at http://web.interware.hu/bandi/ranger.html.


Member Typedef Documentation

typedef std::map<dtCore::RefPtr<PagedTerrainTile>,DrawableEntry> dtTerrain::SoarXTerrainRenderer::DrawableMap

Help minimize some typing...


Constructor & Destructor Documentation

dtTerrain::SoarXTerrainRenderer::SoarXTerrainRenderer ( const std::string &  name = "SoarXRenderer"  ) 

Constructs the SoarX renderer.

Parameters:
name Simple name to assign to this object. Default = "SoarXRenderer"

dtTerrain::SoarXTerrainRenderer::~SoarXTerrainRenderer (  )  [protected, virtual]

Destroy the renderer.


Member Function Documentation

void dtTerrain::SoarXTerrainRenderer::OnLoadTerrainTile ( PagedTerrainTile tile  )  [virtual]

This method constructs a SoarXDrawable for the new terrain tile that needs to be loaded.

Parameters:
tile The new tile.
See also:
SoarXDrawable

Implements dtTerrain::TerrainDataRenderer.

void dtTerrain::SoarXTerrainRenderer::OnUnloadTerrainTile ( PagedTerrainTile tile  )  [virtual]

This method updates an internal map of tiles and drawables based on what tiles were unloaded from the terrain.

Parameters:
tile The tile being unloaded.

Reimplemented from dtTerrain::TerrainDataRenderer.

float dtTerrain::SoarXTerrainRenderer::GetHeight ( float  x,
float  y 
) [virtual]

Gets the height of the terrain at the specified (x,y) coordinates.

Returns:
The height of the terrain at the specified point.

Implements dtTerrain::TerrainDataRenderer.

osg::Vec3 dtTerrain::SoarXTerrainRenderer::GetNormal ( float  x,
float  y 
) [virtual]

Gets the normal vector at the specified point.

Returns:
A vector perpendicular to terrain at the given point.

Implements dtTerrain::TerrainDataRenderer.

osg::Group* dtTerrain::SoarXTerrainRenderer::GetRootDrawable (  )  [inline, virtual]

Returns a scene node that encapsulates the renderable terrain.

Returns:
An OpenSceneGraph group node that contains all the information needed to render the terrain.
Note:
Initialize() is guarenteed to be called before this method by the parent terrain.

Implements dtTerrain::TerrainDataRenderer.

void dtTerrain::SoarXTerrainRenderer::SetDetailMultiplier ( float  value  ) 

Sets the detail multiplier on the SoarX drawable.

See also:
SoarXDrawable::SetDetailMultiplier.

float dtTerrain::SoarXTerrainRenderer::GetDetailMultiplier (  )  const

Gets the current detail multiplier.

Returns:
The current detail multipler. This will equal zero if the SoarXDrawable is not valid.

void dtTerrain::SoarXTerrainRenderer::SetThreshold ( float  value  ) 

Sets the threshold value of the SoarXDrawable.

See also:
SoarXDrawable::SetThreshold()

float dtTerrain::SoarXTerrainRenderer::GetThreshold (  )  const

Gets the threshold value of the SoarXDrawable.

See also:
SoarXDrawable::GetThreshold()

void dtTerrain::SoarXTerrainRenderer::SetTerrainFragmentShader ( const std::string &  filePath  )  [inline]

Sets the file containing the fragment shader to use when rendering the terrain.

Parameters:
filePath The path to the shader file. This path is relative to the Delta3D data path list. The default path is "shaders/terrain.frag".
Note:
This has no affect if the use of fragment shaders has been disabled.

const std::string& dtTerrain::SoarXTerrainRenderer::GetTerrainFragmentShader (  )  const [inline]

Gets the file name containing the fragment shader currently in use by the terrain renderer.

void dtTerrain::SoarXTerrainRenderer::SetEnableFog ( bool  pEnableFog  ) 

Tells the terrain whether or not to use the fog variables when rendering the terrain by default there is no fog.

void dtTerrain::SoarXTerrainRenderer::InitializeRenderer (  )  [protected]

This method initializes data for this renderer that is shared amoungst the terrain tiles.

This includes shaders, textures, some of which are read from the cache if it exists.

void dtTerrain::SoarXTerrainRenderer::CreateFragmentShader (  )  [protected]

Creates the GLSL program object.

void dtTerrain::SoarXTerrainRenderer::SetupRenderState ( PagedTerrainTile tile,
DrawableEntry entry,
osg::StateSet &  ss 
) [protected]

Configures the specified drawable and stateset to use the proper textures and render state for SoarX terrain renderering.

void dtTerrain::SoarXTerrainRenderer::CheckDetailNoiseCache (  )  [protected]

Attempts to load the detail noise data from the terrain cache.

If it is not present, the data will be generated.

void dtTerrain::SoarXTerrainRenderer::CheckDetailGradientCache (  )  [protected]

Checks the cache for a detail gradient texture.

If found, it will load it else it will be generated and then cached if enabled.

void dtTerrain::SoarXTerrainRenderer::CheckDetailScaleCache (  )  [protected]

Checks the cache for a detail scale map.

If found, it will load it, else the data will be generated then cached if enabled.

void dtTerrain::SoarXTerrainRenderer::CheckBaseGradientCache ( const PagedTerrainTile tile,
DrawableEntry entry 
) [protected]

This method is called for each tile that is loaded.

It checks to see if there is a gradient texture in the tile's cache path and if so loads it. If not, the gradient texture is generated and cached if enabled.

void dtTerrain::SoarXTerrainRenderer::CalculateDetailNoise (  )  [protected]

Builds an array of noise values used to dynamically add more detail to the terrain.


Member Data Documentation

const float dtTerrain::SoarXTerrainRenderer::GRADIENT_SCALE = 32.0f [static]

Used to scale the precalculated gradient values used to render the terrain.


http://www.delta3d.org
2.0.0 generated 14 Feb 2008