This page has been translated automatically.
Video Tutorials
Interface
Essentials
Advanced
How To
UnigineEditor
Interface Overview
Assets Workflow
Settings and Preferences
Working With Projects
Adjusting Node Parameters
Setting Up Materials
Setting Up Properties
Lighting
Landscape Tool
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
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.

WorldClutter Class

Warning
The scope of applications for UnigineScript is limited to implementing materials-related logic (material expressions, scriptable materials, brush materials). Do not use UnigineScript as a language for application logic, please consider C#/C++ instead, as these APIs are the preferred ones. Availability of new Engine features in UnigineScript (beyond its scope of applications) is not guaranteed, as the current level of support assumes only fixing critical issues.
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

Members


static 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.

void setAngle ( float angle ) #

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

Arguments

  • float angle - Slope angle cosine. The provided value will be saturated in range [0;1].

float getAngle ( ) #

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

Return value

Slope angle cosine.

void setDensity ( float density ) #

Sets the density factor that defines the amount of reference nodes per square unit.

Arguments

  • float density - Density factor. If a negative value is provided, 0 will be used instead.

float getDensity ( ) #

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

Return value

Density factor.

void setFadeDistance ( float distance ) #

Sets the distance up to which reference nodes will be 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.

Arguments

  • float distance - Distance in units. If a negative value is provided, 0 will be used instead.

float getFadeDistance ( ) #

Returns 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.

Return value

Distance in units.

void setIntersection ( int intersection ) #

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

Arguments

  • int intersection - Positive number to enable intersection; 0 to disable.

int getIntersection ( ) #

Returns 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.

Return value

1 if intersection is enabled; otherwise, 0.

void setMaskFlipX ( int maskflipx ) #

Flip the mask by X axis.

Arguments

  • int maskflipx - Positive value to flip the mask; otherwise, 0.

int getMaskFlipX ( ) #

Returns a flag indicating if a mask is flipped by X axis.

Return value

Positive value if the mask is flipped; otherwise, 0.

void setMaskFlipY ( int maskflipy ) #

Flip the mask by Y axis.

Arguments

  • int maskflipy - Positive value to flip the mask; otherwise, 0.

int getMaskFlipY ( ) #

Returns a flag indicating if a mask is flipped by Y axis.

Return value

Positive value if the mask is flipped; otherwise, 0.

int setMaskImage ( Image image, int invalidate = 1 ) #

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

Arguments

  • Image image - Pointer to the image.
  • int invalidate - Invalidate flag. Set 1 to invalidate all world clutter cells; otherwise, set 0. 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, int 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.
  • int invalidate - Invalidate flag. Set 1 to invalidate all world clutter cells; otherwise, set 0. 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.

void setMaskInverse ( int inverse ) #

Specifies if reference nodes should be rendered inside or outside the mask mesh contour.

Arguments

  • int inverse - 0 to render reference nodes inside the mesh contour; 1 to render them outside.

int getMaskInverse ( ) #

Returns a flag indicating if reference nodes are rendered inside or outside the mask mesh contour.

Return value

0 if reference nodes are rendered inside the mesh contour; 1 if outside.

void setMaskMaxValue ( int value ) #

Sets the maximum mask value for the WorldClutter object.

Arguments

  • int value - Maximum mask value.

int getMaskMaxValue ( ) #

Returns the maximum mask value for the WorldClutter object.

Return value

Maximum mask value.

int setMaskMesh ( Mesh mesh, int 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.
  • int invalidate - Invalidate flag. Set 1 to invalidate all world clutter cells; otherwise, set 0. 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, int 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.
  • int invalidate - Invalidate flag. Set 1 to invalidate all world clutter cells; otherwise, set 0. 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 setMaskMinValue ( int value ) #

Sets the minimum mask value for the WorldClutter object.

Arguments

  • int value - Minimum mask value.

int getMaskMinValue ( ) #

Returns the minimum mask value for the WorldClutter object.

Return value

Minimum mask value.

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

int getNumReferences ( ) #

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

Return value

The number of reference nodes.

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 setOrientation ( int orientation ) #

Sets a value indicating whether reference nodes should be oriented along the normals of the ground (either the terrain or a mesh set as a parent node).

Arguments

  • int orientation - Positive number to enable orientation; 0 to disable.

int getOrientation ( ) #

Returns 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).

Return value

1 if orientation is enabled; otherwise, 0.

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.

void setSeed ( int seed ) #

Sets the seed for pseudo-random positioning of reference nodes.

Arguments

  • int seed - Number used to initialize a pseudo-random sequence. If a negative value is provided, 0 will be used instead.

int getSeed ( ) #

Returns the seed used for pseudo-random positioning of reference nodes.

Return value

Number used to initialize a pseudo-random sequence.

void setSizeX ( float sizex ) #

Sets the width of the world clutter along the X-coordinate.

Arguments

  • float sizex - X-coordinate width in units. If a negative value is provided, 0 will be used instead.

float getSizeX ( ) #

Returns the current width of the world clutter along the X-coordinate.

Return value

X-coordinate width in units.

void setSizeY ( float sizey ) #

Sets the length of the world clutter along the Y-coordinate.

Arguments

  • float sizey - Y-coordinate length in units. If a negative value is provided, 0 will be used instead.

float getSizeY ( ) #

Returns the current length of the world clutter along the Y-coordinate.

Return value

Y-coordinate length in units.

void setSpawnRate ( int rate ) #

Determines how many cells (in which the world clutter is rendered) are updated each frame. High number of updated cells may lead to a performance spike.

Arguments

  • int rate - Number of cells to be updated. If a non-positive value is provided, 1 will be used instead.

int getSpawnRate ( ) #

Returns the number of cells updated each frame. High number of updated cells may lead to a performance spike.

Return value

Number of cells to be updated.

void setStep ( float step ) #

Sets the step for cells used to render node references.

Arguments

  • float step - Step for clutter cells in units.

float getStep ( ) #

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

Return value

Step for clutter cells in units.

void setThreshold ( float threshold ) #

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

Arguments

  • float threshold - Density threshold. The provided value will be saturated in range [0;1].

float getThreshold ( ) #

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

Return value

Density threshold.

void setVisibleDistance ( float distance ) #

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

Arguments

  • float distance - Distance in units. If a negative value is provided, 0 will be used instead.

float getVisibleDistance ( ) #

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

Return value

Distance in units.

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 setCutoutIntersectionMask ( int mask ) #

Sets a new 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:

Arguments

  • int mask - Integer, each bit of which is a mask.

int getCutoutIntersectionMask ( ) #

Returns 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:

Return value

Integer, each bit of which is a mask.

void setCutoutInverse ( int inverse ) #

Sets a value indicating whether the clutter objects should be rendered inside or outside the areas determined by the cutout intersection mask.

Arguments

  • int inverse - 0 to render clutter objects outside the areas determined by the cutout intersection mask; 1 to render the clutter objects inside these areas.

int getCutoutInverse ( ) #

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

Return value

0 if clutter objects are rendered outside the areas determined by the cutout intersection mask; 1 if inside.

void clearReferences ( ) #

Deletes all reference nodes from the world clutter.

int 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 (UnigineScript)
// initialize a node and set its state
WorldClutter worldClutter = new WorldClutter();
worldClutter.setSizeX(500.0f);
worldClutter.setSizeY(500.0f);

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

// change state
worldClutter.setSizeY(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

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

int 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 (UnigineScript)
// initialize a node and set its state
WorldClutter worldClutter = new WorldClutter();
worldClutter.setSizeX(500.0f);
worldClutter.setSizeY(500.0f);

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

// change state
worldClutter.setSizeY(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

1 if the states of all reference nodes from the world clutter were successfully restored from the specified stream; otherwise, 0.
Last update: 2021-12-13
Build: ()