OGRE 14.3
Object-Oriented Graphics Rendering Engine
|
A node in a quad tree used to store a patch of terrain. More...
#include <OgreTerrainQuadTreeNode.h>
Classes | |
struct | LodLevel |
Public Types | |
typedef std::vector< LodLevel * > | LodLevelList |
Public Member Functions | |
TerrainQuadTreeNode (Terrain *terrain, TerrainQuadTreeNode *parent, uint16 xoff, uint16 yoff, uint16 size, uint16 lod, uint16 depth) | |
Constructor. | |
virtual | ~TerrainQuadTreeNode () |
void | assignVertexData (uint16 treeDepthStart, uint16 treeDepthEnd, uint16 resolution, uint sz) |
Assign vertex data to the tree, from a depth and at a given resolution. | |
bool | calculateCurrentLod (const Camera *cam, Real cFactor) |
Calculate appropriate LOD for this node and children. | |
void | finaliseDeltaValues (const Rect &rect) |
Promote the delta values calculated to the runtime ones (this must be called in the main thread). | |
uint16 | getBaseLod () const |
Get the base LOD level this node starts at (the highest LOD it handles) | |
const AxisAlignedBox & | getBoundingBox (void) const override |
Get the AABB (local coords) of this node. | |
Real | getBoundingRadius () const override |
Get the bounding radius of this node. | |
TerrainQuadTreeNode * | getChild (unsigned short child) const |
Get child node. | |
int | getCurrentLod () const |
Get the current LOD index (only valid after calculateCurrentLod) | |
const Vector3 & | getLocalCentre () const |
Get the local centre of this node, relative to parent terrain centre. | |
uint16 | getLodCount () const |
Get the number of LOD levels this node can represent itself (only > 1 for leaf nodes) | |
const LodLevel * | getLodLevel (uint16 lod) |
Get the LodLevel information for a given lod. | |
float | getLodTransition () const |
Get the transition state between the current LOD and the next lower one (only valid after calculateCurrentLod) | |
Real | getMaxHeight () const |
Get the maximum height of the node. | |
Real | getMinHeight () const |
Get the minimum height of the node. | |
TerrainQuadTreeNode * | getParent () const |
Get parent node. | |
Terrain * | getTerrain () const |
Get ultimate parent terrain. | |
uint16 | getXOffset () const |
Get the horizontal offset into the main terrain data of this node. | |
uint16 | getYOffset () const |
Get the vertical offset into the main terrain data of this node. | |
bool | isLeaf () const |
Is this a leaf node (no children) | |
bool | isRenderedAtCurrentLod () const |
Returns whether this node is rendering itself at the current LOD level. | |
bool | isSelfOrChildRenderedAtCurrentLod () const |
Returns whether this node or its children are being rendered at the current LOD level. | |
void | load () |
Load node and children (perform GPU tasks, will be render thread) | |
void | load (uint16 depthStart, uint16 depthEnd) |
Load node and children in a depth range (perform GPU tasks, will be render thread) | |
void | loadSelf () |
void | mergeIntoBounds (long x, long y, const Vector3 &pos) |
Merge a point (relative to terrain node) into the local bounds, and that of children if applicable. | |
void | notifyDelta (uint16 x, uint16 y, uint16 lod, Real delta) |
Notify the node (and children) of a height delta value. | |
bool | pointIntersectsNode (long x, long y) |
Returns true if the given point is in the terrain area that this node references. | |
void | postDeltaCalculation (const Rect &rect) |
Notify the node (and children) that deltas have finished being calculated. | |
void | preDeltaCalculation (const Rect &rect) |
Notify the node (and children) that deltas are going to be calculated for a given range. | |
void | prepare () |
Prepare node and children (perform CPU tasks, may be background thread) | |
void | prepare (StreamSerialiser &stream) |
Prepare node from a stream. | |
bool | rectContainsNode (const Rect &rect) |
Returns true if the given rectangle completely contains the terrain area that this node references. | |
bool | rectIntersectsNode (const Rect &rect) |
Returns true if the given rectangle overlaps the terrain area that this node references. | |
void | resetBounds (const Rect &rect) |
Reset the bounds of this node and all its children for the region given. | |
void | save (StreamSerialiser &stream) |
Save node to a stream. | |
void | setCurrentLod (int lod) |
Manually set the current LOD, intended for internal use only. | |
void | setLodTransition (float t) |
Manually set the current LOD transition state, intended for internal use only. | |
void | unload () |
Unload node and children (perform GPU tasks, will be render thread) | |
void | unload (uint16 depthStart, uint16 depthEnd) |
Unload node and children in a depth range (perform GPU tasks, will be render thread) | |
void | unprepare () |
Unprepare node and children (perform CPU tasks, may be background thread) | |
void | updateVertexData (bool positions, bool deltas, const Rect &rect, bool cpuData) |
Tell the node to update its vertex data for a given region. | |
void | useAncestorVertexData (TerrainQuadTreeNode *owner, uint16 treeDepthEnd, uint16 resolution) |
Tell a node that it should use an anscestor's vertex data. | |
Static Public Attributes | |
static unsigned short | DELTA_BUFFER |
Buffer binding used for holding delta values. | |
static unsigned short | POSITION_BUFFER |
Buffer binding used for holding positions. | |
A node in a quad tree used to store a patch of terrain.
Algorithm overview:
typedef std::vector<LodLevel*> Ogre::TerrainQuadTreeNode::LodLevelList |
Ogre::TerrainQuadTreeNode::TerrainQuadTreeNode | ( | Terrain * | terrain, |
TerrainQuadTreeNode * | parent, | ||
uint16 | xoff, | ||
uint16 | yoff, | ||
uint16 | size, | ||
uint16 | lod, | ||
uint16 | depth | ||
) |
Constructor.
terrain | The ultimate parent terrain |
parent | Optional parent node (in which case xoff, yoff are 0 and size must be entire terrain) |
xoff,yoff | Offsets from the start of the terrain data in 2D |
size | The size of the node in vertices at the highest LOD |
lod | The base LOD level |
depth | The depth that this node is at in the tree (or convenience) |
|
virtual |
|
inline |
Get the horizontal offset into the main terrain data of this node.
|
inline |
Get the vertical offset into the main terrain data of this node.
bool Ogre::TerrainQuadTreeNode::isLeaf | ( | ) | const |
Is this a leaf node (no children)
|
inline |
Get the base LOD level this node starts at (the highest LOD it handles)
uint16 Ogre::TerrainQuadTreeNode::getLodCount | ( | ) | const |
Get the number of LOD levels this node can represent itself (only > 1 for leaf nodes)
TerrainQuadTreeNode * Ogre::TerrainQuadTreeNode::getChild | ( | unsigned short | child | ) | const |
Get child node.
TerrainQuadTreeNode * Ogre::TerrainQuadTreeNode::getParent | ( | ) | const |
Get parent node.
Terrain * Ogre::TerrainQuadTreeNode::getTerrain | ( | ) | const |
Get ultimate parent terrain.
void Ogre::TerrainQuadTreeNode::prepare | ( | ) |
Prepare node and children (perform CPU tasks, may be background thread)
void Ogre::TerrainQuadTreeNode::prepare | ( | StreamSerialiser & | stream | ) |
Prepare node from a stream.
void Ogre::TerrainQuadTreeNode::load | ( | ) |
Load node and children (perform GPU tasks, will be render thread)
Load node and children in a depth range (perform GPU tasks, will be render thread)
void Ogre::TerrainQuadTreeNode::loadSelf | ( | ) |
void Ogre::TerrainQuadTreeNode::unload | ( | ) |
Unload node and children (perform GPU tasks, will be render thread)
Unload node and children in a depth range (perform GPU tasks, will be render thread)
void Ogre::TerrainQuadTreeNode::unprepare | ( | ) |
Unprepare node and children (perform CPU tasks, may be background thread)
void Ogre::TerrainQuadTreeNode::save | ( | StreamSerialiser & | stream | ) |
Save node to a stream.
Get the LodLevel information for a given lod.
lod | The lod level index relative to this classes own list; if you want to use a global lod level, subtract getBaseLod() first. Higher LOD levels are lower detail. |
Notify the node (and children) that deltas are going to be calculated for a given range.
Based on this call, we can know whether or not to reset the max height.
Notify the node (and children) of a height delta value.
Notify the node (and children) that deltas have finished being calculated.
Promote the delta values calculated to the runtime ones (this must be called in the main thread).
void Ogre::TerrainQuadTreeNode::assignVertexData | ( | uint16 | treeDepthStart, |
uint16 | treeDepthEnd, | ||
uint16 | resolution, | ||
uint | sz | ||
) |
Assign vertex data to the tree, from a depth and at a given resolution.
treeDepthStart | The first depth of tree that should use this data, owns the data |
treeDepthEnd | The end of the depth that should use this data (exclusive) |
resolution | The resolution of the data to use (compared to full terrain) |
sz | The size of the data along one edge |
void Ogre::TerrainQuadTreeNode::useAncestorVertexData | ( | TerrainQuadTreeNode * | owner, |
uint16 | treeDepthEnd, | ||
uint16 | resolution | ||
) |
Tell a node that it should use an anscestor's vertex data.
owner | |
treeDepthEnd | The end of the depth that should use this data (exclusive) |
resolution | The resolution of the data to use |
void Ogre::TerrainQuadTreeNode::updateVertexData | ( | bool | positions, |
bool | deltas, | ||
const Rect & | rect, | ||
bool | cpuData | ||
) |
Tell the node to update its vertex data for a given region.
Merge a point (relative to terrain node) into the local bounds, and that of children if applicable.
x,y | The point on the terrain to which this position corresponds (affects which nodes update their bounds) |
pos | The position relative to the terrain centre |
Reset the bounds of this node and all its children for the region given.
rect | The region for which bounds should be reset, in top-level terrain coords |
Returns true if the given rectangle overlaps the terrain area that this node references.
rect | The region in top-level terrain coords |
Returns true if the given rectangle completely contains the terrain area that this node references.
rect | The region in top-level terrain coords |
Returns true if the given point is in the terrain area that this node references.
x,y | The point in top-level terrain coords |
|
inlineoverridevirtual |
Get the AABB (local coords) of this node.
Implements Ogre::MovableObject.
|
overridevirtual |
Get the bounding radius of this node.
Implements Ogre::MovableObject.
Get the local centre of this node, relative to parent terrain centre.
Real Ogre::TerrainQuadTreeNode::getMinHeight | ( | ) | const |
Get the minimum height of the node.
Real Ogre::TerrainQuadTreeNode::getMaxHeight | ( | ) | const |
Get the maximum height of the node.
Calculate appropriate LOD for this node and children.
cam | The camera to be used (this should already be the LOD camera) |
cFactor | The cFactor which incorporates the viewport size, max pixel error and lod bias |
|
inline |
Get the current LOD index (only valid after calculateCurrentLod)
bool Ogre::TerrainQuadTreeNode::isRenderedAtCurrentLod | ( | ) | const |
Returns whether this node is rendering itself at the current LOD level.
bool Ogre::TerrainQuadTreeNode::isSelfOrChildRenderedAtCurrentLod | ( | ) | const |
Returns whether this node or its children are being rendered at the current LOD level.
Manually set the current LOD, intended for internal use only.
|
inline |
Get the transition state between the current LOD and the next lower one (only valid after calculateCurrentLod)
Manually set the current LOD transition state, intended for internal use only.
Buffer binding used for holding positions.
Buffer binding used for holding delta values.