Visualization Library

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

X:/dropbox/visualizationlibrary/src/vlGraphics/Terrain.hpp

Go to the documentation of this file.
00001 /**************************************************************************************/
00002 /*                                                                                    */
00003 /*  Visualization Library                                                             */
00004 /*  http://www.visualizationlibrary.org                                               */
00005 /*                                                                                    */
00006 /*  Copyright (c) 2005-2010, Michele Bosi                                             */
00007 /*  All rights reserved.                                                              */
00008 /*                                                                                    */
00009 /*  Redistribution and use in source and binary forms, with or without modification,  */
00010 /*  are permitted provided that the following conditions are met:                     */
00011 /*                                                                                    */
00012 /*  - Redistributions of source code must retain the above copyright notice, this     */
00013 /*  list of conditions and the following disclaimer.                                  */
00014 /*                                                                                    */
00015 /*  - Redistributions in binary form must reproduce the above copyright notice, this  */
00016 /*  list of conditions and the following disclaimer in the documentation and/or       */
00017 /*  other materials provided with the distribution.                                   */
00018 /*                                                                                    */
00019 /*  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND   */
00020 /*  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED     */
00021 /*  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE            */
00022 /*  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR  */
00023 /*  ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES    */
00024 /*  (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;      */
00025 /*  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON    */
00026 /*  ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT           */
00027 /*  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS     */
00028 /*  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.                      */
00029 /*                                                                                    */
00030 /**************************************************************************************/
00031 
00032 #ifndef Terrain_INCLUDE_ONCE
00033 #define Terrain_INCLUDE_ONCE
00034 
00035 #include <vlGraphics/SceneManagerActorKdTree.hpp>
00036 #include <vlGraphics/ShaderNode.hpp>
00037 
00038 namespace vl
00039 {
00063   class VLGRAPHICS_EXPORT Terrain: public SceneManagerActorKdTree
00064   {
00065     VL_INSTRUMENT_CLASS(vl::Terrain, SceneManagerActorKdTree)
00066 
00067   public:
00068     Terrain(): 
00069         mShaderNode(new ShaderNode), mWidth(0), mHeight(0), mDepth(0), mDetailRepetitionCount(0), 
00070         mHeightmapTextureFormat(TF_LUMINANCE16F), mTerrainTextureFormat(TF_RGB), mDetailTextureFormat(TF_RGB),
00071         mUseGLSL(true) 
00072     {
00073       mChunks.setAutomaticDelete(false);
00074     }
00075 
00076     void init();
00077 
00078     bool useGLSL() const { return mUseGLSL; }
00079     int detailRepetitionMode() const { return mDetailRepetitionCount; }
00080     double width() const { return mWidth; }
00081     double depth() const { return mDepth; }
00082     double height() const { return mHeight; }
00083     const vec3& origin() const { return mOrigin; }
00084     const String& detailTexture() const { return mDetailTexture; }
00085     const String& terrainTexture() const { return mTerrainTexture; }
00086     const String& heightmapTexture() const { return mHeightmapTexture; }
00087     ETextureFormat heightmapTextureFormat() const { return mHeightmapTextureFormat; }
00088     ETextureFormat terrainTextureFormat() const { return mTerrainTextureFormat; }
00089     ETextureFormat detailTextureFormat() const { return mDetailTextureFormat; }
00090 
00091     void setUseGLSL(bool enable) { mUseGLSL = enable; }
00092     void setDetailRepetitionCount(int count) { mDetailRepetitionCount = count; }
00093     void setWidth(double w)  { mWidth = w; }
00094     void setDepth(double d)  { mDepth = d; }
00095     void setHeight(double h) { mHeight = h; }
00096     void setOrigin(const vec3& origin) { mOrigin = origin; }
00097     void setHeightmapTextureFormat(ETextureFormat format) { mHeightmapTextureFormat = format; }
00098     void setTerrainTextureFormat(ETextureFormat format) { mTerrainTextureFormat = format; }
00099     void setDetailTextureFormat(ETextureFormat format) { mDetailTextureFormat = format; }
00100 
00101     void setVertexShader(const String& vs_path) { mVertexShader = vs_path; }
00102     const String& vertexShader() const { return mVertexShader; }
00103 
00104     void setFragmentShader(const String& fs_path) { mFragmentShader = fs_path; }
00105     const String& fragmentShader() const { return mFragmentShader; }
00106 
00107     const ActorCollection& chunks() const { return mChunks; }
00108     int chunkCount() const { return mChunks.size(); }
00109     Actor* chunk(int i) { return mChunks[i].get(); }
00110     const Actor* chunk(int i) const { return mChunks[i].get(); }
00111 
00115     void setDetailTexture(const String& texture) { mDetailTexture = texture; }
00123     void setTerrainTexture(const String& texture) { mTerrainTexture = texture; }
00131     void setHeightmapTexture(const String& texture) { mHeightmapTexture = texture; }
00132 
00133     const ShaderNode* shaderNode() const { return mShaderNode.get(); }
00134     ShaderNode* shaderNode() { return mShaderNode.get(); }
00135 
00136   protected:
00137     ref<ShaderNode> mShaderNode;
00138     ActorCollection mChunks;
00139     double mWidth;
00140     double mHeight;
00141     double mDepth;
00142     vec3 mOrigin;
00143     String mDetailTexture;
00144     String mTerrainTexture;
00145     String mHeightmapTexture;
00146     String mVertexShader;
00147     String mFragmentShader;
00148     int mDetailRepetitionCount;
00149     ETextureFormat mHeightmapTextureFormat;
00150     ETextureFormat mTerrainTextureFormat;
00151     ETextureFormat mDetailTextureFormat;
00152     bool mUseGLSL;
00153   };
00154 }
00155 
00156 #endif

Visualization Library 2011.09.1160 Reference Documentation
Copyright 2005-2011 Michele Bosi. All rights reserved.
Updated on Thu May 2 2013 13:40:41.
Permission is granted to use this page to write and publish articles regarding Visualization Library.