OgrePageManager.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-2012 Torus Knot Software Ltd
    00008
    00009 Permission is hereby granted, free of charge, to any person obtaining a copy
    00010 of this software and associated documentation files (the "Software"), to deal
    00011 in the Software without restriction, including without limitation the rights
    00012 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    00013 copies of the Software, and to permit persons to whom the Software is
    00014 furnished to do so, subject to the following conditions:
    00015
    00016 The above copyright notice and this permission notice shall be included in
    00017 all copies or substantial portions of the Software.
    00018
    00019 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    00020 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    00021 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    00022 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    00023 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    00024 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    00025 THE SOFTWARE.
    00026 -----------------------------------------------------------------------------
    00027 */
    00028
    00029 #ifndef __Ogre_PageManager_H__
    00030 #define __Ogre_PageManager_H__
    00031
    00032 #include "OgrePagingPrerequisites.h"
    00033 #include "OgreString.h"
    00034 #include "OgreResourceGroupManager.h"
    00035 #include "OgreCommon.h"
    00036 #include "OgreCamera.h"
    00037 #include "OgreFrameListener.h"
    00038
    00039 namespace Ogre
    00040 {
    00049     class PagedWorldSection;
    00050     class PagedWorldSectionFactory;
    00051
    00052
    00058     class PageProvider
    00059     {
    00060     public:
    00061         PageProvider() {}
    00062         virtual ~PageProvider() {}
    00063
    00070         virtual bool prepareProceduralPage(Page* page, PagedWorldSection* section) { return false; }
    00077         virtual bool loadProceduralPage(Page* page, PagedWorldSection* section) { return false; }
    00085         virtual bool unloadProceduralPage(Page* page, PagedWorldSection* section) { return false; }
    00093         virtual bool unprepareProceduralPage(Page* page, PagedWorldSection* section) { return false; }
    00094
    00100         virtual StreamSerialiser* readWorldStream(const String& filename) { return 0; }
    00106         virtual StreamSerialiser* writeWorldStream(const String& filename) { return 0; }
    00115         virtual StreamSerialiser* readPageStream(PageID pageID, PagedWorldSection* section) { return 0; }
    00116
    00125         virtual StreamSerialiser* writePageStream(PageID pageID, PagedWorldSection* section) { return 0; }
    00126     };
    00127
    00135     class _OgrePagingExport PageManager : public PageAlloc
    00136     {
    00137     public:
    00138         PageManager();
    00139         virtual ~PageManager();
    00140
    00145         PagedWorld* createWorld(const String& name = StringUtil::BLANK);
    00146
    00148         void destroyWorld(const String& name);
    00149
    00151         void destroyWorld(PagedWorld* world);
    00152
    00158         PagedWorld* loadWorld(const String& filename, const String& name = StringUtil::BLANK);
    00164         PagedWorld* loadWorld(const DataStreamPtr& stream, const String& name = StringUtil::BLANK);
    00170         void saveWorld(PagedWorld* world, const String& filename);
    00175         void saveWorld(PagedWorld* world, const DataStreamPtr& stream);
    00180         PagedWorld* getWorld(const String& name);
    00181         typedef map<String, PagedWorld*>::type WorldMap;
    00183         const WorldMap& getWorlds() const { return mWorlds; }
    00184
    00185
    00186         typedef map<String, PageStrategy*>::type StrategyMap;
    00191         void addStrategy(PageStrategy* strategy);
    00192
    00195         void removeStrategy(PageStrategy* strategy);
    00196
    00201         PageStrategy* getStrategy(const String& name);
    00202
    00205         const StrategyMap& getStrategies() const;
    00206
    00207
    00208         typedef map<String, PageContentCollectionFactory*>::type ContentCollectionFactoryMap;
    00213         void addContentCollectionFactory(PageContentCollectionFactory* f);
    00214
    00217         void removeContentCollectionFactory(PageContentCollectionFactory* f);
    00218
    00223         PageContentCollectionFactory* getContentCollectionFactory(const String& name);
    00224
    00229         PageContentCollection* createContentCollection(const String& typeName);
    00230
    00232         void destroyContentCollection(PageContentCollection* coll);
    00233
    00236         const ContentCollectionFactoryMap& getContentCollectionFactories() const;
    00237
    00238         typedef map<String, PageContentFactory*>::type ContentFactoryMap;
    00243         void addContentFactory(PageContentFactory* f);
    00244
    00247         void removeContentFactory(PageContentFactory* f);
    00248
    00253         PageContentFactory* getContentFactory(const String& name);
    00254
    00257         const ContentFactoryMap& getContentFactories() const;
    00258
    00263         PageContent* createContent(const String& typeName);
    00264
    00266         void destroyContent(PageContent* c);
    00267
    00268
    00269         typedef map<String, PagedWorldSectionFactory*>::type WorldSectionFactoryMap;
    00274         void addWorldSectionFactory(PagedWorldSectionFactory* f);
    00275
    00278         void removeWorldSectionFactory(PagedWorldSectionFactory* f);
    00279
    00284         PagedWorldSectionFactory* getWorldSectionFactory(const String& name);
    00285
    00293         PagedWorldSection* createWorldSection(const String& typeName,
    00294             const String& name, PagedWorld* parent, SceneManager* sm);
    00295
    00297         void destroyWorldSection(PagedWorldSection* s);
    00298
    00301         const WorldSectionFactoryMap& getWorldSectionFactories() const;
    00302
    00303
    00315         void setPageProvider(PageProvider* provider) { mPageProvider = provider; }
    00316
    00318         PageProvider* getPageProvider() const { return mPageProvider; }
    00319
    00327         virtual bool _prepareProceduralPage(Page* page, PagedWorldSection* section);
    00335         virtual bool _loadProceduralPage(Page* page, PagedWorldSection* section);
    00343         virtual bool _unloadProceduralPage(Page* page, PagedWorldSection* section);
    00351         virtual bool _unprepareProceduralPage(Page* page, PagedWorldSection* section);
    00359         StreamSerialiser* _readPageStream(PageID pageID, PagedWorldSection* section);
    00360
    00368         StreamSerialiser* _writePageStream(PageID pageID, PagedWorldSection* section);
    00374         StreamSerialiser* _readWorldStream(const String& filename);
    00375
    00381         StreamSerialiser* _writeWorldStream(const String& filename);
    00382
    00386         const String& getPageResourceGroup() const { return mPageResourceGroup; }
    00390         void setPageResourceGroup(const String& g) { mPageResourceGroup = g; }
    00391
    00399         void addCamera(Camera* c);
    00400
    00403         void removeCamera(Camera* c);
    00404
    00407         bool hasCamera(Camera* c) const;
    00408
    00409         typedef vector<Camera*>::type CameraList;
    00411         const CameraList& getCameraList() const;
    00412
    00422         void setDebugDisplayLevel(uint8 lvl) { mDebugDisplayLvl = lvl; }
    00424         uint8 getDebugDisplayLevel() const { return mDebugDisplayLvl; }
    00425
    00432         void setPagingOperationsEnabled(bool enabled) { mPagingEnabled = enabled; }
    00433
    00435         bool getPagingOperationsEnabled() const { return mPagingEnabled; }
    00436
    00437
    00438     protected:
    00439
    00440         class EventRouter : public Camera::Listener, public FrameListener
    00441         {
    00442         public:
    00443             PageManager* pManager;
    00444             WorldMap* pWorldMap;
    00445             CameraList* pCameraList;
    00446
    00447             EventRouter() {}
    00448             ~EventRouter() {}
    00449
    00450             void cameraPreRenderScene(Camera* cam);
    00451             void cameraDestroyed(Camera* cam);
    00452             bool frameStarted(const FrameEvent& evt);
    00453             bool frameEnded(const FrameEvent& evt);
    00454         };
    00455
    00456         void createStandardStrategies();
    00457         void createStandardContentFactories();
    00458
    00459         WorldMap mWorlds;
    00460         StrategyMap mStrategies;
    00461         ContentCollectionFactoryMap mContentCollectionFactories;
    00462         ContentFactoryMap mContentFactories;
    00463         WorldSectionFactoryMap mWorldSectionFactories;
    00464         NameGenerator mWorldNameGenerator;
    00465         PageProvider* mPageProvider;
    00466         String mPageResourceGroup;
    00467         CameraList mCameraList;
    00468         EventRouter mEventRouter;
    00469         uint8 mDebugDisplayLvl;
    00470         bool mPagingEnabled;
    00471
    00472         Grid2DPageStrategy* mGrid2DPageStrategy;
    00473         Grid3DPageStrategy* mGrid3DPageStrategy;
    00474         SimplePageContentCollectionFactory* mSimpleCollectionFactory;
    00475     };
    00476
    00479 }
    00480
    00481 #endif

Copyright © 2012 Torus Knot Software Ltd
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Last modified Sun Sep 2 2012 07:27:22