Visualization Library v1.0.3

A lightweight C++ OpenGL middleware for 2D/3D graphics

VL     Star     Watch     Fork     Issue

[Download] [Tutorials] [All Classes] [Grouped Classes]
Public Member Functions | Protected Attributes

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

 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()

Definition at line 63 of file Terrain.hpp.


Constructor & Destructor Documentation

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

Definition at line 68 of file Terrain.hpp.


Member Function Documentation

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

Definition at line 78 of file Terrain.hpp.

Referenced by init().

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

Definition at line 79 of file Terrain.hpp.

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

Definition at line 80 of file Terrain.hpp.

Referenced by init().

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

Definition at line 81 of file Terrain.hpp.

Referenced by init().

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

Definition at line 82 of file Terrain.hpp.

Referenced by init().

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

Definition at line 83 of file Terrain.hpp.

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

Definition at line 84 of file Terrain.hpp.

Referenced by init().

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

Definition at line 85 of file Terrain.hpp.

Referenced by init().

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

Definition at line 86 of file Terrain.hpp.

Referenced by init().

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

Definition at line 87 of file Terrain.hpp.

Referenced by init().

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

Definition at line 88 of file Terrain.hpp.

Referenced by init().

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

Definition at line 89 of file Terrain.hpp.

Referenced by init().

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

Definition at line 91 of file Terrain.hpp.

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

Definition at line 92 of file Terrain.hpp.

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

Definition at line 93 of file Terrain.hpp.

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

Definition at line 94 of file Terrain.hpp.

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

Definition at line 95 of file Terrain.hpp.

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

Definition at line 96 of file Terrain.hpp.

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

Definition at line 97 of file Terrain.hpp.

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

Definition at line 98 of file Terrain.hpp.

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

Definition at line 99 of file Terrain.hpp.

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

Definition at line 101 of file Terrain.hpp.

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

Definition at line 102 of file Terrain.hpp.

Referenced by init().

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

Definition at line 104 of file Terrain.hpp.

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

Definition at line 105 of file Terrain.hpp.

Referenced by init().

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

Definition at line 107 of file Terrain.hpp.

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

Definition at line 108 of file Terrain.hpp.

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

Definition at line 109 of file Terrain.hpp.

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

Definition at line 110 of file Terrain.hpp.

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

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

Definition at line 115 of file Terrain.hpp.

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.

Definition at line 123 of file Terrain.hpp.

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.

Definition at line 131 of file Terrain.hpp.

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

Definition at line 133 of file Terrain.hpp.

Referenced by init().

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

Definition at line 134 of file Terrain.hpp.


Member Data Documentation

Definition at line 137 of file Terrain.hpp.

Definition at line 138 of file Terrain.hpp.

Referenced by init().

double vl::Terrain::mWidth [protected]

Definition at line 139 of file Terrain.hpp.

Referenced by init().

double vl::Terrain::mHeight [protected]

Definition at line 140 of file Terrain.hpp.

Referenced by init().

double vl::Terrain::mDepth [protected]

Definition at line 141 of file Terrain.hpp.

Referenced by init().

Definition at line 142 of file Terrain.hpp.

Referenced by init().

Definition at line 143 of file Terrain.hpp.

Definition at line 144 of file Terrain.hpp.

Definition at line 145 of file Terrain.hpp.

Definition at line 146 of file Terrain.hpp.

Definition at line 147 of file Terrain.hpp.

Definition at line 148 of file Terrain.hpp.

Referenced by init().

Definition at line 149 of file Terrain.hpp.

Definition at line 150 of file Terrain.hpp.

Definition at line 151 of file Terrain.hpp.

bool vl::Terrain::mUseGLSL [protected]

Definition at line 152 of file Terrain.hpp.


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

Visualization Library v1.0.3 Reference Documentation
Copyright Michele Bosi. All rights reserved.
Updated on Tue Feb 7 2017 00:55:12.
Permission is granted to use this page to write and publish articles regarding Visualization Library.