Triangulator

Description

sealed class Tinman.Terrain.Kernel.Triangulator

The Triangulator class performs triangulation of terrain meshes.

Public / Methods

Begin


public method Begin → (1)

triangulationBuffer in : TriangulationBuffer

[not-null]
The output triangulation buffer to use.

Begins a new triangulation cycle.

Triangulation outputs chunks up to 128 indices each and will stop if the given output buffer has not enough space left for another whole chunk.

Decode


public method Decode → (4)

buffer in : TriangulationBuffer

[not-null]
The input triangulation buffer.

flip opt : bool = false

Flip triangles?

slices opt : IArrayVector<int32> = null

The triangulation slices to update in-place or null to skip.

output opt : ArrayVector<int32> = null

The output list to use. If null, a new list will be created.

returns → ArrayVector<int32>

The decoded triangles: each triple defines a single triangle.

Decodes the given triangulation buffer into a triangle list.

For rendering, the decoding of the triangulation buffer content is usually done on the GPU, in a dedicated shader program. This method is intended for exporting the triangulation buffer content to a 3D model, but is it also useful for verification and testing.

End


public method End → ()

Ends the current triangulation cycle.

Fan


public method Fan → (2)

sector in : int32

The mesh sector.

triangleFanIndices in : int32 [ ]

[not-null]
Output array for generated vertex indices.

returns → int32

The number of vertex indices that have been written to triangleFanIndices in

Generates a triangle fan that covers the given mesh sector.

Fan​Leaf


public method FanLeaf → (3)

sector in : int32

The mesh sector.

childIdx in : int32

Child index of the non-existent sector in sector in which area shall be triangulated.

vertices out : Vec4I

The vertex indices of the triangle fan, to be processed in this order: Vec4I.X, Vec4I.Y, Vec4I.Z, Vec4I.W.
The resulting counter-clockwise triangles are thus defined as:
<Vec4I.X, Vec4I.Y, Vec4I.Z >
<Vec4I.X, Vec4I.Z, Vec4I.W >
The bounds of the triangulated quadrant may not be expressible with the existing mesh vertices. In this case, the first and/or second triangle will be larger, covering parts of adjacent leaf quadrants.

returns → int32

A combination of the following flags:
0x1 :
Vec4I.Y is outside of the quadrant bounds. The correct vertex is halfway between Vec4I.X and Vec4I.Y.
0x2 :
Vec4I.W is outside of the quadrant bounds. The correct vertex is halfway between Vec4I.X and Vec4I.W.

Generates a triangle fan for a quadrant of the given mesh sector, assuming that it is a leaf (i.e. it has no child sectors).

Mark


[BeginEnd]
public method Mark → ()

returns → int32

The number of emitted vertex indices.

Returns the number of vertex indices that have been emitted so far.

The returned index count can be used to render arbitrary parts of the triangulation.

Sector


[BeginEnd]
public method Sector → (1)

sector in : int32

The mesh sector.

Generates triangles that cover the given mesh sector.

Sector​Leaf


[BeginEnd]
public method SectorLeaf → (2)

sector in : int32

Index of center vertex of sector to visit.

childIdx in : int32

Child index of the non-existent sector in sector in which area shall be triangulated.

Generates triangles that cover a quadrant of the given mesh sector, assuming that it is a leaf (i.e. it has no child sectors).

Sector​Root


[BeginEnd]
public method SectorRoot → (1)

tree in : MeshTree

The mesh tree to use for obtaining root sectors per cubemap face.

Generates triangles that cover the given root mesh sectors.

See also

Triangulator.End