wiki.sine.space | sinespace

Scripting/STerrain

From wiki.sine.space
Revision as of 09:31, 22 July 2017 by Kay T Burnett (Talk | contribs) (Added GetNormal)

Jump to: navigation, search

The STerrain class allows the script to work with the terrain-related data.

Members

GetHeight

float GetHeight (float x, float y)

Gets the height at the (x,y) point. Floats x,y are given within the range from 0 to 1. If we want this script to work with global x, z coordinates, we need to divide their values by the width/length of the terrain respectively (if the terrain's bottom left corner is at the origin).

-- In this example, we are going to calculate the height of the 512x512 terrain at a global point (206, 198).

-- 1 Object Reference to the Terrain object, Name: "terrain".

local terrain = Space.Host.GetReference("terrain");

Space.Log(terrain.Terrain.GetHeight (206/512,198/512));

-- prints the height of the terrain at the global point (206,198) to the console.


GetSteepness

float GetSteepness (float x, float y)

Gets the steepness at the (x,y) point. Floats x,y are given within the range from 0 to 1. If we want this script to work with global x, z coordinates, we need to divide their values by the width/length of the terrain respectively.

-- In this example, we are going to calculate the steepness of the 512x512 terrain at a global point (408, 63).

-- 1 Object Reference to the Terrain object, Name: "terrain".

local terrain = Space.Host.GetReference("terrain");

Space.Log(terrain.Terrain.GetSteepness (408/512,63/512));

-- prints the steepness of the terrain at the global point (408,63) to the console.


GetNormal

SVector GetNormal (float x, float y)

Gets the normal vector (perpendicular to the surface) at the (x,y) point. Floats x,y are given within the range from 0 to 1. If we want this script to work with global x, z coordinates, we need to divide their values by the width/length of the terrain respectively.

-- In this example, we are going to calculate the steepness of the 512x512 terrain at a global point (172,428).

-- 1 Object Reference to the Terrain object, Name: "terrain".

local terrain = Space.Host.GetReference("terrain"); Space.Log(terrain.Terrain.GetNormal(172/512,428/512));

-- prints x,y,z values of the normal vector at the global point (172,428) to the console.