Main Page Namespace List Class Hierarchy Alphabetical List Compound List File List Namespace Members Compound Members File Members Related Pages

# OgreTerrainSceneManager.h

Go to the documentation of this file.

    00001 /*
    00002 -----------------------------------------------------------------------------
    00003 This source file is part of OGRE
    00004 (Object-oriented Graphics Rendering Engine)
    00005 For the latest info, see http://www.ogre3d.org/
    00006
    00007 Copyright © 2000-2004 The OGRE Team
    00008 Also see acknowledgements in Readme.html
    00009
    00010 This program is free software; you can redistribute it and/or modify it under
    00011 the terms of the GNU Lesser General Public License as published by the Free Software
    00012 Foundation; either version 2 of the License, or (at your option) any later
    00013 version.
    00014
    00015 This program is distributed in the hope that it will be useful, but WITHOUT
    00016 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    00017 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
    00018
    00019 You should have received a copy of the GNU Lesser General Public License along with
    00020 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
    00021 Place - Suite 330, Boston, MA 02111-1307, USA, or go to
    00022 http://www.gnu.org/copyleft/lesser.txt.
    00023 -----------------------------------------------------------------------------
    00024 */
    00025 /***************************************************************************
    00026 terrainscenemanager.h  -  description
    00027 ---------------------
    00028   begin                : Mon Sep 23 2002
    00029   copyright            : (C) 2002 by Jon Anderson
    00030   email                : janders@users.sf.net
    00031
    00032   Enhancements 2003 - 2004 (C) The OGRE Team
    00033
    00034 ***************************************************************************/
    00035
    00036 #ifndef TERRAINSCENEMANAGER_H
    00037 #define TERRAINSCENEMANAGER_H
    00038
    00039 #include "OgreTerrainPrerequisites.h"
    00040 #include "OgreOctreeSceneManager.h"
    00041 #include "OgreOctreeSceneQuery.h"
    00042 #include "OgreTerrainRenderable.h"
    00043 #include "OgreTerrainPageSource.h"
    00044 #include "OgreIteratorWrappers.h"
    00045
    00046
    00047 namespace Ogre
    00048 {
    00049
    00050 class Image;
    00051
    00052 typedef std::vector < TerrainPage * > TerrainPageRow;
    00053 typedef std::vector < TerrainPageRow > TerrainPage2D;
    00054
    00056 class _OgreTerrainExport TerrainRaySceneQuery : public OctreeRaySceneQuery
    00057 {
    00058 public:
    00059     TerrainRaySceneQuery(SceneManager* creator);
    00060     ~TerrainRaySceneQuery();
    00061
    00063     void execute(RaySceneQueryListener* listener);
    00064 };
    00065
    00066
    00067
    00073 class _OgreTerrainExport TerrainSceneManager : public OctreeSceneManager
    00074 {
    00075 public:
    00076     TerrainSceneManager( );
    00077     virtual ~TerrainSceneManager( );
    00078
    00080     void setWorldGeometry( const String& filename );
    00081
    00083     virtual void _renderVisibleObjects( void );
    00084
    00086     float getHeightAt( float x, float y );
    00087
    00088
    00089     bool intersectSegment( const Vector3 & start, const Vector3 & end, Vector3 * result );
    00090
    00092     void setWorldTexture(const String& textureName);
    00094     void setDetailTexture(const String& textureName);
    00096     void setDetailTextureRepeat(int repeat);
    00098     void setTileSize(int size);
    00100     void setPageSize(int size);
    00102     void setMaxPixelError(int pixelError);
    00104     void setScale(const Vector3& scale);
    00106     void setMaxGeoMipMapLevel(int maxMip);
    00107
    00109     const String& getWorldTexture(void) { return mWorldTextureName; }
    00111     const String& getDetailTexture(void) { return mDetailTextureName; }
    00113     int setDetailTextureRepeat(void);
    00115     int getTileSize(void);
    00117     int getPageSize(void);
    00119     int getMaxPixelError(void);
    00121     const Vector3& getScale(void);
    00123     int getMaxGeoMipMapLevel(void);
    00124
    00125
    00126
    00131     void setUseTriStrips(bool useStrips);
    00134     void setUseLODMorph(bool useMorph);
    00136     void setUseVertexNormals(bool useNormals);
    00138     void setUseVertexColours(bool useColours);
    00139
    00165     void setCustomMaterial(const String& materialName);
    00184     void setCustomMaterialMorphFactorParam(const String& paramName);
    00203     void setCustomMaterialMorphFactorParam(size_t paramIndex);
    00206     void setLODMorphStart(Real morphStart);
    00207
    00211     virtual TerrainRenderable * getTerrainTile( const Vector3 & pt );
    00212
    00216     virtual TerrainPage* getTerrainPage( const Vector3 & pt );
    00217
    00230     RaySceneQuery*
    00231         createRayQuery(const Ray& ray, unsigned long mask = 0xFFFFFFFF);
    00232
    00236     Camera* createCamera( const String &name );
    00238     static const TerrainOptions& getOptions(void) { return mOptions; }
    00239
    00261     virtual bool setOption( const String &, const void * );
    00262
    00266     virtual void setPrimaryCamera(const Camera* cam);
    00268     typedef std::map<String, TerrainPageSource*> PageSourceMap;
    00269
    00271     typedef ConstMapIterator<PageSourceMap> PageSourceIterator;
    00273     PageSourceIterator getPageSourceIterator(void);
    00286     virtual void registerPageSource(const String& typeName, TerrainPageSource* source);
    00297     virtual void selectPageSource(const String& typeName,
    00298         TerrainPageSourceOptionList& optionList);
    00299
    00310     virtual void attachPage(ushort pageX, ushort pageZ, TerrainPage* page);
    00312     Material* getTerrainMaterial(void);
    00313     // Overridden from basic scene manager
    00314     void _renderScene(Camera *cam, Viewport *vp, bool includeOverlays);
    00315
    00317     SceneNode* getTerrainRootNode(void) const { return mTerrainRoot; }
    00319     void clearScene(void);
    00320
    00321
    00322 protected:
    00323
    00325     bool _checkSize( int s )
    00326     {
    00327         for ( int i = 0; i < 16; i++ )
    00328         {
    00329             printf( "Checking...%d\n", ( 1 << i ) + 1 );
    00330
    00331             if ( s == ( 1 << i ) + 1 )
    00332                 return true;
    00333         }
    00334
    00335         return false;
    00336
    00337     }
    00338
    00340     SceneNode * mTerrainRoot;
    00342     static TerrainOptions mOptions;
    00344     bool mUseCustomMaterial;
    00346     String mCustomMaterialName;
    00348     String mWorldTextureName;
    00350     String mDetailTextureName;
    00352     bool mUseNamedParameterLodMorph;
    00354     String mLodMorphParamName;
    00356     size_t mLodMorphParamIndex;
    00358     bool mPagingEnabled;
    00360     unsigned short mLivePageMargin;
    00362     unsigned short mBufferedPageMargin;
    00364     TerrainPage2D mTerrainPages;
    00365
    00367     void loadConfig(const String& filename);
    00368
    00370     void setupTerrainMaterial(void);
    00372     void setupTerrainPages(void);
    00373
    00374
    00376     PageSourceMap mPageSources;
    00378     TerrainPageSource* mActivePageSource;
    00379
    00380 };
    00381
    00382 }
    00383
    00384 #endif

Copyright © 2002-2003 by The OGRE Team
Last modified Sun Nov 28 19:48:49 2004