Skip to content

TerrainProvider ​

Inherits: Node

Inherited by: ChronicleTerrainProvider, HTerrainProvider, TerraBrushProvider, Terrain3DProvider, VoxelTerrainProvider

The terrain of a world, seen by the TerrainService. The base class answers every question with the physics of the world (the ground is what is on the ground layer) and the surface type with default_surface; the providers of the terrain plugins (Terrain3D, HTerrain, ...) and our own terrain override what they know better. Every question that needs the world takes it: the service passes the world of the caller.

Properties ​

Stringdefault_surface""
Node3Dterrain
floatsearch_topPhysicsGround.DEFAULT_TOP
floatsearch_depthPhysicsGround.DEFAULT_DEPTH

Methods ​

boolsupports( _feature: StringName )
Array[StringName]get_features()
Stringget_surface_type( _position: Vector3 )
floatget_height( world: World3D, x: float, z: float )
Vector3get_normal( world: World3D, x: float, z: float )
Dictionaryget_ground( world: World3D, position: Vector3, up: float, down: float, exclude: Array = [], mask: int = -1 )
Dictionaryraycast_ground( world: World3D, from: Vector3, to: Vector3, exclude: Array = [] )
boolis_hole( _world: World3D, _x: float, _z: float )
boolis_ground_solid( _world: World3D, _x: float, _z: float )
boolis_navigable( world: World3D, x: float, z: float )
Dictionaryget_texture_weights( _position: Vector3 )
intget_area_id( _position: Vector3 )

Constants ​

  • StringName HEIGHTS = &"heights" - What a terrain can be asked besides "where is the ground" (see supports). A provider says honestly which of them it answers from the data of its terrain; the toolkit features that need more than the ground (paint layers, streaming) work only with the terrain of the toolkit (ChronicleTerrain).
  • StringName NORMALS = &"normals" - the direction of the ground from the data
  • StringName HOLES = &"holes" - holes cut in the ground
  • StringName SURFACE_TYPES = &"surface_types" - the kind of ground (for footsteps)
  • StringName TEXTURE_WEIGHTS = &"texture_weights" - the textures under a place and how much of each
  • StringName PAINT_LAYERS = &"paint_layers" - paint layers on the ground: painted zones and Painted spawners
  • StringName STREAMING = &"streaming" - the tiles load and unload as the party moves
  • StringName WEATHER = &"weather" - the ground gets wet, snowy and tinted with the weather of the world

Property descriptions ​

String default_surface = "" ​

The fallback surface type if detection fails

Node3D terrain ​

The terrain node the provider reads.

float search_top = PhysicsGround.DEFAULT_TOP ​

How high above the world origin the search for the ground at a position starts (metres).

float search_depth = PhysicsGround.DEFAULT_DEPTH ​

The total length of that search (metres).

Method descriptions ​

bool supports( _feature: StringName ) ​

Does this provider answer the thing from the data of its terrain? The base class knows nothing but the physics of the world, so it supports nothing. A plugin provider lists what it can.

Array[StringName] get_features() ​

Everything this provider supports.

String get_surface_type( _position: Vector3 ) ​

To be overridden by specific plugin implementations

float get_height( world: World3D, x: float, z: float ) ​

The height of the highest ground at x, z (NAN when there is none): the data of the terrain when the provider has them, else the physics of the world.

Vector3 get_normal( world: World3D, x: float, z: float ) ​

The direction the ground at x, z faces.

Dictionary get_ground( world: World3D, position: Vector3, up: float, down: float, exclude: Array = [], mask: int = -1 ) ​

The first ground below up metres above the position down to down metres below it: {} or {"position", "normal", "collider"}. A mask of -1 is the ground layers of the provider.

Dictionary raycast_ground( world: World3D, from: Vector3, to: Vector3, exclude: Array = [] ) ​

A ray between two points that hits only the ground: {} or the hit.

bool is_hole( _world: World3D, _x: float, _z: float ) ​

Is there a hole in the ground at x, z (a terrain with holes knows; the physics cannot tell a hole from no ground).

bool is_ground_solid( _world: World3D, _x: float, _z: float ) ​

Is there solid ground at x, z for what stands there (a provider that cannot tell says yes: nothing is frozen on a ground it does not know).

bool is_navigable( world: World3D, x: float, z: float ) ​

Can something walk at x, z.

Dictionary get_texture_weights( _position: Vector3 ) ​

The library textures under a position and their weights: {texture id: weight}. Empty when the terrain does not know.

int get_area_id( _position: Vector3 ) ​

The id of the area (zone) of the ground at a position (-1 = none).