TerrainMesh

Description

sealed class Tinman.Engine.Components.TerrainMesh

Derived from

Disposable abstract

Represents a terrain mesh.

The TerrainMesh class provides a high-level API that wraps the terrain features of the Tinman 3D SDK in an easy to use way:

  • Setup and configuration of the object graph that is necessary for terrain rendering.

  • Terrain layers for flexible management of rendering style and data sources.

  • Geo-referenced terrain decals.

  • Geo-referenced terrain 3D models.

  • Global dynamic planting of 3D models onto the terrain surface, using GPU instancing for rendering.

The layers of a terrain mesh are ordered by their sort index value (see TerrainLayer.SortIndex). Layers use alpha-blending, so layers with higher sort index values will occlude others. The implicit layer at sort index -0.5 is used to render the terrain materials:

 +-------+
 | Layer |   SortIndex = -1000 (implicit layer for plain mesh with vertex colors)
 +-------+
 | Layer |   SortIndex =  -999 (minimum allowed sort index)
 +-------+
 |  ...  |
 +-------+
 | Layer |   SortIndex =    -2
 +-------+
 | Layer |   SortIndex =    -1
 +-------+
(Materials)  SortIndex =  -0.5 (implicit layer for materials)
 +-------+
 | Layer |   SortIndex =     0
 +-------+
 | Layer |   SortIndex =    +1
 +-------+
 |  ...  |
 +-------+
 | Layer |   SortIndex =  +999 (maximum allowed sort index)
 +-------+

Public / Constructors

Terrain​Mesh


public constructor TerrainMesh → (3)

buffer in : TerrainBuffer own

[not-null]
The terrain buffer to use.

options in : MeshOptions own

[not-null]
The terrain mesh options.
For geo-referenced terrains, the HeightmapLayer.Elevation values of MeshOptions.Heightmap will be interpreted as VerticalType.Ellipsoid height.
The MeshOptions.Visibility option will be ignored. Instead, a separate instance of ScreenVisibleCheck will be used for each TerrainView.

gravity opt : IHeightmap = null

Optional heightmap that stores gravity-related offsets from the ellipsoid surface (see VerticalType.Gravity).

Creates a new instance of TerrainMesh.

Elevation values of the given mesh heightmap (see MeshOptions.Heightmap) are interpreted as relative offsets to the ellipsoid surface.

ValidatingException

If the given options in are invalid.

GeorefException

If MeshOptions.Geometry is null and the given geo-reference is not suitable.

Public / Methods

Decal​Add


public method DecalAdd → (1)

decal in : TerrainDecal

[not-null]
The terrain decal to add.

Adds the given terrain decal.

If the given decal in is already present, the method silently returns.

Decal​Remove


public method DecalRemove → (1)

decal in : TerrainDecal

[not-null]
The terrain decal to remove.

Removes the given terrain decal.

If the given decal in is not present, the method silently returns.

Layer​At


public method LayerAt → (1)

sortIndex in : int32

The sort index.

returns → TerrainLayer

The terrain layer of null if none.

Returns the terrain layer at the given sort index.

Layer​Create


public method LayerCreate → (2)

sortIndex in : int32

The layer sort index value (see TerrainLayer.SortIndex). Will be clamped to [SortIndexMinimum..SortIndexMaximum].

type in : TerrainLayerType

The terrain layer type. Must be one of: TerrainLayerType.Texture, TerrainLayerType.Region.

returns → TerrainLayer

The created terrain layer.

Creates layer of the given type in for this terrain mesh.

Layer​Get


public method LayerGet → (1)

index in : int32

[0..TerrainMesh.LayerCount-1]
The layer index.

returns → TerrainLayer

The terrain layer.

Returns an existing terrain layer.

The sequence of terrain layers is sorted by the layer sort index ( TerrainLayer.SortIndex), in ascending order.

Layer​Remove


public method LayerRemove → (1)

layer in : TerrainLayer

[not-null]
The terrain layer to remove.

Removes an existing terrain layer.

If the given layer in is not of type TerrainLayerType.Texture or has not been created with LayerCreate, the method will return silently.

Model​Add


public method ModelAdd → (1)

model in : TerrainModel

[not-null]
The model to add.

Adds a terrain 3D model.

If the given model in is already present, the method silently returns.

Model​Get


public method ModelGet → (1)

index in : int32

[0..TerrainMesh.ModelCount-1]
The terrain model index.

returns → TerrainModel

The terrain model.

Returns the index in-th terrain model.

Model​Remove


public method ModelRemove → (1)

model in : TerrainModel

[not-null]
The model to remove.

Removes a terrain 3D model.

If the given model in is not present, the method silently returns.

Planting​Add


public method PlantingAdd → (1)

planting in : TerrainPlanting

[not-null]
The terrain planting options to add.

Adds the given terrain planting options.

If the given planting in is already present, the method silently returns.

Planting​Get


public method PlantingGet → (1)

index in : int32

[0..TerrainMesh.PlantingCount-1]
The terrain planting options index.

returns → TerrainPlanting

The terrain planting options.

Returns the index in-th terrain planting options.

Planting​Remove


public method PlantingRemove → (1)

planting in : TerrainPlanting

[not-null]
The terrain planting options to remove.

Removes the given terrain planting options.

If the given planting in is not present, the method silently returns.

Public / Attributes

Buffer


[Constant]
public attribute Buffer → (get)

value : TerrainBuffer

[not-null]
The terrain buffer object.

Returns the TerrainBuffer object that this terrain mesh is using.

Distance


[Constant]
public attribute Distance → (get)

value : DistanceToGround

[not-null]
The helper object.

Returns the DistanceToGround helper object for this terrain mesh.

Geocentric


[Constant]
public attribute Geocentric → (get)

value : Geocentric

The Geocentric object or null if the terrain mesh does not have a geocentric reference.

The Geocentric helper object of the terrain mesh.

The returned object is obtained from IGeometry.ToGeocentric and then augmented with the following data, if possible:

Gravity


[Constant]
public attribute Gravity → (get)

value : IHeightmap

The gravity-related heightmap or null.

Optional heightmap that stores gravity-related offsets from the ellipsoid surface (see VerticalType.Gravity)

Height


[Constant]
public attribute Height → (get)

value : HeightAboveGround

[not-null]
The helper object.

Returns the HeightAboveGround helper object for this terrain mesh.

Layer​Base


[Constant]
public attribute LayerBase → (get)

value : TerrainLayer

[not-null]
The terrain layer object.

Returns the implicit layer of type TerrainLayerType.Base.

Layer​Count


public attribute LayerCount → (get)

value : int32

[>=2]
The terrain layer count, including the implicit layers LayerBase and LayerMaterial.

Returns the number of terrain layers.

Layer​First


public attribute LayerFirst → (get)

value : int32

[0..TerrainMesh.LayerCount-1]
Index of first non-occluded terrain layer.

Returns the visible terrain layer with the smallest sort index that occludes all other layers below it.

Layer​Material


[Constant]
public attribute LayerMaterial → (get)

value : TerrainLayer

[not-null]
The terrain layer object.

Returns the implicit layer of type TerrainLayerType.Material.

Map​Type


[Constant]
public attribute MapType → (get)

value : MapType

The map type.

Returns the map type of this terrain.

Mesh


[Constant]
public attribute Mesh → (get)

value : IMeshDynamic

[not-null]
The IMesh object.

The CLOD mesh of this terrain.

Model​Count


public attribute ModelCount → (get)

value : int32

[>=0]
The number of terrain 3D models.

Returns the number of terrain 3D models.

Opaque​Mask


public attribute OpaqueMask → (get,set)

value : int32

The opaque mask.

Bitmask that determines when a sequence of layers is considered to be opaque.

Defaults to ~0.

Picking


[Constant]
public attribute Picking → (get)

value : Picking

[not-null]
The helper object.

Returns the Picking helper object for this terrain mesh.

Planting​Count


public attribute PlantingCount → (get)

value : int32

[>=0]
the terrain planting option count.

Returns the number of terrain planting options.

World


[Constant]
public attribute World → (get)

value : MeshCameraWorld

[not-null]
The helper object.

Returns the ICameraWorld helper object for this terrain mesh.