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

class VertexFormat in Tinman.Terrain.Vertices.Formats

Abstract base class for IVertexFormat implementations.

abstract class VertexFormat implements IVertexFormat

Public / Constants

Empty

An empty vertex format.

public static readonly field Empty
type IVertexFormat

Remarks:

Use this value as the initial seed when incrementally building vertex formats with Append.

Public / Attributes

VertexElements

Returns the vertex declaration elements.

public property VertexElements { get }
type VertexElements
value [not-null] The vertex declaration elements.
implements IVertexElements.VertexElements

Public / Constructors

Color

Returns an IVertexFormat for Color usage.

[Pure]
public static method Color (Semantic semantic = null, TupleComponent component = TupleComponent.X)
type IVertexFormat
params semantic The Semantic to source data from. If null, Texture will be used. Defaults to null.
  component The vertex array component to use. Defaults to X.
returns [not-null] The vertex format.

Remarks:

Color tuples are read from the given vertex array (see semantic) using either:

A 32-bit A8R8G8B8 compressed sRGB color value is written to the vertex buffer:
Byte offset #0: color (int32)

Float32

Returns an IVertexFormat for the given usage.

[Pure]
public static method Float32 (VertexElementUsage usage, Semantic semantic, int32 tupleSize = 0)
type IVertexFormat
params usage The vertex element usage.
  semantic [not-null] The Semantic to source data from.
  tupleSize [0..4] Size of a coordinate tuple. If 0, the TupleSize of semantic is used. Defaults to 0.
returns [not-null] The vertex format.

Remarks:

Coordinate tuples are read from the given vertex array (see semantic) and written to the vertex buffer as 32-bit floating-point values:

Byte offset #0:  x (float32)
Byte offset #4:  y (float32) ? tupleSize >= 2
Byte offset #8:  z (float32) ? tupleSize >= 3
Byte offset #12: w (float32) ? tupleSize == 4

HeightmapCoordinates

Returns an IVertexFormat for TextureCoords usage.

[Pure]
public static method HeightmapCoordinates (CoordinatePrecision precision = CoordinatePrecision.Float, int32 tupleSize = 0, Semantic semantic = null)
type IVertexFormat
params precision The texture coordinate precision. Defaults to Float.
  tupleSize [0..4] Size of a coordinate tuple. If 0, the TupleSize of semantic is used. Defaults to 0.
  semantic The Semantic to source data from. If null, HeightmapCoords will be used. Defaults to null.
returns [not-null] The vertex format.

Remarks:

Coordinate tuples are read from the vertex array (see GetVertexArray) using the GetI method. Input coordinates are clamped to 0 and MaxCoord. Then, the precision fix is applied, the resulting coordinates are normalized to [0..1] and finally written to the vertex buffer:

Byte offset #0:  x (float32 or int32)
Byte offset #4:  y (float32 or int32) ? tupleSize >= 2
Byte offset #8:  z (float32 or int32) ? tupleSize >= 3
Byte offset #12: w (float32 or int32) ? tupleSize == 4

See also:

HeightmapsUtil.MaxCoord

Material

Returns an IVertexFormat for Color usage that encodes the weights of the specified materials.

[Pure]
public static method Material (int32 material0 = 0, int32 material1 = 1, int32 material2 = 2, int32 material3 = 3, Semantic semantic = null, TupleComponent component = TupleComponent.X)
type IVertexFormat
params material0 ID of first material. Defaults to 0.
  material1 ID of second material. Defaults to 1.
  material2 ID of third material. Defaults to 2.
  material3 ID of fourth material. Defaults to 3.
  semantic The Semantic to source data from. If null, Material will be used. Defaults to null.
  component The vertex array component to use. Defaults to X.
returns [not-null] The vertex format.

Remarks:

Material token values are read from the vertex array using the given tuple component. Then the weights are extracted for the specified materials (see WeightFor) and then written to the vertex buffer as a single 32-bit integer value:

Byte offset #0: material weights (int32)
                first material  : blue channel
                second material : green channel
                third material  : red channel
                fourth material : alpha channel

See also:

MaterialToken

MaterialId

Returns an IVertexFormat for Color usage that encodes the materials ID of a material token.

[Pure]
public static method MaterialId (Semantic semantic = null, TupleComponent component = TupleComponent.X)
type IVertexFormat
params semantic The Semantic to source data from. If null, Material will be used. Defaults to null.
  component The vertex array component to use. Defaults to X.
returns [not-null] The vertex format.

Remarks:

Material token values are read from the vertex array using the given tuple component. Then the material IDs are written to the vertex buffer as a single 32-bit integer value:

Byte offset #0: bits [32..64[ of material token (int32)
                first material  : blue channel
                second material : green channel
                third material  : red channel
                fourth material : alpha channel

See also:

MaterialToken

MaterialWeight

Returns an IVertexFormat for Color usage that encodes the materials weights of a material token.

[Pure]
public static method MaterialWeight (Semantic semantic = null, TupleComponent component = TupleComponent.X)
type IVertexFormat
params semantic The Semantic to source data from. If null, Material will be used. Defaults to null.
  component The vertex array component to use. Defaults to X.
returns [not-null] The vertex format.

Remarks:

Material token values are read from the vertex array using the given tuple component. Then the material weights are written to the vertex buffer as a single 32-bit integer value:

Byte offset #0: bits [0..32[ of material token (int32)
                first material  : blue channel
                second material : green channel
                third material  : red channel
                fourth material : alpha channel

See also:

MaterialToken

Normal

Returns an IVertexFormat for Normal usage.

[Pure]
public static method Normal (Semantic semantic = null)
type IVertexFormat
params semantic The Semantic to source data from. If null, Normal will be used. Defaults to null.
returns [not-null] The vertex format.

Remarks:

Coordinate tuples are read from the Normal vertex array and written to the vertex buffer as 32-bit floating-point values:

Byte offset #0: x (float32)
Byte offset #4: y (float32)
Byte offset #8: z (float32)

Placeholder

Returns an IVertexFormat that acts as a placeholder for the given usage.

[Pure]
public static method Placeholder (VertexElementUsage usage)
type IVertexFormat
params usage The vertex element usage.
returns [not-null] The vertex format.

Position

Returns an IVertexFormat for Position usage.

[Pure]
public static method Position (PositionPrecision precision = PositionPrecision.Float, int32 tupleSize = 0, Semantic semantic = null)
type IVertexFormat
params precision The desired precision kind. Defaults to Float.
  tupleSize [0..4] Size of a coordinate tuple. If 0, the TupleSize of semantic is used. Defaults to 0.
  semantic The Semantic to source data from. If null, Position will be used. Defaults to null.
returns [not-null] The vertex format.

Remarks:

Coordinate tuples are read from the vertex array (see GetVertexArray) using the GetF resp. GetD method. Then, the given precision fix is applied and the resulting coordinates and written to the vertex buffer as 32-bit floating-point values:

Byte offset #0:  x (float32)
Byte offset #4:  y (float32) ? tupleSize >= 2
Byte offset #8:  z (float32) ? tupleSize >= 3
Byte offset #12: w (float32) ? tupleSIze == 4

Tangent

Returns an IVertexFormat for Tangent usage.

[Pure]
public static method Tangent (Semantic semantic = null)
type IVertexFormat
params semantic The Semantic to source data from. If null, TangentX will be used. Defaults to null.
returns [not-null] The vertex format.

Remarks:

Coordinate tuples are read from the given vertex array and written to the vertex buffer as 32-bit floating-point values:

Byte offset #0: x (float32)
Byte offset #4: y (float32)
Byte offset #8: z (float32)

TextureCoords

Returns an IVertexFormat for TextureCoords usage.

[Pure]
public static method TextureCoords ()
type IVertexFormat
returns [not-null] The vertex format.

Remarks:

Coordinate tuples are read from the TextureCoords vertex array and written to the vertex buffer as 32-bit floating-point values:

Byte offset #0: x (float32)
Byte offset #4: y (float32)

Public / Methods

Append

Appends the given vertex format to this vertex format.

[Pure]
public virtual method Append (IVertexFormat format)
type IVertexFormat
params format [not-null] The vertex format to append.
returns [not-null] The resulting vertex format.
implements IVertexFormat.Append

SetVertexArrays

Sets the vertex data containers from which this vertex converter shall read vertex data.

public virtual method SetVertexArrays (VertexArrays vertexArrays)
params vertexArrays [not-null] The vertex data collection.
implements IVertexArraysDependent.SetVertexArrays

WriteVertex

Writes vertex data to the given vertex buffer.

[Pure]
public abstract method WriteVertex (int32 vertex, ByteBuffer buffer)
params vertex [>=0] The vertex index.
  buffer [not-null] The target vertex buffer region.
implements IVertexFormat.WriteVertex

Protected / Attributes

semantic

The semantic of this vertex format.

protected readonly field semantic
type Semantic

vertexArray

The default vertex array this vertex format uses.

protected field vertexArray
type IVertexArray

Remarks:

This field is set in SetVertexArrays.

Protected / Constructors

VertexFormat

Creates a new instance of VertexFormat.

protected constructor VertexFormat (VertexElements elements, Semantic semantic)
params elements [not-null] The vertex elements.
  semantic [not-null] The Semantic to use for initializing vertexArray.