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
Objects-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.WorldClutter Class

Inherits from: Node

WorldClutter class allows to randomly position reference nodes according to the mask and using the specified seed. For each node a probability of appearing is set. All nodes in the world clutter are rendered visible only within a specified distance and then fade out. Just like the ObjectGrass, world clutter is rendered in cells.

There are two benefits of using WorldClutter:

  • Instances of nodes that are currently outside the view frustum are not stored in the memory, which provides much more efficient memory usage.
  • Less cluttered spatial tree, which allows, for example, faster collision detection.

You can use a mask to cut out clutter objects in the areas of intersection with other objects and decals (e.g. to remove vegetation under houses or from the surface of roads projected using decals).

See Also#

A UnigineScript API sample <UnigineSDK>/data/samples/worlds/clutter_00

WorldClutter Class

Properties

int CutoutInverse#

The A value indicating if the clutter objects is rendered inside or outside the areas determined by the cutout intersection mask.

int CutoutIntersectionMask#

The current cutout intersection mask. this mask allows you to cut out clutter objects in the areas of intersection with other objects and decals (e.g. can be used to remove vegetation under houses or from the surface of roads projected using decals). clutter objects will be cut out by objects and decals that have their intersection mask matching this one (one bit at least).
Notice
To set intersection masks the following methods can be used:

int MaskInverse#

The A flag indicating if reference nodes are rendered inside or outside the mask mesh contour.

int MaskMaxValue#

The maximum mask value for the worldclutter object.

int MaskMinValue#

The minimum mask value for the worldclutter object.

int MaskFlipY#

The A flag indicating if a mask is flipped by y axis.

int MaskFlipX#

The A flag indicating if a mask is flipped by x axis.

float Angle#

The current angle cosine that defines the slope steepness appropriate for positioning nodes.

float Threshold#

The current density threshold (for a mask) starting from which reference nodes are rendered if placed dense enough.

float Density#

The current density factor that defines the number of reference nodes per square unit.

float Step#

The step for cells used to render node references contained in the world clutter.

float SizeY#

The current length of the world clutter along the y-coordinate.

float SizeX#

The current width of the world clutter along the x-coordinate.

int Seed#

The seed used for pseudo-random positioning of reference nodes.

int SpawnRate#

The number of cells updated each frame. high number of updated cells may lead to a performance spike.

float FadeDistance#

The current distance up to which reference nodes are fading out (that is, fewer nodes will be rendered instead of all). the distance is measured starting from the visible distance.
Notice
In order for a fade distance to be applied, visibility distance should not be infinite.

float VisibleDistance#

The current distance up to which all the reference nodes will be rendered. the distance is measured from the camera.

int Intersection#

The A value indicating whether reference nodes are scattered upon the ground (along its relief): either the terrain or a mesh set as a parent node.

int Orientation#

The A value indicating whether reference nodes are oriented along the normals of the ground (either the terrain or a mesh set as a parent node).

int NumReferences#

The total number of reference nodes contained in the world clutter.

Members


WorldClutter ( ) #

Constructor. Creates a world clutter with default properties.

void Invalidate ( ) #

Invalidates all world clutter cells. All invalidated cells will be regenerated.

void Invalidate ( WorldBoundBox bounds ) #

Invalidates all world clutter cells within the area specified by the given bounding box. All invalidated cells will be regenerated.

Arguments

  • WorldBoundBox bounds - Bounding box, defining the area, where world clutter cells will be regenerated.

int SetMaskImage ( Image image, bool invalidate = 1 ) #

Sets an image (in R8 format) that defines the placement of meshes.

Arguments

  • Image image - Pointer to the image.
  • bool invalidate - Invalidate flag. Set true to invalidate all world clutter cells; otherwise, set false. All invalidated cells will be regenerated.

Return value

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

int GetMaskImage ( Image image ) #

Writes the image that is currently used as a mask for the placement of meshes into the given buffer.

Arguments

  • Image image - Image buffer to store a mask into.

Return value

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

void SetMaskImageName ( string image_name, bool invalidate = 1 ) #

Sets the name of a new mask image (in R8 format) that defines the placement of meshes.

Arguments

  • string image_name - Name (path) of the mask image.
  • bool invalidate - Invalidate flag. Set true to invalidate all world clutter cells; otherwise, set false. All invalidated cells will be regenerated.

string GetMaskImageName ( ) #

Returns the name of a mask image (in R8 format) that defines the placement of reference nodes.

Return value

Name (path) of the mask image.

int SetMaskMesh ( Mesh mesh, bool invalidate = 1 ) #

Sets a mesh to be used as a mask on-the-fly. Limitations:
  • Before the method is called, another mesh must be set via setMaskMeshName() first.
  • If the world is reloaded, the mesh set via setMaskMeshName() will be loaded.
  • If the memory limit is exceeded, the new mesh might be replaced with the mesh set via setMaskMeshName().

Arguments

  • Mesh mesh - Mesh instance.
  • bool invalidate - Invalidate flag. Set true to invalidate all world clutter cells; otherwise, set false. All invalidated cells will be regenerated.

Return value

1 if the mesh is set successfully; otherwise - 0.

int GetMaskMesh ( Mesh mesh ) #

Copies the current mask mesh (if it exists) to the specified target mesh.

Arguments

  • Mesh mesh - Mesh instance to copy the current mask mesh to.

Return value

1 if mesh mask exists; otherwise - 0.

void SetMaskMeshName ( string mesh_name, bool invalidate = 1 ) #

Sets a mesh to be used as a mask for the world clutter. This mesh should be plane.

Arguments

  • string mesh_name - Path to the *.mesh file.
  • bool invalidate - Invalidate flag. Set true to invalidate all world clutter cells; otherwise, set false. All invalidated cells will be regenerated.

string GetMaskMeshName ( ) #

Returns the name (path) of the current mesh used as a mask for the world clutter. This mesh should be plane.

Return value

Path to the *.mesh file.

void SetMaxScale ( float mean, float spread ) #

Sets the scale for meshes in the areas with high density (according to the mask). With the minimum scale it is possible to automatically render, for example, big trees in the center of the forest. A spread value enables to control the range of scales relative to the mean value.

Arguments

  • float mean - Scale mean value.
  • float spread - Maximum spread value to randomly upscale or downscale objects.

float GetMaxScaleMean ( ) #

Returns the scale mean value for meshes in the areas with high density (according to the mask).

Return value

Scale mean value.

float GetMaxScaleSpread ( ) #

Returns the scale spread value that controls the range of mesh scales in the areas with high density (according to the mask).

Return value

Scale spread value.

void SetMinScale ( float mean, float spread ) #

Sets the scale for meshes in the areas with low density (according to the mask). With the minimum scale it is possible to automatically render, for example, small trees at the forest border. A spread value allows to control the range of scales relative to the mean value.

Arguments

  • float mean - Scale mean value.
  • float spread - Maximum spread value to randomly upscale or downscale objects.

float GetMinScaleMean ( ) #

Returns the scale mean value for meshes in the areas with low density (according to the mask).

Return value

Scale mean value.

float GetMinScaleSpread ( ) #

Returns the scale spread value that controls the range of mesh scales in the areas with low density (according to the mask).

Return value

Scale spread value.

void SetNodesRotation ( vec3 mean, vec3 spread ) #

Sets the rotation of reference nodes along X, Y and Z axes.

Arguments

  • vec3 mean - Mean values of rotation angles in degrees.
  • vec3 spread - Spread values of rotation angles in degrees.

vec3 GetNodesRotationMean ( ) #

Returns the mean value of reference nodes rotation along X, Y and Z axes.

Return value

Mean values of rotation angles in degrees.

vec3 GetNodesRotationSpread ( ) #

Returns the spread value of reference nodes rotation along X, Y and Z axes.

Return value

Spread values of rotation angles in degrees.

void SetOffset ( float mean, float spread ) #

Sets the vertical offset that determines the placement of reference nodes above or below the surface.

Arguments

  • float mean - Mean value of the offset in units.
  • float spread - Spread value of the offset in units.

float GetOffsetMean ( ) #

Returns the current mean value of the vertical offset that determines the placement of reference nodes above or below the surface.

Return value

Mean value of the offset in units.

float GetOffsetSpread ( ) #

Returns the current spread value of the vertical offset that determines the placement of reference nodes above or below the surface.

Return value

Spread value of the offset in units.

void SetReferenceName ( int num, string name ) #

Sets the name of the specified reference node contained in the world clutter.

Arguments

  • int num - The number of the reference node.
  • string name - Name to be updated.

string GetReferenceName ( int num ) #

Returns the name of the reference node contained in the world clutter.

Arguments

  • int num - The number of the reference node among contained in the world clutter.

Return value

Name of the reference node.

void SetReferenceProbability ( int num, float probability ) #

Sets the probability of the occurrence of the specified node reference.

Arguments

  • int num - The number of the reference node.
  • float probability - Probability factor. The provided value is saturated in range [0;1].

float GetReferenceProbability ( int num ) #

Returns the probability of the occurrence of the specified node reference.

Arguments

  • int num - The number of the reference node.

Return value

Probability factor.

int AddReference ( string name ) #

Adds a new reference node to the world clutter.

Arguments

  • string name - Name of the reference node.

Return value

The number of added reference node.

void RemoveReference ( int num ) #

Removes the specified reference node from the world clutter.

Arguments

  • int num - The number of the reference node.

static int type ( ) #

Returns the type of the node.

Return value

World type identifier.

void ClearReferences ( ) #

Deletes all reference nodes from the world clutter.

bool SaveStateReferences ( Stream stream ) #

Saves the state of all reference nodes from the world clutter to the specified stream.

Example using saveStateReferences() and restoreStateReferences() methods:

Source code (C#)
// initialize a node and set its state
WorldClutter worldClutter = new WorldClutter();
worldClutter.SizeX = 500.0f;
worldClutter.SizeY = 500.0f;

// save state
Blob blob_state = new Blob();
worldClutter.SaveStateReferences(blob_state);

// change the node state
worldClutter.SizeY = 700.0f;

// restore state
blob_state.SeekSet(0);	// returning the carriage to the start of the blob
worldClutter.RestoreStateReferences(blob_state);

Arguments

  • Stream stream - Stream instance.

Return value

true if the states of all reference nodes from the world clutter were successfully saved to the specified stream; otherwise, false.

bool RestoreStateReferences ( Stream stream ) #

Restores the state of all reference nodes from the world clutter from the specified stream.

Example using saveStateReferences() and restoreStateReferences() methods:

Source code (C#)
// initialize a node and set its state
WorldClutter worldClutter = new WorldClutter();
worldClutter.SizeX = 500.0f;
worldClutter.SizeY = 500.0f;

// save state
Blob blob_state = new Blob();
worldClutter.SaveStateReferences(blob_state);

// change the node state
worldClutter.SizeY = 700.0f;

// restore state
blob_state.SeekSet(0);	// returning the carriage to the start of the blob
worldClutter.RestoreStateReferences(blob_state);

Arguments

  • Stream stream - Stream instance.

Return value

true if the states of all reference nodes from the world clutter were successfully restored from the specified stream; otherwise, false.
Last update: 2022-12-14
Build: ()