OGRE  1.7
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
OgreTerrainZonePageSource.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-2011 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 OgreTerrainZonePageSource.h - based on OgreTerrainPageSource.h from Ogre3d
28 
29 -----------------------------------------------------------------------------
30 begin : Thu May 3 2007
31 author : Eric Cha
32 email : ericcATxenopiDOTcom
33 
34 -----------------------------------------------------------------------------
35 */
36 
37 #ifndef __TerrainZonePageSource_H__
38 #define __TerrainZonePageSource_H__
39 
41 #include "OgreSingleton.h"
42 
43 namespace Ogre {
44 
45  typedef std::pair<String, String> TerrainZonePageSourceOption;
47 
52  {
53  public:
61  virtual void pageConstructed(TerrainZone* zone, size_t pagex, size_t pagez, Real* heightData) = 0;
63  };
64 
69  public Singleton<TerrainZonePageSourceListenerManager>, public GeneralAllocatedObject
70  {
71  protected:
74  public:
77 
84  void addListener(TerrainZonePageSourceListener* pl);
88  void removeListener(TerrainZonePageSourceListener* pl);
89 
91  void firePageConstructed(TerrainZone* manager, size_t pagex, size_t pagez, Real* heightData);
92 
95  static TerrainZonePageSourceListenerManager& getSingleton(void);
98  static TerrainZonePageSourceListenerManager* getSingletonPtr(void);
99 
100  };
101 
102 
145  {
146  protected:
152  unsigned short mPageSize;
154  unsigned short mTileSize;
155 
157  void firePageConstructed(size_t pagex, size_t pagez, Real* heightData);
158 
166  virtual TerrainZonePage* buildPage(Real* heightData, const MaterialPtr& pMaterial);
167 
168 
169  public:
171  virtual ~TerrainZonePageSource() { shutdown(); }
172 
193  virtual void initialise(TerrainZone* tz,
194  ushort tileSize, ushort pageSize, bool asyncLoading,
196  {
197  mTerrainZone = tz;
198  mTileSize = tileSize;
199  mPageSize = pageSize;
200  mAsyncLoading = asyncLoading;
201  }
209  virtual void shutdown(void) {}
210 
232  virtual void requestPage(ushort x, ushort z) = 0;
248  virtual void expirePage(ushort x, ushort z) = 0;
249 
256  static void addListener(TerrainZonePageSourceListener* pl);
260  static void removeListener(TerrainZonePageSourceListener* pl);
261 
262  };
263 
264 }
265 
266 #endif
unsigned short mPageSize
The expected size of the page in number of vertices.
float Real
Software floating point type.
std::vector< T, A > type
std::pair< String, String > TerrainZonePageSourceOption
This is a basic PCZone for organizing TerrainRenderables into a total landscape.
Template class for creating single-instance global classes.
Definition: OgreSingleton.h:64
virtual void shutdown(void)
Shut down this tile source, freeing all it's memory ready for decommissioning.
Abstract class which describes the interface which a source of terrain pages must implement...
#define _OgreOctreeZonePluginExport
TerrainZone * mTerrainZone
Link back to parent manager.
Groups a number of TerrainZoneRenderables (tiles) into a page, which is the unit of loading / unloadi...
Superclass for all objects that wish to use custom memory allocators when their new / delete operator...
unsigned short ushort
Simple manager class to hold onto a list of page source listeners across all sources.
vector< TerrainZonePageSourceOption >::type TerrainZonePageSourceOptionList
vector< TerrainZonePageSourceListener * >::type PageSourceListenerList
bool mAsyncLoading
Has asynchronous loading been requested?
Specialisation of SharedPtr to allow SharedPtr to be assigned to MaterialPtr.
Definition: OgreMaterial.h:677
Abstract class which classes can override to receive notifications when a page is ready to be added t...
virtual void initialise(TerrainZone *tz, ushort tileSize, ushort pageSize, bool asyncLoading, TerrainZonePageSourceOptionList &optionList)
Initialise this tile source based on a series of options as dictated by the scene manager...
unsigned short mTileSize
The expected size of a tile in number of vertices.