OgrePageManager.h
Go to the documentation of this file.
1 /*
2 -----------------------------------------------------------------------------
3 This source file is part of OGRE
4 (Object-oriented Graphics Rendering Engine)
5 For the latest info, see http://www.ogre3d.org/
6 
7 Copyright (c) 2000-2013 Torus Knot Software Ltd
8 
9 Permission is hereby granted, free of charge, to any person obtaining a copy
10 of this software and associated documentation files (the "Software"), to deal
11 in the Software without restriction, including without limitation the rights
12 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 copies of the Software, and to permit persons to whom the Software is
14 furnished to do so, subject to the following conditions:
15 
16 The above copyright notice and this permission notice shall be included in
17 all copies or substantial portions of the Software.
18 
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 THE SOFTWARE.
26 -----------------------------------------------------------------------------
27 */
28 
29 #ifndef __Ogre_PageManager_H__
30 #define __Ogre_PageManager_H__
31 
33 #include "OgreString.h"
35 #include "OgreCommon.h"
36 #include "OgreCamera.h"
37 #include "OgreFrameListener.h"
38 #include "OgreNameGenerator.h"
39 
40 namespace Ogre
41 {
50  class PagedWorldSection;
51  class PagedWorldSectionFactory;
52 
53 
60  {
61  public:
63  virtual ~PageProvider() {}
64 
71  virtual bool prepareProceduralPage(Page* page, PagedWorldSection* section) { return false; }
78  virtual bool loadProceduralPage(Page* page, PagedWorldSection* section) { return false; }
86  virtual bool unloadProceduralPage(Page* page, PagedWorldSection* section) { return false; }
94  virtual bool unprepareProceduralPage(Page* page, PagedWorldSection* section) { return false; }
95 
101  virtual StreamSerialiser* readWorldStream(const String& filename) { return 0; }
107  virtual StreamSerialiser* writeWorldStream(const String& filename) { return 0; }
116  virtual StreamSerialiser* readPageStream(PageID pageID, PagedWorldSection* section) { return 0; }
117 
126  virtual StreamSerialiser* writePageStream(PageID pageID, PagedWorldSection* section) { return 0; }
127  };
128 
137  {
138  public:
140  virtual ~PageManager();
141 
147 
149  void destroyWorld(const String& name);
150 
152  void destroyWorld(PagedWorld* world);
153 
159  PagedWorld* loadWorld(const String& filename, const String& name = StringUtil::BLANK);
170  void saveWorld(PagedWorld* world, const String& filename);
175  void saveWorld(PagedWorld* world, const DataStreamPtr& stream);
180  PagedWorld* getWorld(const String& name);
183  const WorldMap& getWorlds() const { return mWorlds; }
184 
185 
191  void addStrategy(PageStrategy* strategy);
192 
195  void removeStrategy(PageStrategy* strategy);
196 
202 
205  const StrategyMap& getStrategies() const;
206 
207 
214 
218 
224 
230 
233 
237 
244 
248 
254 
258 
263  PageContent* createContent(const String& typeName);
264 
267 
268 
275 
279 
285 
294  const String& name, PagedWorld* parent, SceneManager* sm);
295 
298 
302 
303 
315  void setPageProvider(PageProvider* provider) { mPageProvider = provider; }
316 
318  PageProvider* getPageProvider() const { return mPageProvider; }
319 
327  virtual bool _prepareProceduralPage(Page* page, PagedWorldSection* section);
335  virtual bool _loadProceduralPage(Page* page, PagedWorldSection* section);
343  virtual bool _unloadProceduralPage(Page* page, PagedWorldSection* section);
351  virtual bool _unprepareProceduralPage(Page* page, PagedWorldSection* section);
360 
375 
382 
386  const String& getPageResourceGroup() const { return mPageResourceGroup; }
390  void setPageResourceGroup(const String& g) { mPageResourceGroup = g; }
391 
399  void addCamera(Camera* c);
400 
404 
407  bool hasCamera(Camera* c) const;
408 
411  const CameraList& getCameraList() const;
412 
422  void setDebugDisplayLevel(uint8 lvl) { mDebugDisplayLvl = lvl; }
424  uint8 getDebugDisplayLevel() const { return mDebugDisplayLvl; }
425 
432  void setPagingOperationsEnabled(bool enabled) { mPagingEnabled = enabled; }
433 
435  bool getPagingOperationsEnabled() const { return mPagingEnabled; }
436 
437 
438  protected:
439 
441  {
442  public:
446 
447  EventRouter() : pManager(0), pWorldMap(0), pCameraList(0) {}
449 
452  bool frameStarted(const FrameEvent& evt);
453  bool frameEnded(const FrameEvent& evt);
454  };
455 
458 
471 
475  };
476 
479 }
480 
481 #endif
Ogre::FrameListener
A interface class defining a listener which can be used to receive notifications of frame events.
Definition: OgreFrameListener.h:80
Ogre::PageManager::destroyWorldSection
void destroyWorldSection(PagedWorldSection *s)
Destroy an instance of PagedWorldSection.
Ogre::PageManager::destroyContent
void destroyContent(PageContent *c)
Destroy an instance of PageContent.
OgreNameGenerator.h
Ogre::PageManager::getPageProvider
PageProvider * getPageProvider() const
Get the PageProvider which can provide streams for any Page.
Definition: OgrePageManager.h:318
Ogre::PageManager::getPageResourceGroup
const String & getPageResourceGroup() const
Get the resource group that will be used to read/write files when the default load routines are used.
Definition: OgrePageManager.h:386
Ogre::PageManager::createWorld
PagedWorld * createWorld(const String &name=StringUtil::BLANK)
Create a new PagedWorld instance.
Ogre::PageManager::_unprepareProceduralPage
virtual bool _unprepareProceduralPage(Page *page, PagedWorldSection *section)
Give a manager the opportunity to unprepare page content procedurally.
Ogre::AllocatedObject
Superclass for all objects that wish to use custom memory allocators when their new / delete operator...
Definition: OgreMemoryAllocatedObject.h:59
Ogre
Definition: OgreAndroidLogListener.h:35
Ogre::PageManager::mPageProvider
PageProvider * mPageProvider
Definition: OgrePageManager.h:465
Ogre::PageProvider::readPageStream
virtual StreamSerialiser * readPageStream(PageID pageID, PagedWorldSection *section)
Get a serialiser set up to read Page data for the given PageID, or null if this provider cannot suppl...
Definition: OgrePageManager.h:116
Ogre::Grid2DPageStrategy
Page strategy which loads new pages based on a regular 2D grid.
Definition: OgreGrid2DPageStrategy.h:232
Ogre::PageManager::getContentCollectionFactories
const ContentCollectionFactoryMap & getContentCollectionFactories() const
Get a reference to the registered strategies.
Ogre::map
Definition: OgrePrerequisites.h:534
Ogre::PageManager::EventRouter::~EventRouter
~EventRouter()
Definition: OgrePageManager.h:448
Ogre::Camera
A viewpoint from which the scene will be rendered.
Definition: OgreCamera.h:87
Ogre::PageManager::removeWorldSectionFactory
void removeWorldSectionFactory(PagedWorldSectionFactory *f)
Remove a PagedWorldSectionFactory implementation.
Ogre::PageManager::mWorldSectionFactories
WorldSectionFactoryMap mWorldSectionFactories
Definition: OgrePageManager.h:463
Ogre::PageManager::EventRouter::pCameraList
CameraList * pCameraList
Definition: OgrePageManager.h:445
Ogre::PageManager::createStandardStrategies
void createStandardStrategies()
OgrePagingPrerequisites.h
Ogre::PageManager::saveWorld
void saveWorld(PagedWorld *world, const String &filename)
Save a PagedWorld instance to a file.
Ogre::PageManager::EventRouter::EventRouter
EventRouter()
Definition: OgrePageManager.h:447
Ogre::PageManager::_readWorldStream
StreamSerialiser * _readWorldStream(const String &filename)
Get a serialiser set up to read PagedWorld data for the given world name.
Ogre::PageManager::_writeWorldStream
StreamSerialiser * _writeWorldStream(const String &filename)
Get a serialiser set up to write PagedWorld data.
Ogre::PageManager::EventRouter::pManager
PageManager * pManager
Definition: OgrePageManager.h:443
Ogre::PageManager::addWorldSectionFactory
void addWorldSectionFactory(PagedWorldSectionFactory *f)
Add a new PagedWorldSectionFactory implementation.
Ogre::PageManager::mPagingEnabled
bool mPagingEnabled
Definition: OgrePageManager.h:470
Ogre::PageManager::ContentCollectionFactoryMap
map< String, PageContentCollectionFactory * >::type ContentCollectionFactoryMap
Definition: OgrePageManager.h:208
Ogre::PageManager::setPageProvider
void setPageProvider(PageProvider *provider)
Set the PageProvider which can provide streams for any Page.
Definition: OgrePageManager.h:315
Ogre::PageManager
The PageManager is the entry point through which you load all PagedWorld instances,...
Definition: OgrePageManager.h:137
Ogre::PageProvider::PageProvider
PageProvider()
Definition: OgrePageManager.h:62
Ogre::PageManager::mContentFactories
ContentFactoryMap mContentFactories
Definition: OgrePageManager.h:462
Ogre::PageManager::StrategyMap
map< String, PageStrategy * >::type StrategyMap
Definition: OgrePageManager.h:186
Ogre::PageManager::mContentCollectionFactories
ContentCollectionFactoryMap mContentCollectionFactories
Definition: OgrePageManager.h:461
Ogre::PageProvider::writeWorldStream
virtual StreamSerialiser * writeWorldStream(const String &filename)
Get a serialiser set up to write PagedWorld data for the given world filename.
Definition: OgrePageManager.h:107
Ogre::PageManager::mPageResourceGroup
String mPageResourceGroup
Definition: OgrePageManager.h:466
Ogre::PageManager::getStrategy
PageStrategy * getStrategy(const String &name)
Get a PageStrategy.
Ogre::String
_StringBase String
Definition: OgrePrerequisites.h:439
Ogre::PageManager::~PageManager
virtual ~PageManager()
OgreResourceGroupManager.h
Ogre::PageManager::createContentCollection
PageContentCollection * createContentCollection(const String &typeName)
Create a new instance of PageContentCollection using the registered factories.
Ogre::PageManager::mCameraList
CameraList mCameraList
Definition: OgrePageManager.h:467
Ogre::PageManager::addStrategy
void addStrategy(PageStrategy *strategy)
Add a new PageStrategy implementation.
Ogre::PageManager::_loadProceduralPage
virtual bool _loadProceduralPage(Page *page, PagedWorldSection *section)
Give a provider the opportunity to prepare page content procedurally.
Ogre::PageProvider::loadProceduralPage
virtual bool loadProceduralPage(Page *page, PagedWorldSection *section)
Give a provider the opportunity to load page content procedurally.
Definition: OgrePageManager.h:78
Ogre::PageProvider
Abstract class that can be implemented by the user application to provide a way to retrieve or genera...
Definition: OgrePageManager.h:60
Ogre::PageManager::_unloadProceduralPage
virtual bool _unloadProceduralPage(Page *page, PagedWorldSection *section)
Give a manager the opportunity to unload page content procedurally.
Ogre::PageManager::mSimpleCollectionFactory
SimplePageContentCollectionFactory * mSimpleCollectionFactory
Definition: OgrePageManager.h:474
Ogre::PageID
uint32 PageID
Identifier for a page.
Definition: OgrePagingPrerequisites.h:58
Ogre::PageManager::setPagingOperationsEnabled
void setPagingOperationsEnabled(bool enabled)
Pause or unpause all paging operations.
Definition: OgrePageManager.h:432
Ogre::PageManager::EventRouter::frameEnded
bool frameEnded(const FrameEvent &evt)
Called just after a frame has been rendered.
Ogre::PageManager::mDebugDisplayLvl
uint8 mDebugDisplayLvl
Definition: OgrePageManager.h:469
Ogre::PageManager::getCameraList
const CameraList & getCameraList() const
Returns a list of cameras being tracked.
Ogre::PageManager::getContentFactories
const ContentFactoryMap & getContentFactories() const
Get a reference to the registered strategies.
Ogre::PageStrategy
Defines the interface to a strategy class which is responsible for deciding when Page instances are r...
Definition: OgrePageStrategy.h:74
Ogre::PageManager::getPagingOperationsEnabled
bool getPagingOperationsEnabled() const
Get whether paging operations are currently allowed to happen.
Definition: OgrePageManager.h:435
Ogre::StringUtil::BLANK
static const String BLANK
Constant blank string, useful for returning by ref where local does not exist.
Definition: OgreString.h:196
Ogre::SimplePageContentCollectionFactory
Factory class for SimplePageContentCollection.
Definition: OgreSimplePageContentCollection.h:112
Ogre::PageManager::mGrid3DPageStrategy
Grid3DPageStrategy * mGrid3DPageStrategy
Definition: OgrePageManager.h:473
Ogre::PageManager::WorldMap
map< String, PagedWorld * >::type WorldMap
Definition: OgrePageManager.h:181
Ogre::NameGenerator
Utility class to generate a sequentially numbered series of names.
Definition: OgreNameGenerator.h:57
OgreFrameListener.h
Ogre::PageManager::setDebugDisplayLevel
void setDebugDisplayLevel(uint8 lvl)
Set the debug display level.
Definition: OgrePageManager.h:422
Ogre::PageManager::getWorldSectionFactory
PagedWorldSectionFactory * getWorldSectionFactory(const String &name)
Get a PagedWorldSectionFactory.
Ogre::SceneManager
Manages the organisation and rendering of a 'scene' i.e.
Definition: OgreSceneManager.h:144
Ogre::PageManager::EventRouter
Definition: OgrePageManager.h:441
Ogre::PageContentCollection
Definition of the interface for a collection of PageContent instances.
Definition: OgrePageContentCollection.h:56
Ogre::PageManager::createStandardContentFactories
void createStandardContentFactories()
Ogre::PageManager::loadWorld
PagedWorld * loadWorld(const String &filename, const String &name=StringUtil::BLANK)
Load a new PagedWorld from a file.
Ogre::PageManager::addContentCollectionFactory
void addContentCollectionFactory(PageContentCollectionFactory *f)
Add a new PageContentCollectionFactory implementation.
Ogre::PageManager::removeContentFactory
void removeContentFactory(PageContentFactory *f)
Remove a PageContentFactory implementation.
Ogre::PagedWorld
This class represents a collection of pages which make up a world.
Definition: OgrePagedWorld.h:58
Ogre::PagedWorldSectionFactory
A factory class for creating types of world section.
Definition: OgrePagedWorldSection.h:302
Ogre::PageManager::destroyWorld
void destroyWorld(const String &name)
Destroy a world.
Ogre::Page
Page class.
Definition: OgrePage.h:51
Ogre::PageContentFactory
Define the interface to a factory class that will create subclasses of PageContent.
Definition: OgrePageContentFactory.h:51
Ogre::PageProvider::~PageProvider
virtual ~PageProvider()
Definition: OgrePageManager.h:63
Ogre::PageManager::removeCamera
void removeCamera(Camera *c)
Tells the paging system to stop tracking a given camera.
Ogre::PageManager::loadWorld
PagedWorld * loadWorld(const DataStreamPtr &stream, const String &name=StringUtil::BLANK)
Load a new PagedWorld from a stream.
OgreCommon.h
Ogre::PageManager::getWorld
PagedWorld * getWorld(const String &name)
Get a named world.
Ogre::PageManager::destroyWorld
void destroyWorld(PagedWorld *world)
Destroy a world.
Ogre::PagedWorldSection
Represents a section of the PagedWorld which uses a given PageStrategy, and which is made up of a gen...
Definition: OgrePagedWorldSection.h:70
Ogre::FrameEvent
Struct containing information about a frame event.
Definition: OgreFrameListener.h:45
Ogre::PageManager::getContentFactory
PageContentFactory * getContentFactory(const String &name)
Get a PageContentFactory.
Ogre::PageManager::mWorldNameGenerator
NameGenerator mWorldNameGenerator
Definition: OgrePageManager.h:464
Ogre::Grid3DPageStrategy
Page strategy which loads new pages based on a regular 3D grid.
Definition: OgreGrid3DPageStrategy.h:204
Ogre::PageManager::getStrategies
const StrategyMap & getStrategies() const
Get a reference to the registered strategies.
Ogre::PageManager::EventRouter::cameraDestroyed
void cameraDestroyed(Camera *cam)
Called when the camera is being destroyed.
Ogre::SharedPtr< DataStream >
Ogre::uint8
unsigned char uint8
Definition: OgrePlatform.h:361
Ogre::PageManager::createContent
PageContent * createContent(const String &typeName)
Create a new instance of PageContent using the registered factories.
Ogre::StreamSerialiser
Utility class providing helper methods for reading / writing structured data held in a DataStream.
Definition: OgreStreamSerialiser.h:67
Ogre::PageManager::getWorlds
const WorldMap & getWorlds() const
Get a reference to the worlds that are currently loaded.
Definition: OgrePageManager.h:183
Ogre::PageManager::setPageResourceGroup
void setPageResourceGroup(const String &g)
Set the resource group that will be used to read/write files when the default load routines are used.
Definition: OgrePageManager.h:390
Ogre::PageManager::getWorldSectionFactories
const WorldSectionFactoryMap & getWorldSectionFactories() const
Get a reference to the registered strategies.
Ogre::PageManager::createWorldSection
PagedWorldSection * createWorldSection(const String &typeName, const String &name, PagedWorld *parent, SceneManager *sm)
Create a new instance of PagedWorldSection using the registered factories.
Ogre::PageManager::EventRouter::pWorldMap
WorldMap * pWorldMap
Definition: OgrePageManager.h:444
Ogre::PageProvider::writePageStream
virtual StreamSerialiser * writePageStream(PageID pageID, PagedWorldSection *section)
Get a serialiser set up to write Page data for the given PageID, or null if this provider cannot supp...
Definition: OgrePageManager.h:126
Ogre::Camera::Listener
Listener interface so you can be notified of Camera events.
Definition: OgreCamera.h:92
Ogre::PageManager::WorldSectionFactoryMap
map< String, PagedWorldSectionFactory * >::type WorldSectionFactoryMap
Definition: OgrePageManager.h:269
Ogre::PageProvider::unprepareProceduralPage
virtual bool unprepareProceduralPage(Page *page, PagedWorldSection *section)
Give a provider the opportunity to unprepare page content procedurally.
Definition: OgrePageManager.h:94
Ogre::PageManager::removeContentCollectionFactory
void removeContentCollectionFactory(PageContentCollectionFactory *f)
Remove a PageContentCollectionFactory implementation.
Ogre::PageManager::_prepareProceduralPage
virtual bool _prepareProceduralPage(Page *page, PagedWorldSection *section)
Give a provider the opportunity to prepare page content procedurally.
Ogre::PageProvider::prepareProceduralPage
virtual bool prepareProceduralPage(Page *page, PagedWorldSection *section)
Give a provider the opportunity to prepare page content procedurally.
Definition: OgrePageManager.h:71
Ogre::PageManager::destroyContentCollection
void destroyContentCollection(PageContentCollection *coll)
Destroy an instance of PageContentCollection.
Ogre::PageManager::removeStrategy
void removeStrategy(PageStrategy *strategy)
Remove a PageStrategy implementation.
Ogre::PageContent
Interface definition for a unit of content within a page.
Definition: OgrePageContent.h:50
Ogre::PageManager::addContentFactory
void addContentFactory(PageContentFactory *f)
Add a new PageContentFactory implementation.
Ogre::PageManager::mStrategies
StrategyMap mStrategies
Definition: OgrePageManager.h:460
Ogre::PageProvider::unloadProceduralPage
virtual bool unloadProceduralPage(Page *page, PagedWorldSection *section)
Give a provider the opportunity to unload page content procedurally.
Definition: OgrePageManager.h:86
OgreCamera.h
Ogre::PageManager::getContentCollectionFactory
PageContentCollectionFactory * getContentCollectionFactory(const String &name)
Get a PageContentCollectionFactory.
Ogre::PageManager::mEventRouter
EventRouter mEventRouter
Definition: OgrePageManager.h:468
Ogre::PageManager::EventRouter::frameStarted
bool frameStarted(const FrameEvent &evt)
Called when a frame is about to begin rendering.
Ogre::PageManager::mWorlds
WorldMap mWorlds
Definition: OgrePageManager.h:459
OgreString.h
Ogre::vector
Definition: OgrePrerequisites.h:492
Ogre::PageManager::ContentFactoryMap
map< String, PageContentFactory * >::type ContentFactoryMap
Definition: OgrePageManager.h:238
Ogre::PageManager::PageManager
PageManager()
Ogre::PageManager::_readPageStream
StreamSerialiser * _readPageStream(PageID pageID, PagedWorldSection *section)
Get a serialiser set up to read Page data for the given PageID.
Ogre::PageManager::_writePageStream
StreamSerialiser * _writePageStream(PageID pageID, PagedWorldSection *section)
Get a serialiser set up to write Page data for the given PageID.
Ogre::PageProvider::readWorldStream
virtual StreamSerialiser * readWorldStream(const String &filename)
Get a serialiser set up to read PagedWorld data for the given world filename.
Definition: OgrePageManager.h:101
Ogre::PageManager::saveWorld
void saveWorld(PagedWorld *world, const DataStreamPtr &stream)
Save a PagedWorld instance to a file.
Ogre::PageContentCollectionFactory
Define the interface to a factory class that will create subclasses of PageContentCollection.
Definition: OgrePageContentCollectionFactory.h:48
Ogre::PageManager::addCamera
void addCamera(Camera *c)
Tells the paging system to start tracking a given camera.
Ogre::PageManager::mGrid2DPageStrategy
Grid2DPageStrategy * mGrid2DPageStrategy
Definition: OgrePageManager.h:472
Ogre::PageManager::hasCamera
bool hasCamera(Camera *c) const
Returns whether or not a given camera is being watched by the paging system.
Ogre::PageManager::getDebugDisplayLevel
uint8 getDebugDisplayLevel() const
Get the debug display level.
Definition: OgrePageManager.h:424
Ogre::PageManager::CameraList
vector< Camera * >::type CameraList
Definition: OgrePageManager.h:409
Ogre::PageManager::EventRouter::cameraPreRenderScene
void cameraPreRenderScene(Camera *cam)
Called prior to the scene being rendered with this camera.
_OgrePagingExport
#define _OgrePagingExport
Definition: OgrePagingPrerequisites.h:72

Copyright © 2012 Torus Knot Software Ltd
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.