OGRE  1.9.0
OgrePageManager.h
Go to the documentation of this file.
1/*
2-----------------------------------------------------------------------------
3This source file is part of OGRE
4(Object-oriented Graphics Rendering Engine)
5For the latest info, see http://www.ogre3d.org/
6
7Copyright (c) 2000-2014 Torus Knot Software Ltd
8
9Permission is hereby granted, free of charge, to any person obtaining a copy
10of this software and associated documentation files (the "Software"), to deal
11in the Software without restriction, including without limitation the rights
12to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13copies of the Software, and to permit persons to whom the Software is
14furnished to do so, subject to the following conditions:
15
16The above copyright notice and this permission notice shall be included in
17all copies or substantial portions of the Software.
18
19THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25THE 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
40namespace 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
146 PagedWorld* createWorld(const String& name = StringUtil::BLANK);
147
149 void destroyWorld(const String& name);
150
153
159 PagedWorld* loadWorld(const String& filename, const String& name = StringUtil::BLANK);
165 PagedWorld* loadWorld(const DataStreamPtr& stream, const String& name = StringUtil::BLANK);
170 void saveWorld(PagedWorld* world, const String& filename);
175 void saveWorld(PagedWorld* world, const DataStreamPtr& stream);
183 const WorldMap& getWorlds() const { return mWorlds; }
184
185
191 void addStrategy(PageStrategy* strategy);
192
196
202
206
207
214
218
224
230
233
237
244
248
254
258
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
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
#define _OgrePagingExport
Superclass for all objects that wish to use custom memory allocators when their new / delete operator...
Listener interface so you can be notified of Camera events.
Definition OgreCamera.h:92
A viewpoint from which the scene will be rendered.
Definition OgreCamera.h:87
A interface class defining a listener which can be used to receive notifications of frame events.
Page strategy which loads new pages based on a regular 2D grid.
Page strategy which loads new pages based on a regular 3D grid.
Utility class to generate a sequentially numbered series of names.
Define the interface to a factory class that will create subclasses of PageContentCollection.
Definition of the interface for a collection of PageContent instances.
Define the interface to a factory class that will create subclasses of PageContent.
Interface definition for a unit of content within a page.
void cameraDestroyed(Camera *cam)
Called when the camera is being destroyed.
void cameraPreRenderScene(Camera *cam)
Called prior to the scene being rendered with this camera.
bool frameEnded(const FrameEvent &evt)
Called just after a frame has been rendered.
bool frameStarted(const FrameEvent &evt)
Called when a frame is about to begin rendering.
The PageManager is the entry point through which you load all PagedWorld instances,...
void destroyWorld(PagedWorld *world)
Destroy a world.
ContentFactoryMap mContentFactories
void destroyWorldSection(PagedWorldSection *s)
Destroy an instance of PagedWorldSection.
void saveWorld(PagedWorld *world, const String &filename)
Save a PagedWorld instance to a file.
void destroyContent(PageContent *c)
Destroy an instance of PageContent.
SimplePageContentCollectionFactory * mSimpleCollectionFactory
void removeContentFactory(PageContentFactory *f)
Remove a PageContentFactory implementation.
const ContentCollectionFactoryMap & getContentCollectionFactories() const
Get a reference to the registered strategies.
PageContentFactory * getContentFactory(const String &name)
Get a PageContentFactory.
Grid2DPageStrategy * mGrid2DPageStrategy
ContentCollectionFactoryMap mContentCollectionFactories
map< String, PageStrategy * >::type StrategyMap
PageStrategy * getStrategy(const String &name)
Get a PageStrategy.
PagedWorld * createWorld(const String &name=StringUtil::BLANK)
Create a new PagedWorld instance.
const CameraList & getCameraList() const
Returns a list of cameras being tracked.
map< String, PagedWorldSectionFactory * >::type WorldSectionFactoryMap
bool getPagingOperationsEnabled() const
Get whether paging operations are currently allowed to happen.
PageContent * createContent(const String &typeName)
Create a new instance of PageContent using the registered factories.
void destroyWorld(const String &name)
Destroy a world.
const StrategyMap & getStrategies() const
Get a reference to the registered strategies.
void setPageProvider(PageProvider *provider)
Set the PageProvider which can provide streams for any Page.
PageProvider * mPageProvider
WorldSectionFactoryMap mWorldSectionFactories
PageProvider * getPageProvider() const
Get the PageProvider which can provide streams for any Page.
void removeCamera(Camera *c)
Tells the paging system to stop tracking a given camera.
void removeStrategy(PageStrategy *strategy)
Remove a PageStrategy implementation.
StreamSerialiser * _readWorldStream(const String &filename)
Get a serialiser set up to read PagedWorld data for the given world name.
const String & getPageResourceGroup() const
Get the resource group that will be used to read/write files when the default load routines are used.
virtual ~PageManager()
vector< Camera * >::type CameraList
map< String, PagedWorld * >::type WorldMap
void createStandardContentFactories()
virtual bool _loadProceduralPage(Page *page, PagedWorldSection *section)
Give a provider the opportunity to prepare page content procedurally.
void addContentFactory(PageContentFactory *f)
Add a new PageContentFactory implementation.
void addContentCollectionFactory(PageContentCollectionFactory *f)
Add a new PageContentCollectionFactory implementation.
void setDebugDisplayLevel(uint8 lvl)
Set the debug display level.
const ContentFactoryMap & getContentFactories() const
Get a reference to the registered strategies.
PagedWorldSection * createWorldSection(const String &typeName, const String &name, PagedWorld *parent, SceneManager *sm)
Create a new instance of PagedWorldSection using the registered factories.
void addWorldSectionFactory(PagedWorldSectionFactory *f)
Add a new PagedWorldSectionFactory implementation.
StreamSerialiser * _writeWorldStream(const String &filename)
Get a serialiser set up to write PagedWorld data.
PageContentCollection * createContentCollection(const String &typeName)
Create a new instance of PageContentCollection using the registered factories.
const WorldMap & getWorlds() const
Get a reference to the worlds that are currently loaded.
StreamSerialiser * _writePageStream(PageID pageID, PagedWorldSection *section)
Get a serialiser set up to write Page data for the given PageID.
StrategyMap mStrategies
EventRouter mEventRouter
const WorldSectionFactoryMap & getWorldSectionFactories() const
Get a reference to the registered strategies.
Grid3DPageStrategy * mGrid3DPageStrategy
NameGenerator mWorldNameGenerator
void destroyContentCollection(PageContentCollection *coll)
Destroy an instance of PageContentCollection.
void createStandardStrategies()
void addStrategy(PageStrategy *strategy)
Add a new PageStrategy implementation.
map< String, PageContentCollectionFactory * >::type ContentCollectionFactoryMap
PagedWorld * loadWorld(const String &filename, const String &name=StringUtil::BLANK)
Load a new PagedWorld from a file.
PagedWorld * getWorld(const String &name)
Get a named world.
virtual bool _unloadProceduralPage(Page *page, PagedWorldSection *section)
Give a manager the opportunity to unload page content procedurally.
map< String, PageContentFactory * >::type ContentFactoryMap
virtual bool _unprepareProceduralPage(Page *page, PagedWorldSection *section)
Give a manager the opportunity to unprepare page content procedurally.
void saveWorld(PagedWorld *world, const DataStreamPtr &stream)
Save a PagedWorld instance to a file.
PagedWorldSectionFactory * getWorldSectionFactory(const String &name)
Get a PagedWorldSectionFactory.
void removeContentCollectionFactory(PageContentCollectionFactory *f)
Remove a PageContentCollectionFactory implementation.
void addCamera(Camera *c)
Tells the paging system to start tracking a given camera.
void setPagingOperationsEnabled(bool enabled)
Pause or unpause all paging operations.
PageContentCollectionFactory * getContentCollectionFactory(const String &name)
Get a PageContentCollectionFactory.
void removeWorldSectionFactory(PagedWorldSectionFactory *f)
Remove a PagedWorldSectionFactory implementation.
bool hasCamera(Camera *c) const
Returns whether or not a given camera is being watched by the paging system.
uint8 getDebugDisplayLevel() const
Get the debug display level.
PagedWorld * loadWorld(const DataStreamPtr &stream, const String &name=StringUtil::BLANK)
Load a new PagedWorld from a stream.
void setPageResourceGroup(const String &g)
Set the resource group that will be used to read/write files when the default load routines are used.
virtual bool _prepareProceduralPage(Page *page, PagedWorldSection *section)
Give a provider the opportunity to prepare page content procedurally.
StreamSerialiser * _readPageStream(PageID pageID, PagedWorldSection *section)
Get a serialiser set up to read Page data for the given PageID.
Abstract class that can be implemented by the user application to provide a way to retrieve or genera...
virtual StreamSerialiser * readWorldStream(const String &filename)
Get a serialiser set up to read PagedWorld data for the given world filename.
virtual bool loadProceduralPage(Page *page, PagedWorldSection *section)
Give a provider the opportunity to load page content procedurally.
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...
virtual bool unprepareProceduralPage(Page *page, PagedWorldSection *section)
Give a provider the opportunity to unprepare page content procedurally.
virtual bool prepareProceduralPage(Page *page, PagedWorldSection *section)
Give a provider the opportunity to prepare page content procedurally.
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...
virtual StreamSerialiser * writeWorldStream(const String &filename)
Get a serialiser set up to write PagedWorld data for the given world filename.
virtual bool unloadProceduralPage(Page *page, PagedWorldSection *section)
Give a provider the opportunity to unload page content procedurally.
Defines the interface to a strategy class which is responsible for deciding when Page instances are r...
Page class.
Definition OgrePage.h:51
A factory class for creating types of world section.
Represents a section of the PagedWorld which uses a given PageStrategy, and which is made up of a gen...
This class represents a collection of pages which make up a world.
Manages the organisation and rendering of a 'scene' i.e.
Factory class for SimplePageContentCollection.
Utility class providing helper methods for reading / writing structured data held in a DataStream.
unsigned char uint8
uint32 PageID
Identifier for a page.
_StringBase String
Struct containing information about a frame event.
std::map< K, V, P, A > type
std::vector< T, A > type