MapField

Description

struct Tinman.Terrain.Mapping.MapField

The MapField struct describes a rectangular region of a map.

The top-left corner of a map field is specified in cubemap face coordinates, i.e. face X- and Y-coordinates and cubemap face number (see Cubemap). A map field has a step value which depicts the distance between adjacent samples. The map field step is always interpreted relative to the map origin at (0,0).

When a MapField value is created with a field step greater than 1, the given input map coordinates are adjusted to match the nearest map samples that match specified field step (e.g. the tightest fitting bounding rectangle is computed).

The following figure illustrates some example map fields for a map of size 10 x 5:

'.' := Map sample
'o' := Map sample matching field step
'x' := Map sample contained in field

+----------+       +----------+       +----------+
|xxxxoooooo|       |o.o.o.o.o.|       |o...x...x.|
|xxxxoooooo|       |..........|       |..........|
|xxxxoooooo|       |o.x.x.x.o.|       |..........|
|oooooooooo|       |..........|       |..........|
|oooooooooo|       |o.x.x.x.o.|       |o...o...o.|
+----------+       +----------+       +----------+

FaceX  := 0        FaceX  := 2        FaceX  := 4
FaceY  := 0        FaceY  := 2        FaceY  := 0
Width  := 4        Width  := 3        Width  := 2
Height := 3        Height := 2        Height := 1
Step   := 1        Step   := 2        Step   := 4

Public / Constants

Empty


public static readonly attribute Empty → (MapField)

An empty map field (i.e. containing no map samples).

Public / Constructors

Solid​Points


public static method SolidPoints → (5)

faceX1 in : int32

X-coordinate of first corner of map region.

faceY1 in : int32

Y-coordinate of first corner of map region.

faceX2 in : int32

X-coordinate of second corner of map region.

faceY2 in : int32

X-coordinate of second corner of map region.

face opt : CubemapFace = CubemapFace.NegZ

The cubemap face of the region.

returns → MapField

The MapField value.

Creates a solid MapField for the given map region.

Solid​Rect

2 overloads


public static method SolidRect1 → (1)

rect in : CubemapFaceRect

The cubemap face rectangle.

returns → MapField

The MapField value.

Creates a solid MapField for the given map region.


public static method SolidRect2 → (5)

faceX in : int32

X-coordinate of top-left corner of map region.

faceY in : int32

Y-coordinate of top-left corner of map region.

width in : int32

The map region width, in samples.

height in : int32

The map region height, in samples.

face opt : CubemapFace = CubemapFace.NegZ

The cubemap face of the region.

returns → MapField

The MapField value.

Creates a solid MapField for the given map region.

Sparse​Points


public static method SparsePoints → (6)

faceX1 in : int32

X-coordinate of first corner of map region.

faceY1 in : int32

Y-coordinate of first corner of map region.

faceX2 in : int32

X-coordinate of second corner of map region.

faceY2 in : int32

X-coordinate of second corner of map region.

step in : int32

[>=0]
The field step, in map samples, given as logarithm of base 2 (see Maths.Log2_Floor); e.g. 0 means a step of 1, 3 means a step of 8.

face opt : CubemapFace = CubemapFace.NegZ

The cubemap face of the region.

returns → MapField

The MapField value.

Creates a sparse MapField for the given map region.

A sparse map field contains every n-th map sample, relative to the top-left map sample at (0,0). The value of n must be a power of two.

Sparse​Rect


public static method SparseRect → (6)

faceX in : int32

X-coordinate of top-left corner of map region.

faceY in : int32

Y-coordinate of top-left corner of map region.

width in : int32

Width of map region, in field steps.

height in : int32

Height of map region, in field steps.

step in : int32

[>=0]
The field step, in map samples, given as logarithm of base 2 (see Maths.Log2_Floor); e.g. 0 means a step of 1, 3 means a step of 8.

face opt : CubemapFace = CubemapFace.NegZ

The cubemap face of the region.

returns → MapField

The MapField value.

Creates a sparse MapField for the given map region.

A sparse map field contains every n-th map sample, relative to the top-left map sample at (0,0). The value of n must be a power of two.

Public / Methods

Clip


[Pure]
public method Clip → (4)

in : int32

X-coordinate of top-left corner of clip rectangle, in samples.

in : int32

Y-coordinate of top-left corner of clip rectangle, in samples.

width in : int32

Width of clip rectangle, in samples.

height in : int32

Height of clip rectangle, in samples.

returns → MapField

The clipped map field.

Clips this map field at the given region.

Get​Cube​Coords


[Pure]
public method GetCubeCoords → (3)

in : int32

X-coordinate of map field sample.

in : int32

Y-coordinate of map field sample.

cubemapSizeMinusOne in : int32

[pow2]
The cubemap size, minus one.

returns → Vec3I

The absolute cubemap coordinates.

Computes the absolute cubemap coordinates of the given map field sample.

Get​Face​Coords


[Pure]
public method GetFaceCoords → (2)

in : int32

X-coordinate of map field sample.

in : int32

Y-coordinate of map field sample.

returns → CubemapFaceCoordsI

The absolute cubemap face coordinates.

Computes the absolute cubemap face coordinates of the given map field sample.

To​String


public override method ToString → ()

returns → string

The string representation.

Returns the string representation of this value.

Public / Attributes

Face


public readonly attribute Face → (CubemapFace)

The cubemap face on which the map field is located.

See also

Cubemap

Face​X


public readonly attribute FaceX → (int32)

The cubemap face X-coordinate of the top-left corner of the map field.

Face​Y


public readonly attribute FaceY → (int32)

The cubemap face Y-coordinate of the top-left corner of the map field.

Height


public readonly attribute Height → (int32)

The height of the map field, in map field sample steps.

Is​Empty


public attribute IsEmpty → (get)

value : bool

true if the map field is empty, false if not.

Is this map field empty, i.e. it contains no samples?

Step


public readonly attribute Step → (int32)

The step distance between adjacent map field samples.

Width


public readonly attribute Width → (int32)

The width of the map field, in map field sample steps.

Serialization

Serializer


public static readonly attribute Serializer → (ITypeSerializer<MapField>)

The serialization helper object for values of MapField.