This page has been translated automatically.
Video Tutorials
Interface
Essentials
Advanced
How To
Professional (SIM)
UnigineEditor
Interface Overview
Assets Workflow
Settings and Preferences
Working With Projects
Adjusting Node Parameters
Setting Up Materials
Setting Up Properties
Lighting
Sandworm
Using Editor Tools for Specific Tasks
Extending Editor Functionality
Built-in Node Types
Nodes
Objects
Effects
Decals
Light Sources
Geodetics
World Nodes
Sound Objects
Pathfinding Objects
Players
Programming
Fundamentals
Setting Up Development Environment
Usage Examples
C++
C#
UnigineScript
UUSL (Unified UNIGINE Shader Language)
Plugins
File Formats
Materials and Shaders
Rebuilding the Engine 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
IG Plugin
CIGIConnector Plugin
Rendering-Related Classes
Content Creation
Content Optimization
Materials
Material Nodes Library
Miscellaneous
Input
Math
Matrix
Textures
Art Samples
Tutorials
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.

Unigine.Landscape Class

This class is used to manage landscape terrain rendering and modification.

Terrain modification is performed in asynchronous mode on GPU side by calling a corresponding method, that commences a drawing operation. When calling such a method you should specify the GUID of an .lmap file landscape layer map to be modified, the coordinates of the upper-left corner and the resolution of the segment of data to be modified, you should also define which data layers are to be affected (heights, albedo, masks) via a set of flags. The operation itself is to be implemented inside a callback handler.

GPU-Based Terrain Modification#

The workflow is as follows:

  1. Implement your GPU-based terrain modification logic in a function.
  2. Set this callback function to be fired when a Texture Draw (GPU-based terrain modification) operation is performed by calling the AddTextureDrawCallback() method.
  3. Commence a GPU drawing operation by calling the AsyncTextureDraw() method. Here you should specify the GUID of an .lmap file landscape layer map to be modified, the coordinates of the upper-left corner and the resolution of the segment of data to be modified, you should also define which data layers are to be affected (heights, albedo, masks) via a set of flags
    Notice
    In case your modification requires additional data beyond the specified area as well as the data of other landscape layer maps (e.g. a copy brush) you can enable force loading of required data, in this case you should use this overload of the AsyncTextureDraw() method.
Source code (C#)
// GPU-based modification
void my_texture_draw(UGUID guid, int id, LandscapeTextures buffer, in ivec2 coord, int data_mask)
{
	// getting the desired brush material (built - in "cirle_soft" Editor's brush) and inheriting a child material from it
	UGUID file_guid = FileSystem.GetGUID(FileSystem.ResolvePartialVirtualPath("circle_soft.brush"));
	if (!file_guid.IsValid())
	{
		Log.Warning("LandscapePainter Init(): can not find \"circle_soft.brush\" material\n");
		return;
	}

	brush_material = Materials.FindMaterialByFileGUID(file_guid).Inherit();

	// setting necessary textures (e.g., albedo and heights)
	brush_material.SetTexture("terrain_albedo", buffer.Albedo);
	brush_material.SetTexture("terrain_height", buffer.Height);

	// setting up brush material parameters (size, color, etc. and specifying masks to be affected by the brush)
	brush_material.SetParameterFloat("size", 10.0f);
	brush_material.SetParameterFloat("height", 1.0f);
	brush_material.SetParameterFloat4("color", vec4.GREEN);
	brush_material.SetParameterInt("data_mask", data_mask);

	// running material's "brush" expression
	brush_material.RunExpression("brush", buffer.Resolution.x, buffer.Resolution.y);

	// resetting material textures
	brush_material.SetTexture("terrain_albedo", null);
	brush_material.SetTexture("terrain_height", null);

}

// ... 

private void Init()
{
	// getting an existing landscape terrain object
	ObjectLandscapeTerrain terrain = Landscape.GetActiveTerrain();

	// getting the first layermap that we're going to modify
	lmap = terrain.GetChild(0) as LandscapeLayerMap;

	// adding a callback to be fired on a Texture Draw operation
	Landscape.AddTextureDrawCallback(my_texture_draw);
		
	// generating a new ID for the draw operation
	int id = Landscape.GenerateOperationID();
	// user's code (bounding to ID)

	// commencing a Texture Draw operation for the selected landscape map at (1, 1) with the size of [32 x 32]
	Landscape.AsyncTextureDraw(id, lmap.GetGUID(), new ivec2(1, 1),
					new ivec2(32, 32), (int)(Landscape.FLAGS_DATA.HEIGHT | Landscape.FLAGS_DATA.ALBEDO));

	return;
}

// ...

private void Shutdown()
{
	// clearing callbacks
	Landscape.clearTextureDrawCallbacks();
}

And the process:

  1. After commencing of a terrain modification operation with all necessary parameters specified, the Engine copies a fragment of terrain data from the specified landscape layer map file at the specified coordinates to a buffer (LandscapeTextures) of the specified resolution.
  2. Upon completion of the copying process a callback function set via the AddTextureDrawCallback() method is called. This function modifies the buffer.
  3. After this selected data layers of the modified buffer are pasted back to the landscape layer map file.
Usage Example: Brush Editor#

Below is a C# component implementing brush-based Landscape Terrain modification.

LandscapeBrush.cs
using System;
using System.Collections;
using System.Collections.Generic;
using Unigine;

[Component(PropertyGuid = "AUTOGENERATED_GUID")] // <-- this line is generated automatically for a new component
public class LandscapeBrush : Component
{
	public float brush_size = 10.0f;
	public float brush_height = 1.0f;
	private Material brush_material;
	private LandscapeLayerMap lmap;
	private Player player;
	private LandscapeFetch landscape_fetch;
	// GPU-based modification
	void my_texture_draw(UGUID guid, int id, LandscapeTextures buffer, in ivec2 coord, int data_mask)
	{
		// setting necessary textures (e.g., albedo and heights)
		brush_material.SetTexture("terrain_albedo", buffer.Albedo);
		brush_material.SetTexture("terrain_height", buffer.Height);

		// setting up brush material parameters (size, color, etc. and specifying masks to be affected by the brush)
		brush_material.SetParameterFloat("size", brush_size);
		brush_material.SetParameterFloat("height", brush_height);
		brush_material.SetParameterFloat4("color", vec4.GREEN);
		brush_material.SetParameterInt("data_mask", data_mask);

		// running material's "brush" expression
		brush_material.RunExpression("brush", buffer.Resolution.x, buffer.Resolution.y);

		// resetting material textures
		brush_material.SetTexture("terrain_albedo", null);
		brush_material.SetTexture("terrain_height", null);
	}
	private void Init()
	{
		// write here code to be called on component initialization
		// getting the desired brush material (built - in "cirle_soft" Editor's brush) and inheriting a child material from it
		UGUID file_guid = FileSystem.GetGUID(FileSystem.ResolvePartialVirtualPath("circle_soft.brush"));
		if (!file_guid.IsValid())
		{
			Log.Warning("LandscapePainter Init(): can not find \"circle_soft.brush\" material\n");
			return;
		}

		brush_material = Materials.FindMaterialByFileGUID(file_guid).Inherit();

		// getting an existing landscape terrain object
		ObjectLandscapeTerrain terrain = Landscape.GetActiveTerrain();

		// getting the first layermap that we're going to modify
		lmap = terrain.GetChild(0) as LandscapeLayerMap;

		// adding a callback to be fired on a Texture Draw operation
		Landscape.AddTextureDrawCallback(my_texture_draw);

		// setting the mouse handling mode to USER to display the cursor on the screen
		ControlsApp.MouseHandle = Input.MOUSE_HANDLE.USER;

		player = Game.Player;
	}
	
	private void Update()
	{
		// write here code to be called before updating each render frame
			// if right mouse button is clicked
		if (Input.IsMouseButtonDown(Input.MOUSE_BUTTON.RIGHT))
		{
			landscape_fetch = new LandscapeFetch();
			// taking into account main window position to obtain correct direction
			ivec2 mouse = Input.MousePosition;
			vec3 dir = player.GetDirectionFromMainWindow(mouse.x, mouse.y);
			// fetching the coordinates of the point of intersection
			bool fetched = landscape_fetch.IntersectionForce(player.Position,
			new vec3(player.Position + dir * 10000.0));

			if (fetched)
			{
				// getting the local position of the brush relative to the layer map
				vec3 brush_local_position = new vec3(lmap.IWorldTransform * landscape_fetch.Position);

				// calculating the bound of the layer map area to be affected by the brush
				float half_size = brush_size / 2.0f;
				vec3[] brush_local_corners = new vec3[] {
					brush_local_position + new vec3(-half_size, -half_size, 0.0),
					brush_local_position + new vec3(half_size, -half_size, 0.0),
					brush_local_position + new vec3(-half_size,  half_size, 0.0),
					brush_local_position + new vec3(half_size,  half_size, 0.0)
				};
				vec2 brush_local_bbox_min = new vec2(
					MathLib.Min(MathLib.Min(brush_local_corners[0].x, brush_local_corners[1].x), MathLib.Min(brush_local_corners[2].x, brush_local_corners[3].x)),
					MathLib.Min(MathLib.Min(brush_local_corners[0].y, brush_local_corners[1].y), MathLib.Min(brush_local_corners[2].y, brush_local_corners[3].y))
				);
				vec2 brush_local_bbox_max = new vec2(
					MathLib.Max(MathLib.Max(brush_local_corners[0].x, brush_local_corners[1].x), MathLib.Max(brush_local_corners[2].x, brush_local_corners[3].x)),
					MathLib.Max(MathLib.Max(brush_local_corners[0].y, brush_local_corners[1].y), MathLib.Max(brush_local_corners[2].y, brush_local_corners[3].y))
				);

				// calculating the number of pixels per unit length
				vec2 pixels_per_unit = new vec2(lmap.Resolution / lmap.Size);

				// calculating the coordinates and the size of the region or the landscape layer texture to be modified
				ivec2 drawing_region_coord = new ivec2 (pixels_per_unit * brush_local_bbox_min);
				ivec2 drawing_region_size = new ivec2 (pixels_per_unit * (brush_local_bbox_max - brush_local_bbox_min) );

				// user's code (bounding to ID)
				int id = Landscape.GenerateOperationID();

				// commencing a Texture Draw operation for the selected landscape map for the region with the specified coords and size
				// affecting Height and Albedo data
				Landscape.AsyncTextureDraw(id, lmap.GetGUID(), drawing_region_coord,
					drawing_region_size, (int)(Landscape.FLAGS_DATA.HEIGHT | Landscape.FLAGS_DATA.ALBEDO));
			}

		}
	}
	private void Shutdown()
	{
		// clearing callbacks
		Landscape.clearTextureDrawCallbacks();
	}

}

Landscape Class

Enums

TYPE_DATA#

NameDescription
HEIGHT = 0Heights data type.
ALBEDO = 1Albedo data type.
MASK_0 = 2Mask0 data type.
MASK_1 = 3Mask1 data type.
MASK_2 = 4Mask2 data type.
MASK_3 = 5Mask3 data type.
MASK_4 = 6Mask4 data type.
MASK_5 = 7Mask5 data type.
MASK_6 = 8Mask6 data type.
MASK_7 = 9Mask7 data type.
MASK_8 = 10Mask8 data type.
MASK_9 = 11Mask9 data type.
MASK_10 = 12Mask10 data type.
MASK_11 = 13Mask11 data type.
MASK_12 = 14Mask12 data type.
MASK_13 = 15Mask13 data type.
MASK_14 = 16Mask14 data type.
MASK_15 = 17Mask15 data type.
MASK_16 = 18Mask16 data type.
MASK_17 = 19Mask17 data type.
MASK_18 = 20Mask18 data type.
MASK_19 = 21Mask19 data type.

FLAGS_DATA#

NameDescription
HEIGHT = 1 << 0Heights data flag.
ALBEDO = 1 << 1Albedo data flag.
MASK_0 = 1 << 2Mask0 data flag.
MASK_1 = 1 << 3Mask1 data flag.
MASK_2 = 1 << 4Mask2 data flag.
MASK_3 = 1 << 5Mask3 data flag.
MASK_4 = 1 << 6Mask4 data flag.
MASK_5 = 1 << 7Mask5 data flag.
MASK_6 = 1 << 8Mask6 data flag.
MASK_7 = 1 << 9Mask7 data flag.
MASK_8 = 1 << 10Mask8 data flag.
MASK_9 = 1 << 11Mask9 data flag.
MASK_10 = 1 << 12Mask10 data flag.
MASK_11 = 1 << 13Mask11 data flag.
MASK_12 = 1 << 14Mask12 data flag.
MASK_13 = 1 << 15Mask13 data flag.
MASK_14 = 1 << 16Mask14 data flag.
MASK_15 = 1 << 17Mask15 data flag.
MASK_16 = 1 << 18Mask16 data flag.
MASK_17 = 1 << 19Mask17 data flag.
MASK_18 = 1 << 20Mask18 data flag.
MASK_19 = 1 << 21Mask19 data flag.

TYPE_FILE_DATA#

File data types.
NameDescription
HEIGHT = 0Landscape map file heights data.
ALBEDO = 1Landscape map file albedo data.
MASK_0 = 2Landscape map file detail mask data (masks with indices 0, 1, 2, 3).
MASK_1 = 3Landscape map file detail mask data (masks with indices 4, 5, 6, 7).
MASK_2 = 4Landscape map file detail mask data (masks 8, 9, 10, 11).
MASK_3 = 5Landscape map file detail mask data (masks with indices 12, 13, 14, 15).
MASK_4 = 6Landscape map file detail mask data (masks with indices 16, 17, 18, 19).
OPACITY_HEIGHT = 7Landscape map file height opacity data.
OPACITY_MASK_0 = 8Landscape map file detail mask opacity data (masks with indices 0, 1, 2, 3).
OPACITY_MASK_1 = 9Landscape map file detail mask opacity data (masks with indices 4, 5, 6, 7).
OPACITY_MASK_2 = 10Landscape map file detail mask opacity data (masks with indices 8, 9, 10, 11).
OPACITY_MASK_3 = 11Landscape map file detail mask opacity data (masks with indices 12, 13, 14, 15).
OPACITY_MASK_4 = 12Landscape map file detail mask opacity data (masks with indices 16, 17, 18, 19).

FLAGS_FILE_DATA#

File data layer flags.
NameDescription
HEIGHT = 1 << 0Landscape map file height data.
ALBEDO = 1 << 1Landscape map file albedo data.
MASK_0 = 1 << 2Landscape map file first masks data block (masks with indices 0,1,2,3).
MASK_1 = 1 << 3Landscape map file second masks data block (masks with indices 4,5,6,7).
MASK_2 = 1 << 4Landscape map file third masks data block (masks with indices 8,9,10,11).
MASK_3 = 1 << 5Landscape map file fourth masks data block (masks with indices 12,13,14,15).
MASK_4 = 1 << 6Landscape map file fifth masks data block (masks with indices 16,17,18,19).
OPACITY_HEIGHT = 1 << 7Landscape map file height opacity data.
OPACITY_MASK_0 = 1 << 8Landscape map file first masks opacity data block (for masks with indices 0,1,2,3).
OPACITY_MASK_1 = 1 << 9Landscape map file second masks opacity data block (for masks with indices 4,5,6,7).
OPACITY_MASK_2 = 1 << 10Landscape map file third masks opacity data block (for masks with indices 8,9,10,11).
OPACITY_MASK_3 = 1 << 11Landscape map file fourth masks opacity data block (for masks with indices 12,13,14,15).
OPACITY_MASK_4 = 1 << 12Landscape map file fifth masks opacity data block (for masks with indices 16,17,18,19).

COMPRESSOR_TYPE#

Compression method used for the layer map.
NameDescription
NONE = 0No compression is used.
JACKALLESS = 1Our Method compression is used. It is optimized for compressing 2D and 3D textures and provides better results than LZ4 and Zlib without deteriorating the quality.
LZ4 = 2LZ4 compression is used (temporary option, planned to be removed in the upcoming releases).
ZLIB = 3Zlib compression (can provide up to 2 times higher compression ratio, but takes up to 20 times longer).

BLENDING_MODE#

Blending mode used for the layer map.
NameDescription
ALPHA_BLEND = 0Alpha blending mode - the colors of the layer map and the underlying one are blended.
ADDITIVE = 1Additive blending mode - data of the layer map is added atop of the data of underlying maps.
OVERLAY = 2Overlay blending mode - data of the layer map replaces the data of underlying maps.
MULTIPLICATIVE = 3Multiplicative blending mode - albedo colors of the underlying map are multiplied by the colors of the layer map.

Properties

bool IsFilesClosed#

The true if .lmap files for all landscape layer maps are closed; otherwise, false.

Members


LandscapeTextures GetTemporaryTexture ( ivec2 resolution ) #

Returns a fragment of terrain data as a LandscapeTextures of the specified resolution.

Arguments

  • ivec2 resolution - Resolution of a temporary texture to be obtained.

Return value

LandscapeTextures instance containing a fragment of terrain data.

void ReleaseTemporaryTexture ( LandscapeTextures texture ) #

Releases the specified temporary texture.

Arguments

bool TerrainLoad ( WorldBoundBox bb ) #

Loads terrain data (tiles) for all landscape layer maps within the specified bounding box to cache.

Arguments

  • WorldBoundBox bb - Bounding box, defining landscape layer maps for which the data is to be loaded.

Return value

true if terrain data was successfully loaded for all landscape layer maps within the specified bounding box; otherwise, false.

bool Render ( LandscapeTextures buffers, mat4 transform, Scalar texel_size ) #

Renders the area of the specified landscape layer maps defined by the specified transform and texel size, to the specified buffers.

Arguments

  • LandscapeTextures buffers - Target texture buffers to which the specified landscape layer maps are to be rendered.
  • mat4 transform - Transformation of the landscape terrain area to be rendered (Z-coordinate is ignored).
  • Scalar texel_size - Texel size to be used. Defines the size of the area depending on the buffers resolution.

Return value

true if the data of the landscape terrain area (all landscape layer maps) defined by the specified transformation and texel size, was successfully rendered to the specified buffers; otherwise, false.

bool Render ( LandscapeTextures buffers, mat4 transform, Scalar texel_size, int padding ) #

Renders the area of the specified landscape layer maps defined by the specified transform and texel size, to the specified buffers. Use the padding parameter to set inner padding size for the area (when necessary).

Arguments

  • LandscapeTextures buffers - Target texture buffers to which the specified landscape layer maps are to be rendered.
  • mat4 transform - Transformation of the landscape terrain area to be rendered (Z-coordinate is ignored).
  • Scalar texel_size - Texel size to be used. Defines the size of the area depending on the buffers resolution.
  • int padding - Inner padding size for the area to be rendered (if necessary).

Return value

true if the data of the landscape terrain area (all landscape layer maps) defined by the specified transformation and texel size, was successfully rendered to the specified buffers; otherwise, false.

bool Render ( LandscapeLayerMap[] maps, LandscapeTextures buffers, mat4 transform, Scalar texel_size ) #

Renders the area of the specified landscape layer maps defined by the specified transform and texel size, to the specified buffers. Use the padding parameter to set inner padding size for the area (when necessary).

Arguments

  • LandscapeLayerMap[] maps - List of the landscape layer maps to be rendered.
  • LandscapeTextures buffers - Target texture buffers to which the specified landscape layer maps are to be rendered.
  • mat4 transform - Transformation of the landscape terrain area to be rendered (Z-coordinate is ignored).
  • Scalar texel_size - Texel size to be used. Defines the size of the area depending on the buffers resolution.

Return value

true if the data of the landscape terrain area (specified landscape layer maps) defined by the specified transformation and texel size, was successfully rendered to the specified buffers; otherwise, false.

bool Render ( LandscapeLayerMap[] maps, LandscapeTextures buffers, mat4 transform, Scalar texel_size, int padding ) #

Renders the area of the specified landscape layer maps defined by the specified transform and texel size, to the specified buffers. Use the padding parameter to set inner padding size for the area (when necessary).

Arguments

  • LandscapeLayerMap[] maps - List of the landscape layer maps to be rendered.
  • LandscapeTextures buffers - Target texture buffers to which the specified landscape layer maps are to be rendered.
  • mat4 transform - Transformation of the landscape terrain area to be rendered (Z-coordinate is ignored).
  • Scalar texel_size - Texel size to be used. Defines the size of the area depending on the buffers resolution.
  • int padding - Inner padding size for the area to be rendered.

Return value

true if the data of the landscape terrain area (specified landscape layer maps) defined by the specified transformation and texel size, was successfully rendered to the specified buffers; otherwise, false.

void AsyncTextureDraw ( int operation_id, UGUID guid, ivec2 coord, ivec2 resolution, int flags_file_data, WorldBoundBox[] bounds_preload ) #

Commences an asynchronous GPU-based drawing operation with forced pre-loading of terrain data within the specified bounding box (all landscape layer maps). The drawing operation represents modification of the texture buffer of the specified size taken at specified coordinates and combining data layers defined by the specified flags. The operation itself is to be implemented in the TextureDrawCallback handler. This method can be used for implementing GPU-based terrain modification (e.g. brushes) that requires additional data beyond the area specified by coords and resolution parameters as well as the data of other landscape layer maps (e.g. a copy brush).

Arguments

  • int operation_id - Draw operation ID.
  • UGUID guid - GUID of the landscape layer map file to be modified.
  • ivec2 coord - Coordinates of the upper left corner of the landscape layer map data segment to be modified along the X and Y axes.
  • ivec2 resolution - Resolution of the landscape layer map data segment to be modified along the X and Y axes.
  • int flags_file_data - Data layer mask. A combination of FLAGS_FILE_DATA_* flags indicating data layers to be affected (heights, albedo, certain masks).
  • WorldBoundBox[] bounds_preload - Bounding box (world) specifying the area containing terrain tiles (all landscape layer maps) to be loaded to memory prior to making modifications.

void AsyncTextureDraw ( int operation_id, UGUID guid, ivec2 coord, ivec2 resolution, int flags_file_data ) #

Commences an asynchronous GPU-based drawing operation. The drawing operation represents modification of the texture buffer of the specified size taken at specified coordinates and combining data layers defined by the specified flags. The operation itself is to be implemented in the TextureDrawCallback handler. This method can be used for implementing GPU-based terrain modification (e.g. brushes).

Arguments

  • int operation_id - Draw operation ID.
  • UGUID guid - GUID of the landscape layer map file to be modified.
  • ivec2 coord - Coordinates of the upper left corner of the landscape layer map data segment to be modified along the X and Y axes.
  • ivec2 resolution - Resolution of the landscape layer map data segment to be modified along the X and Y axes.
  • int flags_file_data - Data layer mask. A combination of FLAGS_FILE_DATA_* flags indicating data layers to be affected (heights, albedo, certain masks).

void AsyncTextureDraw ( int operation_id, UGUID guid, ivec2 coord, ivec2 resolution ) #

Commences an asynchronous GPU-based drawing operation. The drawing operation represents modification of the texture buffer of the specified size taken at specified coordinates and combining all data layers. The operation itself is to be implemented in the TextureDrawCallback handler. This method can be used for implementing GPU-based terrain modification (e.g. brushes).

Arguments

  • int operation_id - Draw operation ID.
  • UGUID guid - GUID of the landscape layer map file to be modified.
  • ivec2 coord - Coordinates of the upper left corner of the landscape layer map data segment to be modified along the X and Y axes.
  • ivec2 resolution - Resolution of the landscape layer map data segment to be modified along the X and Y axes.

void AsyncTextureDraw ( UGUID guid, ivec2 coord, ivec2 resolution, int flags_file_data, WorldBoundBox[] bounds_preload ) #

Commences an asynchronous GPU-based drawing operation with forced pre-loading of terrain data within the specified bounding box (all landscape layer maps). The drawing operation represents modification of the texture buffer of the specified size taken at specified coordinates and combining data layers defined by the specified flags. The operation itself is to be implemented in the TextureDrawCallback handler. This method can be used for implementing GPU-based terrain modification (e.g. brushes) that requires additional data beyond the area specified by coords and resolution parameters as well as the data of other landscape layer maps (e.g. a copy brush).

Arguments

  • UGUID guid - GUIGUID of the landscape layer map file to be modified.
  • ivec2 coord - Coordinates of the upper left corner of the landscape layer map data segment to be modified along the X and Y axes.
  • ivec2 resolution - Resolution of the landscape layer map data segment to be modified along the X and Y axes.
  • int flags_file_data - Data layer mask. A combination of FLAGS_FILE_DATA_* flags indicating data layers to be affected (heights, albedo, certain masks).
  • WorldBoundBox[] bounds_preload - Bounding box (world) specifying the area containing terrain tiles (all landscape layer maps) to be loaded to memory prior to making modifications.

void AsyncTextureDraw ( UGUID guid, ivec2 coord, ivec2 resolution, int flags_file_data ) #

Commences an asynchronous GPU-based drawing operation. The drawing operation represents modification of the texture buffer of the specified size taken at specified coordinates and combining data layers defined by the specified flags. The operation itself is to be implemented in the TextureDrawCallback handler. This method can be used for implementing GPU-based terrain modification (e.g. brushes).

Arguments

  • UGUID guid - GUID of the landscape layer map file to be modified.
  • ivec2 coord - Coordinates of the upper left corner of the landscape layer map data segment to be modified along the X and Y axes.
  • ivec2 resolution - Resolution of the landscape layer map data segment to be modified along the X and Y axes.
  • int flags_file_data - Data layer mask. A combination of FLAGS_FILE_DATA_* flags indicating data layers to be affected (heights, albedo, certain masks).

void AsyncTextureDraw ( UGUID guid, ivec2 coord, ivec2 resolution ) #

Commences an asynchronous GPU-based drawing operation. The drawing operation represents modification of the texture buffer of the specified size taken at specified coordinates and combining all data layers. The operation itself is to be implemented in the TextureDrawCallback handler. This method can be used for implementing GPU-based terrain modification (e.g. brushes).

Arguments

  • UGUID guid - GUID of the landscape layer map file to be modified.
  • ivec2 coord - Coordinates of the upper left corner of the landscape layer map data segment to be modified along the X and Y axes.
  • ivec2 resolution - Resolution of the landscape layer map data segment to be modified along the X and Y axes.

void AsyncApplyDiff ( int operation_id, UGUID guid, string path ) #

Applies the state of the landscape layer map stored in the specified file to the landscape layer map file with the specified GUID.

Arguments

  • int operation_id - Operation ID.
  • UGUID guid - GUID of the landscape layer map file to which a state stored at the specified path is to be applied.
  • string path - Path to a file where the current landscape map modification state is stored.

void AsyncApplyDiff ( UGUID guid, string path ) #

Applies the state of the landscape layer map stored in the specified file to the landscape layer map file with the specified GUID.

Arguments

  • UGUID guid - GUID of the landscape layer map file to which a state stored at the specified path is to be applied.
  • string path - Path to a file where the current landscape map modification state is stored.

void AsyncSaveFile ( int operation_id, UGUID file_guid ) #

Saves the landscape layer map file with the specified GUID.

Arguments

void AsyncSaveFile ( UGUID file_guid ) #

Saves the landscape layer map file with the specified GUID.

Arguments

  • UGUID file_guid - GUID of the landscape layer map file.

void AsyncSaveFile ( int operation_id, UGUID guid, string path_new_state, string path_old_state ) #

Saves the specified landscape layer map file applying all changes along with saving old and new states (diff) to temporary files. These temporary files can be used to perform undo/redo operations via the applyDiff() method.

Arguments

  • int operation_id - Operation ID.
  • UGUID guid - GUID of the landscape layer map file.
  • string path_new_state - Path to a file to store the new landscape layer map state.
  • string path_old_state - Path to a file to store the old landscape layer map state.

void AsyncSaveFile ( UGUID guid, string path_new_state, string path_old_state ) #

Saves the specified landscape layer map file applying all changes along with saving old and new states (diff) to temporary files. These temporary files can be used to perform undo/redo operations via the applyDiff() method.

Arguments

  • UGUID guid - GUID of the landscape layer map file.
  • string path_new_state - Path to a file to store the new landscape layer map state.
  • string path_old_state - Path to a file to store the old landscape layer map state.

void FilesClose ( UGUID[] reload_files ) #

Closes .lmap files for all landscape layer maps and reloads the ones with specified GUIDs. This method should be called before making any changes (modification, deletion, renaming) to .lmap files of the landscape terrain object to avoid conflicts, as these files are streamed continuosly by the Engine. Thus, by calling this method you inform the Engine that it should stop streaming terrain data. The list informs the Engine which files are no longer valid and should be reloaded or removed. As you're done with modification you should call the filesOpen() method to resume streaming operations.

Arguments

  • UGUID[] reload_files - List of GUIDs of .lmap files to be reloaded. This list should contain .lmap files, that were deleted or having their data changed (albedo, heights, masks). If there are no such files, you can simply call the filesClose() method.

void FilesClose ( ) #

Closes .lmap files for all landscape layer maps. This method should be called before making any changes (modification, deletion, renaming) to .lmap files of the landscape terrain object to avoid conflicts, as these files are streamed continuosly by the Engine. Thus, by calling this method you inform the Engine that it should stop streaming terrain data. As you're done with modification you should call the filesOpen() method to resume streaming operations.

void FilesOpen ( ) #

Opens .lmap files for all landscape layer maps. This method should be called after making any changes (modification, deletion, renaming) to .lmap files of the landscape terrain object. Prior to making such modifications the filesClose() method should be called.

ObjectLandscapeTerrain GetActiveTerrain ( ) #

Returns the current active Landscape Terrain object.
Notice
If a scene contains multiple Landscape Terrain objects, only one of them can be active (rendered).

Return value

Landscape Terrain object that is currently active.

IntPtr AddTextureDrawCallback ( TextureDrawDelegate func ) #

Adds a callback function to be called when a Texture Draw (GPU-based terrain modification) operation is performed. The signature of the callback function must be as follows:
Source code (C#)
void texture_draw_callback(UGUID guid, int id, LandscapeTextures buffer, in ivec2 coord, int data_mask);

You can set a callback function as follows:

Source code (C#)
AddTextureDrawCallback((guid, id, buffer, coord, data_mask) 
						=> texture_draw_callback(guid, id, buffer, coord, data_mask));

Example: Setting a texture draw callback function:

Source code (C#)
class AppWorldLogic : WorldLogic
{

	/*...*/

	// callback function implementing modification of the buffer
	private void TextureDraw(UGUID guid, int id, LandscapeTextures buffer, in ivec2 coord, int data_mask)
	{
		// insert your buffer modification code here (the following lines can be used as an example)
		
		// getting a brush material to be used (e.g., built-in "cirle_soft" Editor's brush)
		Material mat = Materials.findMaterial("circle_soft");
		
		if (mat) {
			// setting necessary textures to be modified by the brush
			mat.setTexture("terrain_albedo", buffer.getAlbedo());
			mat.setTexture("terrain_height", buffer.getHeight());

			// setting up brush material parameters
			mat.setParameterFloat("size", 100.0f);
			mat.setParameterFloat("height", 10.0f);
			mat.setParameterFloat4("color", vec4.RED);
			mat.setParameterInt("data_mask", Landscape.FLAGS_DATA_ALBEDO | Landscape.FLAGS_DATA_HEIGHT);

			// running material's "brush" expression
			mat.runExpression("brush", buffer.getResolution().x, buffer.getResolution().y);
			
			// resetting material textures
			mat.setTexture("terrain_albedo", null);
			mat.setTexture("terrain_height", null);
		}
	}

	/*...*/

	public override bool Init()
	{
		// setting the TextureDraw() function to handle texture drawing
		Landscape.AddTextureDrawCallback((guid, id, buffer, coord, data_mask) 
						=> TextureDraw(guid, id, buffer, coord, data_mask));

		return true;
		}
	/*...*/
}

Arguments

  • TextureDrawDelegate func - Callback function with the following signature:
    void TextureDrawDelegate(UGUID guid, int id, LandscapeTextures buffer, in ivec2 coord, int data_mask)

Return value

ID of the last added texture draw callback, if the callback was added successfully; otherwise, null. This ID can be used to remove this callback when necessary.

bool RemoveTextureDrawCallback ( IntPtr id ) #

Removes the specified callback from the list of texture draw callbacks.

Arguments

  • IntPtr id - Texture draw callback ID obtained when adding it.

Return value

True if the texture draw callback with the given ID was removed successfully; otherwise false.

void ClearTextureDrawCallback ( ) #

Clears all added texture draw callbacks.

IntPtr AddApplyDiffCallback ( ApplyDiffDelegate func ) #

Adds a callback function to be called on applying a diff to the landscape layer map file. The signature of the callback function must be as follows:
Source code (C#)
void apply_diff_callback(UGUID guid, int id, String path);

You can set a callback function as follows:

Source code (C#)
AddApplyDiffCallback((guid, id, path) 
						=> apply_diff_callback(guid, id, path));

Example: Setting an apply diff callback function:

Source code (C#)
class AppWorldLogic : WorldLogic
{

	/*...*/

	// callback function implementing certain actions to be performed on applying a diff
	private void ApplyDiff(UGUID guid, int id, String path)
	{
		// insert your specific handling code here
	}

	/*...*/

	public override bool Init()
	{
		// setting the ApplyDiff() function to handle an apply diff event
		Landscape.AddApplyDiffCallback((guid, id, path) 
						=> ApplyDiff(guid, id, path));

		return true;
		}
	/*...*/
}

Arguments

  • ApplyDiffDelegate func - Callback function with the following signature:
    void ApplyDiffDelegate(UGUID guid, int id, String path)

Return value

ID of the last added apply diff callback, if the callback was added successfully; otherwise, null. This ID can be used to remove this callback when necessary.

bool RemoveApplyDiffCallback ( IntPtr id ) #

Removes the specified callback from the list of apply diff callbacks.

Arguments

  • IntPtr id - Apply diff callback ID obtained when adding it.

Return value

True if the apply diff callback with the given ID was removed successfully; otherwise false.

void ClearApplyDiffCallback ( ) #

Clears all added apply diff callbacks.

IntPtr AddSaveFileCallback ( SaveFileDelegate func ) #

Adds a callback function to be called on applying changes made to a landscape layer map file and saving old and new states to temporary files. The signature of the callback function must be as follows:
Source code (C#)
void save_file_callback(UGUID guid, int id, String path_new_state, String path_old_state);

You can set a callback function as follows:

Source code (C#)
AddSaveFileCallback((guid, id, path_new_state, path_old_state) 
						=> save_file_callback(guid, id, path_new_state, path_old_state));

Example: Setting a save file callback function:

Source code (C#)
class AppWorldLogic : WorldLogic
{

	/*...*/

	// callback function
	private void SaveFile(UGUID guid, int id, String path, String path_new_state, String path_old_state)
	{
		// insert your specific handling code here
	}

	/*...*/

	public override bool Init()
	{
		// setting the SaveFile() function to handle file saving
		Landscape.AddSaveFileCallback((guid, id, path_new_state, path_old_state) 
						=> SaveFile(guid, id, path_new_state, path_old_state));

		return true;
		}
	/*...*/
}

Arguments

  • SaveFileDelegate func - Callback function with the following signature:
    void SaveFileDelegate(UGUID guid, int id, String path_new_state, String path_old_state)

Return value

ID of the last added save file callback, if the callback was added successfully; otherwise, null. This ID can be used to remove this callback when necessary.

bool RemoveSaveFileCallback ( IntPtr id ) #

Removes the specified callback from the list of save file callbacks.

Arguments

  • IntPtr id - Save file callback ID obtained when adding it.

Return value

True if the save file callback with the given ID was removed successfully; otherwise false.

void ClearSaveFileCallback ( ) #

Clears all added save file callbacks.

int GenerateOperationID ( ) #

Generates a new ID for the operation. This ID is used to manage operations.
Source code (C++)
int id = Landscape::generateOperationID();
// user's code (bounding to ID)
Landscape::asyncTextureDraw(id, file_guid, coord, resolution, flags_file_data);

Return value

New operation ID.
Last update: 2022-12-14
Build: ()