Unigine.WorldClutter Class
Inherits: | 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#
A value indicating if the clutter objects is rendered inside or outside the areas determined by the cutout intersection mask.
set
Sets a value indicating whether the clutter objects should be rendered inside or outside the areas determined by the cutout intersection mask.
set value -
0 to render clutter objects outside the areas determined by the cutout intersection mask; 1 to render the clutter objects inside these areas.
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).
To set intersection masks the following methods can be used:
- for decals use getIntersectionMask()
- for objects use getIntersectionMask()
set
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).
To set intersection masks the following methods can be used:
- for decals use getIntersectionMask()
- for objects use getIntersectionMask()
set value -
Integer, each bit of which is a mask.
int MaskInverse#
A flag indicating if reference nodes are rendered inside or outside the mask mesh contour.
set
Specifies if reference nodes should be rendered inside or outside the mask mesh contour.
set value -
0 to render reference nodes inside the mesh contour; 1 to render them outside.
int MaskMaxValue#
The maximum mask value for the worldclutter object.
set
Sets the maximum mask value for the WorldClutter object.
set value -
Maximum mask value.
int MaskMinValue#
The minimum mask value for the worldclutter object.
set
Sets the minimum mask value for the WorldClutter object.
set value -
Minimum mask value.
int MaskFlipY#
A flag indicating if a mask is flipped by y axis.
set
Flip the mask by Y axis.
set value -
Positive value to flip the mask; otherwise, 0.
int MaskFlipX#
A flag indicating if a mask is flipped by x axis.
set
Flip the mask by X axis.
set value -
Positive value to flip the mask; otherwise, 0.
float Angle#
The current angle cosine that defines the slope steepness appropriate for positioning nodes.
set
Sets the angle cosine that defines the slope steepness appropriate for positioning nodes.
set value -
Slope angle cosine. The provided value will be saturated in range [0;1].
float Threshold#
The current density threshold (for a mask) starting from which reference nodes are rendered if placed dense enough.
set
Sets the density threshold (for a mask) starting from which reference nodes are rendered if placed dense enough.
set value -
Density threshold. The provided value will be saturated in range [0;1].
float Density#
The current density factor that defines the number of reference nodes per square unit.
set
Sets the density factor that defines the amount of reference nodes per square unit.
set value -
Density factor. If a negative value is provided, 0 will be used instead.
float Step#
The step for cells used to render node references contained in the world clutter.
set
Sets the step for cells used to render node references.
set value -
Step for clutter cells in units.
float SizeY#
The current length of the world clutter along the y-coordinate.
set
Sets the length of the world clutter along the Y-coordinate.
set value -
Y-coordinate length in units. If a negative value is provided, 0 will be used instead.
float SizeX#
The current width of the world clutter along the x-coordinate.
set
Sets the width of the world clutter along the X-coordinate.
set value -
X-coordinate width in units. If a negative value is provided, 0 will be used instead.
int Seed#
The seed used for pseudo-random positioning of reference nodes.
set
Sets the seed for pseudo-random positioning of reference nodes.
set value -
Number used to initialize a pseudo-random sequence. If a negative value is provided, 0 will be used instead.
int SpawnRate#
The number of cells updated each frame. high number of updated cells may lead to a performance spike.
set
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.
set value -
Number of cells to be updated. If a non-positive value is provided, 1 will be used instead.
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.
In order for a fade distance to be applied, visibility distance should not be infinite.
set
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.
In order for a fade distance to be applied, visibility distance should not be infinite.
set value -
Distance in units. If a negative value is provided, 0 will be used instead.
float VisibleDistance#
The current distance up to which all the reference nodes will be rendered. the distance is measured from the camera.
set
Sets the distance up to which all the reference nodes will be rendered. The distance is measured from the camera.
set value -
Distance in units. If a negative value is provided, 0 will be used instead.
int Intersection#
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.
set
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.
set value -
Positive number to enable intersection; 0 to disable.
int Orientation#
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).
set
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).
set value -
Positive number to enable orientation; 0 to disable.
int NumReferences#
The total number of reference nodes contained in the world clutter.
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.
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 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, 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 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.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 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, 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 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 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.Arguments
- Stream stream - Stream instance.
bool RestoreStateReferences ( Stream stream ) #
Restores the state of all reference nodes from the world clutter from the specified stream.Arguments
- Stream stream - Stream instance.
Last update:
2020-04-10
Help improve this article
Was this article helpful?
(or select a word/phrase and press Ctrl+Enter)