29 #ifndef __Ogre_TerrainQuadTreeNode_H__
30 #define __Ogre_TerrainQuadTreeNode_H__
42 class HardwareVertexBufferSharedPtr;
151 LodLevel() : batchSize(0), gpuIndexData(0), maxHeightDelta(0), calcMaxHeightDelta(0),
152 lastTransitionDist(0), lastCFactor(0) {}
308 : cpuVertexData(0), gpuVertexData(0), resolution(res), size(sz),
309 treeLevels(lvls), numSkirtRowsCols(0),
310 skirtRowColSkip(0), gpuVertexDataDirty(false) {}
#define _OgreTerrainExport
Superclass for all objects that wish to use custom memory allocators when their new / delete operator...
A 3D box aligned with the x/y/z axes.
A viewpoint from which the scene will be rendered.
Shared pointer implementation used to share vertex buffers.
Summary class collecting together index data source information.
Class encapsulating a standard 4x4 homogeneous matrix.
Abstract class defining a movable object in a scene.
'New' rendering operation using vertex buffers.
Class to manage the scene object rendering queue.
Visitor object that can be used to iterate over a collection of Renderable instances abstractly.
Abstract class defining the interface all renderable objects must implement.
Class representing a node in the scene graph.
Utility class providing helper methods for reading / writing structured data held in a DataStream.
Class representing an approach to rendering this particular Material.
MovableObject implementation to provide the hook to the scene.
const String & getMovableType(void) const
Returns the type name of this object.
Real getBoundingRadius(void) const
Retrieves the radius of the origin-centered bounding sphere for this object.
const AxisAlignedBox & getBoundingBox(void) const
Retrieves the local axis-aligned bounding box for this object.
bool getCastShadows(void) const
Returns whether shadow casting is enabled for this object.
bool isVisible(void) const
Returns whether or not this object is supposed to be visible or not.
Movable(TerrainQuadTreeNode *parent)
uint32 getVisibilityFlags(void) const
Returns the visibility flags relevant for this object.
TerrainQuadTreeNode * mParent
uint32 getQueryFlags(void) const
Returns the query flags relevant for this object.
void _updateRenderQueue(RenderQueue *queue)
Internal method by which the movable object must add Renderable subclass instances to the rendering q...
void visitRenderables(Renderable::Visitor *visitor, bool debugRenderables=false)
Method to allow a caller to abstractly iterate over the Renderable instances that this MovableObject ...
Hook to the render queue.
TerrainQuadTreeNode * mParent
Technique * getTechnique(void) const
Retrieves a pointer to the Material Technique this renderable object uses.
Rend(TerrainQuadTreeNode *parent)
void getWorldTransforms(Matrix4 *xform) const
Gets the world transform matrix / matrices for this renderable object.
const MaterialPtr & getMaterial(void) const
Retrieves a weak reference to the material this renderable object uses.
const LightList & getLights(void) const
Gets a list of lights, ordered relative to how close they are to this renderable.
Real getSquaredViewDepth(const Camera *cam) const
Returns the camera-relative squared depth of this renderable.
void getRenderOperation(RenderOperation &op)
Gets the render operation required to send this object to the frame buffer.
bool getCastsShadows(void) const
Method which reports whether this renderable would normally cast a shadow.
A node in a quad tree used to store a patch of terrain.
Renderable * _getRenderable()
Returns the internal renderable object for this node.
void unload()
Unload 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 writeDeltaVertex(bool compress, uint16 x, uint16 y, float delta, float deltaThresh, float **ppDelta)
TerrainQuadTreeNode(Terrain *terrain, TerrainQuadTreeNode *parent, uint16 xoff, uint16 yoff, uint16 size, uint16 lod, uint16 depth, uint16 quadrant)
Constructor.
bool isSelfOrChildRenderedAtCurrentLod() const
Returns whether this node or its children are being rendered at the current LOD level.
void createGpuVertexData()
const LodLevel * getLodLevel(uint16 lod)
Get the LodLevel information for a given lod.
void preDeltaCalculation(const Rect &rect)
Notify the node (and children) that deltas are going to be calculated for a given range.
Real getMaxHeight() const
Get the maximum height of the node.
const MaterialPtr & getMaterial(void) const
void createGpuIndexData()
void useAncestorVertexData(TerrainQuadTreeNode *owner, uint16 treeDepthEnd, uint16 resolution)
Tell a node that it should use an anscestor's vertex data.
uint16 getXOffset() const
Get the horizontal offset into the main terrain data of this node.
void postDeltaCalculation(const Rect &rect)
Notify the node (and children) that deltas have finished being calculated.
TerrainQuadTreeNode * mNodeWithVertexData
TerrainQuadTreeNode * mChildWithMaxHeightDelta
0-1 transition to lower LOD
void populateIndexData(uint16 batchSize, IndexData *destData)
bool isRenderedAtCurrentLod() const
Returns whether this node is rendering itself at the current LOD level.
Terrain * getTerrain() const
Get ultimate parent terrain.
VertexDataRecord * mVertexDataRecord
void prepare()
Prepare node and children (perform CPU tasks, may be background thread)
void visitRenderables(Renderable::Visitor *visitor, bool debugRenderables=false)
vector< LodLevel * >::type LodLevelList
bool getCastsShadows(void) const
virtual ~TerrainQuadTreeNode()
static unsigned short DELTA_BUFFER
Buffer binding used for holding delta values.
unsigned short mMaterialLodIndex
-1 = none (do not render)
void updateRenderQueue(RenderQueue *queue)
void getRenderOperation(RenderOperation &op)
int mCurrentLod
Relative to mLocalCentre.
TerrainQuadTreeNode * getParent() const
Get parent node.
bool calculateCurrentLod(const Camera *cam, Real cFactor)
Calculate appropriate LOD for this node and children.
void setCurrentLod(int lod)
Manually set the current LOD, intended for internal use only.
void load()
Load node and children (perform GPU tasks, will be render thread)
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)
bool pointIntersectsNode(long x, long y)
Returns true if the given point is in the terrain area that this node references.
void prepare(StreamSerialiser &stream)
Prepare node from a stream.
Real getSquaredViewDepth(const Camera *cam) const
int getCurrentLod() const
Get the current LOD index (only valid after calculateCurrentLod)
void writePosVertex(bool compress, uint16 x, uint16 y, float height, const Vector3 &pos, float uvScale, float **ppPos)
AxisAlignedBox mAABB
Relative to terrain centre.
void updateVertexData(bool positions, bool deltas, const Rect &rect, bool cpuData)
Tell the node to update its vertex data for a given region.
const AxisAlignedBox & getAABB() const
Get the AABB (local coords) of this node.
uint16 mSize
The number of vertices at the original terrain resolution this node encompasses.
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.
TerrainQuadTreeNode * mParent
bool mSelfOrChildRendered
Real getMinHeight() const
Get the minimum height of the node.
bool isLeaf() const
Is this a leaf node (no children)
void resetBounds(const Rect &rect)
Reset the bounds of this node and all its children for the region given.
void destroyCpuVertexData()
void destroyGpuIndexData()
bool rectContainsNode(const Rect &rect)
Returns true if the given rectangle completely contains the terrain area that this node references.
TerrainQuadTreeNode * getChild(unsigned short child) const
Get child node.
uint16 getBaseLod() const
Get the base LOD level this node starts at (the highest LOD it handles)
void assignVertexData(uint16 treeDepthStart, uint16 treeDepthEnd, uint16 resolution, uint sz)
Assign vertex data to the tree, from a depth and at a given resolution.
void finaliseDeltaValues(const Rect &rect)
Promote the delta values calculated to the runtime ones (this must be called in the main thread).
void updateGpuVertexData()
void save(StreamSerialiser &stream)
Save node to a stream.
void updateVertexBuffer(HardwareVertexBufferSharedPtr &posbuf, HardwareVertexBufferSharedPtr &deltabuf, const Rect &rect)
uint16 getYOffset() const
Get the vertical offset into the main terrain data of this node.
uint16 calcSkirtVertexIndex(uint16 mainIndex, bool isCol)
static unsigned short POSITION_BUFFER
Buffer binding used for holding positions.
void notifyDelta(uint16 x, uint16 y, uint16 lod, Real delta)
Notify the node (and children) of a height delta value.
void destroyGpuVertexData()
void unprepare()
Unprepare node and children (perform CPU tasks, may be background thread)
Real mBoundingRadius
Relative to mLocalCentre.
float getLodTransition() const
Get the transition state between the current LOD and the next lower one (only valid after calculateCu...
const VertexDataRecord * getVertexDataRecord() const
void unload(uint16 depthStart, uint16 depthEnd)
Unload node and children in a depth range (perform GPU tasks, will be render thread)
void createCpuVertexData()
Technique * getTechnique(void) const
void setLodTransition(float t)
Manually set the current LOD transition state, intended for internal use only.
bool rectIntersectsNode(const Rect &rect)
Returns true if the given rectangle overlaps the terrain area that this node references.
const LightList & getLights(void) const
Real getBoundingRadius() const
Get the bounding radius of this node.
void getWorldTransforms(Matrix4 *xform) const
The main containing class for a chunk of terrain.
Standard 3-dimensional vector.
Summary class collecting together vertex source information.
float Real
Software floating point type.
Real maxHeightDelta
Maximum delta height between this and the next lower lod.
uint16 batchSize
Number of vertices rendered down one side (not including skirts)
Real calcMaxHeightDelta
Temp calc area for max height delta.
IndexData * gpuIndexData
Index data on the gpu.
Real lastTransitionDist
The most recently calculated transition distance.
Real lastCFactor
The cFactor value used to calculate transitionDist.
VertexDataRecord(uint16 res, uint16 sz, uint16 lvls)
uint16 resolution
Resolution of the data compared to the base terrain data (NOT number of vertices!)
VertexData * gpuVertexData
uint16 numSkirtRowsCols
Number of rows and columns of skirts.
bool gpuVertexDataDirty
Is the GPU vertex data out of date?
uint16 treeLevels
Number of quadtree levels (including this one) this data applies to.
VertexData * cpuVertexData
uint16 skirtRowColSkip
The number of rows / cols to skip in between skirts.
uint16 size
Size of the data along one edge.