EcoTerrain¶
from acron.vegetation import EcoTerrain
- class EcoTerrain¶
Bases:
Bases:
TypedReferenceCountThe ground an ecosystem grows on: a heightfield over a rectangle of the world, and optional masks over the same rectangle – moisture (0 dry .. 1 wet), exclusion (1 where nothing may grow: roads, yards, a runway) and water (1 open water). World units are metres, z up.
Images map onto the rectangle with their first row at the north edge (+y, the top of the picture as seen from above) and their first column at the west edge (-x); pixel centres sit on the rectangle’s corners and edges, so a (n+1)-pixel image over n metres has a pixel every metre. A
PTA_floatheightfield is read the same way (rows north to south). Samples are bilinear; outside the rectangle they clamp to its edge.Species’ altitude limits read the altitude, `z * scale + offset` (set_altitude; by default the height itself): a game whose hills are 200 m high can map them onto a montane range for its species’ zonation without changing the ground.
Without a moisture mask, moisture is derived from the relief: hollows and valley floors (lower than the ground around them) are wetter, ridges and steep slopes drier, and the ground near water wettest.
Threads: change a terrain from one thread at a time (from Python, as usual). The BLOCKING calls of Ecosystem and
GrassFieldthat read it take a snapshot when they start, so changing it while one runs is safe and takes effect from the next call. Non-finite heights, sizes and settings are rejected (an error, the value unchanged), NaN heights read as 0.Inheritance diagram
digraph inheritanceb203b694ce { bgcolor=transparent; rankdir=BT; size="8.0, 12.0"; "DTOOL_SUPER_BASE" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=11,height=0.25,shape=box,style=""]; "EcoTerrain" [URL="acron.vegetation.EcoTerrain.html#acron.vegetation.EcoTerrain",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=11,height=0.25,shape=box,style="",target="_top",tooltip="/**"]; "TypedReferenceCount" -> "EcoTerrain" [arrowsize=0.75,style=""]; "ReferenceCount" [URL="acron.core.ReferenceCount.html#acron.core.ReferenceCount",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=11,height=0.25,shape=box,style="",target="_top",tooltip="/**"]; "DTOOL_SUPER_BASE" -> "ReferenceCount" [arrowsize=0.75,style=""]; "TypedObject" [URL="acron.core.TypedObject.html#acron.core.TypedObject",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=11,height=0.25,shape=box,style="",target="_top",tooltip="/**"]; "DTOOL_SUPER_BASE" -> "TypedObject" [arrowsize=0.75,style=""]; "TypedReferenceCount" [URL="acron.core.TypedReferenceCount.html#acron.core.TypedReferenceCount",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=11,height=0.25,shape=box,style="",target="_top",tooltip="/**"]; "TypedObject" -> "TypedReferenceCount" [arrowsize=0.75,style=""]; "ReferenceCount" -> "TypedReferenceCount" [arrowsize=0.75,style=""]; }- __init__()¶
A flat terrain at z = 0 over the rectangle from `origin` (its south-west corner) spanning `size` metres.
A copy (sharing the grids, which are never changed in place).
- clear_exclusion()¶
- clear_moisture()¶
- clear_water()¶
- get_altitude()¶
The altitude at (x, y) (see
set_altitude()).
- get_altitude_offset()¶
- get_altitude_scale()¶
- static get_class_type()¶
- get_exclusion()¶
The exclusion mask at (x, y) (0 without one).
- get_height()¶
The ground’s height at (x, y).
- get_max_height()¶
- get_min_height()¶
- get_moisture()¶
Moisture 0..1 at (x, y): the mask’s, or the relief’s estimate (0.5 on level open ground, wetter in hollows and by water, drier on ridges and steep slopes).
- get_normal()¶
The ground’s unit normal at (x, y), from central differences one pixel of the heightfield apart.
- get_origin()¶
- get_relief_radius()¶
- get_size()¶
- get_slope()¶
The slope at (x, y) in degrees (0 level, 90 a cliff).
- get_water()¶
The water mask at (x, y) (0 without one).
- get_x_size()¶
- get_y_size()¶
- has_exclusion()¶
- has_moisture_mask()¶
- has_water()¶
- paint_path()¶
Adds a path – a road, a track, a firebreak – to the exclusion mask: the polyline through `points` (x, y pairs, world), `width` metres of full exclusion fading over `verge` metres either side. Without a mask yet, one of `resolution` pixels a side is made over the terrain.
- set_altitude()¶
How heights map onto the altitude species’ limits are written in: altitude = z * scale + offset.
- set_exclusion()¶
Where nothing grows (1) – roads, yards – from the image’s grey level. Partial values thin the plants out.
- set_flat()¶
A level terrain at height `z`.
- set_heights()¶
The heights from an image’s grey level (0..1) times `z_scale` plus `z_offset`. A 16-bit greyscale image keeps the full precision.
The heights from `x_size` x `y_size` floats, rows north to south, times `z_scale` plus `z_offset`.
- set_moisture()¶
Moisture 0 (dry) .. 1 (wet) from the image’s grey level; replaces the moisture derived from the relief.
- set_relief_radius()¶
The radius (m) of the neighbourhood the derived moisture compares a point with: hollows lower than the mean of this disc are wetter.
- set_water()¶
Open water (1) from the image’s grey level.
- property size LVecBase2f¶