# STerrain

## Index

### Functions Index

<table><thead><tr><th>Function Name</th><th data-hidden>Description</th></tr></thead><tbody><tr><td>float <a href="#getheight"><strong>GetHeight</strong> </a>(float x, float y)</td><td>Get an interpolated height at a point x,y.</td></tr><tr><td>float <a href="#getsteepness"><strong>GetSteepness</strong> </a>(float x, float y)</td><td>Get the gradient of the terrain at point (x,y).</td></tr><tr><td>float[,] <a href="#getheights"><strong>GetHeights</strong> </a>()</td><td>Get an array of heightmap samples.</td></tr><tr><td>void <a href="#setheights"><strong>SetHeights</strong> </a>(float[,] data)</td><td>Set the resolution of the detail map.</td></tr><tr><td>void <a href="#setheight"><strong>SetHeight</strong> </a>(int x, int y, float value)</td><td>Set value to height of [x,y]</td></tr><tr><td>SVector <a href="#getnormal"><strong>GetNormal</strong> </a>(float x, float y)</td><td>Get an interpolated normal at a given location.</td></tr><tr><td>SVector <a href="#getslope"><strong>GetSlope</strong> </a>(float x, float y)</td><td>Get a normalized and interpolated normal at a given location.</td></tr><tr><td>SVector <a href="#getcontour"><strong>GetContour</strong> </a>(float x, float y)</td><td>Get a contour of interpolated normal at a given location.</td></tr></tbody></table>

### Properties Index

| Property Name                                   |
| ----------------------------------------------- |
| bool [**Enabled** ](#enabled)`get` `set`        |
| SGameObject [**GameObject** ](#gameobject)`get` |

## Functions

### GetHeight

float **GetHeight** (float x, float y)

*Get an interpolated height at a point x,y.*

| Parameter | Type | Description |
| --------- | ---- | ----------- |
|           |      |             |

{% tabs %}
{% tab title="Lua" %}

```lua
floatHeight = Space.Host.ExecutingObject.Terrain.GetHeight(1,1)
```

{% endtab %}
{% endtabs %}

### GetSteepness

float **GetSteepness** (float x, float y)

*Get the gradient of the terrain at point (x,y).*

| Parameter | Type | Description |
| --------- | ---- | ----------- |
|           |      |             |

{% tabs %}
{% tab title="Lua" %}

```lua
floatSteepness = Space.Host.ExecutingObject.Terrain.GetSteepness(1,1)
```

{% endtab %}
{% endtabs %}

### GetHeights

float\[,] **GetHeights** ()

*Returns a two dimensional array of heightmap samples. The samples are represented as float values ranging from 0 to 1. The array has the dimensions \[height,width] and is indexed as \[y,x].*

{% tabs %}
{% tab title="Lua" %}

```lua
tableHeights = Space.Host.ExecutingObject.Terrain.GetHeights()
```

{% endtab %}
{% endtabs %}

### SetHeights

void **SetHeights** (float\[,] data)

*Sets heightmap data using a two dimensional array of heightmap samples. The samples are represented as float values ranging from 0 to 1. The heights array is indexed as \[y,x].*

| Parameter | Type | Description |
| --------- | ---- | ----------- |
|           |      |             |

{% tabs %}
{% tab title="Lua" %}

```lua
tableHeights = Space.Host.ExecutingObject.Terrain.SetHeights({{1,2},{1,2}})
```

{% endtab %}
{% endtabs %}

### SetHeight

void **SetHeight** (int x, int y, float value)

*Set value to height of \[x,y]*

| Parameter | Type | Description |
| --------- | ---- | ----------- |
|           |      |             |

{% tabs %}
{% tab title="Lua" %}

```lua
Space.Host.ExecutingObject.Terrain.SetHeight(1,1,0.11) 
```

{% endtab %}
{% endtabs %}

### GetNormal

[SVector](https://docs.sine.space/scripting/client-scripting-api-reference/types/svector) **GetNormal** (float x, float y)

*Get an interpolated normal at a given location.*

| Parameter | Type | Description |
| --------- | ---- | ----------- |
|           |      |             |

{% tabs %}
{% tab title="Lua" %}

```lua
vectorNormal = Space.Host.ExecutingObject.Terrain.GetNormal(1,1)
```

{% endtab %}
{% endtabs %}

### GetSlope

[SVector](https://docs.sine.space/scripting/client-scripting-api-reference/types/svector) **GetSlope** (float x, float y)

*Get a normalized and interpolated normal at a given location.*

| Parameter | Type | Description |
| --------- | ---- | ----------- |
|           |      |             |

{% tabs %}
{% tab title="Lua" %}

```lua
vectorSlope = Space.Host.ExecutingObject.Terrain.GetSlope(1,1)
```

{% endtab %}
{% endtabs %}

### GetContour

[SVector](https://docs.sine.space/scripting/client-scripting-api-reference/types/svector) **GetContour** (float x, float y)

*Get a contour of interpolated normal at a given location.*

| Parameter | Type | Description |
| --------- | ---- | ----------- |
|           |      |             |

{% tabs %}
{% tab title="Lua" %}

```lua
vectorContour = Space.Host.ExecutingObject.Terrain.GetContour(1,1)
```

{% endtab %}
{% endtabs %}

## Properties

### Enabled

bool **Enabled** `get` `set`

*Is the Terrain component enabled?*

{% tabs %}
{% tab title="Lua" %}

```lua
Space.Host.ExecutingObject.Terrain.Enabled = false
```

{% endtab %}
{% endtabs %}

### GameObject

[SGameObject](https://docs.sine.space/scripting/client-scripting-api-reference/types/sgameobject) **GameObject** `get`

*The GameObject that this Terrain component is added to.*

{% tabs %}
{% tab title="Lua" %}

```lua
theGameObject = Space.Host.ExecutingObject.Terrain.GameObject
```

{% endtab %}
{% endtabs %}
