ITerrainExporter

Description

interface Tinman.AddOns.Export.ITerrainExporter

Derived from

IGeorefInfo
IDisposable

Full source code is included in the Tinman 3D SDK download.

Base interface for classes that export terrain mesh chunks.

Based on a view-dependent continuous level-of-detail terrain mesh, a terrain exporter generates static terrain chunks, for various usages:

  • Mesh geometry for rendering.

  • Mesh geometry for collision detection resp. physics simulation.

  • Terrain imagery, for example PNG or JPG files.

  • Terrain textures, for example BC1 for GPU upload and rendering.

Using a ITerrainExporter to render a 3D terrain involves the following steps:

  1. Inspect IMapInfo.Map to determine the map type, then use MapInfo.FaceFirst and MapInfo.FaceLast to find the pyramid coordinates of the root tile on each cubemap face. Perform the following steps for each root tile.

  2. Use HasChunk and PyramidCoords.Child to traverse the tile hierarchy, starting at the root tile. Perform the following steps for each visited tile.

  3. Use GetChunk to obtain the coefficients that are necessary to perform common computations for the terrain mesh chunk.

  4. Use the GetVertexData method to obtain vertex data for the tile. Optionally use GetVertexMask to determine an optimal vertex format.

  5. Use the GetIndexData method to obtain index data for the tile, then use GetIndexRange to find the index ranges for rendering the either whole tile or just one of its quadrants.

  6. Use GetTextureMask to determine the kind of unique texturing to perform for the tile. Then, use GetTextureData to obtain the texture data for rendering with TerrainVertexData.TextureCoordinates.

  7. Use GetMaterialMask to determine if material-based texturing must be applied to the tile. Then, use GetMaterialMask and GetMaterialData to obtain the required materials and to determine the texturing mode: tri-planar texturing or planar texturing (use TerrainChunk.MaterialCoordinates to compute the texture coordinates, based on position).

Public / Methods

Get​Chunk


public method GetChunk → (1)

coords in : PyramidCoords

The pyramid coordinates of the terrain mesh chunk.

returns → TerrainChunk

The terrain chunk metadata.

Returns metadata information about the given terrain mesh chunk.

Get​Index​Data


public method GetIndexData → (1)

coords in : PyramidCoords

The pyramid coordinates of the terrain mesh chunk.

returns → int32 [ ]

The buffer that holds the index data of the terrain mesh chunk.

Exports the indices of the given terrain mesh chunk.

Get​Index​Range


public method GetIndexRange → (2)

coords in : PyramidCoords

The pyramid coordinates of the terrain mesh chunk.

quadrant opt : int32 = -1

[-1..3]
The quadrant index or -1 for the whole chunk.

returns → RangeI

The index range of the terrain mesh chunk quadrant.

Returns the index range that encompasses the given terrain mesh chunk quadrant.

Get​Layer​Ids


public method GetLayerIds → (1)

coords in : PyramidCoords

The pyramid coordinates of the terrain mesh chunk.

returns → int32 [ ]

The layer IDs.

Returns the layer IDs that are present in the given terrain mesh chunk.

Get​Material​Data


public method GetMaterialData → (2)

materialId in : int32

[0..63]
The material ID (see MaterialToken).

vertical opt : bool = false

If true, return the vertical material for tri-planar texturing.
If false, return the horizontal material for tri-planar texturing

returns → IMaterial

The terrain material for rendering or null if unused.

Returns a terrain material for rendering.

Get​Material​Mask


public method GetMaterialMask → (2)

coords in : PyramidCoords

The pyramid coordinates of the terrain mesh chunk.

quadrant in : int32

[-1..3]
The quadrant index or -1 for the whole chunk.

returns → int64

A bitmask that indicates which material ID is present in the terrain mesh chunk quadrant.

Returns the terrain materials that are present in the given terrain mesh chunk quadrant.

Get​Model​Data


public method GetModelData → (1)

modelId in : int32

Identifier of the 3D model (see GetModelIds).

returns → IModel

The 3D model data.

Returns the 3D data of a model for a given pyramid level.

Get​Model​Ids


public method GetModelIds → (1)

coords in : PyramidCoords

The pyramid coordinates of the terrain mesh chunk.

returns → int32 [ ]

The model IDs.

Returns the model IDs that are present in the given terrain mesh chunk.

Get​Model​Instances


public method GetModelInstances → (3)

modelId in : int32

Identifier of the 3D model (see GetModelIds).

coords in : PyramidCoords

The pyramid coordinates of the terrain mesh chunk.

quadrant opt : int32 = -1

[-1..3]
The quadrant index or -1 for the whole chunk.

returns → AffineTransform [ ]

The model instances, each given as a transformation matrix from the model coordinate system to the local coordinate system of the terrain mesh chunk.

Returns the instances of a model in the specified terrain mesh chunk.

Get​Texture​Data


public method GetTextureData → (7)

layerId in : int32

Identifier of the terrain layer (see GetLayerIds).

coords in : PyramidCoords

The pyramid coordinates of the terrain mesh chunk.

red opt : TerrainTextureData = TerrainTextureData.AlbedoRed

The texture data to put into the red channel (single flag, no bitmask).

green opt : TerrainTextureData = TerrainTextureData.AlbedoGreen

The texture data to put into the green channel (single flag, no bitmask).

blue opt : TerrainTextureData = TerrainTextureData.AlbedoBlue

The texture data to put into the blue channel (single flag, no bitmask).

alpha opt : TerrainTextureData = TerrainTextureData.Opacity

The texture data to put into the alpha channel (single flag, no bitmask).

inverse opt : int32 = 0

A bitmask that depicts which channels to invert after putting the texture data into it:

1 : red channel
2 : green channel
4 : blue channel
8 : alpha channel
returns → ColorBuffer

The pixel buffer that holds the imagery of the terrain mesh chunk.

Exports texture data of the given terrain mesh chunk.

Get​Texture​Mask


public method GetTextureMask → (1)

layerId in : int32

Identifier of the terrain layer (see GetLayerIds).

returns → TerrainTextureData

Bitmask of TerrainTextureData values that indicates the available texture data.

Returns the texture data that is available for the given terrain layer.

Get​Vertex​Data


public method GetVertexData → (2)

coords in : PyramidCoords

The pyramid coordinates of the terrain mesh chunk.

data in : TerrainVertexData

The vertex data to return (single flag, no bitmask).

returns → float32 [ ]

The vertex data, to be interpreted according to data in.

Exports vertex data of the given terrain mesh chunk.

Get​Vertex​Mask


public method GetVertexMask → (1)

coords in : PyramidCoords

The pyramid coordinates of the terrain mesh chunk.

returns → TerrainVertexData

Bitmask of TerrainVertexData values that indicates the available vertex data.

Returns the vertex data that is available for the given terrain mesh chunk.

Has​Chunk


public method HasChunk → (1)

coords in : PyramidCoords

The pyramid coordinates of the terrain mesh chunk.

returns → bool

true if a terrain mesh chunk exists for coords in,
false if not.

Check if a terrain mesh chunk exists.

Public / Attributes

Models


public attribute Models → (get)

value : IVectorConst<string>

[not-null]
The list of 3D model identifiers.

Returns the available 3D models.

On​Changed


public attribute OnChanged → (get)

value : IEventGeneric<TerrainExporterEventArgs>

[not-null]
The event object.

An event that is fired each time the source terrain data has changed, affecting the generated data of one or more terrain mesh chunks.

Tile​Size


public attribute TileSize → (get)

value : int32

[pow2]
The tile size, in pixels resp. texels.

Returns the tile size of the root terrain chunk (on any cubemap face).

The tile size defines the visual quality threshold that is used to generate terrain mesh chunks. The continuous level-of-detail of each terrain mesh chunk is chosen so that the projected geometric error correlates with the ratio between screen pixels and texels.