OGRE  2.0
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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-2014 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 "OgreCommon.h"
34 #include "OgreCamera.h"
35 #include "OgreFrameListener.h"
36 #include "OgreNameGenerator.h"
37 
38 namespace Ogre
39 {
48  class PagedWorldSection;
49  class PagedWorldSectionFactory;
50 
51 
58  {
59  public:
61  virtual ~PageProvider() {}
62 
69  virtual bool prepareProceduralPage(Page* page, PagedWorldSection* section) { return false; }
76  virtual bool loadProceduralPage(Page* page, PagedWorldSection* section) { return false; }
84  virtual bool unloadProceduralPage(Page* page, PagedWorldSection* section) { return false; }
92  virtual bool unprepareProceduralPage(Page* page, PagedWorldSection* section) { return false; }
93 
99  virtual StreamSerialiser* readWorldStream(const String& filename) { return 0; }
105  virtual StreamSerialiser* writeWorldStream(const String& filename) { return 0; }
114  virtual StreamSerialiser* readPageStream(PageID pageID, PagedWorldSection* section) { return 0; }
115 
124  virtual StreamSerialiser* writePageStream(PageID pageID, PagedWorldSection* section) { return 0; }
125  };
126 
135  {
136  public:
137  PageManager();
138  virtual ~PageManager();
139 
144  PagedWorld* createWorld(const String& name = BLANKSTRING);
145 
147  void destroyWorld(const String& name);
148 
150  void destroyWorld(PagedWorld* world);
151 
157  PagedWorld* loadWorld(const String& filename, const String& name = BLANKSTRING);
163  PagedWorld* loadWorld(const DataStreamPtr& stream, const String& name = BLANKSTRING);
168  void saveWorld(PagedWorld* world, const String& filename);
173  void saveWorld(PagedWorld* world, const DataStreamPtr& stream);
178  PagedWorld* getWorld(const String& name);
181  const WorldMap& getWorlds() const { return mWorlds; }
182 
183 
189  void addStrategy(PageStrategy* strategy);
190 
193  void removeStrategy(PageStrategy* strategy);
194 
199  PageStrategy* getStrategy(const String& name);
200 
203  const StrategyMap& getStrategies() const;
204 
205 
211  void addContentCollectionFactory(PageContentCollectionFactory* f);
212 
215  void removeContentCollectionFactory(PageContentCollectionFactory* f);
216 
221  PageContentCollectionFactory* getContentCollectionFactory(const String& name);
222 
227  PageContentCollection* createContentCollection(const String& typeName);
228 
230  void destroyContentCollection(PageContentCollection* coll);
231 
234  const ContentCollectionFactoryMap& getContentCollectionFactories() const;
235 
241  void addContentFactory(PageContentFactory* f);
242 
245  void removeContentFactory(PageContentFactory* f);
246 
251  PageContentFactory* getContentFactory(const String& name);
252 
255  const ContentFactoryMap& getContentFactories() const;
256 
261  PageContent* createContent(const String& typeName);
262 
264  void destroyContent(PageContent* c);
265 
266 
272  void addWorldSectionFactory(PagedWorldSectionFactory* f);
273 
276  void removeWorldSectionFactory(PagedWorldSectionFactory* f);
277 
282  PagedWorldSectionFactory* getWorldSectionFactory(const String& name);
283 
291  PagedWorldSection* createWorldSection(const String& typeName,
292  const String& name, PagedWorld* parent, SceneManager* sm);
293 
295  void destroyWorldSection(PagedWorldSection* s);
296 
299  const WorldSectionFactoryMap& getWorldSectionFactories() const;
300 
301 
313  void setPageProvider(PageProvider* provider) { mPageProvider = provider; }
314 
316  PageProvider* getPageProvider() const { return mPageProvider; }
317 
325  virtual bool _prepareProceduralPage(Page* page, PagedWorldSection* section);
333  virtual bool _loadProceduralPage(Page* page, PagedWorldSection* section);
341  virtual bool _unloadProceduralPage(Page* page, PagedWorldSection* section);
349  virtual bool _unprepareProceduralPage(Page* page, PagedWorldSection* section);
357  StreamSerialiser* _readPageStream(PageID pageID, PagedWorldSection* section);
358 
366  StreamSerialiser* _writePageStream(PageID pageID, PagedWorldSection* section);
372  StreamSerialiser* _readWorldStream(const String& filename);
373 
379  StreamSerialiser* _writeWorldStream(const String& filename);
380 
384  const String& getPageResourceGroup() const { return mPageResourceGroup; }
388  void setPageResourceGroup(const String& g) { mPageResourceGroup = g; }
389 
397  void addCamera(Camera* c);
398 
401  void removeCamera(Camera* c);
402 
405  bool hasCamera(Camera* c) const;
406 
409  const CameraList& getCameraList() const;
410 
420  void setDebugDisplayLevel(uint8 lvl) { mDebugDisplayLvl = lvl; }
422  uint8 getDebugDisplayLevel() const { return mDebugDisplayLvl; }
423 
430  void setPagingOperationsEnabled(bool enabled) { mPagingEnabled = enabled; }
431 
433  bool getPagingOperationsEnabled() const { return mPagingEnabled; }
434 
435 
436  protected:
437 
439  {
440  public:
444 
445  EventRouter() : pManager(0), pWorldMap(0), pCameraList(0) {}
447 
448  void cameraPreRenderScene(Camera* cam);
449  void cameraDestroyed(Camera* cam);
450  bool frameStarted(const FrameEvent& evt);
451  bool frameEnded(const FrameEvent& evt);
452  };
453 
454  void createStandardStrategies();
455  void createStandardContentFactories();
456 
469 
473  };
474 
477 }
478 
479 #endif
Grid3DPageStrategy * mGrid3DPageStrategy
unsigned char uint8
Definition: OgrePlatform.h:422
WorldSectionFactoryMap mWorldSectionFactories
A viewpoint from which the scene will be rendered.
Definition: OgreCamera.h:82
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...
ContentFactoryMap mContentFactories
void setPageResourceGroup(const String &g)
Set the resource group that will be used to read/write files when the default load routines are used...
Utility class to generate a sequentially numbered series of names.
const String & getPageResourceGroup() const
Get 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.
Page strategy which loads new pages based on a regular 3D grid.
void setPageProvider(PageProvider *provider)
Set the PageProvider which can provide streams for any Page.
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.
map< String, PagedWorldSectionFactory * >::type WorldSectionFactoryMap
Manages the organisation and rendering of a 'scene' i.e.
This class represents a collection of pages which make up a world.
void setPagingOperationsEnabled(bool enabled)
Pause or unpause all paging operations.
SimplePageContentCollectionFactory * mSimpleCollectionFactory
Page strategy which loads new pages based on a regular 2D grid.
Grid2DPageStrategy * mGrid2DPageStrategy
const String BLANKSTRING
Constant blank string, useful for returning by ref where local does not exist.
Definition: OgreCommon.h:574
Define the interface to a factory class that will create subclasses of PageContentCollection.
A factory class for creating types of world section.
Interface definition for a unit of content within a page.
Factory class for SimplePageContentCollection.
StrategyMap mStrategies
void setDebugDisplayLevel(uint8 lvl)
Set the debug display level.
map< String, PageContentCollectionFactory * >::type ContentCollectionFactoryMap
Definition of the interface for a collection of PageContent instances.
Superclass for all objects that wish to use custom memory allocators when their new / delete operator...
PageProvider * mPageProvider
ContentCollectionFactoryMap mContentCollectionFactories
A interface class defining a listener which can be used to receive notifications of frame events...
const WorldMap & getWorlds() const
Get a reference to the worlds that are currently loaded.
#define _OgrePagingExport
map< String, PagedWorld * >::type WorldMap
Utility class providing helper methods for reading / writing structured data held in a DataStream...
vector< Camera * >::type CameraList
Define the interface to a factory class that will create subclasses of PageContent.
bool getPagingOperationsEnabled() const
Get whether paging operations are currently allowed to happen.
map< String, PageStrategy * >::type StrategyMap
Page class.
Definition: OgrePage.h:49
EventRouter mEventRouter
CameraList mCameraList
virtual bool loadProceduralPage(Page *page, PagedWorldSection *section)
Give a provider the opportunity to load page content procedurally.
virtual bool unloadProceduralPage(Page *page, PagedWorldSection *section)
Give a provider the opportunity to unload page content procedurally.
NameGenerator mWorldNameGenerator
map< String, PageContentFactory * >::type ContentFactoryMap
Struct containing information about a frame event.
_StringBase String
Definition: OgreCommon.h:53
PageProvider * getPageProvider() const
Get the PageProvider which can provide streams for any Page.
virtual bool unprepareProceduralPage(Page *page, PagedWorldSection *section)
Give a provider the opportunity to unprepare page content procedurally.
Abstract class that can be implemented by the user application to provide a way to retrieve or genera...
Listener interface so you can be notified of Camera events.
Definition: OgreCamera.h:87
Represents a section of the PagedWorld which uses a given PageStrategy, and which is made up of a gen...
Defines the interface to a strategy class which is responsible for deciding when Page instances are r...
virtual StreamSerialiser * readWorldStream(const String &filename)
Get a serialiser set up to read PagedWorld data for the given world filename.
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...
uint8 getDebugDisplayLevel() const
Get the debug display level.
virtual StreamSerialiser * writeWorldStream(const String &filename)
Get a serialiser set up to write PagedWorld data for the given world filename.
uint32 PageID
Identifier for a page.