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

OgreTerrainPageSource.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 #ifndef __TerrainPageSource_H__
00027 #define __TerrainPageSource_H__
00028 
00029 #include "OgreTerrainPrerequisites.h"
00030 #include "OgreSingleton.h"
00031 
00032 namespace Ogre {
00033 
00034     typedef std::pair<String, String> TerrainPageSourceOption;
00035     typedef std::vector<TerrainPageSourceOption> TerrainPageSourceOptionList;
00036 
00040     class _OgreTerrainExport TerrainPageSourceListener
00041     {
00042     public:
00049         virtual void pageConstructed(size_t pagex, size_t pagez, Real* heightData) = 0;
00050     };
00051 
00055     class _OgreTerrainExport TerrainPageSourceListenerManager :
00056         public Singleton<TerrainPageSourceListenerManager>
00057     {
00058     protected:
00059         typedef std::vector<TerrainPageSourceListener*> PageSourceListenerList;
00060         PageSourceListenerList mPageSourceListeners;
00061     public:
00062         TerrainPageSourceListenerManager() {}
00063         ~TerrainPageSourceListenerManager() {}
00064 
00071         void addListener(TerrainPageSourceListener* pl);
00075         void removeListener(TerrainPageSourceListener* pl);
00076         
00078         void firePageConstructed(size_t pagex, size_t pagez, Real* heightData);
00079 
00082         static TerrainPageSourceListenerManager& getSingleton(void);
00085         static TerrainPageSourceListenerManager* getSingletonPtr(void); 
00086     
00087     };
00088 
00089 
00131     class _OgreTerrainExport TerrainPageSource
00132     {
00133     protected:
00135         TerrainSceneManager* mSceneManager;
00137         bool mAsyncLoading;
00139         unsigned short mPageSize;
00141         unsigned short mTileSize;
00142 
00144         static void firePageConstructed(size_t pagex, size_t pagez, Real* heightData);
00145 
00153         virtual TerrainPage* buildPage(Real* heightData, const MaterialPtr& pMaterial);
00154 
00155 
00156     public:
00157         TerrainPageSource(); 
00158         virtual ~TerrainPageSource() { shutdown(); }
00159 
00180         virtual void initialise(TerrainSceneManager* tsm, 
00181             ushort tileSize, ushort pageSize, bool asyncLoading, 
00182             TerrainPageSourceOptionList& optionList)
00183         {
00184             mSceneManager = tsm;
00185             mTileSize = tileSize;
00186             mPageSize = pageSize;
00187             mAsyncLoading = asyncLoading;
00188         }
00196         virtual void shutdown(void) {}
00197 
00219         virtual void requestPage(ushort x, ushort z) = 0;
00235         virtual void expirePage(ushort x, ushort z) = 0;
00236         
00243         static void addListener(TerrainPageSourceListener* pl);
00247         static void removeListener(TerrainPageSourceListener* pl);
00248 
00249     };
00250 
00251 }
00252 
00253 #endif

Copyright © 2000-2005 by The OGRE Team
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.
Last modified Sun Feb 12 12:59:53 2006