HeightmapRegion

Description

sealed class Tinman.Terrain.Heightmaps.HeightmapRegion

This class represents the samples of a rectangular region of a heightmap.

See also

HeightmapSample

Public / Constants

Quantize​Coverage​Max


public constant QuantizeCoverageMax → (1071636447:int32)

Minimum coverage value that will be quantized up to full coverage.

Quantize​Coverage​Min


public constant QuantizeCoverageMin → (2105376:int32)

Maximum coverage value that will be quantized down to zero coverage.

Public / Constructors

Create


public static method Create → (4)

width in : int32

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

height in : int32

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

layers in : HeightmapLayer

The heightmap layers.

swapAxes opt : bool = false

Swap width and height (useful when creating buffers for Transforms)?

returns → HeightmapRegion

The heightmap region.

Creates a new instance of HeightmapRegion.

Instances of HeightmapRegion can be pooled by calling IDeletable.Delete.

Public / Methods

Apply​Transform


public method ApplyTransform → (5)

in : int32

[0..ISampleBufferBase.Width]
X-coordinate of top-left sample of region.

in : int32

[0..ISampleBufferBase.Height]
Y-coordinate of top-left sample of region.

width in : int32

[0..ISampleBufferBase.Width-x]
Width of region to transform.

height in : int32

[0..ISampleBufferBase.Height-y]
Height of region to transform.

transform in : Transform

The 2D transform to apply.

Perform an in-place Transform of the samples in the given region.

For square regions (i.e. same width and height), all Transforms can be applied in-place. For rectangular regions, width and height might be swapped ( Transforms.WillSwapAxes) while the top-left sample of the given region remains in the same place.

If this sample buffer is not big enough to hold the swapped width resp. height, output samples will be discarded.

This method reads samples from the given input region and writes samples to the transformed output region. No other sample are accessed by this method.

Buffer


public method Buffer → (1)

layer in : HeightmapLayer

The heightmap layer.

returns → ISampleBuffer

The sample buffer or null if not present.

Returns the sample buffer for the given heightmap layer.

Clear


public method Clear → (7)

voidOrDefault in : bool

Clear to HeightmapSample.Void (true) or to HeightmapSample.Default (false)?

width in : int32

[>=0]
Number of samples to clear along X-axis.

height in : int32

[>=0]
Number of samples to clear along Y-axis.

layers opt : HeightmapLayer = HeightmapLayer.All

The heightmap layers to clear.

opt : int32 = 0

[0..ISampleBufferBase.Width]
X-coordinate of top-left sample to clear.

opt : int32 = 0

[0..ISampleBufferBase.Height]
Y-coordinate of top-left sample to clear.

step opt : int32 = 1

[>=1]
Step distance between samples to clear in region.

Clears the given sample block.

Copy


public method Copy → (11)

target in : HeightmapRegion

[not-null]
The target heightmap region.

width in : int32

[>=0]
Number of samples to copy along source X-axis.

height in : int32

[>=0]
Number of samples to copy along source Y-axis.

layers opt : HeightmapLayer = HeightmapLayer.All

The heightmap layers to copy.

sourceX opt : int32 = 0

[0..ISampleBufferBase.Width]
X-coordinate of top-left source sample to copy.

sourceY opt : int32 = 0

[0..ISampleBufferBase.Height]
Y-coordinate of top-left source sample to copy.

targetX opt : int32 = 0

[0..target.Width]
X-coordinate of top-left target sample to copy.

targetY opt : int32 = 0

[0..target.Height]
Y-coordinate of top-left target sample to copy.

sourceStep opt : int32 = 1

[>=1]
Step distance between samples to copy in source region.

targetStep opt : int32 = 1

[>=1]
Step distance between samples to copy in target region.

transform opt : Transform = Transform.None

Optional affine transformation to apply to the copied samples. The top-left corners of the source region and transformed target region coincide.

Copies heightmap samples from this region to the given one.

Coverage​Flags​Of


public method CoverageFlagsOf → (6)

opt : int32 = 0

[0..ISampleBufferBase.Width]
X-coordinate of top-left sample to check.

opt : int32 = 0

[0..ISampleBufferBase.Height]
Y-coordinate of top-left sample to check.

width opt : int32 = -1

[>=-1]
Number of samples to check along X-axis. If -1, all samples towards the right buffer edge will be checked.

height opt : int32 = -1

[>=-1]
Number of samples to check along Y-axis. If -1, all samples towards to the bottom buffer edge will be checked.

step opt : int32 = 1

[>=1]
Step distance between samples to check.

quantized opt : bool = false

If true, the quantized minimum coverage (see QuantizeCoverageMin) resp. maximum coverage (see QuantizeCoverageMax) will be used to test for CoverageFlags.NotSolid resp. CoverageFlags.NotEmpty.
Otherwise, 0 resp. HeightmapSample.MaxValue30 will be used.

returns → CoverageFlags

The coverage flags.

Compute the coverage flags of the heightmap samples in the given rectangle.

Fill


public method Fill → (6)

value in : HeightmapSample

The value to fill with.

opt : int32 = 0

[0..ISampleBufferBase.Width]
X-coordinate of top-left buffer sample to clear.

opt : int32 = 0

[0..ISampleBufferBase.Height]
Y-coordinate of top-left buffer sample to clear.

countX opt : int32 = -1

[>=-1]
Number of buffer samples to clear along X-axis. If -1, samples up to the right buffer edge will be cleared.

countY opt : int32 = -1

[>=-1]
Number of buffer samples to clear along Y-axis. If -1, samples down to the bottom buffer edge will be cleared.

step opt : int32 = 1

[>=1]
The step distance between buffer samples.

Fills buffer samples with the given value.

Gather


public method Gather → (6)

target in : HeightmapSamples

[not-null]
The target buffer.

coords in : Vec2I [ ]

[not-null]
Buffer coordinates of samples to gather from this region.

indices in : int32 [ ]

[not-null]
Indices into coords in, determining which samples to gather. Also output sample indices for storing results into target in.

first in : int32

[0..indices.Length]
Index of first element in indices in to process.

count in : int32

[0..indices.Length-first]
Number of samples to gather.

layers opt : HeightmapLayer = HeightmapLayer.All

The heightmap layers to gather.

Fetches scattered samples from this heightmap region and stores them into the given linear buffer.

Get​At

2 overloads


public method GetAt2 → (2)

in : int32

[0..ISampleBufferBase.Width-1]
The sample X-coordinate (relative to region).

in : int32

[0..ISampleBufferBase.Height-1]
The sample Y-coordinate (relative to region).

returns → HeightmapSample

The heightmap sample value.

Returns a single sample in the region.

Modulate


public method Modulate → (2)

coverage opt : CoverageBuffer = null

The coverage buffer or null. If null the coverage of this region will be used.

layers opt : HeightmapLayer = HeightmapLayer.All

The heightmap layers to modulate.

Modulates the heightmap samples in this region with the given coverage buffer.

Pad

2 overloads


public method Pad1 → (3)

heightmap in : IHeightmap

The heightmap from which this region has been read.

bounds in : CubemapFaceRect

The cubemap face rectangle that corresponds to this region.

step opt : int32 = 1

The sample step.

Computes a rectangle in this region and then calls Pad2.

If the given the heightmap in is not rectangular (see MapType.Rect), the method returns silently. Otherwise, the given bounds in are aligned to the sample step opt with CubemapFaceRect.StepAlign. Then, the aligned bounds are clipped to the size of the given heightmap in. The resulting buffer rectangle is then used to pad the buffer samples towards the buffer boundary.


public method Pad2 → (4)

in : int32

[0..ISampleBufferBase.Width]
X-coordinate of top-left corner of rectangle.

in : int32

[0..ISampleBufferBase.Height]
Y-coordinate of top-left corner of rectangle.

width in : int32

[0..ISampleBufferBase.Width-x]
Width of rectangle.

height in : int32

[0..ISampleBufferBase.Height-y]
Height of rectangle.

Duplicates the samples on the edge of the given rectangle towards the buffer boundary.

Quantize​Coverage


public method QuantizeCoverage → ()

Performs quantification of coverage values to 8-bit.

Set​At

2 overloads


public method SetAt2 → (4)

in : int32

[0..ISampleBufferBase.Width-1]
The sample X-coordinate (relative to region).

in : int32

[0..ISampleBufferBase.Height-1]
The sample Y-coordinate (relative to region).

sample in : HeightmapSample

The sample.

layers opt : HeightmapLayer = HeightmapLayer.All

The heightmap layers to set.

Sets a single sample in the region.

Sub​Region


public method SubRegion → (4)

in : int32

[0..ISampleBufferBase.Width]
X-coordinate of top-left corner of sub-region.

in : int32

[0..ISampleBufferBase.Height]
Y-coordinate of top-left corner of sub-region.

width in : int32

[0..ISampleBufferBase.Width-x]
Width of sub-region.

height in : int32

[0..ISampleBufferBase.Height-y]
Height of sub-region.

returns → HeightmapRegion

The sub-region of this heightmap region.

Returns a HeightmapRegion object that represents a sub-region of this region.

Warp


public method Warp → (11)

transform in : Mat3F

The homogeneous transformation matrix that warps target in buffer coordinates (relative to targetX opt and targetY opt) to source buffer coordinates (relative to sourceX opt and sourceY opt). Such a matrix can be created with Mat3F.Warp. Source buffer coordinates will be clamped to the specified range.

target in : HeightmapRegion

[not-null]
The target sample buffer.

layers opt : HeightmapLayer = HeightmapLayer.All

The heightmap layers to process.

targetX opt : int32 = 0

[0..target.Width]
X-coordinate of top-left corner of target buffer rectangle to fill.

targetY opt : int32 = 0

[0..target.Height]
Y-coordinate of top-left corner of target buffer rectangle to fill.

targetWidth opt : int32 = -1

[>=-1]
Width of of target buffer rectangle. If -1, the rectangle will reach to the right target buffer edge.

targetHeight opt : int32 = -1

[>=-1]
Height of of target buffer rectangle. If -1, the rectangle will reach to the bottom target buffer edge.

sourceX opt : int32 = 0

[0..ISampleBufferBase.Width]
X-coordinate of top-left corner of source buffer rectangle to use for interpolation.

sourceY opt : int32 = 0

[0..ISampleBufferBase.Height]
Y-coordinate of top-left corner of source buffer rectangle to use for interpolation.

sourceWidth opt : int32 = -1

[>=-1]
Width of of source buffer rectangle. If -1, the rectangle will reach to the right source buffer edge.

sourceHeight opt : int32 = -1

[>=-1]
Height of of source buffer rectangle. If -1, the rectangle will reach to the bottom source buffer edge.

Fills a rectangular region in the given target in buffer by warping target buffer coordinates to source buffer coordinates using the given transform in, followed by interpolation of source buffer samples.

Public / Attributes

Coverage


public attribute Coverage → (get)

value : CoverageBuffer

[not-null]
The coverage buffer.

The buffer for HeightmapLayer.Coverage values.

TinmanException

If this heightmap region does not store values of that layer.

Coverage​Lazy


public attribute CoverageLazy → (get)

value : CoverageBuffer

The coverage buffer or null iff all samples in this region are fully solid or this heightmap region does not store coverage values.

The buffer for HeightmapLayer.Coverage values.

Coverage​Null


public attribute CoverageNull → (get)

value : CoverageBuffer

The coverage buffer or null if this heightmap region does not store values of that layer.

The buffer for HeightmapLayer.Coverage values.

Displacement


public attribute Displacement → (get)

value : ElevationBuffer

[not-null]
The displacement buffer.

The buffer for HeightmapLayer.Displacement values.

TinmanException

If this heightmap region does not store values of that layer.

Displacement​Null


public attribute DisplacementNull → (get)

value : ElevationBuffer

The displacement buffer or null iff this heightmap region does not store values of that layer.

The buffer for HeightmapLayer.Displacement values.

Elevation


public attribute Elevation → (get)

value : ElevationBuffer

[not-null]
The elevation buffer.

The buffer for HeightmapLayer.Elevation values.

TinmanException

If this heightmap region does not store values of that layer.

Elevation​Null


public attribute ElevationNull → (get)

value : ElevationBuffer

The elevation buffer or null iff this heightmap region does not store values of that layer.

The buffer for HeightmapLayer.Elevation values.

Horizontal


public attribute Horizontal → (get,set)

value : float64

[>0]
The horizontal scale (i.e. ground sample distance).

The horizontal scale of the samples in this region (in UnitOfMeasure.Metre).

Defaults to 1.

Material


public attribute Material → (get)

value : MaterialBuffer

[not-null]
The material buffer.

The buffer for HeightmapLayer.Material values.

The heightmap region will never modify the MaterialBuffer.ScanlineMaterials property of the material buffer.

TinmanException

If this heightmap region does not store values of that layer.

Material​Null


public attribute MaterialNull → (get)

value : MaterialBuffer

The material buffer or null iff this heightmap region does not store values of that layer.

The buffer for HeightmapLayer.Material values.

The heightmap region will never modify the MaterialBuffer.ScanlineMaterials property of the material buffer.

Slope


public attribute Slope → (get)

value : SlopeInfo

The slope info.

Returns the slope info of the samples in this region.

The slope info is computed from Vertical and Horizontal.

Texture


public attribute Texture → (get)

value : ColorBuffer

[not-null]
The texture buffer.

The buffer for HeightmapLayer.Texture values.

TinmanException

If this heightmap region does not store values of that layer.

Texture​Null


public attribute TextureNull → (get)

value : ColorBuffer

The texture buffer or null iff this heightmap region does not store values of that layer.

The buffer for HeightmapLayer.Texture values.

Vertical


public attribute Vertical → (get,set)

value : VerticalRange

The vertical range.

The vertical range of the samples in this region (in UnitOfMeasure.Metre).

Defaults to VerticalRange.Default.