Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class 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 (c) 2000-2005 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     MaterialPtr& 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);
00321     void setWorldGeometryRenderQueue(RenderQueueGroupID qid);
00322 
00323 
00324 protected:
00325 
00327     bool _checkSize( int s )
00328     {
00329         for ( int i = 0; i < 16; i++ )
00330         {
00331             printf( "Checking...%d\n", ( 1 << i ) + 1 );
00332 
00333             if ( s == ( 1 << i ) + 1 )
00334                 return true;
00335         }
00336 
00337         return false;
00338 
00339     }
00340 
00342     SceneNode * mTerrainRoot;
00344     static TerrainOptions mOptions;
00346     bool mUseCustomMaterial;
00348     String mCustomMaterialName;
00350     String mWorldTextureName;
00352     String mDetailTextureName;
00354     bool mUseNamedParameterLodMorph;
00356     String mLodMorphParamName;
00358     size_t mLodMorphParamIndex;
00360     bool mPagingEnabled;
00362     unsigned short mLivePageMargin;
00364     unsigned short mBufferedPageMargin;
00366     TerrainPage2D mTerrainPages;
00367     
00369     void loadConfig(const String& filename);
00370 
00372     void setupTerrainMaterial(void);
00374     void setupTerrainPages(void);
00375 
00376 
00378     PageSourceMap mPageSources;
00380     TerrainPageSource* mActivePageSource;
00381 
00382 };
00383 
00384 }
00385 
00386 #endif

Copyright © 2000-2005 by The OGRE Team
Last modified Wed Feb 23 00:19:15 2005