This page has been translated automatically.
Programming
Fundamentals
Setting Up Development Environment
UnigineScript
High-Level Systems
C++
C#
UUSL (Unified UNIGINE Shader Language)
File Formats
Rebuilding the Engine and Tools
GUI
Double Precision Coordinates
API
Containers
Common Functionality
Controls-Related Classes
Engine-Related Classes
Filesystem Functionality
GUI-Related Classes
Math Functionality
Node-Related Classes
Networking Functionality
Pathfinding-Related Classes
Physics-Related Classes
Plugins-Related Classes
Rendering-Related Classes
Warning! This version of documentation is OUTDATED, as it describes an older SDK version! Please switch to the documentation for the latest SDK version.
Warning! This version of documentation describes an old SDK version which is no longer supported! Please upgrade to the latest SDK version.

ObjectTerrain Class

Inherits:Object

This class is used to create terrains. The terrain is rendered using grid-based surfaces, each of which has has a unique set of textures. The following textures are created automatically:

ObjectTerrain Class

Members


static ObjectTerrain()

Constructor. Creates a new terrain object with default properties.

static ObjectTerrain(string name)

Constructor. Creates a new terrain object from a given file.

Arguments

  • string name - Name of the terrain file.

ObjectTerrain cast(Node node)

Arguments

  • Node node

ObjectTerrain cast(Object base)

Arguments

  • Object base

void setAlbedoTextureArrayName(string name)

Arguments

  • string name

string getAlbedoTextureArrayName()

int setAlbedoTextureImage(Image image)

Arguments

  • Image image

int getAlbedoTextureImage(Image image)

Arguments

  • Image image

void setAlbedoTextureName(string name)

Arguments

  • string name

string getAlbedoTextureName()

void setHeight(int x, int y, float height)

Changes the height of a given terrain point.

Arguments

  • int x - X coordinate of the point on the terrain grid.
  • int y - Y coordinate of the point on the terrain grid.
  • float height - Height, in units.

float getHeight(variable x, variable y)

Returns a height of a given terrain point.

Arguments

  • variable x - X coordinate of the point. Can be either int (exact grid point) or float (interpolated height value between two points).
  • variable y - Y coordinate of the point. Can be either int (exact grid point) or float (interpolated height value between two points).

Return value

Height.

int setHeights(int x, int y, Image image, float scale = 1.0f)

Imports a height map for the terrain.

Arguments

  • int x - X coordinate of the point on the terrain grid in range from 0 to the maximum terrain width.
  • int y - Y coordinate of the point on the terrain grid in range from 0 to the maximum terrain length.
  • Image image - Height map.
  • float scale - Maximum height value.

Return value

Returns 1 if the height map is imported successfully; otherwise, 0.

int getHeights(int x, int y, int width, int height, Image image, int format, float scale = 1.0f)

Exports a height map into an image of the specified format. The sum of the X coordinate of the point on the terrain grid and width of the exported image must be less than or equal to the maximum terrain width. The sum of the Y coordinate of the point on the terrain grid and height of the exported image must be less than or equal to the maximum terrain length.

Arguments

  • int x - X coordinate of the point on the terrain grid.
  • int y - Y coordinate of the point on the terrain grid.
  • int width - Width of the exported image in grid points.
  • int height - Height of the exported image in grid points.
  • Image image - Image to export a height map into.
  • int format - Image format.
  • float scale - Height map scale. The default is 1.0f

Return value

Returns 1 if the height map is exported successfully; otherwise, 0.

void setHeightTextureArrayName(string name)

Arguments

  • string name

string getHeightTextureArrayName()

void setHole(int x, int y, int hole)

Adds or removes holes to the terrain.

Arguments

  • int x - X coordinate of the point on the terrain grid.
  • int y - Y coordinate of the point on the terrain grid.
  • int hole - 1 to add a hole, 0 to remove a hole.

int getHole(variable x, variable y)

Returns a value indicating if there is a hole at a given point.

Arguments

  • variable x - X-coordinate of the point. Can be either int or float.
  • variable y - Y-coordinate of the point. Must be of the same type as x.

Return value

1 if there is a hole at a given point; otherwise, 0.

int setHoles(int x, int y, Image image)

Imports a holes texture for the terrain.

Arguments

  • int x - X coordinate of the point on the terrain grid.
  • int y - Y coordinate of the point on the terrain grid.
  • Image image - Holes texture.

Return value

1 if the holes image was successfully set; otherwise, 0.

int getHoles(int x, int y, int width, int height, Image image)

Exports a holes texture into an R8 image.

Arguments

  • int x - X coordinate of the point on the terrain grid.
  • int y - Y coordinate of the point on the terrain grid.
  • int width - Width of the exported image in grid points.
  • int height - Height of the exported image in grid points.
  • Image image - Image to export a holes texture into.

Return value

1 if the holes texture was successfully exported; otherwise, 0.

int getIntersection(vec3 p0, vec3 p1, vec3 * ret_point, vec3 * ret_normal, vec4 * ret_texcoord, int surface, int holes)

Performs the search for the intersection of the given terrain surface with the given traced line. Depending on the variable, passed as the third argument, the return value can be the intersection point, the intersection point normal or the intersection point texture coordinates.

Notice
Terrain local space coordinates are used for this function.

Arguments

  • vec3 p0 - Start point coordinates.
  • vec3 p1 - End point coordinates.
  • vec3 * ret_point - Variable defining the return array content. It can be one of the following:
    • ObjectIntersectionpoint- The intersection point.
    • ObjectIntersectionNormalnormal- The intersection point normal.
    • ObjectIntersectionTexCoordtexcoord- The intersection point texture coordinates along theX and the Y axes (the Z and the W values are always equal to zero).
  • vec3 * ret_normal - The number of the terrain surface.
  • vec4 * ret_texcoord - 0 is to return the intersection with a terrain even if it hits the hole; otherwise, 1.
  • int surface - Number of the surface.
  • int holes - 0 is to return the intersection with a terrain even if it hits the hole; otherwise, 1.

Return value

The return array ID.

void setLayerEnabled(int layer, int enable)

Arguments

  • int layer
  • int enable

int getLayerEnabled(int layer)

Arguments

  • int layer

void setLayerName(int layer, string name)

Arguments

  • int layer
  • string name

string getLayerName(int layer)

Arguments

  • int layer

int isLoaded()

Returns a value indicating whether terrain is loaded.

Return value

1 if the terrain is loaded; otherwise, 0.

vec3 getLocalPoint(const Vec3 & position)

Arguments

  • const Vec3 & position

void setLodDistance(float distance)

Sets a distance to the first level of details.

Arguments

  • float distance - Distance, in units.

float getLodDistance()

Returns a distance to the first level of details. This distance is used to calculate distances to the rest of levels of details.

Return value

Base LOD distance in units.

void setLodProgression(float progression)

Sets LOD Progression value. This distance is used to calculate distances to the rest of levels of details.

Arguments

  • float progression - LOD Progression value.

float getLodProgression()

Returns LOD progression value. Default value is 2.0.

Return value

LOD Progression value.

void setLodTerrainBottom(ObjectTerrain bottom)

Sets the new bottom LOD for the current terrain.

Arguments

  • ObjectTerrain bottom - Bottom LOD.

ObjectTerrain getLodTerrainBottom()

Returns the bottom LOD of the current terrain.

Return value

Bottom terrain LOD.

void setLodTerrainLeft(ObjectTerrain left)

Sets the new left LOD for the current terrain.

Arguments

  • ObjectTerrain left - Left LOD.

ObjectTerrain getLodTerrainLeft()

Returns the left LOD of the current terrain.

Return value

Left terrain LOD.

void setLodTerrainRight(ObjectTerrain right)

Sets the new right LOD for the current terrain.

Arguments

  • ObjectTerrain right - Right LOD.

ObjectTerrain getLodTerrainRight()

Returns the right LOD of the current terrain.

Return value

Right terrain LOD.

void setLodTerrainTop(ObjectTerrain top)

Sets the new top LOD for the current terrain.

Arguments

  • ObjectTerrain top - Top LOD.

ObjectTerrain getLodTerrainTop()

Returns the top LOD of the current terrain.

Return value

Top terrain LOD.

void setLodThreshold(float threshold, int force = 0)

Sets the LOD height threshold.

Arguments

  • float threshold - LOD height threshold.
  • int force - Force flag. The terrain will load all height maps into the memory and will perform height map relaxation for the smooth LOD transition for the given threshold level.

float getLodThreshold()

Returns the LOD height threshold.

Return value

LOD height threshold.

int setMaskTextureImage(Image image)

Sets an image that will be used as a mask texture for a whole terrain.

Arguments

  • Image image - Pointer to the image.

Return value

1 if the mask image is successfully set; otherwise, 0.

int getMaskTextureImage(Image image)

Writes the image that is currently used as a mask for a whole terrain into the given buffer.

Arguments

  • Image image - Image buffer to write the mask into.

Return value

1 if the mask image is successfully written into the buffer; otherwise, 0.

void setMaskTextureName(string name)

Sets a mask texture name that is used for the whole terrain.

Arguments

  • string name - Name (path) of the terrain mask texture.

string getMaskTextureName()

Returns a name of the mask texture used for the whole terrain.

Return value

Name (path) of the terrain mask texture.

void setMaterialAlbedoColor(int layer, int material, vec4 color)

Arguments

  • int layer
  • int material
  • vec4 color

vec4 getMaterialAlbedoColor(int layer, int material)

Arguments

  • int layer
  • int material

void setMaterialAlbedoScale(int layer, int material, float scale)

Arguments

  • int layer
  • int material
  • float scale

float getMaterialAlbedoScale(int layer, int material)

Arguments

  • int layer
  • int material

void setMaterialAlbedoTextureName(int layer, int material, string name)

Arguments

  • int layer
  • int material
  • string name

string getMaterialAlbedoTextureName(int layer, int material)

Arguments

  • int layer
  • int material

void setMaterialDetail(int layer, int material, int detail)

Arguments

  • int layer
  • int material
  • int detail

int getMaterialDetail(int layer, int material)

Arguments

  • int layer
  • int material

void setMaterialEnabled(int layer, int material, int enable)

Arguments

  • int layer
  • int material
  • int enable

int getMaterialEnabled(int layer, int material)

Arguments

  • int layer
  • int material

void setMaterialHeightTextureName(int layer, int material, string name)

Arguments

  • int layer
  • int material
  • string name

string getMaterialHeightTextureName(int layer, int material)

Arguments

  • int layer
  • int material

void setMaterialLayer(int layer, int material, int layer_target)

Arguments

  • int layer
  • int material
  • int layer_target

int getMaterialLayer(int layer, int material)

Arguments

  • int layer
  • int material

void setMaterialMaskThreshold(int layer, int material, float threshold)

Arguments

  • int layer
  • int material
  • float threshold

float getMaterialMaskThreshold(int layer, int material)

Arguments

  • int layer
  • int material

void setMaterialMaskValue(int layer, int material, float value)

Arguments

  • int layer
  • int material
  • float value

float getMaterialMaskValue(int layer, int material)

Arguments

  • int layer
  • int material

void setMaterialMaskWidth(int layer, int material, float width)

Arguments

  • int layer
  • int material
  • float width

float getMaterialMaskWidth(int layer, int material)

Arguments

  • int layer
  • int material

void setMaterialName(int layer, int material, string name)

Arguments

  • int layer
  • int material
  • string name

string getMaterialName(int layer, int material)

Arguments

  • int layer
  • int material

void setMaterialNormalScale(int layer, int material, float scale)

Arguments

  • int layer
  • int material
  • float scale

float getMaterialNormalScale(int layer, int material)

Arguments

  • int layer
  • int material

void setMaterialNormalTextureName(int layer, int material, string name)

Arguments

  • int layer
  • int material
  • string name

string getMaterialNormalTextureName(int layer, int material)

Arguments

  • int layer
  • int material

void setMaterialOverlap(int layer, int material, int overlap)

Arguments

  • int layer
  • int material
  • int overlap

int getMaterialOverlap(int layer, int material)

Arguments

  • int layer
  • int material

void setMaterialRoughness(int layer, int material, float roughness)

Arguments

  • int layer
  • int material
  • float roughness

float getMaterialRoughness(int layer, int material)

Arguments

  • int layer
  • int material

void setMaterialRoughnessScale(int layer, int material, float scale)

Arguments

  • int layer
  • int material
  • float scale

float getMaterialRoughnessScale(int layer, int material)

Arguments

  • int layer
  • int material

void setMaterialRoughnessTextureName(int layer, int material, string name)

Arguments

  • int layer
  • int material
  • string name

string getMaterialRoughnessTextureName(int layer, int material)

Arguments

  • int layer
  • int material

void setMaterialTransform(int layer, int material, vec4 transform)

Arguments

  • int layer
  • int material
  • vec4 transform

vec4 getMaterialTransform(int layer, int material)

Arguments

  • int layer
  • int material

int getNormals(int x, int y, int width, int height, Image image)

Exports a selected area of the normal map into the RG8 image.

Arguments

  • int x - X coordinate of the point on the terrain grid.
  • int y - Y coordinate of the point on the terrain grid.
  • int width - Width of the exported image in grid points.
  • int height - Height of the exported image in grid points.
  • Image image - Image to export a normal map into.

Return value

1 if the normal map was successfully exported; otherwise, 0.

void setNormalTextureArrayName(string name)

Sets the new name of the normal textures array.

Arguments

  • string name - Normal textures array name.

string getNormalTextureArrayName()

Returns the name of the normal textures array.

Return value

Name of the normal textures array.

int setNormalTextureImage(Image image)

Sets the new normal texture for a whole terrain.

Arguments

  • Image image - Pointer to the image.

Return value

1 if the texture image is successfully set; otherwise, 0.

int getNormalTextureImage(Image image)

Writes the image that is currently used as a normal texture for a terrain into the given buffer.

Arguments

  • Image image - Image buffer to write a texture into.

Return value

1 if the texture has been successfully written into the buffer; otherwise, 0.

void setNormalTextureName(string name)

Sets the new name of a normal map used for the whole terrain.

Arguments

  • string name - Name (path) of the normal map texture.

string getNormalTextureName()

Returns the name of the normal map texture, which is used for the whole terrain.

Return value

Name (path) of the normal map texture.

int getNumAllMaterials()

int getNumLayers()

int getNumMaterials(int layer)

Returns the total number of terrain layers.

Arguments

  • int layer

Return value

The total number of layers.

void setShadowDistance(float distance)

Sets the new Shadow distance parameter value (the distance up to which a terrain casts shadows).

Arguments

  • float distance - Distance, in units.

float getShadowDistance()

Returns the Shadow distance parameter value (the distance up to which a terrain casts shadows).

Return value

Distance, in units.

void setShadowRadius(float radius)

Sets the new the Off-camera shadow extension parameter value (the distance up to which additional terrain polygons outside the viewing frustum are rendered).

Arguments

  • float radius - Distance, in units.

float getShadowRadius()

Returns the Off-camera shadow extension parameter value (the distance up to which additional terrain polygons outside the viewing frustum are rendered).

Return value

Distance, in units.

int getSizeX()

Returns terrain width, in grid cells.

Return value

Terrain width along X axis.

int getSizeY()

Returns terrain length, in grid cells.

Return value

Terrain length along Y axis.

float getStep()

Returns the linear size of a cell, in units.

Return value

Cell size.

int setSurfaceAlbedoTextureImage(int x, int y, Image image)

Arguments

  • int x
  • int y
  • Image image

int getSurfaceAlbedoTextureImage(int x, int y, Image image)

Arguments

  • int x
  • int y
  • Image image

void setSurfaceAlbedoTextureName(int x, int y, string name)

Arguments

  • int x
  • int y
  • string name

string getSurfaceAlbedoTextureName(int x, int y)

Arguments

  • int x
  • int y

BoundBox getSurfaceBoundBox(int x, int y)

Returns the bounding box of the specified surface.

Arguments

  • int x - Number of the surface along the X axis.
  • int y - Number of the surface along the Y axis.

Return value

Bounding box of the surface.

BoundSphere getSurfaceBoundSphere(int x, int y)

Returns the bounding sphere of the surface.

Arguments

  • int x - Number of the surface along the X axis.
  • int y - Number of the surface along the Y axis.

Return value

Bounding sphere of the surface.

void setSurfaceCastShadow(int x, int y, int cast_shadow)

Sets a value indicating whether terrain geometry across the current surface should cast shadows (from all types of light sources).

Arguments

  • int x - Number of the surface along the X axis.
  • int y - Number of the surface along the Y axis.
  • int cast_shadow - 1 is to cast shadows; 0 not to cast.

int isSurfaceCastShadow(int x, int y)

Returns a value indicating whether terrain geometry across the current surface casts shadows (from all types of light sources).

Arguments

  • int x - Number of the surface along the X axis.
  • int y - Number of the surface along the Y axis.

Return value

1 if the refined surface casts shadows; otherwise, 0.

void setSurfaceEnabled(int x, int y, int enabled)

Sets a value indicating whether a specified refined surface is enabled or disabled for rendering.

Arguments

  • int x - Number of the surface along the X axis.
  • int y - Number of the surface along the Y axis.
  • int enabled - Enabled flag. 1 to enable the surface; 0 to disable it.

int isSurfaceEnabled(int x, int y)

Returns a value indicating whether a specified refined surface is enabled or disabled for rendering.

Arguments

  • int x - Number of the surface along the X axis.
  • int y - Number of the surface along the Y axis.

Return value

1 if the surface is enabled; otherwise, 0.

void setSurfaceLodThreshold(int x, int y, float threshold, int force = 0)

Sets the height threshold value for the LOD of the specified surface.

Arguments

  • int x - Number of the surface along the X axis.
  • int y - Number of the surface along the Y axis.
  • float threshold - Threshold of the surface LOD.
  • int force - The force flag. The terrain will load all height maps into the memory and will perform a height map relaxation for the smooth LOD transition for the given threshold level.

float getSurfaceLodThreshold(int x, int y)

Returns the threshold value for the first LOD of the specified surface.

Arguments

  • int x - Number of the surface along the X axis.
  • int y - Number of the surface along the Y axis.

Return value

Threshold value.

int setSurfaceMaskTextureImage(int x, int y, Image image)

Imports a mask texture to the specified surface.

Arguments

  • int x - Number of the surface along the X axis.
  • int y - Number of the surface along the Y axis.
  • Image image - Surface mask texture image.

Return value

1 if the surface mask texture was successfully set; otherwise, 0.

int getSurfaceMaskTextureImage(int x, int y, Image image)

Exports a mask texture of the specified surface.

Arguments

  • int x - Number of the surface along the X axis.
  • int y - Number of the surface along the Y axis.
  • Image image - Image to export a surface mask texture into.

Return value

1 if the surface mask texture was successfully exported; otherwise, 0.

void setSurfaceMaskTextureName(int x, int y, string name)

Sets a mask texture name for the specified surface.

Arguments

  • int x - Number of the surface along the X axis.
  • int y - Number of the surface along the Y axis.
  • string name - Name (path) of the surface mask texture.

string getSurfaceMaskTextureName(int x, int y)

Returns a mask texture name of the specified surface.

Arguments

  • int x - Number of the surface along the X axis.
  • int y - Number of the surface along the Y axis.

Return value

Name (path) of the surface mask texture.

int setSurfaceNormalTextureImage(int x, int y, Image image)

Imports a normal map for the specified refined surface.

Arguments

  • int x - Number of the surface along the X axis.
  • int y - Number of the surface along the Y axis.
  • Image image - Surface normal map image.

Return value

1 if the surface normal map was successfully set; otherwise, 0.

int getSurfaceNormalTextureImage(int x, int y, Image image)

Exports a normal map of the specified surface.

Arguments

  • int x - Number of the surface along the X axis.
  • int y - Number of the surface along the Y axis.
  • Image image - Image to export a surface normal map into.

Return value

1 if the surface normal map was successfully exported; otherwise, 0.

void setSurfaceNormalTextureName(int x, int y, string name)

Sets a new normal map name for the specified refined surface.

Arguments

  • int x - Number of the surface along the X axis.
  • int y - Number of the surface along the Y axis.
  • string name - Name (path) of the surface normal map.

string getSurfaceNormalTextureName(int x, int y)

Returns a normal map name of the specified surface.

Arguments

  • int x - Number of the surface along the X axis.
  • int y - Number of the surface along the Y axis.

Return value

Name (path) of the surface normal map.

int getSurfacesX()

Returns the number of the surface along the X axis.

Return value

Number of the surface along the X axis.

int getSurfacesY()

Returns the number of the surface along the Y axis.

Return value

Number of the surface along the Y axis.

void setTerrainName(string name)

Sets the name for the terrain.

Arguments

  • string name - Terrain name (path to the .TER file).

string getTerrainName()

Returns a name of the terrain.

Return value

Terrain name (path to the .TER file).

void setVisibleDistance(float distance)

Sets the distance up to which terrain is rendered visible. The terrain would disappear on per-surface basis.

Arguments

  • float distance - Visibility distance, in units.

float getVisibleDistance()

Returns the distance up to which terrain is rendered visible. The terrain would disappear on the per-surface basis.

Return value

Visibility distance, in units.

float getWorldHeight(Vec3 position)

Arguments

  • Vec3 position

int addLayer(string name)

Arguments

  • string name

int addMaterial(int layer, string name)

Arguments

  • int layer
  • string name

void allocateLayers(int num)

Arguments

  • int num

void allocateMaterials(int layer, int num)

Arguments

  • int layer
  • int num

int cloneLayer(int layer)

Arguments

  • int layer

int cloneMaterial(int layer, int material)

Arguments

  • int layer
  • int material

int create(variable a0, variable a1, variable a2)

Creates a new terrain. Depending on the variables passed as arguments, the terrain is created in one of the following ways:
  • int size_x, int size_y and float step - a flat terrain of the specified size and step.
  • Image image, float step and float scale - a terrain with already defined relief based on a height map.

Arguments

  • variable a0 - A variable of one of the following types:
    • int size_x - the width of the terrain along theX axis in range [257;32679], in grid cells.
    • Image image - a height map.
  • variable a1 - A variable of one of the following types:
    • int size_y - the length of the terrain along theY axis in range [257;32679], in grid cells.
    • float step - the step of terrain grid cell, in units.
  • variable a2 - A variable of one of the following types:
    • float step - the step of the terrain grid cell, in units.
    • float scale - the maximum height, in units.

Return value

Returns 1 if the terrain is created successfully; otherwise, 0.

int loadHeights(vec3 center, float radius, vec3 max, vec3 min, int force = 0)

Sets a diffuse texture name for the specified layer.

Arguments

  • vec3 center - Bounding sphere center.
  • float radius - Bounding sphere radius.
  • vec3 max - Bounding box maximum.
  • vec3 min - Bounding box minimum.
  • int force - Force data loading with possible stall.

int loadTerrain(string name)

Loads a terrain from a given file.

Arguments

  • string name - Path to the terrain file (*.ter).

Return value

Returns 1 if the terrain is loaded successfully; otherwise, 0.

void removeLayer(int layer)

Arguments

  • int layer

void removeMaterial(int layer, int material)

Arguments

  • int layer
  • int material

int saveTerrain(string name, int force = 0)

Saves the terrain.

Arguments

  • string name - Path to the terrain file (*.ter).
  • int force - Force flag. Use 1 to save the terrain file in any case or 0 to save the terrain file only if any changes were made.

Return value

Returns 1 if the terrain is saved successfully; otherwise, 0.

void swapLayer(int layer_0, int layer_1)

Arguments

  • int layer_0
  • int layer_1

void swapMaterial(int layer_0, int material_0, int layer_1, int material_1)

Arguments

  • int layer_0
  • int material_0
  • int layer_1
  • int material_1

int type()

Last update: 2017-07-03
Build: ()