TriangulationBuffer

Description

sealed class Tinman.Terrain.Kernel.TriangulationBuffer

Derived from

ICapacity

The TriangulationBuffer consume the output of a mesh triangulation process.

The triangulation process always outputs triangles, which may be encoded in different ways. Obvious ones are triangle lists and triangle strips, more sophisticated ones are terminal triangle lists and sector lists (see TriangleMode). The latter ones require compute features on the GPU, when being used for rendering.

See also

Triangulator

Public / Constructors

Triangulation​Buffer


public constructor TriangulationBuffer → (1)

capacity opt : int32 = 1048576

[>0]
The fixed buffer capacity, in indices.

Creates a new instance of TriangulationBuffer.

Public / Methods

Indices​Per​Triangle


[Pure]
public static method IndicesPerTriangle → (1)

mode in : TriangleMode

The triangle mode.

returns → int32

The number of indices per triangles, multiplied with 100.

Returns the estimated average number of 32-bit integer indices that need to be generated to describe a single triangle.

Reset


public method Reset → (2)

capacity in : int32

[>0]
The buffer capacity, in indices.

grow opt : bool = false

true to only grow the buffer if capacity in is greater than ICapacity.Capacity,
false to re-allocate the buffer so that capacity in will be equal to ICapacity.Capacity.

Resets the buffer to a new capacity.

Calling this method will invalidate the current triangulation result (if any).

Set


public method Set → (2)

indexCount in : int32

[0..ICapacity.Capacity]
The number of indices that have been generated.

overflow in : bool

If this triangulation buffer has overflown during the last triangulation process.

Sets the index count of this buffer.

Triangle​Winding​For

2 overloads


public method TriangleWindingFor1 → (1)

geometry in : IGeometry

[not-null]
The geometry.

Sets the TriangleWinding property according to the handedness of the given geometry.


public method TriangleWindingFor2 → (1)

handedness in : CartesianHandedness

The coordinate system handedness.

Sets the TriangleWinding property according to the given handedness.

Update


public method Update → (3)

buffer in : IIndexBuffer

[not-null]
The index buffer to update.

bufferIndex opt : int32 = 0

[>=0]
Offset of first index in buffer in to write.

flag opt : GpuUpdateFlag = GpuUpdateFlag.Discard

The update flag to apply.

returns → bool

true if buffer in has been updated, false if the given index buffer has not enough capacity.

Updates the given index buffer.

Public / Attributes

Has​Overflow


public attribute HasOverflow → (get)

value : bool

true if an overflow has occurred, false if not.

Returns if this triangulation buffer has overflown during the last triangulation process.

Index​Count


public attribute IndexCount → (get)

value : int32

[0..ICapacity.Capacity]
The number of generated indices.

Returns the number of indices that have been generated.

Indices


public attribute Indices → (get)

value : int32 [ ]

[not-null]
The vertex indices array.

Returns the array that holds the generated vertex indices.

Mode


public attribute Mode → (get,set)

value : TriangleMode

The triangulation mode.

The triangulation mode that has been used to fill this triangulation buffer.

Primitive​Restart


public attribute PrimitiveRestart → (get,set)

value : bool

true to restart primitives with special index value ~0,
false to use degenerated triangles.

Use special index value ~0 for restarting primitives, instead of inserting degenerated triangles?

Primitives only need to be restarted when in TriangleMode.TriangleStrip mode. Degenerated triangles resp. special index values will only appear in this mode.

Defaults to false.

Triangle​Winding


public attribute TriangleWinding → (get,set)

value : bool

The desired winding value (see remarks).

The winding of the triangles in the triangulation buffer.

The winding is defined according to the cubemap face coordinates of the triangle vertices:

winding = sign(cross(B - A, C - A)) > 0

where A, B and C are the two-dimensional cubemap face coordinates of the triangle vertices (in the same order as they are referenced in the triangulation buffer).

Defaults to false.