TINMAN 3D / REALTIME TERRAIN
Software Development Kit - User Manual

class MeshTree in Tinman.Terrain.Kernel

This interface provides quad-tree like access to the structure of a CLOD mesh.

sealed class MeshTree  

Remarks

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:

XDag

Public / Methods

Filter

Returns an MeshTree object which represents the mesh structure filtered by the given filter.

public method Filter (MeshTreeFilter filterIn, MeshTreeFilter filterOut = null)
type MeshTree
params filterIn Optional input filter to use. Defaults to null.
  filterOut Optional output filter to use. Defaults to null.
returns [not-null] The resulting MeshTree object.

Remarks:

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.

GetChild

Returns a child of the given mesh sector.

[Pure]
public method GetChild (int32 sector, int32 child)
type int32
params sector The mesh sector.
  child Index of child sector in the range [0..3].
returns Index of child sector center or Null if the child sector does not exist or Void if the child sector has been culled away.

See also:

SectorCull

GetCorners

Returns the four corner vertices of the given sector.

[Pure]
public method GetCorners (int32 sector)
type Vec4I
params sector The mesh sector.
returns The four corner vertices of the mesh sector.

Remarks:

The returned vector has the following meaning:

GetDown

Returns a downwards vertex link.

[Pure]
public method GetDown (int32 vertex, int32 link)
type int32
params vertex The mesh vertex.
  link One of LL, LR, RL and RR.
returns Index of linked vertex or Null if the vertex does not exist or Void if the vertex has been culled away.

See also:

SectorCull

GetDownForce

Returns a downwards vertex link.

[Pure]
public method GetDownForce (int32 sector, int32 link)
type int32
params sector Index of mesh sector center.
  link One of LL, LR, RL and RR.
returns Index of linked vertex or Void if the vertex does not exist.

GetIndex

Returns the child index of the given sector in its parent sector.

[Pure]
public method GetIndex (int32 sector)
type int32
params sector The mesh sector.
returns [0..3] Child index of sector in its parent sector.

See also:

GetParent

GetOrientation

Returns the orientation of the given mesh sector.

[Pure]
public static method GetOrientation (Vec4I corners, Int3 heightmapCoords, CubemapFace face = CubemapFace.NegZ)
type int32
params corners The mesh sector corners (see GetCorners).
  heightmapCoords The heightmap coordinates (see HeightmapCoords).
  face The cubemap face. Defaults to NegZ.
returns [0..7] The orientation code (see remarks).

Remarks:

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.

GetParent

Returns the parent sector for the given mesh sector.

[Pure]
public method GetParent (int32 sector)
type int32
params sector The mesh sector.
returns The parent sector or Null if not existent.

See also:

GetIndex

GetRoot

Returns the root sector of the given mesh face.

[Pure]
public method GetRoot (CubemapFace face)
type int32
params face The mesh face.
returns Index of root sector center vertex or Null.

See also:

GetParent

GetUp

Returns an upwards vertex link.

[Pure]
public method GetUp (int32 vertex, int32 link)
type int32
params vertex The mesh vertex.
  link One of L, R, G and A.
returns Index of linked vertex or Null if the vertex does not exist.

See also:

SectorCull

HasMark

Checks if the given mesh sector has a mark, either implicit, explicit or both.

public method HasMark (int32 sector)
type bool
params sector The mesh sector.
returns true if the sector is marked, false if not.

See also:

MeshTreeFilter

HasMarkExplicit

Checks if the given mesh sector has an explicit mark.

public method HasMarkExplicit (int32 sector)
type bool
params sector The mesh sector.
returns true if the sector is marked explicitly, false if not.

Remarks:

Mesh sectors receive explicit marks only from the MeshTree method.

See also:

MeshTreeFilter

HasMarkImplicit

Checks if the given mesh sector has an implicit mark.

public method HasMarkImplicit (int32 sector)
type bool
params sector The mesh sector.
returns true if the sector is marked implicitly, false if not.

Remarks:

A mesh sector receives an implicit mark when one of its descendants is marked explicitly.

See also:

MeshTreeFilter

IsEven

Is the given mesh sector 'even' (see XDag)?

[Pure]
public method IsEven (int32 vertex)
type bool
params vertex The mesh sector.
returns true if the mesh sector is 'even', false if it is 'odd'.

IsSolid

Checks if the given mesh sector is solid, i.e. if none of its descendants have been culled away.

public method IsSolid (int32 sector)
type bool
params sector The mesh sector.
returns true if the sector is solid, false if not.

See also:

SectorCull

SectorCull

Culls the given mesh sector.

public method SectorCull (int32 sector)
params sector Index of mesh sector center.

Remarks:

When culling a mesh sector, its marks (both explicit and implicit) will be retained.

SectorCullKeepMarked

Removes cull flags (see SectorCull) from the input filter of this mesh tree, so that all mesh sectors that have an explicit mark (see SectorMark) will become solid (see IsSolid).

public method SectorCullKeepMarked ()

See also:

SectorCull

SectorMark

Marks the given mesh sector.

public method SectorMark (int32 sector)
params sector Index of mesh sector center vertex.

Remarks:

Mesh sectors can receive marks (both explicit or implicit) even if they have been culled away earlier.

See also:

MeshTreeFilter

SectorMarkRoots

Marks the root sectors of the mesh.

public method SectorMarkRoots ()

See also:

SectorMark