HeightmapPainter

Description

sealed class Tinman.Terrain.Heightmaps.HeightmapPainter

Derived from

Disposable abstract
IHeightmapLayers

The heightmap painter paints brushes onto heightmaps using background tasks.

Public / Constructors

Heightmap​Painter


public constructor HeightmapPainter → ()

Creates a new instance of HeightmapPainter.

Public / Methods

Paint​Canvas


public method PaintCanvas → (5)

in : Vec2D

Canvas coordinates of top-left brush corner.

in : Vec2D

Canvas coordinates of top-right brush corner.

in : Vec2D

Canvas coordinates of bottom-right brush corner.

in : Vec2D

Canvas coordinates of bottom-left brush corner.

join opt : bool = false

Return a TaskResultVoid object that can be used by the calling code to wait for the paint task to finish?

returns → TaskResultVoid

The background task or null if painting is disabled or join opt is false. If a TaskResultVoid object is returned, the caller is responsible for properly finishing the task by calling TaskResultVoid.Finish.

Applies the current brush to the current canvas.

Paint​Cursor


public method PaintCursor → (1)

join opt : bool = false

Return a TaskResultVoid object that can be used by the calling code to wait for the paint task to finish?

returns → TaskResultVoid

The background task or null if painting is disabled or join opt is false. If a TaskResultVoid object is returned, the caller is responsible for properly finishing the task (see TaskResultVoid.Finish).

Applies the current brush to the current canvas.

Paint​Cursor​Bounds


public method PaintCursorBounds → (4)

out : Vec2D

Cursor decal vertex A, in canvas space.

out : Vec2D

Cursor decal vertex B, in canvas space.

out : Vec2D

Cursor decal vertex C, in canvas space.

out : Vec2D

Cursor decal vertex D, in canvas space.

Computes the bounds of the decal that represents the paint cursor on the canvas.

The following figure shows how the cursor decal vertices are arranged before applying the cursor transformation:

(a)---------(b)
 |           |    a := (-0.5 | -0.5)
 |           |    b := (+0.5 | -0.5)
 |     x     |    c := (+0.5 | +0.5)
 |           |    d := (-0.5 | +0.5)
 |           |    x := ( 0.0 |  0.0)
(d)---------(c)

The default cursor vertices are transformed as follows:

  1. Scaling by:
    X: brush width (see IBrush.Width) multiplied with cursor scale (see CursorScale).
    Y: brush height (see IBrush.Height) multiplied with cursor scale (see CursorScale).

  2. Simple 2D transform (see CursorTransform).

  3. Counter-clockwise rotation around x (see CursorRotation).

  4. Translation to cursor center (see CursorCenter).

If CanPaintCursor returns false, the out, out, out and out output parameters will be set to Vec2D.Undefined.

Paint​Heightmap


public method PaintHeightmap → (2)

coords in : CubemapFaceCoordsI

The target coordinates of the top-left brush sample on the cubemap face of the target heightmap.

join opt : bool = false

Return a TaskResultVoid object that can be used by the calling code to wait for the paint task to finish?

returns → TaskResultVoid

The background task or null if painting is disabled or join opt is false. If a TaskResultVoid object is returned, the caller is responsible for properly finishing the task (see TaskResultVoid.Finish).

Applies the current brush to the current heightmap.

This method does not perform any resampling or projection, instead it maps brush samples directly to heightmap samples.

The current LayerMask will be used for the paint job.

Public / Attributes

Brush


[OwnerValue]
public attribute Brush → (get,set)

value : IBrush

The heightmap brush or null to disable painting.

The current heightmap brush.

Can​Paint​Canvas


public attribute CanPaintCanvas → (get)

value : bool

true if painting is enabled,
false if not due to missing settings.

Can PaintCanvas perform painting using the current settings?

The following settings are required:

Can​Paint​Cursor


public attribute CanPaintCursor → (get)

value : bool

true if painting is enabled,
false if not due to missing settings.

Can PaintCursor perform painting using the current settings?

The following settings are required:

Can​Paint​Heightmap


public attribute CanPaintHeightmap → (get)

value : bool

true if painting is enabled,
false if not due to missing settings.

Can PaintHeightmap perform painting using the current settings?

The following settings are required:

Canvas​Coordinates


public attribute CanvasCoordinates → (get,set)

value : CoordinateSystem

The coordinate system or null to disable canvas painting.

The coordinate system of the heightmap painter canvas.

On-the-fly projection will be performed in order to map the canvas to the current target heightmap.

Cursor​Center


public attribute CursorCenter → (get,set)

value : Vec2D

The paint cursor center, in canvas coordinates.

The center coordinates of the paint cursor.

Cursor​Rotation


public attribute CursorRotation → (get,set)

value : float64

The rotation angle, in degrees.

Paint cursor rotation angle.

Cursor​Scale


public attribute CursorScale → (get,set)

value : float64

The scale factor or 0 to disable cursor painting.

Scale factor from brush samples to canvas units.

Defaults to 0.

Cursor​Transform


public attribute CursorTransform → (get,set)

value : Transform

The paint cursor 2D transform.

Simple 2D transform of paint cursor.

Layer​Mask


public attribute LayerMask → (get,set)

value : HeightmapLayer

Bitwise combination of HeightmapLayer values.

The mask of heightmap layers this object uses.

These heightmap layers store actual terrain data:

Missing data is represented with the HeightmapLayer.Coverage layer. It describes how much information is present in a stored heightmap sample. The semantics of coverage with heightmap samples is the same as premultiplied alpha with texture samples. A LayerMask without HeightmapLayer.Coverage means that all samples are fully solid. If a LayerMask contains the HeightmapLayer.Coverage layer but no others, the coverage values are used to represent 'holes' in the terrain (e.g. creating holes for caves, tunnels, etc.).