MeshTree
Description
This interface provides quad-tree like access to the structure of a CLOD mesh.
The structure of a CLOD mesh is a directed acyclic graph of vertices and links and can be interpreted as a quadtree. The MeshTree interface provides access to this quadtree.
The MeshTree object of a CLOD IMesh can be used to implement hierarchical traversal algorithms, such as frustum culling, picking and collision detection.
Each face of a mesh represents the root node of a quadtree (see GetRoot). The GetChild*
methods can be used to traverse the quadtree hierarchy. A quadtree node is equivalent to a mesh sector which is referred to using the index of its center vertex. So the vertex index values using with this class can also be used to access vertex data arrays.
The following figures illustrates the concept of parent/child sectors and parent index values:
Pidx(S) = 3 Pidx(S) = 2 +--------+--------+ +--------+--------+ | | | | | | | C(3) | C(2) | | (C0) | (C3) | | | | | | | +-------(S)-------+ +-------(S)-------+ | | | | | | | C(0) | C(1) | | (C1) | (C2) | | | | | | | +--------+-------(P) (P)-------+--------+ Pidx(S) = 0 Pidx(S) = 1 +--------+-------(P) (P)-------+--------+ | | | | | | | (C2) | (C1) | | (C1) | (C0) | | | | | | | +-------(S)-------+ +-------(S)-------+ | | | | | | | (C3) | (C0) | | (C2) | (C3) | | | | | | | +--------+--------+ +--------+--------+ C(0) := S.LL.LL = S.L[L.L]L = S.LLL = S.L[L]L => LL = 0 C(1) := S.LL.LR = S.L[L.L]R = S.LLR = S.L[L]R => LR = 1 C(2) := S.RL.LL = S.R[L.L]L = S.RLL = S.R[L]L => RL = 2 C(3) := S.RL.LR = S.R[L.L]R = S.RLR = S.R[L]R => RR = 3
where (P)
is the center vertex of the parent sector, (S)
is the center vertex of the current sector, C(n)
is the center vertex of the n-th
child vertex with n
being the child index and Pidx(S)
is the child index of (S)
in (P)
.
- See also
Public / Methods
ComputeSectorHash
2 overloads
Computes a hash value that represents the mesh structure.
Computes a hash value that represents the mesh structure of the given sector.
Filter
Returns an MeshTree object which represents the mesh structure filtered by the given filter.
Specifying the same MeshTreeFilter instance multiple times will result in a single filtered MeshTree instance. A MeshTreeFilter object must only be used with one MeshTree object.
GetCorners
Returns the four corner vertices of the given sector.
The returned vector has the following meaning:
GetOrientation
Returns the orientation of the given mesh sector.
The orientation of the mesh sector is computed relative to the face coordinates of the cubemap coordinates of its corner vertices:
o--> face X-coordinates | V face Y-coordinates #0: #1: #2: #3: #4: #5: #6: #7: A R A L L G R G R A L A G L G R L G R G A R A L G L G R R A L A 0x1 := diagonal flip (along line from A to G)? 0x2 := vertical flip? 0x4 := horizontal flip?
where A
, R
, L
and G
represent the corner vertices of the mesh sector, specified via corners in.
HasMarkExplicit
Checks if the given mesh sector has an explicit mark.
Mesh sectors receive explicit marks only from the SectorMark method.
- See also
HasMarkImplicit
Checks if the given mesh sector has an implicit mark.
A mesh sector receives an implicit mark when one of its descendants is marked explicitly.
- See also
IsSolid
Checks if the given mesh sector is solid, i.e. if none of its descendants have been culled away.
- See also
SectorCull
Culls the given mesh sector by adding cull flags to the output filter of this mesh tree.
When culling a mesh sector, its marks (both explicit and implicit) will be retained.
SectorCullAdd
Computes the union of the cull flags (see SectorCull) in the input filter of this mesh tree and the given mesh filter, storing the result back into the input filter.
If this mesh tree does not have an input filter, the method silently returns.
SectorCullRetain
Computes the intersection of the cull flags (see SectorCull) in the input filter of this mesh tree and the given mesh filter, storing the result back into the input filter.
If this mesh tree does not have an input filter, the method silently returns.
SectorMark
Marks the given mesh sector by adding mark flags to the output filter of this mesh tree.
Mesh sectors can receive marks (both explicit or implicit) even if they have been culled away earlier.
- See also
SectorMarkAdd
Computes the union of the mark flags (see SectorMark) in the input filter of this mesh tree and the given mesh filter, storing the result back into the input filter.
If this mesh tree does not have an input filter, the method silently returns.