Unigine.ObjectMeshClutter Class
Inherits: | Object |
MeshClutter is used to scatter identical meshes (with the same material applied to their surfaces), as well as randomly scale and orient them. Scattered meshes are baked into one object, which allows for less cluttered spatial tree, reduces the number of texture fetches and speeds up rendering.
Meshes are rendered within a specified
distance from the camera. Further than this distance, nodes fade out and then disappear completely.
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 set of UnigineScript API samples located in the <UnigineSDK>/data/samples/objects/ folder:
ObjectMeshClutter 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 clutter meshes are rendered inside or outside the mask mesh contour.
set
Specifies if clutter meshes should be rendered inside or outside the mask mesh contour.
set value -
0 to render clutter meshes inside the mask mesh contour; 1 to render them outside.
string MaskMeshName#
The name (path) of the current mesh used as a mask for the mesh clutter. this mesh should be plane.
set
Sets a mesh to be used as a mask for the mesh clutter. This mesh should be plane.
set value -
Path to the *.mesh file.
int MaskMaxValue#
The maximum value of the mask application range.
set
Sets the maximum value of the mask application range.
set value -
Maximum mask value, [0;255].
int MaskMinValue#
The minimum value of the mask application range.
set
Sets the minimum value of the mask application range.
set value -
Minimum mask value, [0;255].
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.
string MaskImageName#
The name of a mask image (in R8 format) that defines the placement of meshes.
set
Sets the path to a mask image (in R8 format) that defines the placement of meshes.
set value -
float Angle#
The current angle cosine that defines the slope steepness appropriate for positioning meshes.
set
Sets the angle cosine that defines the slope steepness appropriate for positioning meshes.
set value -
Slope angle cosine. The provided value will be clipped in range [0;1].
float Threshold#
The current density threshold (for a mask) starting from which meshes are rendered if placed dense enough.
set
Sets the density threshold (for a mask) starting from which meshes are rendered if placed dense enough.
set value -
Density threshold. The provided value will be clipped in range [0;1].
float Density#
The current density factor that defines the number of meshes per square unit.
set
Sets the density factor that defines the number of meshes 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 meshes scattered by the mesh clutter.
set
Sets the step for cells used to render mesh clutter.
set value -
Step for clutter cells in units.
float SizeY#
The current length of the mesh clutter along the y-coordinate.
set
Sets the length of the mesh 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 mesh clutter along the x-coordinate.
set
Sets the width of the mesh 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 meshes.
set
Sets the seed for pseudo-random positioning of meshes.
set value -
Number used to initialize a pseudo-random sequence. If a negative value is provided, 0 will be used instead.
int SpawnCount#
The number of cells to be generated.
float FadeDistance#
The current distance up to which meshes scattered by the mesh clutter are fading out (that is, fewer meshes 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 meshes scattered by the mesh clutter will be fading out (that is, fewer meshes 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 of fading for meshes in units. If a negative value is provided, 0 will be used instead.
float VisibleDistance#
The current distance up to which meshes scattered by the mesh clutter are rendered.
set
Sets the distance up to which meshes scattered by the mesh clutter will be rendered.
set value -
Distance of visibility for meshes in units. If a negative value is provided, 0 will be used instead.
bool Intersection#
A value indicating whether meshes 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 meshes 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.
bool Orientation#
A value indicating whether meshes 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 meshes 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.
bool Collision#
A value indicating if collisions with the object should be taken into account.
If the return value is 0 the new geometry will never be generated by collision detection request.
set
Sets a value indicating if collisions with the object should be taken into account.
If the collision parameter is set to 0, the new geometry will never be generated by collision detection request.
set value -
1 to take collisions into account and make the object important for physics; 0 to allow collisions only with already generated geometry.
string MeshName#
The name of the mesh scattered by mesh clutter.
set
Sets a path to the mesh scattered by the mesh clutter. Does not update mesh immediately using the new path, unlike the setMeshNameForce() method.
set value -
Path to the mesh to be set.
Members
static ObjectMeshClutter ( string arg1, bool unique = 0 ) #
ObjectMeshClutter constructor.Arguments
- string arg1 - Name of the mesh file.
- bool unique - When you create several objects out of a single .mesh file, the instance of the mesh geometry is created. If you then change the source geometry, its instances will be changed as well. To avoid this, set the unique flag to 1, so a copy of the mesh geometry will be created and changes won't be applied.
int SetMaskImage ( Image image, bool invalidate = 1 ) #
Sets an image (in R8 format) as a mask, that defines placement of meshes.Arguments
- Image image - Image instance.
- bool invalidate - Invalidate flag. Set 1 to invalidate all mesh 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 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 path to a mask image (in R8 format) that defines the placement of meshes.Arguments
- string image_name - Path to the mask image.
- bool invalidate - Invalidate flag. Set 1 to invalidate all mesh clutter cells; otherwise, set 0. All invalidated cells will be regenerated.
void SetMaskImageName ( string name ) #
Sets the path to a mask image (in R8 format) that defines the placement of meshes.Arguments
- string name
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 mesh 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 mesh clutter. This mesh should be plane.Arguments
- string mesh_name - Path to the *.mesh file.
- bool invalidate - Invalidate flag. Set 1 to invalidate all mesh clutter cells; otherwise, set 0. All invalidated cells will be regenerated.
void SetMaskMeshName ( string name ) #
Sets a mesh to be used as a mask for the mesh clutter. This mesh should be plane.Arguments
- string name - Path to the *.mesh file.
void CreateClutterTransforms ( ) #
Creates transformations for all clutter meshes.void SetTerrainMask ( int mask ) #
Sets a new Landscape Terrain mask to be used to define placement of meshes.Arguments
- int mask - Index of Landscape Terrain mask to be used to define placement of meshes, in the [0; 19] range.
int GetTerrainMask ( ) #
Returns the index of the Landscape Terrain mask currently used to define placement of meshes.Return value
Index of the Landscape Terrain mask currently used to define placement of meshes, in the [0; 19] range.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 you 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.int SetMesh ( Mesh mesh ) #
Copies the source mesh into the current mesh.Arguments
- Mesh mesh - The source mesh to be copied.
Return value
1 if the mesh is copied successfully; otherwise, 0.int GetMesh ( Mesh mesh ) #
Copies the current mesh into the source mesh.Arguments
- Mesh mesh - Source mesh.
Return value
1 if the mesh is copied successfully; otherwise, 0.void SetMeshesRotation ( vec3 mean, vec3 spread ) #
Sets the parameters of pseudo-random rotation of meshes along X, Y and Z axes.Arguments
- vec3 mean - Mean values of meshes rotation angles, in degrees.
- vec3 spread - Maximum spread values of meshes rotation angles, in degrees.
vec3 GetMeshesRotationMean ( ) #
Returns the vector of mean values of meshes rotation along X, Y and Z axes.Return value
Mean values of meshes rotation angles, in degrees.vec3 GetMeshesRotationSpread ( ) #
Returns the vector of spread values of meshes rotation along X, Y and Z axes.Return value
Maximum spread values of meshes rotation angles, in degrees.void SetMeshName ( string name ) #
Sets a path to the mesh scattered by the mesh clutter. Does not update mesh immediately using the new path, unlike the setMeshNameForce() method.Arguments
- string name - Path to the mesh to be set.
void SetMeshNameForce ( string path ) #
Sets a new path to the mesh handled by the mesh clutter and forces mesh creation using the new path. The new mesh is created from the specified path immediately with the unique flag set to 0.Arguments
- string path - Path to the mesh file.
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 you 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.int GetNumSurfaceTargets ( int surface ) #
Returns the total number of surface targets.Arguments
- int surface - Surface number.
Return value
Total number of surface targets.void SetOffset ( float mean, float spread ) #
Sets the vertical offset that determines the placement of meshes 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 meshes 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 meshes above or below the surface.Return value
Spread value of the offset in units.string GetSurfaceTargetName ( int surface, int target ) #
Returns the name of a given surface target.Arguments
- int surface - Surface number.
- int target - Target number.
Return value
Target name.bool CreateMesh ( string name, bool unique = 0 ) #
Creates the clutter mesh with the specified parameters.Arguments
- string name - Mesh name.
- bool unique - When you create several objects out of a single .mesh file, the instance of the mesh geometry is created. If you then change the source geometry, its instances will be changed as well. To avoid this, set the unique flag to 1, so a copy of the mesh geometry will be created and changes won't be applied.
Return value
1 if the mesh is created successfully; otherwise, 0.int FindSurfaceTarget ( string name, int surface ) #
Searches for a surface target with a given name.Arguments
- string name - Target name.
- int surface - Surface number.
Return value
Target number if it exists; otherwise, -1.void FlushMesh ( ) #
Flushes the mesh geometry into the video memory.void Invalidate ( ) #
Invalidates all mesh clutter cells. All invalidated cells will be regenerated.void Invalidate ( WorldBoundBox bounds ) #
Invalidates all mesh 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 mesh clutter cells will be regenerated.
bool LoadMesh ( string name ) #
Loads a new mesh instead of the current mesh from the .mesh file. This function doesn't change the mesh name.Arguments
- string name - Path to the mesh file.
Return value
1 if the mesh is loaded successfully; otherwise, 0.bool SaveMesh ( string name ) #
Saves the mesh into the .mesh format.Arguments
- string name - Path to the mesh file.
Return value
1 if the mesh is saved successfully; otherwise, 0.static int type ( ) #
Returns the node type.Return value
Node type identifier.void ClearClutterExcludes ( ) #
Restores all cells removed by the calls to the setClutterExclude() method. Restored cells will be regenerated.void SetClutterExclude ( WorldBoundBox bounds, int exclude ) #
Removes all cells within the area specified by the given bounding box. Generation of these cells will be skipped. This method can be used to replace some parts of the clutter with modified meshes (e.g., broken trees within the area around the shell crater in the forest).Arguments
- WorldBoundBox bounds - Bounding box, defining the area, where mesh clutter cells will not be generated.
- int exclude - Exclude flag. Set 1 to remove all mesh clutter cells within the area; otherwise, set 0 to restore the removed ones. Restored cells will be regenerated.
bool GetClutterTransforms ( WorldBoundBox bounds, mat4[] transforms, bool precise = 1, bool force = 1 ) #
Collects transformations for all clutter meshes in the generated cells within the area specified by the given bounding box and puts them to the specified buffer.Generation of clutter cells is performed in separate threads. Some of the cells may have their lifetime expired. Therefore, the content of certain cells might be unavailable at the moment, such cells are considered as not generated.
Arguments
- WorldBoundBox bounds - Bounding box, defining the area, for which the transformations of clutter meshes are to be collected.
- mat4[] transforms - Buffer to store transformations of clutter meshes.
- bool precise - Precision flag:
- 1 - transformations will be collected for clutter meshes within the specified bounding box
- 0 - transformations will be collected for clutter meshes within the cells intersected by the specified bounding box
- bool force - Force flag.
- 1 - regenerate all cells within the area, that were not generated, before collecting transformations for the meshes inside them.
- 0 - transformations will be collected only for the meshes inside the clutter cells, that were generated.
Return value
1, if there are transformations of clutter meshes; or 0, if there are no transformations of clutter meshes found.bool GetClutterTransforms ( mat4[] transforms ) #
Collects transformations for all clutter meshes within the generated cells and puts them to the specified buffer.Generation of clutter cells is performed in separate threads. Some of the cells may have their lifetime expired. Therefore, the content of certain cells might be unavailable at the moment, such cells are considered as not generated.
Arguments
- mat4[] transforms - Buffer to store transformations of clutter meshes.
Return value
1, if there are transformations of clutter meshes; or 0, if there are no transformations of clutter meshes found.bool GetClutterWorldTransforms ( WorldBoundBox bounds, mat4[] transforms, bool precise = 1, bool force = 1 ) #
Collects transformations (in world coordinates) for all clutter meshes in the generated cells within the area specified by the given bounding box and puts them to the specified buffer.Generation of clutter cells is performed in separate threads. Some of the cells may have their lifetime expired. Therefore, the content of certain cells might be unavailable at the moment, such cells are considered as not generated.
Arguments
- WorldBoundBox bounds - Bounding box, defining the area, for which the transformations of clutter meshes are to be collected.
- mat4[] transforms - Buffer to store transformations of clutter meshes, in world coordinates.
- bool precise - Precision flag:
- 1 - transformations will be collected for clutter meshes within the specified bounding box
- 0 - transformations will be collected for clutter meshes within the cells intersected by the specified bounding box
- bool force - Force flag.
- 1 - regenerate all cells within the area, that were not generated, before collecting transformations for the meshes inside them.
- 0 - transformations will be collected only for the meshes inside the clutter cells, that were generated.
Return value
1, if there are transformations of clutter meshes; or 0, if there are no transformations of clutter meshes found.bool GetClutterWorldTransforms ( mat4[] transforms ) #
Collects transformations (in world coordinates) for all clutter meshes within the generated cells and puts them to the specified buffer.Generation of clutter cells is performed in separate threads. Some of the cells may have their lifetime expired. Therefore, the content of certain cells might be unavailable at the moment, such cells are considered as not generated.
Arguments
- mat4[] transforms - Buffer to store transformations of clutter meshes, in world coordinates.
Return value
1, if there are transformations of clutter meshes; or 0, if there are no transformations of clutter meshes found.int GetClutterLocalTransforms ( BoundBox bounds, mat4[] transforms, int precise = 1, int force = 1 ) #
Collects transformations (in local coordinates) for all clutter meshes within the generated cells and puts them to the specified buffer.Generation of clutter cells is performed in separate threads. Some of the cells may have their lifetime expired. Therefore, the content of certain cells might be unavailable at the moment, such cells are considered as not generated.
Arguments
- BoundBox bounds - Bounding box, defining the area, for which the transformations of clutter meshes are to be collected.
- mat4[] transforms - Buffer to store transformations of clutter meshes, in local coordinates.
- int precise - Precision flag:
- 1 - transformations will be collected for clutter meshes within the specified bounding box
- 0 - transformations will be collected for clutter meshes within the cells intersected by the specified bounding box
- int force - Force flag.
- 1 - regenerate all cells within the area, that were not generated, before collecting transformations for the meshes inside them.
- 0 - transformations will be collected only for the meshes inside the clutter cells, that were generated.
Return value
1, if there are transformations of clutter meshes; or 0, if there are no transformations of clutter meshes found.Last update:
2020-06-01
Help improve this article
Was this article helpful?
(or select a word/phrase and press Ctrl+Enter)