IBrush

Description

interface Tinman.Terrain.Heightmaps.Painting.IBrush

Derived from

IDisposableGeneric<IBrush>
IConfigurable
IHeightmapLayers

Extended by

Brush abstract

Base interface for heightmap brushes.

Basically, a heightmap brush computes a rectangular block of heightmap samples, usually using input data that has been fetched from a IHeightmap object. The working data is provided as a PaintingBuffer wrapper object, which allows to perform additional computations (e.g. normals / slopes) on the input and to share the results between IBrush instances.

Depending on the input / output layers, brushes can be categorized as follows:

A brush implementation may choose to cache sample buffers in order to improve performance. cached data can be discarded at any time by calling the Flush method on the brush. Flushing brushes must not introduce any side-effects.

Public / Methods

Append


[OwnerReturn] [OwnerThis]
public method Append → (1)

other in : IBrush own

[not-null]
The brush to apply after this one.

returns → IBrush

The resulting brush.

Applies this brush, followed by the given one.

Average


[OwnerReturn] [OwnerThis]
public method Average → ()

returns → IBrush

The resulting brush.

Fills PaintingBuffer.Samples with the average heightmap sample value per output layer of this brush.

Combine


[OwnerReturn] [OwnerThis]
public method Combine → (3)

other in : IBrush own

[not-null]
The other brush.

colorOp opt : ColorOp = ColorOp.Blend

The color operation to use.

scalarOp opt : ScalarOp = ScalarOp.Add

The scalar operation to use.

returns → IBrush

The resulting brush.

Combines the output of this brush with the output of the given brush ( other in augmenting this with additional detail).

Compute​Samples


[ThreadSafe]
public method ComputeSamples → (3)

bounds in : BrushBounds

[not-null]
The brush bounds to use.

buffer in : PaintingBuffer

[not-null]
The brush buffer to use.

layers opt : HeightmapLayer = HeightmapLayer.All

The layers to compute.

Computes the output samples of this brush.

The PaintingBuffer.Samples region of the given buffer in must contain all layers of this brush (see IHeightmapLayers.LayerMask), and its dimensions must be equal to or greater than the dimensions of this brush (only applies to fixed brushes).

IOException

If an I/O error has occurred.

GeorefException

If the available geo-reference information is incomplete or malformed and brush samples must be projected to resp. from another coordinate system.

Flush


public method Flush → ()

Deletes cached data (if present), causing it to be recreated later, if necessary.

Invert


[OwnerReturn] [OwnerThis]
public method Invert → ()

returns → IBrush

The inverted brush or null iff CanInvert returns false.

Inverts this brush.

Implementing classes can choose to provide a meaningful inverse operation, for example:

  • Raise terrain vs. lower terrain

  • Add material vs. remove material

  • Add terrain holes vs. remove terrain holes

Mask​Slope


[OwnerReturn] [OwnerThis]
public method MaskSlope → (2)

zero in : float32

[>=0]
The slope angle (in degrees) to map to zero coverage.

one in : float32

[>=0]
The slope angle (in degrees) to map to full coverage.

returns → IBrush

The resulting brush.

A brush that creates a slope-based coverage mask from the elevation layer that is output by this brush.

Merge


[OwnerReturn] [OwnerThis]
public method Merge → (1)

other in : IBrush own

[not-null]
The other brush.

returns → IBrush

The resulting brush.

Merges the output of this brush (first) with the output of the given brush (second).

Modulate


[OwnerReturn] [OwnerThis]
public method Modulate → (1)

mask in : IBrush own

[not-null]
The brush from which to get the modulation coverage values.

returns → IBrush

The resulting brush.

Modulates the output of this brush with the coverage layer produced by the given brush.

Output​Heightmap


[OwnerReturn] [OwnerThis]
public method OutputHeightmap → (3)

heightmap in : IHeightmap own

[not-null]
The heightmap to update.

layers opt : HeightmapLayer = HeightmapLayer.All

The heightmap layers to update.

strength opt : int32 = HeightmapSample.MaxValue30

[>=0]
The overall brush strength.

returns → IBrush

The resulting brush.

Uses the output of this brush and updates the given heightmap with it.

Prepend


[OwnerReturn] [OwnerThis]
public method Prepend → (1)

other in : IBrush own

[not-null]
The brush to apply before this one.

returns → IBrush

The resulting brush.

Applies the given brush, followed by this one.

Public / Attributes

Can​Invert


public attribute CanInvert → (get)

value : bool

true if the brush can be inverted, false if not.

Can this brush be inverted?

See also

IBrush.Invert

Height


public attribute Height → (get)

value : int32

[>=0]
The brush height or 0 iff this brush is flexible.

The brush height.

Is​Flexible


public attribute IsFlexible → (get)

value : bool

true if this brush is flexible, false if not.

Is this brush flexible?

A flexible brush can be used to paint rectangular regions that have arbitrary dimensions (e.g. a gaussian blur brush). The Width and Height properties of a flexible brush always return 0.

A fixed brush can only be used to paint rectangular regions that have the same dimensions as its Width and Height properties (e.g. an image-based stamp brush).

Is​Invariant


public attribute IsInvariant → (get)

value : bool

true if this brush is invariant, false if not.

Is this brush invariant?

An invariant brush will produce the same output, regardless of the given BrushBounds value.

Layer​Mask​Input


public attribute LayerMaskInput → (get)

value : HeightmapLayer

The input heightmap layers.

The input heightmap layers that are read from PaintingBuffer.Samples when ComputeSamples is called.

The ComputeSamples method may only read from those layers of PaintingBuffer.Samples that are included in this input layer set.

Layer​Mask​Output


public attribute LayerMaskOutput → (get)

value : HeightmapLayer

The output heightmap layers.

The output heightmap layers that are written to PaintingBuffer.Samples when ComputeSamples is called.

The ComputeSamples method may only write to those layers of PaintingBuffer.Samples that are included in this output layer set.

Width


public attribute Width → (get)

value : int32

[>=0]
The brush width or 0 iff this brush is flexible.

The brush width.

Extensions

Create​Buffer


public static method CreateBuffer → (2)

width opt : int32 = 0

[>=0]
The buffer width, with padding. If 0, the padded fixed brush width will be used instead (see IBrush.Width).

height opt : int32 = 0

[>=0]
The buffer height, with padding. If 0, the padded fixed brush height will be used instead (see IBrush.Height).

returns → PaintingBuffer

The input buffer or null if no input layers are required.

Creates a new instance of PaintingBuffer that is suitable for being used as the input buffer when calling IBrush.ComputeSamples on this IBrush object.

To​Color​Buffer


[OwnerThis]
public static method ToColorBuffer → (4)

layer in : HeightmapLayer

The heightmap layer to fetch.

bounds opt : BrushBounds = null

The brush bounds to use. Will be ignored if this brush in invariant (see IBrush.IsInvariant).

width opt : int32 = 0

[>=0]
The image width. Will be ignored if this brush is not flexible (see IBrush.IsFlexible).

height opt : int32 = 0

[>=0]
The image height. Will be ignored if this brush is not flexible (see IBrush.IsFlexible).

returns → ColorBuffer

The color buffer or null if the resulting width or height would be zero or if IBrush.ComputeSamples has thrown an exception.

Converts this brush to a color buffer.