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:
139  PageManager();
140  virtual ~PageManager();
141 
146  PagedWorld* createWorld(const String& name = StringUtil::BLANK);
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);
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);
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 
201  PageStrategy* getStrategy(const String& name);
202 
205  const StrategyMap& getStrategies() const;
206 
207 
213  void addContentCollectionFactory(PageContentCollectionFactory* f);
214 
217  void removeContentCollectionFactory(PageContentCollectionFactory* f);
218 
223  PageContentCollectionFactory* getContentCollectionFactory(const String& name);
224 
229  PageContentCollection* createContentCollection(const String& typeName);
230 
232  void destroyContentCollection(PageContentCollection* coll);
233 
236  const ContentCollectionFactoryMap& getContentCollectionFactories() const;
237 
243  void addContentFactory(PageContentFactory* f);
244 
247  void removeContentFactory(PageContentFactory* f);
248 
253  PageContentFactory* getContentFactory(const String& name);
254 
257  const ContentFactoryMap& getContentFactories() const;
258 
263  PageContent* createContent(const String& typeName);
264 
266  void destroyContent(PageContent* c);
267 
268 
274  void addWorldSectionFactory(PagedWorldSectionFactory* f);
275 
278  void removeWorldSectionFactory(PagedWorldSectionFactory* f);
279 
284  PagedWorldSectionFactory* getWorldSectionFactory(const String& name);
285 
293  PagedWorldSection* createWorldSection(const String& typeName,
294  const String& name, PagedWorld* parent, SceneManager* sm);
295 
297  void destroyWorldSection(PagedWorldSection* s);
298 
301  const WorldSectionFactoryMap& getWorldSectionFactories() const;
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);
359  StreamSerialiser* _readPageStream(PageID pageID, PagedWorldSection* section);
360 
368  StreamSerialiser* _writePageStream(PageID pageID, PagedWorldSection* section);
374  StreamSerialiser* _readWorldStream(const String& filename);
375 
381  StreamSerialiser* _writeWorldStream(const String& filename);
382 
386  const String& getPageResourceGroup() const { return mPageResourceGroup; }
390  void setPageResourceGroup(const String& g) { mPageResourceGroup = g; }
391 
399  void addCamera(Camera* c);
400 
403  void removeCamera(Camera* c);
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:
444  WorldMap* pWorldMap;
445  CameraList* pCameraList;
446 
447  EventRouter() : pManager(0), pWorldMap(0), pCameraList(0) {}
449 
450  void cameraPreRenderScene(Camera* cam);
451  void cameraDestroyed(Camera* cam);
452  bool frameStarted(const FrameEvent& evt);
453  bool frameEnded(const FrameEvent& evt);
454  };
455 
456  void createStandardStrategies();
457  void createStandardContentFactories();
458 
459  WorldMap mWorlds;
460  StrategyMap mStrategies;
461  ContentCollectionFactoryMap mContentCollectionFactories;
462  ContentFactoryMap mContentFactories;
463  WorldSectionFactoryMap mWorldSectionFactories;
467  CameraList mCameraList;
471 
475  };
476 
479 }
480 
481 #endif
Grid2DPageStrategy * mGrid2DPageStrategy
virtual bool unloadProceduralPage(Page *page, PagedWorldSection *section)
Give a provider the opportunity to unload page content procedurally.
#define _OgrePagingExport
map< String, PagedWorldSectionFactory * >::type WorldSectionFactoryMap
WorldSectionFactoryMap mWorldSectionFactories
Page strategy which loads new pages based on a regular 3D grid.
void setPagingOperationsEnabled(bool enabled)
Pause or unpause all paging operations.
map< String, PageContentFactory * >::type ContentFactoryMap
map< String, PagedWorld * >::type WorldMap
Page class.
Definition: OgrePage.h:49
Interface definition for a unit of content within a page.
Utility class to generate a sequentially numbered series of names.
A factory class for creating types of world section.
Define the interface to a factory class that will create subclasses of PageContentCollection.
uint8 getDebugDisplayLevel() const
Get the debug display level.
Represents a section of the PagedWorld which uses a given PageStrategy, and which is made up of a gen...
map< String, PageContentCollectionFactory * >::type ContentCollectionFactoryMap
virtual bool loadProceduralPage(Page *page, PagedWorldSection *section)
Give a provider the opportunity to load page content procedurally.
SimplePageContentCollectionFactory * mSimpleCollectionFactory
ContentFactoryMap mContentFactories
NameGenerator mWorldNameGenerator
map< String, PageStrategy * >::type StrategyMap
virtual StreamSerialiser * readWorldStream(const String &filename)
Get a serialiser set up to read PagedWorld data for the given world filename.
void setPageProvider(PageProvider *provider)
Set the PageProvider which can provide streams for any Page.
Grid3DPageStrategy * mGrid3DPageStrategy
vector< Camera * >::type CameraList
CameraList mCameraList
virtual bool unprepareProceduralPage(Page *page, PagedWorldSection *section)
Give a provider the opportunity to unprepare page content procedurally.
unsigned char uint8
Definition: OgrePlatform.h:361
The PageManager is the entry point through which you load all PagedWorld instances, and the place where PageStrategy instances and factory classes are registered to customise the paging behaviour.
Struct containing information about a frame event.
void setDebugDisplayLevel(uint8 lvl)
Set the debug display level.
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 of the interface for a collection of PageContent instances.
_StringBase String
ContentCollectionFactoryMap mContentCollectionFactories
This class represents a collection of pages which make up a world.
Utility class providing helper methods for reading / writing structured data held in a DataStream...
A viewpoint from which the scene will be rendered.
Definition: OgreCamera.h:86
Page strategy which loads new pages based on a regular 2D grid.
uint32 PageID
Identifier for a page.
PageProvider * mPageProvider
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...
EventRouter mEventRouter
const String & getPageResourceGroup() const
Get the resource group that will be used to read/write files when the default load routines are used...
Abstract class that can be implemented by the user application to provide a way to retrieve or genera...
virtual bool prepareProceduralPage(Page *page, PagedWorldSection *section)
Give a provider the opportunity to prepare page content procedurally.
Factory class for SimplePageContentCollection.
virtual StreamSerialiser * writeWorldStream(const String &filename)
Get a serialiser set up to write PagedWorld data for the given world filename.
Define the interface to a factory class that will create subclasses of PageContent.
Listener interface so you can be notified of Camera events.
Definition: OgreCamera.h:91
Manages the organisation and rendering of a &#39;scene&#39; i.e.
StrategyMap mStrategies
bool getPagingOperationsEnabled() const
Get whether paging operations are currently allowed to happen.
const WorldMap & getWorlds() const
Get a reference to the worlds that are currently loaded.
static const String BLANK
Constant blank string, useful for returning by ref where local does not exist.
Definition: OgreString.h:196
void setPageResourceGroup(const String &g)
Set the resource group that will be used to read/write files when the default load routines are used...
A interface class defining a listener which can be used to receive notifications of frame events...
Defines the interface to a strategy class which is responsible for deciding when Page instances are r...
Superclass for all objects that wish to use custom memory allocators when their new / delete operator...
PageProvider * getPageProvider() const
Get the PageProvider which can provide streams for any Page.

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