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.LandscapeFetch Class

This class is used to fetch data of the Landscape Terrain Object at a certain point (e.g. a height request) or check for an intersection with a traced line. The following performance optimizations are available:

  • For each request you can engage or disengage certain data types (albedo, heights, masks, etc.). When the data type is engaged, you can obtain information via the corresponding get() method. Disengaging unnecessary data when performing requests saves some performance (e.g., you can engage albedo data only if you need only color information at a certain point).
  • Both fetch and intersection requests can be performed asynchronously when an instant result is not required.

The workflow is as follows:

  1. Create a new LandscapeFetch object instance.
  2. Set necessary parameters (e.g. which data layers are to be used, whether to enable holes or not, etc.).
  3. To get terrain data for a certain point call the fetchForce() method providing coordinates for the desired point.
    Notice
    You can also fetch terrain data asynchronously via the fetchAsync() method.
  4. To find an intersection of a traced line with the terrain call either the intersectionForce() method or the intersectionAsync() method, if you want to perform an asynchronous request.

Usage Example#

Source code (C++)
// creating a fetch object and setting necessary parameters
LandscapeFetchPtr landscape_fetch = LandscapeFetch::create();
landscape_fetch->setUses(0);
landscape_fetch->setUsesHeight(true);
landscape_fetch->setHolesEnabled(true);


// ...

// getting terrain data for a point at (100, 100) and printing the height value
landscape_fetch->setFetchPosition(Vec2(100, 100));
if (landscape_fetch->fetchForce())
	Log::message("Terrain height at the specified point is: %f", Scalar(landscape_fetch->getHeight()));

Asynchronous Operations Example#

Source code (C++)
// creating a fetch object and setting necessary parameters
LandscapeFetchPtr landscape_fetch = LandscapeFetch::create();
landscape_fetch->setUses(0);
landscape_fetch->setUsesHeight(true);
landscape_fetch->setHolesEnabled(true);


// ...

// making an asynchronous fetch request for a point at (2.05, 2.05)
landscape_fetch->setFetchPosition(Vec2(2.05f, 2.05f));
landscape_fetch->fetchAsync();

// ...

// checking if our asynchronous fetch request is completed and printing the height value
if (landscape_fetch->isAsyncCompleted()) {
		Log::message("Terrain height at the specified point is: %f", Scalar(landscape_fetch->getHeight()));
}

LandscapeFetch Class

Properties

vec3 Position#

The Fetch/intersection point coordinates as a three-component vector.

float Height#

The Height value at the point.

vec3 Normal#

The Normal vector coordinates at the point.

vec4 Albedo#

The Albedo color at the point as a 4 component vector (R, G, B, A).

bool IsIntersection#

The true if an intersection was detected; otherwise, false.

int Uses#

The Current combination of data engagement flags.

bool UsesHeight#

The true if heights data is engaged in the fetch/intersection request; otherwise, false.

bool UsesNormal#

The true if normals data is engaged in the fetch/intersection request; otherwise, false.

bool UsesAlbedo#

The true if albedo data is engaged in the fetch/intersection request; otherwise, false.

float IntersectionPrecision#

The Returns the current precision value used for intersection detection requested by intersectionForce() and intersectionAsync() methods.

vec3 IntersectionPositionEnd#

The Coordinates of the end point for intersection detection.

vec3 IntersectionPositionBegin#

The Coordinates of the starting point for intersection detection.

vec2 FetchPosition#

The Point for which terrain data is to be fetched. Two-component vector specifying point coordinates along X and Y axes.

bool IsAsyncCompleted#

The true if async operation is completed; otherwise, false.

bool HolesEnabled#

The A value indicating if checking for terrain holes in the fetch/intersection request is enabled. this option is enabled by default. when disabled terrain holes created using decals are ignored.

Members


LandscapeFetch ( ) #

The LandscapeFetch constructor.

float GetMask ( int num ) #

Returns information stored for the point in the detail mask with the specified number.
Notice
To get valid detail mask information via this method, engage mask data for the fetch/intersection request.

Arguments

  • int num - Number of the detail mask in the [0; 19] range.

Return value

Value for the point stored in the detail mask with the specified number.

void SetUsesMask ( int num, bool value ) #

Sets a value indicating if data of the specified detail mask is engaged in the fetch/intersection request. When the data type is engaged, you can obtain it via the corresponding get() method. Disengaging unnecessary data when performing requests saves some performance (e.g., you can engage albedo data only if you need only color information at a certain point).
Notice
Enable this option to get detail mask data for the point.

Arguments

  • int num - Detail mask number in the [0; 19] range.
  • bool value - true to engage data of the specified detail mask in the fetch/intersection request, false - to disengage.

bool IsUsesMask ( int num ) #

Returns a value indicating if data of the specified detail mask is engaged in the fetch/intersection request. When the data type is engaged, you can obtain it via the corresponding get() method. Disengaging unnecessary data when performing requests saves some performance (e.g., you can engage albedo data only if you need only color information at a certain point).
Notice
Enable this option to get detail mask data for the point.

Arguments

  • int num - Detail mask number in the [0; 19] range.

Return value

true if data of the specified detail mask is engaged in the fetch/intersection request; otherwise, false.

bool FetchForce ( ) #

Fetches terrain data in forced mode for the point specified by the setFetchPosition(). You can use the fetchAsync() method to reduce load, when an instant result is not required.

Return value

true if terrain data was successfully obtained for the specified point; otherwise, false.

bool FetchForce ( vec2 position ) #

Fetches terrain data in forced mode for the specified point. You can use the fetchAsync() method to reduce load, when an instant result is not required.

Arguments

  • vec2 position - Coordinates of the point.

Return value

true if terrain data was successfully obtained for the specified point; otherwise, false.

bool IntersectionForce ( ) #

Performs tracing along the line from the p0 point specified by the setIntersectionPositionBegin() to the p1 point specified by the setIntersectionPositionEnd() to find an intersection with the terrain in forced mode. You can use the intersectionAsync() method to reduce load, when an instant result is not required.

Return value

true if an intersection with the terrain was found; otherwise, false.

bool IntersectionForce ( vec3 p0, vec3 p1 ) #

Performs tracing along the line from the p0 point to the p1 point to find an intersection with the terrain in forced mode. You can use the intersectionAsync() method to reduce load, when an instant result is not required.

Arguments

  • vec3 p0 - Coordinates of the p0 point.
  • vec3 p1 - Coordinates of the p1 point.

Return value

true if an intersection with the terrain was found; otherwise, false.

void FetchAsync ( bool critical = false ) #

Fetches terrain data for the point specified by the setFetchPosition() in asynchronous mode (the corresponding task shall be put to the queue, to wait until the result is obtained use the wait() method). For an instant result use the fetchForce() method.

Arguments

  • bool critical - true to set high priority for the fetch task, false - to set normal priority.

void FetchAsync ( vec2 position, bool critical = false ) #

Fetches terrain data for the specified point in asynchronous mode (the corresponding task shall be put to the queue, to wait until the result is obtained use the wait() method). For an instant result use the fetchForce() method.

Arguments

  • vec2 position - Coordinates of the point.
  • bool critical - true to set high priority for the fetch task, false - to set normal priority.

void IntersectionAsync ( bool critical = false ) #

Performs tracing along the line from the p0 point specified by the setIntersectionPositionBegin() to the p1 point specified by the setIntersectionPositionEnd() to find an intersection with the terrain in asynchronous mode (the corresponding task shall be put to the queue, to wait until the result is obtained use the wait() method). For an instant result use the intersectionForce() method.

Arguments

  • bool critical - true to set high priority for the intersection task, false - to set normal priority.

void IntersectionAsync ( vec3 p0, vec3 p1, bool critical = false ) #

Performs tracing along the line from the p0 point to the p1 point to find an intersection with the terrain in asynchronous mode (the corresponding task shall be put to the queue, to wait until the result is obtained use the wait() method). For an instant result use the intersectionForce() method.

Arguments

  • vec3 p0 - Coordinates of the p0 point.
  • vec3 p1 - Coordinates of the p1 point.
  • bool critical - true to set high priority for the intersection task, false - to set normal priority.

static void FetchForce ( LandscapeFetch[] fetches ) #

Fetches (batch) terrain data in forced mode for the point specified by the setFetchPosition(). You can use the fetchAsync() method to reduce load, when an instant result is not required.

Arguments

  • LandscapeFetch[] fetches - List of fetch requests to be completed.

static void IntersectionForce ( LandscapeFetch[] fetches ) #

Performs tracing (batch) along the line from the p0 point specified by the setIntersectionPositionBegin() to the p1 point specified by the setIntersectionPositionEnd() to find an intersection with the terrain in forced mode. You can use the intersectionAsync() method to reduce load, when an instant result is not required.

Arguments

  • LandscapeFetch[] fetches - List of fetch requests to be completed.

static void FetchAsync ( LandscapeFetch[] fetches, bool critical = false ) #

Fetches (batch) terrain data for the point specified by the setFetchPosition() in asynchronous mode (the corresponding task shall be put to the queue, to wait until the result is obtained use the wait() method). For an instant result use the fetchForce() method.

Arguments

  • LandscapeFetch[] fetches - List of fetch requests to be completed.
  • bool critical - true to set high priority for the fetch task, false - to set normal priority.

static void IntersectionAsync ( LandscapeFetch[] fetches, bool critical = false ) #

Performs tracing (batch) along the line from the p0 point specified by the setIntersectionPositionBegin() to the p1 point specified by the setIntersectionPositionEnd() to find an intersection with the terrain in asynchronous mode (the corresponding task shall be put to the queue, to wait until the result is obtained use the wait() method). For an instant result use the intersectionForce() method.

Arguments

  • LandscapeFetch[] fetches - List of fetch requests to be completed.
  • bool critical - true to set high priority for the intersection task, false - to set normal priority.

void Wait ( ) #

Waits for completion of the fetch operation. As the operation is completed you can obtain necessary data via get*() methods.

static void Wait ( LandscapeFetch[] fetches ) #

Waits for completion of the specified fetch operations. As the operations are completed you can obtain necessary data via get*() methods.

Arguments

  • LandscapeFetch[] fetches - List of fetch requests to be completed.

IntPtr AddStartCallback ( StartDelegate func ) #

Adds a callback function to be called on fetch completion. The signature of the callback function must be as follows:
Source code (C#)
void fetch_start_callback();

You can set a callback function as follows:

Source code (C#)
AddStartCallback(() 
						=> fetch_start_callback());

Example: Setting a fetch start callback function:

Source code (C#)
class AppWorldLogic : WorldLogic
{

	/*...*/

	// callback function implementing certain actions to be performed on beginning of the fetch process
	private void FetchStart()
	{
		// insert your specific handling code here
	}

	/*...*/

	public override bool Init()
	{
		// setting the FetchStart() function to handle beginning of the fetch process
		LandscapeFetch lf = new LandscapeFetch();
		lf.AddStartCallback(() 
						=> FetchStart(creator));

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

Arguments

  • StartDelegate func - Callback function with the following signature:
    void StartDelegate()

Return value

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

bool RemoveStartCallback ( IntPtr id ) #

Removes the specified callback from the list of file fetch start callbacks.

Arguments

  • IntPtr id - Start callback ID obtained when adding it.

Return value

True if the fetch start callback with the given ID was removed successfully; otherwise false.

void ClearStartCallback ( ) #

Clears all added fetch start callbacks.

IntPtr AddEndCallback ( EndDelegate func ) #

Adds a callback function to be called on fetch completion. The signature of the callback function must be as follows:
Source code (C#)
void fetch_end_callback();

You can set a callback function as follows:

Source code (C#)
AddEndCallback(() 
						=> fetch_end_callback());

Example: Setting a fetch completion callback function:

Source code (C#)
class AppWorldLogic : WorldLogic
{

	/*...*/

	// callback function implementing certain actions to be performed on fetch completion
	private void FetchEnd()
	{
		// insert your specific handling code here
	}

	/*...*/

	public override bool Init()
	{
		// setting the FetchEnd() function to handle fetch completion
		LandscapeFetch lf = new LandscapeFetch();
		lf.AddEndCallback(() 
						=> FetchEnd(creator));

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

Arguments

  • EndDelegate func - Callback function with the following signature:
    void EndDelegate()

Return value

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

bool RemoveEndCallback ( IntPtr id ) #

Removes the specified callback from the list of file fetch end callbacks.

Arguments

  • IntPtr id - End callback ID obtained when adding it.

Return value

True if the fetch end callback with the given ID was removed successfully; otherwise false.

void ClearEndCallback ( ) #

Clears all added fetch end callbacks.
Last update: 2022-12-14
Build: ()