Visualization Library 2.0.0
A 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>
Public Member Functions | |
Terrain () | |
void | init () |
bool | useGLSL () const |
int | detailRepetitionMode () const |
double | width () const |
double | depth () const |
double | height () const |
const vec3 & | origin () const |
const String & | detailTexture () const |
const String & | terrainTexture () const |
const String & | heightmapTexture () 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 String & | vertexShader () const |
void | setFragmentShader (const String &fs_path) |
const String & | fragmentShader () const |
const ActorCollection & | chunks () const |
int | chunkCount () const |
Actor * | chunk (int i) |
const Actor * | chunk (int i) const |
void | setDetailTexture (const String &texture) |
Sets the texture to be used as detail texture, it can be of any size. More... | |
void | setTerrainTexture (const String &texture) |
Sets the texture to be used as the base terrain texture. More... | |
void | setHeightmapTexture (const String &texture) |
Sets the texture to be used as the heightmap. More... | |
const ShaderNode * | shaderNode () const |
ShaderNode * | shaderNode () |
Public Member Functions inherited from vl::SceneManagerActorKdTree | |
SceneManagerActorKdTree () | |
Public Member Functions inherited from vl::SceneManagerBVH< ActorKdTree > | |
void | setTree (ActorKdTree *bbh) |
Sets the tree to be used by the scene manager. More... | |
const ActorKdTree * | tree () const |
Returns the tree used by the scene manager. More... | |
ActorKdTree * | tree () |
Returns the tree used by the scene manager. More... | |
virtual void | extractVisibleActors (ActorCollection &list, const Camera *camera) |
Extracts all the enabled and visible Actors contained in the ActorTree hierarchy and appends them to the given ActorCollection. More... | |
virtual void | extractActors (ActorCollection &list) |
Appends all the Actors contained in the scene manager without performing frustum culling or checking enable masks. More... | |
Public Member Functions inherited from vl::SceneManager | |
SceneManager () | |
Constructor. More... | |
virtual void | computeBounds () |
Computes the bounding box and bounding sphere of the scene manager and of all the Actors contained in the SceneManager. More... | |
void | setBoundingSphere (const Sphere &sphere) |
Explicitly set the scene manager's bounding sphere. See also computeBounds(). More... | |
const Sphere & | boundingSphere () const |
Returns the scene manager's bounding sphere. More... | |
void | setBoundingBox (const AABB &bbox) |
Explicitly set the scene manager's bounding sphere. See also computeBounds(). More... | |
const AABB & | boundingBox () const |
Returns the scene manager's bounding box. More... | |
void | setBoundsDirty (bool dirty) |
Flags a scene manager's bounding box and bounding sphere as dirty. The bounds will be recomputed using computeBounds() at the next rendering frame. More... | |
bool | boundsDirty () const |
Returns true if the scene manager's bounds should be recomputed at the next rendering frame. More... | |
void | setCullingEnabled (bool enable) |
Used to enable or disable frustum culling or whichever culling system the scene manager implements. More... | |
bool | cullingEnabled () const |
Used to enable or disable frustum culling or whichever culling system the scene manager implements. More... | |
void | setEnableMask (unsigned int enabled) |
The enable mask to be used by extractVisibleActors() More... | |
unsigned int | enableMask () const |
The enable mask to be used by extractVisibleActors() More... | |
bool | isEnabled (Actor *a) const |
Returns true if "a->enableMask() & enableMask()) != 0" . More... | |
Public Member Functions inherited from vl::Object | |
Object () | |
Constructor. More... | |
Object (const Object &other) | |
Copy constructor: copies the name, ref count mutex and user data. More... | |
Object & | operator= (const Object &other) |
Copy operator: copies the object's name, ref count mutex and user data. More... | |
const std::string & | objectName () const |
The name of the object, by default set to the object's class name. More... | |
void | setObjectName (const char *name) |
The name of the object, by default set to the object's class name in debug builds. More... | |
void | setObjectName (const std::string &name) |
The name of the object, by default set to the object's class name in debug builds. More... | |
void | setRefCountMutex (IMutex *mutex) |
The mutex used to protect the reference counting of an Object across multiple threads. More... | |
IMutex * | refCountMutex () |
The mutex used to protect the reference counting of an Object across multiple threads. More... | |
const IMutex * | refCountMutex () const |
The mutex used to protect the reference counting of an Object across multiple threads. More... | |
int | referenceCount () const |
Returns the number of references of an object. More... | |
void | incReference () const |
Increments the reference count of an object. More... | |
void | decReference () |
Decrements the reference count of an object and deletes it if both automaticDelete() is true the count reaches 0. More... | |
void | setAutomaticDelete (bool autodel_on) |
If set to true the Object is deleted when its reference count reaches 0. More... | |
bool | automaticDelete () const |
If set to true the Object is deleted when its reference count reaches 0. More... | |
template<class T > | |
T * | as () |
Casts an Object to the specified class. More... | |
template<class T > | |
const T * | as () const |
Casts an Object to the specified class. More... | |
Protected Attributes | |
ref< ShaderNode > | mShaderNode |
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 |
Protected Attributes inherited from vl::SceneManagerBVH< ActorKdTree > | |
ref< ActorKdTree > | mBoundingVolumeTree |
Protected Attributes inherited from vl::SceneManager | |
Sphere | mSphere |
AABB | mAABB |
unsigned int | mEnableMask |
bool | mBoundsDirty |
bool | mCullingEnabled |
Protected Attributes inherited from vl::Object | |
std::string | mObjectName |
IMutex * | mRefCountMutex |
int | mReferenceCount |
bool | mAutomaticDelete |
Additional Inherited Members | |
Protected Member Functions inherited from vl::Object | |
virtual | ~Object () |
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.
|
inline |
Definition at line 68 of file Terrain.hpp.
|
inline |
Definition at line 109 of file Terrain.hpp.
|
inline |
Definition at line 110 of file Terrain.hpp.
|
inline |
Definition at line 108 of file Terrain.hpp.
|
inline |
Definition at line 107 of file Terrain.hpp.
|
inline |
Definition at line 81 of file Terrain.hpp.
Referenced by init().
|
inline |
Definition at line 79 of file Terrain.hpp.
|
inline |
Definition at line 84 of file Terrain.hpp.
Referenced by init().
|
inline |
Definition at line 89 of file Terrain.hpp.
Referenced by init().
|
inline |
Definition at line 105 of file Terrain.hpp.
Referenced by init().
|
inline |
Definition at line 82 of file Terrain.hpp.
Referenced by init().
|
inline |
Definition at line 86 of file Terrain.hpp.
Referenced by init().
|
inline |
Definition at line 87 of file Terrain.hpp.
Referenced by init().
void Terrain::init | ( | ) |
Definition at line 43 of file Terrain.cpp.
References vl::ShaderNode::addChild(), vl::Object::as(), vl::Array< T_VectorType, T_Scalar, T_GL_Size, T_GL_Type >::at(), vl::GLSLProgram::attachShader(), 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(), vl::Texture::getTexParameter(), height(), vl::Image::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::Array< T_VectorType, T_Scalar, T_GL_Size, T_GL_Type >::resize(), vl::Vector2< T_Scalar >::s(), vl::Image::sample(), vl::Matrix4< T_Scalar >::scale(), vl::TexParameter::setAnisotropy(), vl::Renderable::setBoundingBox(), vl::Renderable::setBoundingSphere(), vl::Renderable::setBoundsDirty(), vl::Geometry::setColorArray(), vl::ShaderNode::setEnable(), vl::Transform::setLocalAndWorldMatrix(), vl::TexParameter::setMagFilter(), vl::AABB::setMaxCorner(), vl::AABB::setMinCorner(), vl::TexParameter::setMinFilter(), vl::TexEnv::setMode(), vl::ShaderNode::setRenderState(), vl::ShaderNode::setShader(), vl::Geometry::setTexCoordArray(), vl::TextureSampler::setTexture(), vl::Uniform::setUniform(), vl::Actor::setUniform(), vl::GLSLProgram::setUniform(), vl::Shader::setUniform(), vl::Uniform::setUniformF(), vl::Uniform::setUniformI(), vl::Actor::setUniformSet(), vl::TexParameter::setWrapS(), vl::TexParameter::setWrapT(), vl::Effect::shader(), shaderNode(), vl::Image::subImage(), vl::Vector2< T_Scalar >::t(), vl::TEM_MODULATE, terrainTexture(), terrainTextureFormat(), vl::TextureSampler::texture(), 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(), vl::Geometry::vertexArray(), vertexShader(), VL_CHECK, width(), vl::Image::width(), and vl::Vector3< T_Scalar >::y().
|
inline |
Definition at line 83 of file Terrain.hpp.
|
inline |
Definition at line 94 of file Terrain.hpp.
|
inline |
Definition at line 92 of file Terrain.hpp.
|
inline |
Sets the texture to be used as detail texture, it can be of any size.
Definition at line 115 of file Terrain.hpp.
|
inline |
Definition at line 99 of file Terrain.hpp.
|
inline |
Definition at line 104 of file Terrain.hpp.
|
inline |
Definition at line 95 of file Terrain.hpp.
|
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.
|
inline |
Definition at line 97 of file Terrain.hpp.
|
inline |
Definition at line 96 of file Terrain.hpp.
|
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.
|
inline |
Definition at line 98 of file Terrain.hpp.
|
inline |
Definition at line 91 of file Terrain.hpp.
|
inline |
Definition at line 101 of file Terrain.hpp.
|
inline |
Definition at line 93 of file Terrain.hpp.
|
inline |
Definition at line 133 of file Terrain.hpp.
Referenced by init().
|
inline |
Definition at line 134 of file Terrain.hpp.
|
inline |
Definition at line 85 of file Terrain.hpp.
Referenced by init().
|
inline |
Definition at line 88 of file Terrain.hpp.
Referenced by init().
|
inline |
Definition at line 78 of file Terrain.hpp.
Referenced by init().
|
inline |
Definition at line 102 of file Terrain.hpp.
Referenced by init().
|
inline |
Definition at line 80 of file Terrain.hpp.
Referenced by init().
|
protected |
Definition at line 138 of file Terrain.hpp.
Referenced by init().
|
protected |
Definition at line 141 of file Terrain.hpp.
Referenced by init().
|
protected |
Definition at line 148 of file Terrain.hpp.
Referenced by init().
|
protected |
Definition at line 143 of file Terrain.hpp.
|
protected |
Definition at line 151 of file Terrain.hpp.
|
protected |
Definition at line 147 of file Terrain.hpp.
|
protected |
Definition at line 140 of file Terrain.hpp.
Referenced by init().
|
protected |
Definition at line 145 of file Terrain.hpp.
|
protected |
Definition at line 149 of file Terrain.hpp.
|
protected |
Definition at line 142 of file Terrain.hpp.
Referenced by init().
|
protected |
Definition at line 137 of file Terrain.hpp.
|
protected |
Definition at line 144 of file Terrain.hpp.
|
protected |
Definition at line 150 of file Terrain.hpp.
|
protected |
Definition at line 152 of file Terrain.hpp.
|
protected |
Definition at line 146 of file Terrain.hpp.
|
protected |
Definition at line 139 of file Terrain.hpp.
Referenced by init().
Visualization Library 2.0.0 Reference Documentation
Updated on Wed Dec 23 2020 12:44:12.
© Copyright Michele Bosi. All rights reserved.