OGRE  1.7
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Ogre::TerrainPageSource Class Referenceabstract

Abstract class which describes the interface which a source of terrain pages must implement. More...

#include <OgreTerrainPageSource.h>

+ Inheritance diagram for Ogre::TerrainPageSource:
+ Collaboration diagram for Ogre::TerrainPageSource:

Public Member Functions

 TerrainPageSource ()
 
virtual ~TerrainPageSource ()
 
virtual void expirePage (ushort x, ushort z)=0
 This notifies the tile source that the specified page of tiles has been automatically detached. More...
 
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. More...
 
void operator delete (void *ptr)
 
void operator delete (void *ptr, void *)
 
void operator delete (void *ptr, const char *, int, const char *)
 
void operator delete[] (void *ptr)
 
void operator delete[] (void *ptr, const char *, int, const char *)
 
void * operator new (size_t sz, const char *file, int line, const char *func)
 operator new, with debug line info More...
 
void * operator new (size_t sz)
 
void * operator new (size_t sz, void *ptr)
 placement operator new More...
 
void * operator new[] (size_t sz, const char *file, int line, const char *func)
 array operator new, with debug line info More...
 
void * operator new[] (size_t sz)
 
virtual void requestPage (ushort x, ushort z)=0
 Requests a new page of tiles from the source. More...
 
virtual void shutdown (void)
 Shut down this tile source, freeing all it's memory ready for decommissioning. More...
 

Static Public Member Functions

static void addListener (TerrainPageSourceListener *pl)
 Register a class which will be called back whenever a new page is available. More...
 
static void removeListener (TerrainPageSourceListener *pl)
 Unregister a class which will be called back whenever a new page is available. More...
 

Protected Member Functions

virtual TerrainPagebuildPage (Real *heightData, const MaterialPtr &pMaterial)
 Utility method for building a page of tiles based on some source data, wherever that may have come from. More...
 
void firePageConstructed (size_t pagex, size_t pagez, Real *heightData)
 Internal method for firing pageContructed events. More...
 

Protected Attributes

bool mAsyncLoading
 Has asynchronous loading been requested? More...
 
unsigned short mPageSize
 The expected size of the page in number of vertices. More...
 
TerrainSceneManagermSceneManager
 Link back to parent manager. More...
 
unsigned short mTileSize
 The expected size of a tile in number of vertices. More...
 

Detailed Description

Abstract class which describes the interface which a source of terrain pages must implement.

Remarks
The TerrainSceneManager can accept external classes as providers of terrain data, to allow terrain height data to come from anywhere the user application may choose, and additionally to support on-demand loading an unloading of terrain data. Providers must suclass this class, and implement the abstract methods (details are described within each method)
The overall sequence of events is this:
  1. TerrainSceneManager is created as usual, and options such as tile size etc are set.
  2. CustomTerrainPageSource is registered with TerrainSceneManager by calling registerPageSource(), registering a particular named type of source data with this tile source.
  3. TerrainSceneManager::setWorldGeometry is called. Depending on the configuration, this will call one of the page source classes initialise methods, when the scene manager will communicate it's preferred options. It does not have to load anything immediately on this call (especially if the terrain options include paging). It will also set this tile source as the primary.
  4. As and when TerrainSceneManager requires more tiles (and this will either be done all up-front, or progressively depending on paging settings) it will call the primary tile source's requestPage() method, with the page it requires.
  5. It is then the responsibility of the tile source to prepare TerrainRenderable instances for the page(s) requested, and to attach them to the TerrainSceneManager. Note that preparing the tiles does not involve modifying any shared data so may be done in an alternate thread, if required. Attaching them must be done synchronously though.
  6. When paging, the TerrainSceneManager will request tiles in advance, within it's 'buffer zone' so some delay in loading is acceptable. It will also indicate when tiles are no longer required (and will detach them); it is up to the tile source whether that memory is actually freed or held for a while longer.
Note
The comments on paging above are in principle, the implementation of paging in this manager is not present yet but the system is designed to extend to it. For now, all tiles are requested up-front.

Definition at line 136 of file OgreTerrainPageSource.h.

Constructor & Destructor Documentation

Ogre::TerrainPageSource::TerrainPageSource ( )
virtual Ogre::TerrainPageSource::~TerrainPageSource ( )
inlinevirtual

Definition at line 163 of file OgreTerrainPageSource.h.

Member Function Documentation

static void Ogre::TerrainPageSource::addListener ( TerrainPageSourceListener pl)
static

Register a class which will be called back whenever a new page is available.

Remarks
Since this method is static, it applies to any page source which is in active use; there is no need to register one per source.
virtual TerrainPage* Ogre::TerrainPageSource::buildPage ( Real heightData,
const MaterialPtr pMaterial 
)
protectedvirtual

Utility method for building a page of tiles based on some source data, wherever that may have come from.

Remarks
It is expected that this height data is represented in the range [0..1], which will be duly scaled by the TerrainRenderables it creates.
virtual void Ogre::TerrainPageSource::expirePage ( ushort  x,
ushort  z 
)
pure virtual

This notifies the tile source that the specified page of tiles has been automatically detached.

Remarks
When paging is enabled, tiles go out of scope and the TerrainSceneManager detaches them automatically, notifying the TerrainPageSource that this has happened. The tile source can choose to either keep these tiles in memory (incase they are requested again) or can delete them if it wishes to free memory. This freeing does not need to be done before the return of this method - like requesting tiles, the freeing of them can be done in another thread or across many frames if required, since the shared data in TerrainSceneManager has already been updated synchronously when the page was detached.
Parameters
xThe x index of the page expired
zThe z index of the page expired

Implemented in Ogre::HeightmapTerrainPageSource.

void Ogre::TerrainPageSource::firePageConstructed ( size_t  pagex,
size_t  pagez,
Real heightData 
)
protected

Internal method for firing pageContructed events.

virtual void Ogre::TerrainPageSource::initialise ( TerrainSceneManager tsm,
ushort  tileSize,
ushort  pageSize,
bool  asyncLoading,
TerrainPageSourceOptionList optionList 
)
inlinevirtual

Initialise this tile source based on a series of options as dictated by the scene manager.

Parameters
tsmThe TerrainSceneManager doing the initialising. This should be allowed NULL, for use by external tools if they want to read data generically without necessarily having a real scene manager involved
tileSizeThe number of horizontal (and hence also vertical) vertices in a single tile (which is a TerrainRenderable). This will always be (2^n)+1.
pageSizeThe number of horizontal (and hence also vertical) vertices in a single page. This will always be (2^n)+1.
asyncLoadingTrue if the scene manager would like the tile source to load tiles asynchronously. It does not have to do this, although if it does not when requested, it will likely result in stalls in the terrain rendering.
optionListA list of name/value pairs describing custom options for this particular page source. The expected convention for option names is "TypeName.OptionName", where TypeName is the type under which this page source has been registered.

Reimplemented in Ogre::HeightmapTerrainPageSource.

Definition at line 185 of file OgreTerrainPageSource.h.

template<class Alloc >
void Ogre::AllocatedObject< Alloc >::operator delete ( void *  ptr)
inlineinherited

Definition at line 95 of file OgreMemoryAllocatedObject.h.

template<class Alloc >
void Ogre::AllocatedObject< Alloc >::operator delete ( void *  ptr,
void *   
)
inlineinherited

Definition at line 101 of file OgreMemoryAllocatedObject.h.

template<class Alloc >
void Ogre::AllocatedObject< Alloc >::operator delete ( void *  ptr,
const char *  ,
int  ,
const char *   
)
inlineinherited

Definition at line 107 of file OgreMemoryAllocatedObject.h.

template<class Alloc >
void Ogre::AllocatedObject< Alloc >::operator delete[] ( void *  ptr)
inlineinherited

Definition at line 112 of file OgreMemoryAllocatedObject.h.

template<class Alloc >
void Ogre::AllocatedObject< Alloc >::operator delete[] ( void *  ptr,
const char *  ,
int  ,
const char *   
)
inlineinherited

Definition at line 118 of file OgreMemoryAllocatedObject.h.

template<class Alloc >
void* Ogre::AllocatedObject< Alloc >::operator new ( size_t  sz,
const char *  file,
int  line,
const char *  func 
)
inlineinherited

operator new, with debug line info

Definition at line 67 of file OgreMemoryAllocatedObject.h.

template<class Alloc >
void* Ogre::AllocatedObject< Alloc >::operator new ( size_t  sz)
inlineinherited

Definition at line 72 of file OgreMemoryAllocatedObject.h.

template<class Alloc >
void* Ogre::AllocatedObject< Alloc >::operator new ( size_t  sz,
void *  ptr 
)
inlineinherited

placement operator new

Definition at line 78 of file OgreMemoryAllocatedObject.h.

template<class Alloc >
void* Ogre::AllocatedObject< Alloc >::operator new[] ( size_t  sz,
const char *  file,
int  line,
const char *  func 
)
inlineinherited

array operator new, with debug line info

Definition at line 85 of file OgreMemoryAllocatedObject.h.

template<class Alloc >
void* Ogre::AllocatedObject< Alloc >::operator new[] ( size_t  sz)
inlineinherited

Definition at line 90 of file OgreMemoryAllocatedObject.h.

static void Ogre::TerrainPageSource::removeListener ( TerrainPageSourceListener pl)
static

Unregister a class which will be called back whenever a new page is available.

virtual void Ogre::TerrainPageSource::requestPage ( ushort  x,
ushort  z 
)
pure virtual

Requests a new page of tiles from the source.

Remarks
The TerrainSceneManager will call this method when it needs new tiles. In response, this class must prepare TerrainRenderable instances for the page requested and attach the entire page when ready using TerrainSceneManager::attachTerrainPage.
Now, the tile source does not necessarily need to do all that before the return of this method. If it likes, and particularly if asynchronous loading is enabled, it can merely queue this request, and process it either in another thread, or over a series of frames. The key thing is that attaching the new page has to be done synchronously with the main rendering loop in order to avoid concurrency issues; other than that, you are free to load and prepare new tiles in a concurrent fashion if you like.
Typically the scene manager will request at least one page up-front, with the possibility of requesting more if paging is enabled.
Parameters
xThe x index of the page requested
zThe z index of the page requested

Implemented in Ogre::HeightmapTerrainPageSource.

virtual void Ogre::TerrainPageSource::shutdown ( void  )
inlinevirtual

Shut down this tile source, freeing all it's memory ready for decommissioning.

Remarks
This method will normally just be called on destruction; however it may also be called by the TerrainSceneManager if another source is provided for the same type of tile source.

Reimplemented in Ogre::HeightmapTerrainPageSource.

Definition at line 201 of file OgreTerrainPageSource.h.

Member Data Documentation

bool Ogre::TerrainPageSource::mAsyncLoading
protected

Has asynchronous loading been requested?

Definition at line 142 of file OgreTerrainPageSource.h.

unsigned short Ogre::TerrainPageSource::mPageSize
protected

The expected size of the page in number of vertices.

Definition at line 144 of file OgreTerrainPageSource.h.

TerrainSceneManager* Ogre::TerrainPageSource::mSceneManager
protected

Link back to parent manager.

Definition at line 140 of file OgreTerrainPageSource.h.

unsigned short Ogre::TerrainPageSource::mTileSize
protected

The expected size of a tile in number of vertices.

Definition at line 146 of file OgreTerrainPageSource.h.


The documentation for this class was generated from the following file: