Visualization Library v1.0.3A lightweight C++ OpenGL middleware for 2D/3D graphics |
[Download] [Tutorials] [All Classes] [Grouped Classes] |
The Terrain class implements a ActorKdTree-based terrain scene manager. More...
#include <Terrain.hpp>
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.
Definition at line 63 of file Terrain.hpp.
vl::Terrain::Terrain | ( | ) | [inline] |
Definition at line 68 of file Terrain.hpp.
void Terrain::init | ( | ) |
Definition at line 43 of file Terrain.cpp.
References vl::ShaderNode::addChild(), vl::ActorKdTree::buildKdTree(), vl::Collection< T >::clear(), depth(), detailTexture(), detailTextureFormat(), vl::String::empty(), vl::EN_CULL_FACE, vl::EN_DEPTH_TEST, vl::Log::error(), fragmentShader(), vl::ref< T >::get(), height(), heightmapTexture(), heightmapTextureFormat(), vl::IN_Propagate, vl::loadImage(), vl::String::loadText(), vl::makeGrid(), vl::max(), mChunks, mDepth, mDetailRepetitionCount, mHeight, mOrigin, mWidth, NULL, vl::Collection< T >::push_back(), vl::Vector4< T_Scalar >::r(), vl::Matrix4< T_Scalar >::scale(), vl::ShaderNode::setEnable(), vl::AABB::setMaxCorner(), vl::AABB::setMinCorner(), vl::ShaderNode::setRenderState(), shaderNode(), vl::TEM_MODULATE, terrainTexture(), terrainTextureFormat(), vl::TPF_LINEAR, vl::TPF_LINEAR_MIPMAP_LINEAR, vl::TPF_NEAREST, vl::TPW_REPEAT, vl::Matrix4< T_Scalar >::translate(), vl::SceneManagerBVH< ActorKdTree >::tree(), vl::ShaderNode::updateHierarchy(), useGLSL(), vertexShader(), VL_CHECK, and width().
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:
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:
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.
ref<ShaderNode> vl::Terrain::mShaderNode [protected] |
Definition at line 137 of file Terrain.hpp.
ActorCollection vl::Terrain::mChunks [protected] |
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().
vec3 vl::Terrain::mOrigin [protected] |
Definition at line 142 of file Terrain.hpp.
Referenced by init().
String vl::Terrain::mDetailTexture [protected] |
Definition at line 143 of file Terrain.hpp.
String vl::Terrain::mTerrainTexture [protected] |
Definition at line 144 of file Terrain.hpp.
String vl::Terrain::mHeightmapTexture [protected] |
Definition at line 145 of file Terrain.hpp.
String vl::Terrain::mVertexShader [protected] |
Definition at line 146 of file Terrain.hpp.
String vl::Terrain::mFragmentShader [protected] |
Definition at line 147 of file Terrain.hpp.
int vl::Terrain::mDetailRepetitionCount [protected] |
Definition at line 148 of file Terrain.hpp.
Referenced by init().
ETextureFormat vl::Terrain::mHeightmapTextureFormat [protected] |
Definition at line 149 of file Terrain.hpp.
ETextureFormat vl::Terrain::mTerrainTextureFormat [protected] |
Definition at line 150 of file Terrain.hpp.
ETextureFormat vl::Terrain::mDetailTextureFormat [protected] |
Definition at line 151 of file Terrain.hpp.
bool vl::Terrain::mUseGLSL [protected] |
Definition at line 152 of file Terrain.hpp.