Class TerrainCanvas
Once it is created by the ElasticSceneGenerator the TerrainCanvas takes care of all the different steps, that need to be done to create the terrain. Traversing over all filter trees to evaluate and generate the height-, texture- and spawnArea maps and creating the actual Terrain out of precomputed terrainData.
Namespace: Holoride.ElasticSDK
Assembly: Holoride.ElasticSDK.Library.Runtime.dll
Syntax
public class TerrainCanvas
Constructors
TerrainCanvas(GenerationContext, GenerationSettings, GenerationState)
Instantiates a TerrainCanvas.
Declaration
public TerrainCanvas(GenerationContext context, GenerationSettings settings, GenerationState state)
Parameters
| Type | Name | Description |
|---|---|---|
| GenerationContext | context | Contains the immutable meta-information of a single update iteration. |
| GenerationSettings | settings | Contains immutable data that cannot be changed during the whole generation loop. |
| GenerationState | state | Contains the current state of the generation process and will be updated over time. |
TerrainCanvas(GenerationContext, TerrainCanvas)
Initializes a new instance of the TerrainCanvas class.
Declaration
public TerrainCanvas(GenerationContext context, TerrainCanvas previousTerrainCanvas)
Parameters
| Type | Name | Description |
|---|---|---|
| GenerationContext | context | Contains the immutable meta-information of a single update iteration. |
| TerrainCanvas | previousTerrainCanvas | The previous terrain canvas if it exists. |
Fields
GenerationContext
Contains the immutable meta-information of a single update iteration.
Declaration
public readonly GenerationContext GenerationContext
Field Value
| Type | Description |
|---|---|
| GenerationContext |
GenerationSettings
Contains immutable data that cannot be changed during the whole generation loop.
Declaration
public readonly GenerationSettings GenerationSettings
Field Value
| Type | Description |
|---|---|
| GenerationSettings |
GenerationState
Contains the current state of the generation process and will be updated over time.
Declaration
public readonly GenerationState GenerationState
Field Value
| Type | Description |
|---|---|
| GenerationState |
HeightMap
The HeightMap created by the height compositing.
Declaration
public IReadOnlyList<float> HeightMap
Field Value
| Type | Description |
|---|---|
| IReadOnlyList<float> |
HeightRatioMap
The HeightRatioMap created by the height compositing with height values normalized between 0 and 1.
Declaration
public float[,] HeightRatioMap
Field Value
| Type | Description |
|---|---|
| float[,] |
HeightRatioMapChunk
A single chunk to upload to the height of the TerrainData.
Declaration
public float[,] HeightRatioMapChunk
Field Value
| Type | Description |
|---|---|
| float[,] |
PreviousTerrainCanvas
The previous terrain canvas.
Declaration
public TerrainCanvas PreviousTerrainCanvas
Field Value
| Type | Description |
|---|---|
| TerrainCanvas |
Terrain
The actual Unity Terrain object.
Declaration
public Terrain Terrain
Field Value
| Type | Description |
|---|---|
| Terrain |
TerrainData
The terrainData of the Unity Terrain object.
Declaration
public TerrainData TerrainData
Field Value
| Type | Description |
|---|---|
| TerrainData |
TerrainExtents
The extents of the generated terrain.
Declaration
public readonly float TerrainExtents
Field Value
| Type | Description |
|---|---|
| float |
TerrainFloatFilterOffset
The offset of the terrain to the underlying FloatFilter.
Declaration
public readonly int TerrainFloatFilterOffset
Field Value
| Type | Description |
|---|---|
| int |
TerrainGenerationSettings
Contains immutable data that cannot be changed during the whole generation loop.
Declaration
public readonly TerrainGenerationSettings TerrainGenerationSettings
Field Value
| Type | Description |
|---|---|
| TerrainGenerationSettings |
TerrainGenerationState
Contains the current state of the terrain generation process and will be updated over time.
Declaration
public readonly TerrainGenerationState TerrainGenerationState
Field Value
| Type | Description |
|---|---|
| TerrainGenerationState |
TerrainResolution
The resolution of the generated terrain.
Declaration
public readonly int TerrainResolution
Field Value
| Type | Description |
|---|---|
| int |
TextureWeightmapChunk
A single chunk to upload to the texture weights of the TerrainData.
Declaration
public float[,,] TextureWeightmapChunk
Field Value
| Type | Description |
|---|---|
| float[,,] |
TextureWeightmapData
The heightRatioMap created by the height compositing with height values normalized between 0 and 1.
Declaration
public float[,,] TextureWeightmapData
Field Value
| Type | Description |
|---|---|
| float[,,] |
Properties
TextureLayers
Gets the attached terrain layers.
Declaration
public List<KeyValuePair<TerrainLayer, MapWorker>> TextureLayers { get; }
Property Value
| Type | Description |
|---|---|
| List<KeyValuePair<TerrainLayer, MapWorker>> |
Methods
GenerateTerrainAsync(CancellationToken)
Starts the whole generation process of the Terrain.
Declaration
public UniTask GenerateTerrainAsync(CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Cysharp.Threading.Tasks.UniTask |
GetFloorPosition(GlobalPosition, bool)
Computes the position on the ground.
Declaration
public GlobalPosition GetFloorPosition(GlobalPosition position, bool mindPivotHeight = true)
Parameters
| Type | Name | Description |
|---|---|---|
| GlobalPosition | position | The position. |
| bool | mindPivotHeight | States whether the pivot altitude should be added. |
Returns
| Type | Description |
|---|---|
| GlobalPosition | The position on the ground. |
GetHeightAtPosition(GlobalPosition, bool)
Computes the height at a given position.
Declaration
public float GetHeightAtPosition(GlobalPosition position, bool mindPivotHeight = true)
Parameters
| Type | Name | Description |
|---|---|---|
| GlobalPosition | position | The position. |
| bool | mindPivotHeight | States whether the pivot altitude should be added. |
Returns
| Type | Description |
|---|---|
| float | The height at the given position. |
GetHeightAtPosition(Vector3, bool)
Computes the height at a given position.
Declaration
public float GetHeightAtPosition(Vector3 position, bool mindPivotHeight = true)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector3 | position | The position. |
| bool | mindPivotHeight | States whether the pivot altitude should be added. |
Returns
| Type | Description |
|---|---|
| float | The height at the given position. |
GetHeightAtUV(Vector2, bool)
Computes the height at a given ratio.
Declaration
public float GetHeightAtUV(Vector2 ratio, bool mindPivotHeight = true)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | ratio | The ratio where to sample the height. |
| bool | mindPivotHeight | States whether the pivot altitude should be added. |
Returns
| Type | Description |
|---|---|
| float | The height at a given ratio. |
SampleMapData(GlobalPosition, float[])
Samples a mapData at a given position.
Declaration
public float SampleMapData(GlobalPosition position, float[] mapData)
Parameters
| Type | Name | Description |
|---|---|---|
| GlobalPosition | position | The position where to sample. |
| float[] | mapData | The data to sample from. |
Returns
| Type | Description |
|---|---|
| float | The mapData value. |