Heightmap

Description

abstract class Tinman.Terrain.Heightmaps.Heightmap

Derived from

Disposable abstract
IHeightmap

Extended by

CompositeHeightmapOne abstract
CompositeHeightmapTwo abstract
MandelbrotHeightmap sealed
RandomHeightmap sealed
TestPatternHeightmap sealed

Abstract base class for IHeightmap implementations.

Public / Constructors

Builder

4 overloads


public static method Builder1 → (1)

size in : int32

[pow2+1]
The cubemap size.

returns → HeightmapBuilder

The heightmap builder object.

Builds a heightmap of type MapType.Cube with PixelCoverage.PixelIsPoint.


public static method Builder2 → (3)

width in : int32

[>0]
The map width, in heightmap samples.

height in : int32

[>0]
The map height, in heightmap samples.

coverage opt : PixelCoverage = PixelCoverage.PixelIsPoint

The sample coverage of the rectangular heightmap.

returns → HeightmapBuilder

The heightmap builder object.

Builds a heightmap of type MapType.Rect.


public static method Builder3 → (1)

map in : MapInfo

The map raster.

returns → HeightmapBuilder

The heightmap builder object.

Builds a heightmap for the given map raster.


public static method Builder4 → (1)

heightmap in : IHeightmap

The other heightmap to use as template.

returns → HeightmapBuilder

The heightmap builder object.

Builds a heightmap similar to heightmap in.

Public / Methods

Merge


[OwnerReturn]
public static method Merge → (2)

first in : IHeightmap

The first heightmap or null.

second in : IHeightmap

The second heightmap or null.

returns → IHeightmap

The resulting heightmap or null if both input heightmaps are null.

Merges the given heightmaps.

Public / Attributes

Datasets


public static attribute Datasets → (get)

value : HeightmapCollection

[not-null]
The dataset collection.

The shared collection of heightmap datasets.

Protected / Constructors

Heightmap


protected constructor Heightmap → ()

Creates a new instance of Heightmap.

Protected / Methods

AssertSameSize


protected method AssertSameSize → (2)

source in : string

The error source tag.

other in : Heightmap

The other heightmap.

Asserts that the given heightmap has the same size as this one.

DoGetRegion


protected virtual method DoGetRegion → (9)

region in : CubemapFaceRect

The rectangular region to fetch (already aligned to step in).

step in : int32

The step value between samples. This is always a power of two (including 1).

buffer in : HeightmapRegion

The output heightmap buffer.

bufferX in : int32

X-coordinate of top-left pixel in buffer in to set.

bufferY in : int32

Y-coordinate of top-left pixel in buffer in to set.

bufferWidth in : int32

Width of buffer region to fetch.

bufferHeight in : int32

Height of buffer region to fetch.

layers in : HeightmapLayer

The heightmap layers to fetch. Will contain one or more layers of this heightmaps IHeightmapLayers.LayerMask.

smooth in : bool

Use smooth interpolation?

Fetches a rectangular region of heightmap samples.

The default implementation fetches each sample individually, which is slow. Subclasses are encouraged to provide an optimized implementation for this method.

The heightmap coordinate range given by region in will always be fully inside of the valid coordinate range of this heightmap.

The given buffer in is guaranteed to contain at least all layers of the intersection of the specified layers in and the IHeightmapLayers.LayerMask of this heightmap.

IOException

If an I/O error has occurred.

DoGetSample


protected abstract method DoGetSample → (3)

in : int32

X-coordinate of heightmap sample.

in : int32

Y-coordinate of heightmap sample.

in : int32

Z-coordinate of heightmap sample (for MapType.Cube).

returns → HeightmapSample

The heightmap sample.

Returns a single heightmap sample.

The default implementations of DoGetSamples and DoGetRegion use of this method. This is convenient but will most likely be very slow. It is better to also provide optimized implementations for DoGetSamples and DoGetRegion.

The in, and in and in coordinates will always be within the valid bounds of this heightmap.

IOException

If an I/O error has occurred.

DoGetSamples


protected virtual method DoGetSamples → (4)

xyz in : Vec3I [ ]

The heightmap sample coordinates (given for a heightmap of size HeightmapsUtil.MaxSize).

count in : int32

Number of samples to fetch.

buffer in : HeightmapSamples

The output heightmap buffer.

layers in : HeightmapLayer

The heightmap layers to get.

Fetches a series of heightmap samples.

The default implementation fetches each sample individually, which is slow. Subclasses are encouraged to provide an optimized implementation for this method.

The given buffer in is guaranteed to contain at least all layers of the intersection of the specified layers in and the IHeightmapLayers.LayerMask of this heightmap.

IOException

If an I/O error has occurred.

DoHasRegion


protected abstract method DoHasRegion → (2)

region in : CubemapFaceRect

The step-aligned cubemap face region.

flags in : CoverageFlags

The coverage flags that need to be determined.

returns → CoverageFlags

The result of the check.

Checks if this heightmap contains samples in the given region.

The given region in will never be empty (see CubemapFaceRect.IsEmpty) and its bounds will always be inside of its cubemap face (see CubemapFaceRect.Face).

IOException

If an I/O error has occurred.

DoSetRegion


[EmptyBody]
protected virtual method DoSetRegion → (5)

region in : CubemapFaceRect

The rectangular region to fetch.

buffer in : HeightmapRegion

The output heightmap buffer.

bufferX in : int32

X-coordinate of top-left pixel in buffer in to set.

bufferY in : int32

Y-coordinate of top-left pixel in buffer in to set.

layers in : HeightmapLayer

The heightmap layers to fetch. Will contain one or more layers of this heightmaps IHeightmapLayers.LayerMask.

Stores a rectangular region of heightmap samples.

The heightmap coordinate range given by region in will always be fully inside of the valid coordinate range of this heightmap.

The given buffer in is guaranteed to contain at least all layers of the intersection of the specified layers in and the IHeightmapLayers.LayerMask of this heightmap.

IOException

If an I/O error has occurred.

DoSplit


[OwnerReturn] [OwnerThis]
protected virtual method DoSplit → (1)

layers in : HeightmapLayer

The heightmap layers to retain.

returns → IHeightmap

The resulting heightmap.

Filters this heightmap by retaining only the given heightmap layers.

The given layers in will never be HeightmapLayer.None and will always be a subset of this heightmaps IHeightmapLayers.LayerMask.

Initialize

2 overloads


protected method Initialize1 → (1)

map in : IHeightmap

[not-null]
The IHeightmap object.

Initializes the map to the size and type of the given IHeightmap object.


protected method Initialize2 → (4)

type in : MapType

The heightmap type.

size in : int32

[>=0]
The internal size, in samples.

width opt : int32 = 0

[>=0]
The heightmap width, in samples. If 0, the internal size will be used.

height opt : int32 = 0

[>=0]
The heightmap height, in samples. If 0, the internal size will be used.

Initializes the heightmap to the given type and size.

The internal size of this heightmap will be set to the maximum of size in, width opt and height opt, clamped to the next power of two plus one between HeightmapsUtil.MinSize and HeightmapsUtil.MaxSize.

UpdateRegion_Lock


[EmptyBody]
protected virtual method UpdateRegion_Lock → (1)

region in : Box3I

The region to lock.

Locks the given region for subsequent updates.

UpdateRegion_Unlock


[EmptyBody]
protected virtual method UpdateRegion_Unlock → (1)

region in : Box3I

The region to unlock.

Unlocks the given region.

ValidCoords

2 overloads


[Pure]
protected method ValidCoords1 → (2)

in : Vec3I

The heightmap coordinates.

maxSize opt : bool = false

Are the coordinate specified for a heightmap of HeightmapsUtil.MaxSize?

returns → bool

true if the coordinates are valid, false if not.

Checks if the given heightmap coordinates are valid for this heightmap.


[Pure]
protected method ValidCoords2 → (4)

in : int32

The heightmap X-coordinate.

in : int32

The heightmap Y-coordinate.

opt : int32 = 0

The heightmap Z-coordinate.

maxSize opt : bool = false

Are the coordinate specified for a heightmap of HeightmapsUtil.MaxSize?

returns → bool

true if the coordinates are valid, false if not.

Checks if the given heightmap coordinates are valid for this heightmap.

Protected / Attributes

GeorefMaxSize


protected attribute GeorefMaxSize → (get)

value : Raster

The adjusted value of IGeorefInfo.Georef or null.

height


protected attribute height → (int32)

The height of the heightmap.

This value is set by Initialize2.

isCube


protected attribute isCube → (bool)

Is this map of type MapType.Cube?

This value is set by Initialize2.

mapType


protected attribute mapType → (MapType)

The type of the heightmap (rectangular or cube).

This value is set by Initialize2.

maxSizeMask


protected attribute maxSizeMask → (int32)

Bitmask for aligning coordinates to the size of this heightmap.

This value is set by Initialize2.

A binary and with this bitmask has the same effect as doing a right-shift of maxSizeShift bits followed by a left-shift of the same bit count.

maxSizeScale


protected attribute maxSizeScale → (int32)

Scale factor to apply to coordinates of this map in order to translate them to HeightmapsUtil.MaxSize.

This value is set by Initialize2.

maxSizeShift


protected attribute maxSizeShift → (int32)

Shift amount to apply to coordinates of this map in order to translate them to HeightmapsUtil.MaxSize.

This value is set by Initialize2.

According to HeightmapsUtil.MinSize and HeightmapsUtil.MaxSize, this value will always be in the range [0..22].

maxSizeX


protected attribute maxSizeX → (int32)

Maximum cubemap face X-coordinate of this heightmap, given for HeightmapsUtil.MaxSize.

maxSizeY


protected attribute maxSizeY → (int32)

Maximum cubemap face Y-coordinate of this heightmap, given for HeightmapsUtil.MaxSize.

onUpdated


[Owner]
protected attribute onUpdated → (EventGeneric<HeightmapEventArgs>)

The event object of IHeightmap.OnUpdated.

size


protected attribute size → (int32)

The internal size of the heightmap.

This value is set by Initialize2.

sizeMinusOne


protected attribute sizeMinusOne → (int32)

The internal size of the heightmap, minus one.

This value is set by Initialize2.

width


protected attribute width → (int32)

The width of the heightmap.

This value is set by Initialize2.

Configuration

Config


public static attribute Config → (get)

value : IConfigurator<IHeightmap>

[not-null]
The configurator object.

The configurator object for this type.