vtlib library
Public Member Functions | List of all members
SMTerrain Class Reference
Inheritance diagram for SMTerrain:
Inheritance graph

Public Member Functions

DTErr Init (const vtElevationGrid *pGrid, float fZScale)
- Public Member Functions inherited from vtDynTerrainGeom
DTErr BasicInit (const vtElevationGrid *pGrid)
virtual void SetPolygonTarget (int iPolygonCount)
int GetPolygonTarget () const
int NumDrawnTriangles () const
- Public Member Functions inherited from vtDynGeom
int IsVisible (const FSphere &sphere) const
int IsVisible (const FPoint3 &point0, const FPoint3 &point1, const FPoint3 &point2, const float fTolerance=0.0f) const
int IsVisible (const FPoint3 &point, float radius) const
bool IsVisible (const FPoint3 &point) const
- Public Member Functions inherited from vtGeode
void AddMesh (vtMesh *pMesh, int iMatIdx)
void RemoveMesh (vtMesh *pMesh)
void RemoveAllMeshes ()
void AddTextMesh (vtTextMesh *pMesh, int iMatIdx, bool bOutline=true)
uint NumMeshes () const
vtMeshGetMesh (int i) const
vtTextMeshGetTextMesh (int i) const
- Public Member Functions inherited from NodeExtension
void SetEnabled (bool bOn)
bool GetEnabled () const
void SetCastShadow (bool b)
 Set this node to cast a shadow, if it is under a vtShadow node. Default is false.
bool GetCastShadow ()
 Get whether this node casts a shadow.
void GetBoundSphere (FSphere &sphere, bool bGlobal=false)
 Get the Bounding Sphere of the node.

Detailed Description

The SMTerrain class implements Seumas McNally's algorithm for regular-grid terrain LOD. It was implemented directly from correspondence from the dearly missed Seumas, and is highly similar to the implementation in his game Treadmarks.
This implementation requires that the input heightfield is a square regular grid of dimension 2^n+1, e.g.. 1025, 2049, or 4097. Storage requirements are around 3-5 bytes/vertex. The data is represented in memory by a regular grid of height values, an implicit binary tree of variance values, and an explicit binary tree of visible faces.
This is the fastest and most memory-efficient algorithm currently known for terrain rendering with a long viewing distance and an unconstrained viewpoint.


  1. Create a new SMTerrain object
  2. Initialize it with a LocalGrid to provide height values
  3. add it to your scene graph
  4. set the desired level detail with SetPolygonTarget()
  5. let the scene graph API render the terrain for you each frame