23#ifndef __PagedGeometry_H__
24#define __PagedGeometry_H__
30#include <OgrePrerequisites.h>
31#include <OgreRenderSystem.h>
32#include <OgreEntity.h>
33#include <OgreCommon.h>
34#include <OgreCamera.h>
35#include <OgreVector3.h>
41class GeometryPageManager;
92 PagedGeometry(Ogre::Camera *cam = NULL, Ogre::Real
pageSize = 100, Ogre::SceneNode* groupingSceneNode = NULL, Ogre::RenderQueueGroupID queue = Ogre::RENDER_QUEUE_6);
715 virtual void setRegion(Ogre::Real left, Ogre::Real top, Ogre::Real right, Ogre::Real bottom) {};
732 virtual void addEntity(Ogre::Entity *ent,
const Ogre::Vector3 &position,
const Ogre::Quaternion &rotation,
const Ogre::Vector3 &scale,
const Ogre::ColourValue &color) = 0;
778 virtual void setFade(
bool enabled, Ogre::Real visibleDist = 0, Ogre::Real invisibleDist = 0) = 0;
842 virtual void addEntityToBoundingBox(Ogre::Entity *ent,
const Ogre::Vector3 &position,
const Ogre::Quaternion &rotation,
const Ogre::Vector3 &scale);
880 std::list<GeometryPage*>::iterator
_iter;
1081 void addEntity(Ogre::Entity *ent,
const Ogre::Vector3 &position,
const Ogre::Quaternion &rotation,
const Ogre::Vector3 &scale = Ogre::Vector3::UNIT_SCALE,
const Ogre::ColourValue &color = Ogre::ColourValue::White)
1213 if (transitionLength > 0) {
1239 template <
class PageType>
void initPages(
const TBounds& bounds,
const Ogre::Any &data = Ogre::Any());
1242 void update(
unsigned long deltaTime, Ogre::Vector3 &camPos, Ogre::Vector3 &camSpeed,
bool &enableCache,
GeometryPageManager *prevManager);
1280 OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS,
1281 "Grid dimension is out of bounds",
1282 "GeometryPageManager::_getGridPage()");
1291 OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS,
1292 "Grid dimension is out of bounds",
1293 "GeometryPageManager::_setGridPage()");
1334 Ogre::Root *root = root->getSingletonPtr();
1335 if (!root->getRenderSystem()->getCapabilities()->hasCapability(Ogre::RSC_VERTEX_PROGRAM))
1336 transitionLength = 0;
1353 if(bounds.width() < 0.00001)
This base-class can be extended to provide different ways of representing entities.
virtual void setFade(bool enabled, Ogre::Real visibleDist=0, Ogre::Real invisibleDist=0)=0
Sets fade behavior for this page.
Ogre::Vector3 _centerPoint
Ogre::AxisAlignedBox _trueBounds
virtual void removeEntities()=0
Remove all geometry/entities from the page completely.
virtual void init(PagedGeometry *geom, const Ogre::Any &data)=0
Prepare a geometry page for use.
virtual void clearBoundingBox()
Advanced: Reset the bounding box used by addEntityToBoundingBox()
virtual void build()
Perform any final steps to make added entities appear in the scene.
virtual void setVisible(bool visible)=0
Toggle the entire page's visibility.
virtual void update()
Do whatever needs to be done to keep the page geometry up-to-date.
bool _trueBoundsUndefined
std::list< GeometryPage * >::iterator _iter
virtual const Ogre::AxisAlignedBox & getBoundingBox()
Advanced: Return the bounding box computed with addEntityToBoundingBox()
virtual void addEntity(Ogre::Entity *ent, const Ogre::Vector3 &position, const Ogre::Quaternion &rotation, const Ogre::Vector3 &scale, const Ogre::ColourValue &color)=0
Add an entity to the page, at the specified position, rotation, and scale.
virtual ~GeometryPage()
Destructor This is defined here so the destructors of derived classes are called properly.
Ogre::Vector3 & getCenterPoint()
Gets the center point of the page.
bool isVisible()
Return the current visibility status of the page.
GeometryPage()
Constructor Initialise everything to zero, false or NULL except for _trueBoundsUndefined that is set ...
unsigned long _inactiveTime
virtual void addEntityToBoundingBox(Ogre::Entity *ent, const Ogre::Vector3 &position, const Ogre::Quaternion &rotation, const Ogre::Vector3 &scale)
Advanced: Expand the current bounding box to include the given entity.
virtual void setRegion(Ogre::Real left, Ogre::Real top, Ogre::Real right, Ogre::Real bottom)
Prepare a geometry page for entities.
Manages the rendering of geometry for a detail level type.
void setTransition(Ogre::Real transitionLength)
Ogre::Real getTransition() const
TPGeometryPages pendingList
void update(unsigned long deltaTime, Ogre::Vector3 &camPos, Ogre::Vector3 &camSpeed, bool &enableCache, GeometryPageManager *prevManager)
Internal function - DO NOT USE.
void reloadGeometryPage(const Ogre::Vector3 &point)
Internal function - DO NOT USE.
void _scrollGridPages(int shiftX, int shiftZ)
GeometryPage * _getGridPage(const int x, const int z)
GeometryPage ** scrollBuffer
void initPages(const TBounds &bounds, const Ogre::Any &data=Ogre::Any())
Internal function - DO NOT USE.
void _unloadPage(GeometryPage *page)
void setFarRange(Ogre::Real farRange)
Sets the far viewing range of this page manager.
void setCacheSpeed(unsigned long maxCacheInterval=200, unsigned long inactivePageLife=2000)
Customizes the cache behaviour (advanced).
~GeometryPageManager()
Internal function - DO NOT USE.
void setNearRange(Ogre::Real nearRange)
Sets the near viewing range of this page manager.
void preloadGeometry(const TBounds &area)
Internal function - DO NOT USE.
unsigned long inactivePageLife
TPGeometryPages getLoadedPages() const
Internal function - DO NOT USE.
void _setGridPage(const int x, const int z, GeometryPage *page)
void resetPreloadedGeometry()
Internal function - DO NOT USE.
unsigned long maxCacheInterval
Ogre::Real getNearRange() const
Gets the near viewing range of this page manager.
TPGeometryPages loadedList
void _loadPage(GeometryPage *page)
Ogre::Real farTransDistSq
Ogre::Real getFarRange() const
Gets the far viewing range of this page manager.
void reloadGeometryPages(const Ogre::Vector3 ¢er, Ogre::Real radius)
Internal function - DO NOT USE.
std::list< GeometryPage * > TPGeometryPages
A std::list of pointers to geometry pages.
void _unloadPageDelayed(GeometryPage *page)
void reloadGeometry()
Internal function - DO NOT USE.
A class which you extend to provide a callback function for loading entities.
virtual void unloadPage(PageInfo &page)
This may be overridden (optional) to unload custom data associated with a page.
virtual void frameUpdate()
Provides a method for you to perform per-frame tasks for your PageLoader if overridden (optional)
virtual void loadPage(PageInfo &page)=0
This should be overridden to load a specified region of entities.
virtual ~PageLoader()
Destructor This is defined here so the destructors of derived classes are called properly.
void addEntity(Ogre::Entity *ent, const Ogre::Vector3 &position, const Ogre::Quaternion &rotation, const Ogre::Vector3 &scale=Ogre::Vector3::UNIT_SCALE, const Ogre::ColourValue &color=Ogre::ColourValue::White)
Call this from loadPage() to add an entity to the page being loaded.
A class providing highly optimized methods for rendering massive amounts of geometry.
Ogre::Real getPageSize()
Gets the current page size.
std::list< GeometryPageManager * > managerList
void reloadGeometryPages(const Ogre::Vector3 ¢er, Ogre::Real radius)
Reloads geometry in the given radius area.
void removeDetailLevels()
Removes all detail levels from the PagedGeometry object.
bool geometryAllowedVisible
const TBounds & getBounds() const
Gets the current geometry boundary.
void setCamera(Ogre::Camera *cam)
Sets the camera to use when calculating levels of detail.
void setTempDir(Ogre::String dir)
Sets the output directory for the imposter pages.
void setVisible(bool visible)
Hides or unhides all geometry managed by this PagedGeometry instance \params visible Whether or not y...
void preloadGeometry(const TBounds &area)
Preloads a region of geometry (loads once and never loads again)
Ogre::uint8 getRenderQueue() const
Returns the rendering queue that paged geometry was constructed with.
void reloadGeometryPage(const Ogre::Vector3 &point)
Reloads geometry at the given location.
void setPageLoader(PageLoader *loader)
Assigns a PageLoader object for the PagedGeometry.
GeometryPageManager * addDetailLevel(Ogre::Real maxRange, Ogre::Real transitionLength=0, const Ogre::Any &data=Ogre::Any())
Adds a detail level to the PagedGeometry object.
const std::list< GeometryPageManager * > & getDetailLevels()
Returns a reference to a list of all added detail levels.
Ogre::SceneManager * sceneMgr
bool getVisible()
Returns whether or not geometry managed by this PagedGeometry instance is visible.
Ogre::SceneNode * getSceneNode() const
Gets the scene node to which all PagedGeometry geometry is attached.
void setInfinite()
Switches to infinite mode.
Ogre::Vector3 lastOldCamPos
Ogre::String getTempdir()
Ogre::SceneManager * getSceneManager() const
Gets the scene manager which is being used to display the geometry.
Ogre::uint8 m_nRenderQueue
The used rendering queue.
Ogre::Camera * getCamera() const
Gets the camera which is used to calculate levels of detail.
PageLoader * getPageLoader()
Gets the PageLoader currently being used to load geometry.
void setShadersEnabled(bool value)
disables the use of shaders
Ogre::Camera * lastSceneCam
void resetPreloadedGeometry()
Releases geometry preloaded with preloadGeometry() to be unloaded if necessary.
void setPageSize(Ogre::Real size)
Sets the page size.
Ogre::SceneNode * m_pagedGroupingNode
void _addDetailLevel(GeometryPageManager *mgr, Ogre::Real maxRange, Ogre::Real transitionLength)
void update()
Updates this PagedGeometry object.
void setBounds(const TBounds bounds)
Switches to bounded mode and uses the given boundaries.
TBounds convertAABToTBounds(const Ogre::AxisAlignedBox &aab) const
Convert an Ogre::AxisAlignedBox to a TBounds coplanar to the plane defined by the UP axis.
void reloadGeometry()
Reloads all visible geometry.
Ogre::TRect< Ogre::Real > TBounds
Define TBounds as a TRect using Real numeric units.
Useful page information supplied to a pageloader.
int zIndex
The Z index of the page tile.
Ogre::Vector3 centerPoint
The center of the page (simply the middle of the bounds).
TBounds bounds
The page boundaries in which all entities should be placed.
int xIndex
The X index of the page tile.
std::vector< Ogre::Mesh * > meshList