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:
- Implement your GPU-based terrain modification logic in a function.
- Set this handler function when subscribing for the Texture Draw event (when GPU-based terrain modification operation is performed) via EventTextureDraw.
- 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
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.
// GPU-based modification
void my_texture_draw(UGUID guid, int id, LandscapeTextures buffer, 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 handler function to be executed on a Texture Draw operation
Landscape.EventTextureDraw.Connect(texture_draw_connections, 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()
{
// removing all subscriptions for the TextureDraw event
texture_draw_connections.DisconnectAll();
}
And the process:
- 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.
- Upon completion of the copying process a handler function which you used to subscribe for the TextureDraw event is executed. This function modifies the buffer.
- 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.
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;
private EventConnections texture_draw_connections = new EventConnections();
// GPU-based modification
void my_texture_draw(UGUID guid, int id, LandscapeTextures buffer, 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 handler function to be executed on a Texture Draw operation
Landscape.EventTextureDraw.Connect(texture_draw_connections, 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();
// getting direction from the current mouse position
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()
{
// removing all subscriptions for the TextureDraw event
texture_draw_connections.DisconnectAll();
}
}
Landscape Class
Перечисления (Enums)
TYPE_DATA#
FLAGS_DATA#
TYPE_FILE_DATA#
File data types.FLAGS_FILE_DATA#
File data layer flags.COMPRESSOR_TYPE#
Compression method used for the layer map.BLENDING_MODE#
Blending mode used for the layer map.Properties
bool IsFilesClosed#
Event<UGUID, int, string, string> EventSaveFile#
void savefile_handler(UGUID guid, int operation_id, string path_new_state, string path_old_state)
Usage Example
// implement the SaveFile event handler
void savefile_event_handler(UGUID guid, int operation_id, string path_new_state, string path_old_state)
{
Log.Message("\Handling SaveFile event\n");
}
//////////////////////////////////////////////////////////////////////////////
// 1. Multiple subscriptions can be linked to an EventConnections instance
// class that you can use later to remove all these subscriptions at once
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnections class
EventConnections savefile_event_connections = new EventConnections();
// link to this instance when subscribing to an event (subscription to various events can be linked)
Landscape.EventSaveFile.Connect(savefile_event_connections, savefile_event_handler);
// other subscriptions are also linked to this EventConnections instance
// (e.g. you can subscribe using lambdas)
Landscape.EventSaveFile.Connect(savefile_event_connections, (UGUID guid, int operation_id, string path_new_state, string path_old_state) => {
Log.Message("Handling SaveFile event lambda\n");
}
);
// later all of these linked subscriptions can be removed with a single line
savefile_event_connections.DisconnectAll();
//////////////////////////////////////////////////////////////////////////////
// 2. You can subscribe and unsubscribe via the handler function directly
//////////////////////////////////////////////////////////////////////////////
// subscribe to the SaveFile event with a handler function
Landscape.EventSaveFile.Connect(savefile_event_handler);
// remove subscription to the SaveFile event later by the handler function
Landscape.EventSaveFile.Disconnect(savefile_event_handler);
//////////////////////////////////////////////////////////////////////////////
// 3. Subscribe to an event and unsubscribe later via an EventConnection instance
//////////////////////////////////////////////////////////////////////////////
// define a connection to be used to unsubscribe later
EventConnection savefile_event_connection;
// subscribe to the SaveFile event with a lambda handler function and keeping the connection
savefile_event_connection = Landscape.EventSaveFile.Connect((UGUID guid, int operation_id, string path_new_state, string path_old_state) => {
Log.Message("Handling SaveFile event lambda\n");
}
);
// ...
// you can temporarily disable a particular event connection
savefile_event_connection.Enabled = false;
// ... perform certain actions
// and enable it back when necessary
savefile_event_connection.Enabled = true;
// ...
// remove the subscription later using the saved connection
savefile_event_connection.Disconnect();
//////////////////////////////////////////////////////////////////////////////
// 4. Ignoring SaveFile events when necessary
//////////////////////////////////////////////////////////////////////////////
// you can temporarily disable the event to perform certain actions without triggering it
Landscape.EventSaveFile.Enabled = false;
// ... actions to be performed
// and enable it back when necessary
Landscape.EventSaveFile.Enabled = true;
Event<UGUID, int, string> EventApplyDiff#
void applydiff_handler(UGUID guid, int operation_id, string lmap_file_path)
Usage Example
// implement the ApplyDiff event handler
void applydiff_event_handler(UGUID guid, int operation_id, string lmap_file_path)
{
Log.Message("\Handling ApplyDiff event\n");
}
//////////////////////////////////////////////////////////////////////////////
// 1. Multiple subscriptions can be linked to an EventConnections instance
// class that you can use later to remove all these subscriptions at once
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnections class
EventConnections applydiff_event_connections = new EventConnections();
// link to this instance when subscribing to an event (subscription to various events can be linked)
Landscape.EventApplyDiff.Connect(applydiff_event_connections, applydiff_event_handler);
// other subscriptions are also linked to this EventConnections instance
// (e.g. you can subscribe using lambdas)
Landscape.EventApplyDiff.Connect(applydiff_event_connections, (UGUID guid, int operation_id, string lmap_file_path) => {
Log.Message("Handling ApplyDiff event lambda\n");
}
);
// later all of these linked subscriptions can be removed with a single line
applydiff_event_connections.DisconnectAll();
//////////////////////////////////////////////////////////////////////////////
// 2. You can subscribe and unsubscribe via the handler function directly
//////////////////////////////////////////////////////////////////////////////
// subscribe to the ApplyDiff event with a handler function
Landscape.EventApplyDiff.Connect(applydiff_event_handler);
// remove subscription to the ApplyDiff event later by the handler function
Landscape.EventApplyDiff.Disconnect(applydiff_event_handler);
//////////////////////////////////////////////////////////////////////////////
// 3. Subscribe to an event and unsubscribe later via an EventConnection instance
//////////////////////////////////////////////////////////////////////////////
// define a connection to be used to unsubscribe later
EventConnection applydiff_event_connection;
// subscribe to the ApplyDiff event with a lambda handler function and keeping the connection
applydiff_event_connection = Landscape.EventApplyDiff.Connect((UGUID guid, int operation_id, string lmap_file_path) => {
Log.Message("Handling ApplyDiff event lambda\n");
}
);
// ...
// you can temporarily disable a particular event connection
applydiff_event_connection.Enabled = false;
// ... perform certain actions
// and enable it back when necessary
applydiff_event_connection.Enabled = true;
// ...
// remove the subscription later using the saved connection
applydiff_event_connection.Disconnect();
//////////////////////////////////////////////////////////////////////////////
// 4. Ignoring ApplyDiff events when necessary
//////////////////////////////////////////////////////////////////////////////
// you can temporarily disable the event to perform certain actions without triggering it
Landscape.EventApplyDiff.Enabled = false;
// ... actions to be performed
// and enable it back when necessary
Landscape.EventApplyDiff.Enabled = true;
Event<UGUID, int, LandscapeTextures, ivec2, int> EventTextureDraw#
void texturedraw_handler(UGUID guid, int operation_id, LandscapeTextures buffer, ivec2 coords, int data_mask)
Usage Example
// implement the TextureDraw event handler
void texturedraw_event_handler(UGUID guid, int operation_id, LandscapeTextures buffer, ivec2 coords, int data_mask)
{
Log.Message("\Handling TextureDraw event\n");
}
//////////////////////////////////////////////////////////////////////////////
// 1. Multiple subscriptions can be linked to an EventConnections instance
// class that you can use later to remove all these subscriptions at once
//////////////////////////////////////////////////////////////////////////////
// create an instance of the EventConnections class
EventConnections texturedraw_event_connections = new EventConnections();
// link to this instance when subscribing to an event (subscription to various events can be linked)
Landscape.EventTextureDraw.Connect(texturedraw_event_connections, texturedraw_event_handler);
// other subscriptions are also linked to this EventConnections instance
// (e.g. you can subscribe using lambdas)
Landscape.EventTextureDraw.Connect(texturedraw_event_connections, (UGUID guid, int operation_id, LandscapeTextures buffer, ivec2 coords, int data_mask) => {
Log.Message("Handling TextureDraw event lambda\n");
}
);
// later all of these linked subscriptions can be removed with a single line
texturedraw_event_connections.DisconnectAll();
//////////////////////////////////////////////////////////////////////////////
// 2. You can subscribe and unsubscribe via the handler function directly
//////////////////////////////////////////////////////////////////////////////
// subscribe to the TextureDraw event with a handler function
Landscape.EventTextureDraw.Connect(texturedraw_event_handler);
// remove subscription to the TextureDraw event later by the handler function
Landscape.EventTextureDraw.Disconnect(texturedraw_event_handler);
//////////////////////////////////////////////////////////////////////////////
// 3. Subscribe to an event and unsubscribe later via an EventConnection instance
//////////////////////////////////////////////////////////////////////////////
// define a connection to be used to unsubscribe later
EventConnection texturedraw_event_connection;
// subscribe to the TextureDraw event with a lambda handler function and keeping the connection
texturedraw_event_connection = Landscape.EventTextureDraw.Connect((UGUID guid, int operation_id, LandscapeTextures buffer, ivec2 coords, int data_mask) => {
Log.Message("Handling TextureDraw event lambda\n");
}
);
// ...
// you can temporarily disable a particular event connection
texturedraw_event_connection.Enabled = false;
// ... perform certain actions
// and enable it back when necessary
texturedraw_event_connection.Enabled = true;
// ...
// remove the subscription later using the saved connection
texturedraw_event_connection.Disconnect();
//////////////////////////////////////////////////////////////////////////////
// 4. Ignoring TextureDraw events when necessary
//////////////////////////////////////////////////////////////////////////////
// you can temporarily disable the event to perform certain actions without triggering it
Landscape.EventTextureDraw.Enabled = false;
// ... actions to be performed
// and enable it back when necessary
Landscape.EventTextureDraw.Enabled = true;
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
- LandscapeTextures texture - Temporary landscape texture to be released.
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.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 file_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 TextureDraw event 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 file_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 file_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 TextureDraw event handler. This method can be used for implementing GPU-based terrain modification (e.g. brushes).Arguments
- int operation_id - Draw operation ID.
- UGUID file_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 file_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 TextureDraw event handler. This method can be used for implementing GPU-based terrain modification (e.g. brushes).Arguments
- int operation_id - Draw operation ID.
- UGUID file_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 file_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 TextureDraw event 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 file_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 file_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 TextureDraw event handler. This method can be used for implementing GPU-based terrain modification (e.g. brushes).Arguments
- UGUID file_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 file_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 TextureDraw event handler. This method can be used for implementing GPU-based terrain modification (e.g. brushes).Arguments
- UGUID file_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 file_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 file_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 file_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 file_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
- int operation_id - Operation ID.
- UGUID file_guid - GUID of the landscape layer map file.
void AsyncSaveFile ( UGUID file_guid ) #
Saves the landscape layer map file with the specified GUID.Arguments
void AsyncSaveFile ( int operation_id, UGUID file_guid, string path_new_diff, string path_old_diff ) #
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 file_guid - GUID of the landscape layer map file.
- string path_new_diff - Path to a file to store the new landscape layer map state.
- string path_old_diff - Path to a file to store the old landscape layer map state.
void AsyncSaveFile ( UGUID file_guid, string path_new_diff, string path_old_diff ) #
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 file_guid - GUID of the landscape layer map file.
- string path_new_diff - Path to a file to store the new landscape layer map state.
- string path_old_diff - 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.Return value
Landscape Terrain object that is currently active.int GenerateOperationID ( ) #
Generates a new ID for the operation. This ID is used to manage operations.int id = Landscape::generateOperationID();
// user's code (bounding to ID)
Landscape::asyncTextureDraw(id, file_guid, coord, resolution, flags_file_data);