C# Класс 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.
Наследование: IDisposable
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
DELTA_BUFFER short
POSITION_BUFFER short

Защищенные свойства (Protected)

Свойство Тип Описание
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

Открытые методы

Метод Описание
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

Защищенные методы

Метод Описание
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

Приватные методы

Метод Описание
UpdateVertexBufferr ( HardwareVertexBuffer posbuf, HardwareVertexBuffer deltabuf, Rectangle rect ) : void

Описание методов

AssignVertexData() публичный Метод

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
Результат void

CalcSkirtVertexIndex() защищенный Метод

protected CalcSkirtVertexIndex ( ushort mainIndex, bool isCol ) : ushort
mainIndex ushort
isCol bool
Результат ushort

CalculateCurrentLod() публичный Метод

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
Результат bool

CreateCpuIndexData() защищенный Метод

protected CreateCpuIndexData ( ) : void
Результат void

CreateCpuVertexData() защищенный Метод

protected CreateCpuVertexData ( ) : void
Результат void

CreateGpuIndexData() защищенный Метод

protected CreateGpuIndexData ( ) : void
Результат void

CreateGpuVertexData() защищенный Метод

protected CreateGpuVertexData ( ) : void
Результат void

CreateTriangleStripBuffer() защищенный Метод

protected CreateTriangleStripBuffer ( ushort batchSize, IndexData destData ) : void
batchSize ushort
destData Axiom.Graphics.IndexData
Результат void

DestroyCpuIndexData() защищенный Метод

protected DestroyCpuIndexData ( ) : void
Результат void

DestroyCpuVertexData() защищенный Метод

protected DestroyCpuVertexData ( ) : void
Результат void

DestroyGpuIndexData() защищенный Метод

protected DestroyGpuIndexData ( ) : void
Результат void

DestroyGpuVertexData() защищенный Метод

protected DestroyGpuVertexData ( ) : void
Результат void

Dispose() публичный Метод

public Dispose ( ) : void
Результат void

FinaliseDeltaValues() публичный Метод

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
Результат void

GetChild() публичный Метод

Get child node
public GetChild ( ushort child ) : TerrainQuadTreeNode
child ushort
Результат TerrainQuadTreeNode

GetLodLevel() публичный Метод

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. ///
Результат LodLevel

GetSquaredViewDepth() публичный Метод

public GetSquaredViewDepth ( Camera cam ) : float
cam Axiom.Core.Camera
Результат float

GetWorldTransforms() публичный Метод

public GetWorldTransforms ( Matrix4 xform ) : void
xform Axiom.Math.Matrix4
Результат void

Load() публичный Метод

Load node and children (perform GPU tasks, will be render thread)
public Load ( ) : void
Результат void

MergeIntoBounds() публичный Метод

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
Результат void

NotifyDelta() публичный Метод

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
Результат void

PointIntersectsNode() публичный Метод

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
Результат bool

PostDeltaCalculation() публичный Метод

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
Результат void

PreDeltaCalculation() публичный Метод

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
Результат void

Prepare() публичный Метод

Prepare node and children (perform CPU tasks, may be background thread)
public Prepare ( ) : void
Результат void

RectContainsNode() публичный Метод

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
Результат bool

RectIntersectsNode() публичный Метод

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
Результат bool

ResetBounds() публичный Метод

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
Результат void

TerrainQuadTreeNode() публичный Метод

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)
Результат System

Unload() публичный Метод

Unload node and children (perform GPU tasks, will be render thread)
public Unload ( ) : void
Результат void

Unprepare() публичный Метод

Unprepare node and children (perform CPU tasks, may be background thread)
public Unprepare ( ) : void
Результат void

UpdateGpuVertexData() защищенный Метод

protected UpdateGpuVertexData ( ) : void
Результат void

UpdateRenderQueue() публичный Метод

public UpdateRenderQueue ( RenderQueue queue ) : void
queue Axiom.Graphics.RenderQueue
Результат void

UpdateVertexBuffer() защищенный Метод

protected UpdateVertexBuffer ( HardwareVertexBuffer posBuff, HardwareVertexBuffer deltaBuf, Rectangle rect ) : void
posBuff Axiom.Graphics.HardwareVertexBuffer
deltaBuf Axiom.Graphics.HardwareVertexBuffer
rect Axiom.Core.Rectangle
Результат void

UpdateVertexData() публичный Метод

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
Результат void

UseAncestorVertexData() публичный Метод

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
Результат void

VisitRenderables() публичный Метод

public VisitRenderables ( bool debugRenderables ) : void
debugRenderables bool
Результат void

Описание свойств

DELTA_BUFFER публичное статическое свойство

Buffer binding used for holding delta values
public static short DELTA_BUFFER
Результат short

POSITION_BUFFER публичное статическое свойство

Buffer binding used for holding positions.
public static short POSITION_BUFFER
Результат short

mAABB защищенное свойство

relative to mLocalCentre
protected AxisAlignedBox,Axiom.Math mAABB
Результат Axiom.Math.AxisAlignedBox

mBaseLod защищенное свойство

protected ushort mBaseLod
Результат ushort

mBoundaryX защищенное свойство

protected ushort mBoundaryX
Результат ushort

mBoundaryY защищенное свойство

protected ushort mBoundaryY
Результат ushort

mBoundingRadius защищенное свойство

relative to mLocalCentre
protected float mBoundingRadius
Результат float

mChildWithMaxHeightDelta защищенное свойство

The child with the largest height delta
protected TerrainQuadTreeNode mChildWithMaxHeightDelta
Результат TerrainQuadTreeNode

mChildren защищенное свойство

protected TerrainQuadTreeNode[] mChildren
Результат TerrainQuadTreeNode[]

mCurrentLod защищенное свойство

-1 = none (do not render)
protected int mCurrentLod
Результат int

mDepth защищенное свойство

protected ushort mDepth
Результат ushort

mLocalCentre защищенное свойство

relative to terrain centre
protected Vector3 mLocalCentre
Результат Vector3

mLodLevels защищенное свойство

protected List mLodLevels
Результат List

mLodTransition защищенное свойство

// 0-1 transition to lower LOD
protected float mLodTransition
Результат float

mMaterialLodIndex защищенное свойство

protected ushort mMaterialLodIndex
Результат ushort

mNodeWithVertexData защищенное свойство

protected TerrainQuadTreeNode mNodeWithVertexData
Результат TerrainQuadTreeNode

mOffsetX защищенное свойство

protected ushort mOffsetX
Результат ushort

mOffsetY защищенное свойство

protected ushort mOffsetY
Результат ushort

mParent защищенное свойство

protected TerrainQuadTreeNode mParent
Результат TerrainQuadTreeNode

mQuadrant защищенное свойство

protected ushort mQuadrant
Результат ushort

mRend защищенное свойство

protected TerrainRendable mRend
Результат TerrainRendable

mSelfOrChildRendered защищенное свойство

protected bool mSelfOrChildRendered
Результат bool

mSize защищенное свойство

protected ushort mSize
Результат ushort

mTerrain защищенное свойство

protected Terrain mTerrain
Результат Terrain

mVertexDataRecord защищенное свойство

protected VertexDataRecord mVertexDataRecord
Результат VertexDataRecord