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 protected: 00059 WorldFragment mWorldFrag; 00060 public: 00061 TerrainRaySceneQuery(SceneManager* creator); 00062 ~TerrainRaySceneQuery(); 00063 00065 void execute(RaySceneQueryListener* listener); 00066 }; 00067 00068 00069 00075 class _OgreTerrainExport TerrainSceneManager : public OctreeSceneManager 00076 { 00077 public: 00078 TerrainSceneManager(const String& name); 00079 virtual ~TerrainSceneManager( ); 00080 00082 const String& getTypeName(void) const; 00083 00085 void setWorldGeometry( const String& filename ); 00088 virtual void setWorldGeometry(DataStreamPtr& stream, 00089 const String& typeName = StringUtil::BLANK); 00090 00092 virtual void _renderVisibleObjects( void ); 00093 00095 float getHeightAt( float x, float y ); 00096 00097 00098 bool intersectSegment( const Vector3 & start, const Vector3 & end, Vector3 * result ); 00099 00101 void setWorldTexture(const String& textureName); 00103 void setDetailTexture(const String& textureName); 00105 void setDetailTextureRepeat(int repeat); 00107 void setTileSize(int size); 00109 void setPageSize(int size); 00111 void setMaxPixelError(int pixelError); 00113 void setScale(const Vector3& scale); 00115 void setMaxGeoMipMapLevel(int maxMip); 00116 00118 const String& getWorldTexture(void) { return mWorldTextureName; } 00120 const String& getDetailTexture(void) { return mDetailTextureName; } 00122 int getDetailTextureRepeat(void); 00124 int getTileSize(void); 00126 int getPageSize(void); 00128 int getMaxPixelError(void); 00130 const Vector3& getScale(void); 00132 int getMaxGeoMipMapLevel(void); 00133 00134 00135 00140 void setUseTriStrips(bool useStrips); 00143 void setUseLODMorph(bool useMorph); 00145 void setUseVertexNormals(bool useNormals); 00147 void setUseVertexColours(bool useColours); 00148 00174 void setCustomMaterial(const String& materialName); 00193 void setCustomMaterialMorphFactorParam(const String& paramName); 00212 void setCustomMaterialMorphFactorParam(size_t paramIndex); 00215 void setLODMorphStart(Real morphStart); 00216 00220 virtual TerrainRenderable * getTerrainTile( const Vector3 & pt ); 00221 00225 virtual TerrainPage* getTerrainPage( const Vector3 & pt ); 00226 00239 RaySceneQuery* 00240 createRayQuery(const Ray& ray, unsigned long mask = 0xFFFFFFFF); 00241 00245 Camera* createCamera( const String &name ); 00247 const TerrainOptions& getOptions(void) { return mOptions; } 00248 00270 virtual bool setOption( const String &, const void * ); 00271 00275 virtual void setPrimaryCamera(const Camera* cam); 00277 typedef std::map<String, TerrainPageSource*> PageSourceMap; 00278 00280 typedef ConstMapIterator<PageSourceMap> PageSourceIterator; 00282 PageSourceIterator getPageSourceIterator(void); 00295 virtual void registerPageSource(const String& typeName, TerrainPageSource* source); 00306 virtual void selectPageSource(const String& typeName, 00307 TerrainPageSourceOptionList& optionList); 00308 00319 virtual void attachPage(ushort pageX, ushort pageZ, TerrainPage* page); 00321 MaterialPtr& getTerrainMaterial(void); 00322 // Overridden from basic scene manager 00323 void _renderScene(Camera *cam, Viewport *vp, bool includeOverlays); 00324 00326 SceneNode* getTerrainRootNode(void) const { return mTerrainRoot; } 00328 void clearScene(void); 00330 void setWorldGeometryRenderQueue(uint8 qid); 00331 00333 TerrainBufferCache& _getIndexCache(void) {return mIndexCache;} 00334 00336 LevelArray& _getLevelIndex(void) { return mLevelIndex; } 00337 00339 size_t _getPageCount(void) { return mTerrainPages.size(); } 00340 00342 void shutdown(void); 00343 00344 00345 protected: 00346 00348 bool _checkSize( int s ) 00349 { 00350 for ( int i = 0; i < 16; i++ ) 00351 { 00352 printf( "Checking...%d\n", ( 1 << i ) + 1 ); 00353 00354 if ( s == ( 1 << i ) + 1 ) 00355 return true; 00356 } 00357 00358 return false; 00359 00360 } 00361 00363 SceneNode * mTerrainRoot; 00365 TerrainOptions mOptions; 00367 bool mUseCustomMaterial; 00369 String mCustomMaterialName; 00371 String mWorldTextureName; 00373 String mDetailTextureName; 00375 bool mUseNamedParameterLodMorph; 00377 String mLodMorphParamName; 00379 size_t mLodMorphParamIndex; 00381 bool mPagingEnabled; 00383 unsigned short mLivePageMargin; 00385 unsigned short mBufferedPageMargin; 00387 TerrainPage2D mTerrainPages; 00388 //-- attributes to share across tiles 00390 TerrainBufferCache mIndexCache; 00392 LevelArray mLevelIndex; 00393 00395 void loadConfig(DataStreamPtr& stream); 00396 00398 void setupTerrainMaterial(void); 00400 void setupTerrainPages(void); 00402 void initLevelIndexes(void); 00404 void destroyLevelIndexes(void); 00405 00406 00408 PageSourceMap mPageSources; 00410 TerrainPageSource* mActivePageSource; 00411 00412 }; 00414 class TerrainSceneManagerFactory : public SceneManagerFactory 00415 { 00416 protected: 00417 typedef std::vector<TerrainPageSource*> TerrainPageSources; 00418 TerrainPageSources mTerrainPageSources; 00419 void initMetaData(void) const; 00420 public: 00421 TerrainSceneManagerFactory(); 00422 ~TerrainSceneManagerFactory(); 00424 static const String FACTORY_TYPE_NAME; 00425 SceneManager* createInstance(const String& instanceName); 00426 void destroyInstance(SceneManager* instance); 00427 }; 00428 00429 } 00430 00431 #endif
Copyright © 2000-2005 by The OGRE Team
This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.
Last modified Sun Mar 12 14:37:51 2006