Visualization Library

A lightweight C++ OpenGL middleware for 2D/3D graphics
[Home] [Tutorials] [All Classes] [Grouped Classes]

vl::Terrain Class Reference

The Terrain class implements a ActorKdTree-based terrain scene manager. More...

#include <Terrain.hpp>

Inheritance diagram for vl::Terrain:

vl::SceneManagerActorKdTree vl::SceneManagerBVH< ActorKdTree > vl::SceneManager vl::Object

List of all members.

Public Member Functions

virtual const char * className ()
 Returns the name of the class.
 Terrain ()
void init ()
bool useGLSL () const
int detailRepetitionMode () const
double width () const
double depth () const
double height () const
const vec3origin () const
const StringdetailTexture () const
const StringterrainTexture () const
const StringheightmapTexture () const
ETextureFormat heightmapTextureFormat () const
ETextureFormat terrainTextureFormat () const
ETextureFormat detailTextureFormat () const
void setUseGLSL (bool enable)
void setDetailRepetitionCount (int count)
void setWidth (double w)
void setDepth (double d)
void setHeight (double h)
void setOrigin (const vec3 &origin)
void setHeightmapTextureFormat (ETextureFormat format)
void setTerrainTextureFormat (ETextureFormat format)
void setDetailTextureFormat (ETextureFormat format)
void setVertexShader (const String &vs_path)
const StringvertexShader () const
void setFragmentShader (const String &fs_path)
const StringfragmentShader () const
const ActorCollectionchunks () const
int chunkCount () const
Actorchunk (int i)
const Actorchunk (int i) const
void setDetailTexture (const String &texture)
 Sets the texture to be used as detail texture, it can be of any size.
void setTerrainTexture (const String &texture)
 Sets the texture to be used as the base terrain texture.
void setHeightmapTexture (const String &texture)
 Sets the texture to be used as the heightmap.
const ShaderNodeshaderNode () const
ShaderNodeshaderNode ()

Protected Attributes

ref< ShaderNodemShaderNode
ActorCollection mChunks
double mWidth
double mHeight
double mDepth
vec3 mOrigin
String mDetailTexture
String mTerrainTexture
String mHeightmapTexture
String mVertexShader
String mFragmentShader
int mDetailRepetitionCount
ETextureFormat mHeightmapTextureFormat
ETextureFormat mTerrainTextureFormat
ETextureFormat mDetailTextureFormat
bool mUseGLSL


Detailed Description

The Terrain class implements a ActorKdTree-based terrain scene manager.

Some applications do not need complex LOD or CLOD management algorithms to display height fields or terrains, either because the data displayed has a limited size or because particular constraints are applied to the camera (like in RTS games for example) for which only a limited portion of the terrain is visible at a given time.

This applications can greatly benefit from the vl::Terrain scene manager which implements a fool-proof, high-precision (8, 16 and 32 bits heightmaps are supported) and efficient terrain/heightfield generation and management system. All the user has to provide is a texture for the terrain, a heightfield image and a detail texture following very simple and precise guidelines.

The vl::Terrain class takes care of all the rest, like dividing the provided images into chunks, generating the geometry, generating the kd-tree, computing the appropriate texture coordinates in order to prevent seams and so on.

If the OpenGL Shading Language is available, the vl::Terrain class can also store the heightmap directly on the GPU and can generate the geometry on the fly using a technique called "vertex texture fetch" (http://developer.nvidia.com/object/using_vertex_textures.html). This technique allows the application to save GPU memory and to manage even greater terrain databases at a higher speed.

See also:
setTerrainTexture(), setHeightmapTexture(), setDetailTexture()

Constructor & Destructor Documentation

vl::Terrain::Terrain (  )  [inline]


Member Function Documentation

virtual const char* vl::Terrain::className (  )  [inline, virtual]

Returns the name of the class.

Reimplemented from vl::SceneManagerActorKdTree.

void Terrain::init (  ) 

bool vl::Terrain::useGLSL (  )  const [inline]

int vl::Terrain::detailRepetitionMode (  )  const [inline]

double vl::Terrain::width (  )  const [inline]

double vl::Terrain::depth (  )  const [inline]

double vl::Terrain::height (  )  const [inline]

const vec3& vl::Terrain::origin (  )  const [inline]

const String& vl::Terrain::detailTexture (  )  const [inline]

const String& vl::Terrain::terrainTexture (  )  const [inline]

const String& vl::Terrain::heightmapTexture (  )  const [inline]

ETextureFormat vl::Terrain::heightmapTextureFormat (  )  const [inline]

ETextureFormat vl::Terrain::terrainTextureFormat (  )  const [inline]

ETextureFormat vl::Terrain::detailTextureFormat (  )  const [inline]

void vl::Terrain::setUseGLSL ( bool  enable  )  [inline]

void vl::Terrain::setDetailRepetitionCount ( int  count  )  [inline]

void vl::Terrain::setWidth ( double  w  )  [inline]

void vl::Terrain::setDepth ( double  d  )  [inline]

void vl::Terrain::setHeight ( double  h  )  [inline]

void vl::Terrain::setOrigin ( const vec3 origin  )  [inline]

void vl::Terrain::setHeightmapTextureFormat ( ETextureFormat  format  )  [inline]

void vl::Terrain::setTerrainTextureFormat ( ETextureFormat  format  )  [inline]

void vl::Terrain::setDetailTextureFormat ( ETextureFormat  format  )  [inline]

void vl::Terrain::setVertexShader ( const String vs_path  )  [inline]

const String& vl::Terrain::vertexShader (  )  const [inline]

void vl::Terrain::setFragmentShader ( const String fs_path  )  [inline]

const String& vl::Terrain::fragmentShader (  )  const [inline]

const ActorCollection& vl::Terrain::chunks (  )  const [inline]

int vl::Terrain::chunkCount (  )  const [inline]

Actor* vl::Terrain::chunk ( int  i  )  [inline]

const Actor* vl::Terrain::chunk ( int  i  )  const [inline]

void vl::Terrain::setDetailTexture ( const String texture  )  [inline]

Sets the texture to be used as detail texture, it can be of any size.

void vl::Terrain::setTerrainTexture ( const String texture  )  [inline]

Sets the texture to be used as the base terrain texture.

Its size must be of the form: n * d - n + 1 where:

  • 'n' is any positive integer. 'n' is the value passed to setChunkSubdivision().
  • 'd' is a power of 2 and defines the dimension of the texture applied to each terrain chunk. For example: for a terrain with 8x8 chunks each of which with a 256x256 texture we have: 8*256-8+1 = 2041 = x and y size of the texture image.

void vl::Terrain::setHeightmapTexture ( const String texture  )  [inline]

Sets the texture to be used as the heightmap.

Its size must be of the form: n * d - n + 1 where:

  • 'n' is any positive integer. 'n' is the value passed to setChunkSubdivision().
  • 'd' is a power of 2 and defines the dimension of the heightmap portion used to build each terrain chunk. For example: for a terrain with 8x8 chunks each of which with a 256x256 heightmap we have: 8*256-8+1 = 2041 = x and y size of the heightmap image.

const ShaderNode* vl::Terrain::shaderNode (  )  const [inline]

ShaderNode* vl::Terrain::shaderNode (  )  [inline]


Member Data Documentation

double vl::Terrain::mWidth [protected]

double vl::Terrain::mHeight [protected]

double vl::Terrain::mDepth [protected]

bool vl::Terrain::mUseGLSL [protected]


The documentation for this class was generated from the following files:

Visualization Library v2010.06 Reference Documentation
Copyright 2005-2009 Michele Bosi. All rights reserved.
Updated on Tue Jun 1 00:57:28 2010.
Permission is granted to use this page to write and publish articles regarding Visualization Library.