C# Class Axiom.Components.Terrain.TerrainQuadTreeNode

A node in a quad tree used to store a patch of terrain.
Algorithm overview: Our goal is to perform traditional chunked LOD with geomorphing. But, instead of just dividing the terrain into tiles, we will divide them into a hierarchy of tiles, a quadtree, where any level of the quadtree can be a rendered tile (to the exclusion of its children). The idea is to collect together children into a larger batch with their siblings as LOD decreases, to improve performance. The minBatchSize and maxBatchSize parameters on Terrain a key to defining this behaviour. Both values are expressed in vertices down one axis. maxBatchSize determines the number of tiles on one side of the terrain, which is numTiles = (terrainSize-1) / (maxBatchSize-1). This in turn determines the depth of the quad tree, which is sqrt(numTiles). The minBatchSize determines the 'floor' of how low the number of vertices can go in a tile before it has to be grouped together with its siblings to drop any lower. We also do not group a tile with its siblings unless all of them are at this minimum batch size, rather than trying to group them when they all end up on the same 'middle' LOD; this is for several reasons; firstly, tiles hitting the same 'middle' LOD is less likely and more transient if they have different levels of 'roughness', and secondly since we're sharing a vertex / index pool between all tiles, only grouping at the min level means that the number of combinations of buffer sizes for any one tile is greatly simplified, making it easier to pool data. To be more specific, any tile / quadtree node can only have log2(maxBatchSize-1) - log2(minBatchSize-1) + 1 LOD levels (and if you set them to the same value, LOD can only change by going up/down the quadtree). The numbers of vertices / indices in each of these levels is constant for the same (relative) LOD index no matter where you are in the tree, therefore buffers can potentially be reused more easily.
Inheritance: IDisposable
Afficher le fichier Open project: WolfgangSt/axiom Class Usage Examples

Méthodes publiques

Свойство Type Description
DELTA_BUFFER short
POSITION_BUFFER short

Protected Properties

Свойство Type Description
mAABB Axiom.Math.AxisAlignedBox
mBaseLod ushort
mBoundaryX ushort
mBoundaryY ushort
mBoundingRadius float
mChildWithMaxHeightDelta TerrainQuadTreeNode
mChildren TerrainQuadTreeNode[]
mCurrentLod int
mDepth ushort
mLocalCentre Vector3
mLodLevels List
mLodTransition float
mMaterialLodIndex ushort
mNodeWithVertexData TerrainQuadTreeNode
mOffsetX ushort
mOffsetY ushort
mParent TerrainQuadTreeNode
mQuadrant ushort
mRend TerrainRendable
mSelfOrChildRendered bool
mSize ushort
mTerrain Terrain
mVertexDataRecord VertexDataRecord

Méthodes publiques

Méthode Description
AssignVertexData ( ushort treeDepthStart, ushort treeDepthEnd, ushort resolution, ushort sz ) : void

Assign vertex data to the tree, from a depth and at a given resolution.

CalculateCurrentLod ( Camera cam, float cFactor ) : bool

Calculate appropriate LOD for this node and children

Dispose ( ) : void

FinaliseDeltaValues ( Rectangle rect ) : void

Promote the delta values calculated to the runtime ones (this must be called in the main thread).

GetChild ( ushort child ) : TerrainQuadTreeNode

Get child node

GetLodLevel ( ushort lod ) : LodLevel

Get the LodLevel information for a given lod.

GetSquaredViewDepth ( Camera cam ) : float

GetWorldTransforms ( Matrix4 xform ) : void

Load ( ) : void

Load node and children (perform GPU tasks, will be render thread)

MergeIntoBounds ( long x, long y, Vector3 pos ) : void

Merge a point (relative to terrain node) into the local bounds, and that of children if applicable.

NotifyDelta ( ushort x, ushort y, ushort lod, float delta ) : void

Notify the node (and children) of a height delta value.

PointIntersectsNode ( long x, long y ) : bool

Returns true if the given point is in the terrain area that this node references.

PostDeltaCalculation ( Rectangle rect ) : void

Notify the node (and children) that deltas are going to be calculated for a given range.

PreDeltaCalculation ( Rectangle rect ) : void

Notify the node (and children) that deltas are going to be calculated for a given range.

Prepare ( ) : void

Prepare node and children (perform CPU tasks, may be background thread)

RectContainsNode ( Rectangle rect ) : bool

Returns true if the given rectangle completely contains the terrain area that this node references.

RectIntersectsNode ( Rectangle rect ) : bool

Returns true if the given rectangle overlaps the terrain area that this node references.

ResetBounds ( Rectangle rect ) : void

Reset the bounds of this node and all its children for the region given.

TerrainQuadTreeNode ( Axiom.Components.Terrain.Terrain terrain, TerrainQuadTreeNode parent, ushort xOff, ushort yOff, ushort size, ushort lod, ushort depth, ushort quadrant ) : System

Default constructor.

Unload ( ) : void

Unload node and children (perform GPU tasks, will be render thread)

Unprepare ( ) : void

Unprepare node and children (perform CPU tasks, may be background thread)

UpdateRenderQueue ( RenderQueue queue ) : void

UpdateVertexData ( bool positions, bool deltas, Rectangle rect, bool cpuData ) : void

Tell the node to update its vertex data for a given region.

UseAncestorVertexData ( TerrainQuadTreeNode owner, int treeDepthEnd, int resolution ) : void

Tell a node that it should use an anscestor's vertex data.

VisitRenderables ( bool debugRenderables ) : void

Méthodes protégées

Méthode Description
CalcSkirtVertexIndex ( ushort mainIndex, bool isCol ) : ushort

CreateCpuIndexData ( ) : void

CreateCpuVertexData ( ) : void

CreateGpuIndexData ( ) : void

CreateGpuVertexData ( ) : void

CreateTriangleStripBuffer ( ushort batchSize, IndexData destData ) : void

DestroyCpuIndexData ( ) : void

DestroyCpuVertexData ( ) : void

DestroyGpuIndexData ( ) : void

DestroyGpuVertexData ( ) : void

UpdateGpuVertexData ( ) : void

UpdateVertexBuffer ( HardwareVertexBuffer posBuff, HardwareVertexBuffer deltaBuf, Rectangle rect ) : void

Private Methods

Méthode Description
UpdateVertexBufferr ( HardwareVertexBuffer posbuf, HardwareVertexBuffer deltabuf, Rectangle rect ) : void

Method Details

AssignVertexData() public méthode

Assign vertex data to the tree, from a depth and at a given resolution.
public AssignVertexData ( ushort treeDepthStart, ushort treeDepthEnd, ushort resolution, ushort sz ) : void
treeDepthStart ushort
treeDepthEnd ushort The end of the depth that should use this data (exclusive)
resolution ushort The resolution of the data to use (compared to full terrain)
sz ushort The size of the data along one edge
Résultat void

CalcSkirtVertexIndex() protected méthode

protected CalcSkirtVertexIndex ( ushort mainIndex, bool isCol ) : ushort
mainIndex ushort
isCol bool
Résultat ushort

CalculateCurrentLod() public méthode

Calculate appropriate LOD for this node and children
public CalculateCurrentLod ( Camera cam, float cFactor ) : bool
cam Axiom.Core.Camera The camera to be used (this should already be the LOD camera)
cFactor float The cFactor which incorporates the viewport size, max pixel error and lod bias
Résultat bool

CreateCpuIndexData() protected méthode

protected CreateCpuIndexData ( ) : void
Résultat void

CreateCpuVertexData() protected méthode

protected CreateCpuVertexData ( ) : void
Résultat void

CreateGpuIndexData() protected méthode

protected CreateGpuIndexData ( ) : void
Résultat void

CreateGpuVertexData() protected méthode

protected CreateGpuVertexData ( ) : void
Résultat void

CreateTriangleStripBuffer() protected méthode

protected CreateTriangleStripBuffer ( ushort batchSize, IndexData destData ) : void
batchSize ushort
destData Axiom.Graphics.IndexData
Résultat void

DestroyCpuIndexData() protected méthode

protected DestroyCpuIndexData ( ) : void
Résultat void

DestroyCpuVertexData() protected méthode

protected DestroyCpuVertexData ( ) : void
Résultat void

DestroyGpuIndexData() protected méthode

protected DestroyGpuIndexData ( ) : void
Résultat void

DestroyGpuVertexData() protected méthode

protected DestroyGpuVertexData ( ) : void
Résultat void

Dispose() public méthode

public Dispose ( ) : void
Résultat void

FinaliseDeltaValues() public méthode

Promote the delta values calculated to the runtime ones (this must be called in the main thread).
public FinaliseDeltaValues ( Rectangle rect ) : void
rect Axiom.Core.Rectangle
Résultat void

GetChild() public méthode

Get child node
public GetChild ( ushort child ) : TerrainQuadTreeNode
child ushort
Résultat TerrainQuadTreeNode

GetLodLevel() public méthode

Get the LodLevel information for a given lod.
public GetLodLevel ( ushort lod ) : LodLevel
lod ushort /// 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. ///
Résultat LodLevel

GetSquaredViewDepth() public méthode

public GetSquaredViewDepth ( Camera cam ) : float
cam Axiom.Core.Camera
Résultat float

GetWorldTransforms() public méthode

public GetWorldTransforms ( Matrix4 xform ) : void
xform Axiom.Math.Matrix4
Résultat void

Load() public méthode

Load node and children (perform GPU tasks, will be render thread)
public Load ( ) : void
Résultat void

MergeIntoBounds() public méthode

Merge a point (relative to terrain node) into the local bounds, and that of children if applicable.
public MergeIntoBounds ( long x, long y, Vector3 pos ) : void
x long The point on the terrain to which this position corresponds /// (affects which nodes update their bounds)
y long The point on the terrain to which this position corresponds /// (affects which nodes update their bounds)
pos Vector3 The position relative to the terrain centre
Résultat void

NotifyDelta() public méthode

Notify the node (and children) of a height delta value.
public NotifyDelta ( ushort x, ushort y, ushort lod, float delta ) : void
x ushort
y ushort
lod ushort
delta float
Résultat void

PointIntersectsNode() public méthode

Returns true if the given point is in the terrain area that this node references.
public PointIntersectsNode ( long x, long y ) : bool
x long The point in top-level terrain coords
y long The point in top-level terrain coords
Résultat bool

PostDeltaCalculation() public méthode

Notify the node (and children) that deltas are going to be calculated for a given range.
public PostDeltaCalculation ( Rectangle rect ) : void
rect Axiom.Core.Rectangle
Résultat void

PreDeltaCalculation() public méthode

Notify the node (and children) that deltas are going to be calculated for a given range.
public PreDeltaCalculation ( Rectangle rect ) : void
rect Axiom.Core.Rectangle
Résultat void

Prepare() public méthode

Prepare node and children (perform CPU tasks, may be background thread)
public Prepare ( ) : void
Résultat void

RectContainsNode() public méthode

Returns true if the given rectangle completely contains the terrain area that this node references.
public RectContainsNode ( Rectangle rect ) : bool
rect Axiom.Core.Rectangle The region in top-level terrain coords
Résultat bool

RectIntersectsNode() public méthode

Returns true if the given rectangle overlaps the terrain area that this node references.
public RectIntersectsNode ( Rectangle rect ) : bool
rect Axiom.Core.Rectangle The region in top-level terrain coords
Résultat bool

ResetBounds() public méthode

Reset the bounds of this node and all its children for the region given.
public ResetBounds ( Rectangle rect ) : void
rect Axiom.Core.Rectangle The region for which bounds should be reset, in top-level terrain coords
Résultat void

TerrainQuadTreeNode() public méthode

Default constructor.
public TerrainQuadTreeNode ( Axiom.Components.Terrain.Terrain terrain, TerrainQuadTreeNode parent, ushort xOff, ushort yOff, ushort size, ushort lod, ushort depth, ushort quadrant ) : System
terrain Axiom.Components.Terrain.Terrain The ultimate parent terrain
parent TerrainQuadTreeNode ptional parent node (in which case xoff, yoff are 0 and size must be entire terrain)
xOff ushort Offsets from the start of the terrain data in 2D
yOff ushort Offsets from the start of the terrain data in 2D
size ushort The size of the node in vertices at the highest LOD
lod ushort The base LOD level
depth ushort The depth that this node is at in the tree (or convenience)
quadrant ushort The index of the quadrant (0, 1, 2, 3)
Résultat System

Unload() public méthode

Unload node and children (perform GPU tasks, will be render thread)
public Unload ( ) : void
Résultat void

Unprepare() public méthode

Unprepare node and children (perform CPU tasks, may be background thread)
public Unprepare ( ) : void
Résultat void

UpdateGpuVertexData() protected méthode

protected UpdateGpuVertexData ( ) : void
Résultat void

UpdateRenderQueue() public méthode

public UpdateRenderQueue ( RenderQueue queue ) : void
queue Axiom.Graphics.RenderQueue
Résultat void

UpdateVertexBuffer() protected méthode

protected UpdateVertexBuffer ( HardwareVertexBuffer posBuff, HardwareVertexBuffer deltaBuf, Rectangle rect ) : void
posBuff Axiom.Graphics.HardwareVertexBuffer
deltaBuf Axiom.Graphics.HardwareVertexBuffer
rect Axiom.Core.Rectangle
Résultat void

UpdateVertexData() public méthode

Tell the node to update its vertex data for a given region.
public UpdateVertexData ( bool positions, bool deltas, Rectangle rect, bool cpuData ) : void
positions bool
deltas bool
rect Axiom.Core.Rectangle
cpuData bool
Résultat void

UseAncestorVertexData() public méthode

Tell a node that it should use an anscestor's vertex data.
public UseAncestorVertexData ( TerrainQuadTreeNode owner, int treeDepthEnd, int resolution ) : void
owner TerrainQuadTreeNode
treeDepthEnd int The end of the depth that should use this data (exclusive)
resolution int The resolution of the data to use
Résultat void

VisitRenderables() public méthode

public VisitRenderables ( bool debugRenderables ) : void
debugRenderables bool
Résultat void

Property Details

DELTA_BUFFER public_oe static_oe property

Buffer binding used for holding delta values
public static short DELTA_BUFFER
Résultat short

POSITION_BUFFER public_oe static_oe property

Buffer binding used for holding positions.
public static short POSITION_BUFFER
Résultat short

mAABB protected_oe property

relative to mLocalCentre
protected AxisAlignedBox,Axiom.Math mAABB
Résultat Axiom.Math.AxisAlignedBox

mBaseLod protected_oe property

protected ushort mBaseLod
Résultat ushort

mBoundaryX protected_oe property

protected ushort mBoundaryX
Résultat ushort

mBoundaryY protected_oe property

protected ushort mBoundaryY
Résultat ushort

mBoundingRadius protected_oe property

relative to mLocalCentre
protected float mBoundingRadius
Résultat float

mChildWithMaxHeightDelta protected_oe property

The child with the largest height delta
protected TerrainQuadTreeNode mChildWithMaxHeightDelta
Résultat TerrainQuadTreeNode

mChildren protected_oe property

protected TerrainQuadTreeNode[] mChildren
Résultat TerrainQuadTreeNode[]

mCurrentLod protected_oe property

-1 = none (do not render)
protected int mCurrentLod
Résultat int

mDepth protected_oe property

protected ushort mDepth
Résultat ushort

mLocalCentre protected_oe property

relative to terrain centre
protected Vector3 mLocalCentre
Résultat Vector3

mLodLevels protected_oe property

protected List mLodLevels
Résultat List

mLodTransition protected_oe property

// 0-1 transition to lower LOD
protected float mLodTransition
Résultat float

mMaterialLodIndex protected_oe property

protected ushort mMaterialLodIndex
Résultat ushort

mNodeWithVertexData protected_oe property

protected TerrainQuadTreeNode mNodeWithVertexData
Résultat TerrainQuadTreeNode

mOffsetX protected_oe property

protected ushort mOffsetX
Résultat ushort

mOffsetY protected_oe property

protected ushort mOffsetY
Résultat ushort

mParent protected_oe property

protected TerrainQuadTreeNode mParent
Résultat TerrainQuadTreeNode

mQuadrant protected_oe property

protected ushort mQuadrant
Résultat ushort

mRend protected_oe property

protected TerrainRendable mRend
Résultat TerrainRendable

mSelfOrChildRendered protected_oe property

protected bool mSelfOrChildRendered
Résultat bool

mSize protected_oe property

protected ushort mSize
Résultat ushort

mTerrain protected_oe property

protected Terrain mTerrain
Résultat Terrain

mVertexDataRecord protected_oe property

protected VertexDataRecord mVertexDataRecord
Résultat VertexDataRecord