Visualization Library 2.1.0

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

VL     Star     Watch     Fork     Issue

[Download] [Tutorials] [All Classes] [Grouped Classes]
Terrain.hpp
Go to the documentation of this file.
1 /**************************************************************************************/
2 /* */
3 /* Visualization Library */
4 /* http://visualizationlibrary.org */
5 /* */
6 /* Copyright (c) 2005-2020, Michele Bosi */
7 /* All rights reserved. */
8 /* */
9 /* Redistribution and use in source and binary forms, with or without modification, */
10 /* are permitted provided that the following conditions are met: */
11 /* */
12 /* - Redistributions of source code must retain the above copyright notice, this */
13 /* list of conditions and the following disclaimer. */
14 /* */
15 /* - Redistributions in binary form must reproduce the above copyright notice, this */
16 /* list of conditions and the following disclaimer in the documentation and/or */
17 /* other materials provided with the distribution. */
18 /* */
19 /* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND */
20 /* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED */
21 /* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE */
22 /* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR */
23 /* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES */
24 /* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */
25 /* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON */
26 /* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */
27 /* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS */
28 /* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
29 /* */
30 /**************************************************************************************/
31 
32 #ifndef Terrain_INCLUDE_ONCE
33 #define Terrain_INCLUDE_ONCE
34 
37 
38 namespace vl
39 {
64  {
66 
67  public:
69  mShaderNode(new ShaderNode), mWidth(0), mHeight(0), mDepth(0), mDetailRepetitionCount(0),
70  mHeightmapTextureFormat(TF_LUMINANCE16F), mTerrainTextureFormat(TF_RGB), mDetailTextureFormat(TF_RGB),
71  mUseGLSL(true)
72  {
73  mChunks.setAutomaticDelete(false);
74  }
75 
76  void init();
77 
78  bool useGLSL() const { return mUseGLSL; }
79  int detailRepetitionMode() const { return mDetailRepetitionCount; }
80  double width() const { return mWidth; }
81  double depth() const { return mDepth; }
82  double height() const { return mHeight; }
83  const vec3& origin() const { return mOrigin; }
84  const String& detailTexture() const { return mDetailTexture; }
85  const String& terrainTexture() const { return mTerrainTexture; }
86  const String& heightmapTexture() const { return mHeightmapTexture; }
87  ETextureFormat heightmapTextureFormat() const { return mHeightmapTextureFormat; }
88  ETextureFormat terrainTextureFormat() const { return mTerrainTextureFormat; }
89  ETextureFormat detailTextureFormat() const { return mDetailTextureFormat; }
90 
91  void setUseGLSL(bool enable) { mUseGLSL = enable; }
92  void setDetailRepetitionCount(int count) { mDetailRepetitionCount = count; }
93  void setWidth(double w) { mWidth = w; }
94  void setDepth(double d) { mDepth = d; }
95  void setHeight(double h) { mHeight = h; }
96  void setOrigin(const vec3& origin) { mOrigin = origin; }
97  void setHeightmapTextureFormat(ETextureFormat format) { mHeightmapTextureFormat = format; }
98  void setTerrainTextureFormat(ETextureFormat format) { mTerrainTextureFormat = format; }
99  void setDetailTextureFormat(ETextureFormat format) { mDetailTextureFormat = format; }
100 
101  void setVertexShader(const String& vs_path) { mVertexShader = vs_path; }
102  const String& vertexShader() const { return mVertexShader; }
103 
104  void setFragmentShader(const String& fs_path) { mFragmentShader = fs_path; }
105  const String& fragmentShader() const { return mFragmentShader; }
106 
107  const ActorCollection& chunks() const { return mChunks; }
108  int chunkCount() const { return mChunks.size(); }
109  Actor* chunk(int i) { return mChunks[i].get(); }
110  const Actor* chunk(int i) const { return mChunks[i].get(); }
111 
115  void setDetailTexture(const String& texture) { mDetailTexture = texture; }
123  void setTerrainTexture(const String& texture) { mTerrainTexture = texture; }
131  void setHeightmapTexture(const String& texture) { mHeightmapTexture = texture; }
132 
133  const ShaderNode* shaderNode() const { return mShaderNode.get(); }
134  ShaderNode* shaderNode() { return mShaderNode.get(); }
135 
136  protected:
139  double mWidth;
140  double mHeight;
141  double mDepth;
152  bool mUseGLSL;
153  };
154 }
155 
156 #endif
const ShaderNode * shaderNode() const
Definition: Terrain.hpp:133
Associates a Renderable object to an Effect and Transform.
Definition: Actor.hpp:130
int mDetailRepetitionCount
Definition: Terrain.hpp:148
bool mUseGLSL
Definition: Terrain.hpp:152
ETextureFormat detailTextureFormat() const
Definition: Terrain.hpp:89
ShaderNode * shaderNode()
Definition: Terrain.hpp:134
int detailRepetitionMode() const
Definition: Terrain.hpp:79
The String class implements an advanced UTF16 (Unicode BMP) string manipulation engine.
Definition: String.hpp:62
ActorCollection mChunks
Definition: Terrain.hpp:138
ETextureFormat mDetailTextureFormat
Definition: Terrain.hpp:151
void setDetailTexture(const String &texture)
Sets the texture to be used as detail texture, it can be of any size.
Definition: Terrain.hpp:115
String mDetailTexture
Definition: Terrain.hpp:143
bool useGLSL() const
Definition: Terrain.hpp:78
ETextureFormat terrainTextureFormat() const
Definition: Terrain.hpp:88
The Terrain class implements a ActorKdTree-based terrain scene manager.
Definition: Terrain.hpp:63
ref< ShaderNode > mShaderNode
Definition: Terrain.hpp:137
The ShaderNode class is used to conveniently manage complex hierarchies of Shader[s].
Definition: ShaderNode.hpp:45
ETextureFormat heightmapTextureFormat() const
Definition: Terrain.hpp:87
void setFragmentShader(const String &fs_path)
Definition: Terrain.hpp:104
const String & heightmapTexture() const
Definition: Terrain.hpp:86
#define VL_INSTRUMENT_CLASS(ClassName, BaseClass)
Definition: TypeInfo.hpp:122
int chunkCount() const
Definition: Terrain.hpp:108
String mHeightmapTexture
Definition: Terrain.hpp:145
void setUseGLSL(bool enable)
Definition: Terrain.hpp:91
Visualization Library main namespace.
void setTerrainTextureFormat(ETextureFormat format)
Definition: Terrain.hpp:98
void setOrigin(const vec3 &origin)
Definition: Terrain.hpp:96
ETextureFormat mTerrainTextureFormat
Definition: Terrain.hpp:150
double width() const
Definition: Terrain.hpp:80
double mHeight
Definition: Terrain.hpp:140
ETextureFormat mHeightmapTextureFormat
Definition: Terrain.hpp:149
void setHeight(double h)
Definition: Terrain.hpp:95
void setVertexShader(const String &vs_path)
Definition: Terrain.hpp:101
void setWidth(double w)
Definition: Terrain.hpp:93
void setTerrainTexture(const String &texture)
Sets the texture to be used as the base terrain texture.
Definition: Terrain.hpp:123
double depth() const
Definition: Terrain.hpp:81
double mWidth
Definition: Terrain.hpp:139
const String & fragmentShader() const
Definition: Terrain.hpp:105
const Actor * chunk(int i) const
Definition: Terrain.hpp:110
Actor * chunk(int i)
Definition: Terrain.hpp:109
String mTerrainTexture
Definition: Terrain.hpp:144
void setDetailTextureFormat(ETextureFormat format)
Definition: Terrain.hpp:99
void setHeightmapTexture(const String &texture)
Sets the texture to be used as the heightmap.
Definition: Terrain.hpp:131
double mDepth
Definition: Terrain.hpp:141
double height() const
Definition: Terrain.hpp:82
A SceneManagerBVH that implements its spatial partitioning strategy using an ActorKdTree.
Defined as a simple subclass of Collection<Actor>, see Collection for more information.
Definition: Actor.hpp:479
void setDetailRepetitionCount(int count)
Definition: Terrain.hpp:92
const vec3 & origin() const
Definition: Terrain.hpp:83
String mFragmentShader
Definition: Terrain.hpp:147
const String & detailTexture() const
Definition: Terrain.hpp:84
void setDepth(double d)
Definition: Terrain.hpp:94
vec3 mOrigin
Definition: Terrain.hpp:142
String mVertexShader
Definition: Terrain.hpp:146
const ActorCollection & chunks() const
Definition: Terrain.hpp:107
The ref<> class is used to reference-count an Object.
Definition: Object.hpp:55
const String & terrainTexture() const
Definition: Terrain.hpp:85
ETextureFormat
Definition: vlnamespace.hpp:45
void setHeightmapTextureFormat(ETextureFormat format)
Definition: Terrain.hpp:97
const String & vertexShader() const
Definition: Terrain.hpp:102