OGRE  1.7
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
OgreTerrainPageSource.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 */
28 
29 #ifndef __TerrainPageSource_H__
30 #define __TerrainPageSource_H__
31 
33 #include "OgreSingleton.h"
34 
35 namespace Ogre {
36 
37  typedef std::pair<String, String> TerrainPageSourceOption;
39 
44  {
45  public:
53  virtual void pageConstructed(TerrainSceneManager* manager, size_t pagex, size_t pagez, Real* heightData) = 0;
55  };
56 
61  public Singleton<TerrainPageSourceListenerManager>, public GeneralAllocatedObject
62  {
63  protected:
66  public:
69 
76  void addListener(TerrainPageSourceListener* pl);
80  void removeListener(TerrainPageSourceListener* pl);
81 
83  void firePageConstructed(TerrainSceneManager* manager, size_t pagex, size_t pagez, Real* heightData);
84 
87  static TerrainPageSourceListenerManager& getSingleton(void);
90  static TerrainPageSourceListenerManager* getSingletonPtr(void);
91 
92  };
93 
94 
137  {
138  protected:
144  unsigned short mPageSize;
146  unsigned short mTileSize;
147 
149  void firePageConstructed(size_t pagex, size_t pagez, Real* heightData);
150 
158  virtual TerrainPage* buildPage(Real* heightData, const MaterialPtr& pMaterial);
159 
160 
161  public:
163  virtual ~TerrainPageSource() { shutdown(); }
164 
185  virtual void initialise(TerrainSceneManager* tsm,
186  ushort tileSize, ushort pageSize, bool asyncLoading,
187  TerrainPageSourceOptionList& optionList)
188  {
189  mSceneManager = tsm;
190  mTileSize = tileSize;
191  mPageSize = pageSize;
192  mAsyncLoading = asyncLoading;
193  }
201  virtual void shutdown(void) {}
202 
224  virtual void requestPage(ushort x, ushort z) = 0;
240  virtual void expirePage(ushort x, ushort z) = 0;
241 
248  static void addListener(TerrainPageSourceListener* pl);
252  static void removeListener(TerrainPageSourceListener* pl);
253 
254  };
255 
256 }
257 
258 #endif
float Real
Software floating point type.
bool mAsyncLoading
Has asynchronous loading been requested?
std::vector< T, A > type
Template class for creating single-instance global classes.
Definition: OgreSingleton.h:64
unsigned short mPageSize
The expected size of the page in number of vertices.
virtual void shutdown(void)
Shut down this tile source, freeing all it's memory ready for decommissioning.
Abstract class which classes can override to receive notifications when a page is ready to be added t...
unsigned short mTileSize
The expected size of a tile in number of vertices.
virtual void initialise(TerrainSceneManager *tsm, ushort tileSize, ushort pageSize, bool asyncLoading, TerrainPageSourceOptionList &optionList)
Initialise this tile source based on a series of options as dictated by the scene manager...
This is a basic SceneManager for organizing TerrainRenderables into a total landscape.
Superclass for all objects that wish to use custom memory allocators when their new / delete operator...
vector< TerrainPageSourceListener * >::type PageSourceListenerList
unsigned short ushort
vector< TerrainPageSourceOption >::type TerrainPageSourceOptionList
Simple manager class to hold onto a list of page source listeners across all sources.
Groups a number of TerrainRenderables (tiles) into a page, which is the unit of loading / unloading...
Specialisation of SharedPtr to allow SharedPtr to be assigned to MaterialPtr.
Definition: OgreMaterial.h:677
Abstract class which describes the interface which a source of terrain pages must implement...
std::pair< String, String > TerrainPageSourceOption
TerrainSceneManager * mSceneManager
Link back to parent manager.