This page has been translated automatically.
UnigineEditor
Interface Overview
Assets Workflow
Settings and Preferences
Adjusting Node Parameters
Setting Up Materials
Setting Up Properties
Landscape Tool
Using Editor Tools for Specific Tasks
FAQ
编程
Fundamentals
Setting Up Development Environment
Usage Examples
UnigineScript
C++
C#
UUSL (Unified UNIGINE Shader Language)
File Formats
Rebuilding the Engine and Tools
GUI
Double Precision Coordinates
应用程序接口
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
CIGI Client Plugin
Rendering-Related Classes
注意! 这个版本的文档是过时的,因为它描述了一个较老的SDK版本!请切换到最新SDK版本的文档。
注意! 这个版本的文档描述了一个不再受支持的旧SDK版本!请升级到最新的SDK版本。

Unigine::ObjectMeshClutter Class

Header:#include <UnigineObjects.h>
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).

The following samples demonstrate the ObjectMeshClutter class usage:

ObjectMeshClutter Class

Members


static ObjectMeshClutterPtr create(const char * arg1, int unique = 0)

ObjectMeshClutter constructor.

Arguments

  • const char * arg1 - Name of the mesh file.
  • int 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.

Ptr<ObjectMeshClutter> cast(const Ptr<Object> & base)

Casts an ObjectMeshClutter out of the Object instance.

Arguments

  • const Ptr<Object> & base - Pointer to Object.

Return value

Pointer to ObjectMeshClutter.

Ptr<ObjectMeshClutter> cast(const Ptr<Node> & node)

Casts an ObjectMeshClutter out of the Node instance.

Arguments

  • const Ptr<Node> & node - Pointer to Node.

Return value

Pointer to ObjectMeshClutter.

void setAngle(float angle)

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

Arguments

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

float getAngle()

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

Return value

Slope angle cosine.

void setCollision(int collision)

Sets a value indicating if collisions with the object should be taken into account.
Notice
If the collision parameter is set to 0, the new geometry will never be generated by collision detection request.

Arguments

  • int collision - 1 to take collisions into account and make the object important for physics; 0 to allow collisions only with already generated geometry.

int getCollision()

Returns a value indicating if collisions with the object should be taken into account.
Notice
If the return value is 0 the new geometry will never be generated by collision detection request.

Return value

1 if collisions are taken into account; 0 if collisions are allowed only with already generated geometry.

void setDensity(float density)

Sets the density factor that defines the number of meshes 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 meshes per square unit.

Return value

Density factor.

void setFadeDistance(float distance)

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.
Notice
In order for a fade distance to be applied, visibility distance should not be infinite.

Arguments

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

float getFadeDistance()

Returns 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.
Notice
In order for a fade distance to be applied, visibility distance should not be infinite.

Return value

Distance of nodes fading in units.

void setIntersection(int intersection)

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.

Arguments

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

int getIntersection()

Returns a value indicating whether meshes 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 value)

Flip the mask by X axis.

Arguments

  • int value - 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 value)

Flip the mask by Y axis.

Arguments

  • int value - 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(const Ptr<Image> & image, int invalidate = 1)

Sets an image (in R8 format) as a mask, that defines placement of meshes.

Arguments

  • const Ptr<Image> & image - Image smart pointer.
  • int 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(const Ptr<Image> & image)

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

Arguments

  • const Ptr<Image> & image - Image smart pointer.

Return value

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

void setMaskImageName(const char * name, int invalidate = 1)

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

Arguments

  • const char * name - Name (path) of the mask image.
  • int invalidate - Invalidate flag. Set 1 to invalidate all mesh clutter cells; otherwise, set 0. All invalidated cells will be regenerated.

const char * getMaskImageName()

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

Return value

Name (path) of the mask image.

void setMaskInverse(int inverse)

Specifies if clutter meshes should be rendered inside or outside the mask mesh contour.

Arguments

  • int inverse - 0 to render clutter meshes inside the mask mesh contour; 1 to render them outside.

int getMaskInverse()

Returns a flag indicating if clutter meshes are rendered inside or outside the mask mesh contour.

Return value

0 if clutter meshes are rendered inside the mask mesh contour; 1 if outside.

void setMaskMaxValue(int value)

Sets the maximum value of the mask application range.

Arguments

  • int value - Maximum mask value, [0;255].

int getMaskMaxValue()

Returns the maximum value of the mask application range.

Return value

Maximum mask value.

int setMaskMesh(const Ptr<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

  • const Ptr<Mesh> & mesh - Pointer to the mesh.
  • int 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(const Ptr<Mesh> & mesh)

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

Arguments

  • const Ptr<Mesh> & mesh - Pointer to the mesh to copy the current mask mesh to.

Return value

1 if mesh mask exists; otherwise - 0.

void setMaskMeshName(const char * name, int invalidate = 1)

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

Arguments

  • const char * name - Path to the *.mesh file.
  • int invalidate - Invalidate flag. Set 1 to invalidate all mesh clutter cells; otherwise, set 0. All invalidated cells will be regenerated.

const char * getMaskMeshName()

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

Return value

Path to the *.mesh file.

void setMaskMinValue(int value)

Sets the minimum value of the mask application range.

Arguments

  • int value - Minimum mask value, [0;255].

int getMaskMinValue()

Returns the minimum value of the mask application range.

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 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(const Ptr<Mesh> & mesh)

Copies the source mesh into the current mesh.

Arguments

  • const Ptr<Mesh> & mesh - The source mesh to be copied.

Return value

1 if the mesh is copied successfully; otherwise, 0.

int getMesh(const Ptr<Mesh> & mesh)

Copies the current mesh into the source mesh.

Arguments

  • const Ptr<Mesh> & mesh - The source mesh.

Return value

1 if the mesh is copied successfully; otherwise, 0.

void setMeshesRotation(const Math::vec3 & mean, const Math::vec3 & spread)

Sets the parameters of pseudo-random rotation of meshes along X, Y and Z axes.

Arguments

  • const Math::vec3 & mean - Mean values of meshes rotation angles, in degrees.
  • const Math::vec3 & spread - Maximum spread values of meshes rotation angles, in degrees.

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

Math::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(const char * name, int force_load = 0)

Sets a name for the mesh scattered by the mesh clutter and forces creating of the mesh with the new name.

Arguments

  • const char * name - Name to be set for the mesh.
  • int force_load - Force flag.
    • If 1 is specified, the mesh with the new name will be created immediately with the unique flag set to 0.
    • If 0 is specified, only the mesh name will be updated.

const char * getMeshName()

Returns the name of the mesh scattered by mesh clutter.

Return value

Mesh name.

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.

void setOrientation(int orientation)

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

Arguments

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

int getOrientation()

Returns a value indicating whether meshes 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 setSeed(int seed)

Sets the seed for pseudo-random positioning of meshes.

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

Return value

Number used to initialize a pseudo-random sequence.

void setSizeX(float sizex)

Sets the width of the mesh 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 mesh clutter along the X-coordinate.

Return value

X-coordinate width in units.

void setSizeY(float sizey)

Sets the length of the mesh 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 mesh clutter along the Y-coordinate.

Return value

Y-coordinate length in units.

int getSpawnCount()

Returns the number of cells to be generated.

Return value

Number of cells to be generated if the scene generation is not completed; otherwise, 0.

void setStep(float step)

Sets the step for cells used to render mesh clutter.

Arguments

  • float step - Step for clutter cells in units.

float getStep()

Returns the step for cells used to render meshes scattered by the mesh clutter.

Return value

Step for clutter cells in units.

const char * 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.

void setThreshold(float threshold)

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

Arguments

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

float getThreshold()

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

Return value

Density threshold.

void setVisibleDistance(float distance)

Sets the distance up to which meshes scattered by the mesh clutter will be rendered.

Arguments

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

float getVisibleDistance()

Returns the current distance up to which meshes scattered by the mesh clutter are rendered.

Return value

Distance of visibility for meshes in units.

int createMesh(const char * name, int unique = 0)

Creates the clutter mesh with the specified parameters.

Arguments

  • const char * name - Path to the mesh file.
  • int 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(const char * name, int surface)

Searches for a surface target with a given name.

Arguments

  • const char * 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(const UNIGINE_BOUND_BOX & bounds)

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

Arguments

  • const UNIGINE_BOUND_BOX & bounds - Bounding box, defining the area, where mesh clutter cells will be regenerated.

int loadMesh(const char * name)

Loads a new mesh instead of the current mesh from the .mesh file. This function doesn't change the mesh name.

Arguments

  • const char * name - Path to the mesh file.

Return value

1 if the mesh is loaded successfully; otherwise, 0.

int saveMesh(const char * name)

Saves the mesh into a file.

Arguments

  • const char * name - Path to the mesh file.

Return value

1 if the mesh is saved successfully; otherwise, 0.

static int type()

Returns the type of ObjectMeshStatic.

Return value

ObjectMeshStatic type identifier.

void clearClutterExcludes()

Restores all cells removed by the calls to the setClutterExclude() method. Restored cells will be regenerated.

void setClutterExclude(const UNIGINE_BOUND_BOX & 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

  • const UNIGINE_BOUND_BOX & 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.

int getClutterTransforms(const UNIGINE_BOUND_BOX & bounds, Vector< Math::mat4 > & transforms, int precise = 1, int 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.
Notice
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

  • const UNIGINE_BOUND_BOX & bounds - Bounding box, defining the area, for which the transformations of clutter meshes are to be collected.
  • Vector< Math::mat4 > & transforms - Buffer to store transformations of clutter meshes.
  • 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

Number of clutter meshes, for which the transformations were collected; or 0, if there are no clutter meshes within the specified area.

int getClutterTransforms(Vector< Math::mat4 > & transforms)

Collects transformations for all clutter meshes within the generated cells and puts them to the specified buffer.
Notice
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

  • Vector< Math::mat4 > & transforms - Buffer to store transformations of clutter meshes.

Return value

Number of clutter meshes, for which the transformations were collected; or 0, if there are no clutter meshes found.

int getClutterWorldTransforms(const UNIGINE_BOUND_BOX & bounds, Vector< Math::Mat4 > & transforms, int precise = 1, int 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.
Notice
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

  • const UNIGINE_BOUND_BOX & bounds - Bounding box, defining the area, for which the transformations of clutter meshes are to be collected.
  • Vector< Math::Mat4 > & transforms - Buffer to store transformations of clutter meshes, in world 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

Number of clutter meshes, for which the transformations were collected; or 0, if there are no clutter meshes within the specified area.

int getClutterWorldTransforms(Vector< Math::Mat4 > & transforms)

Collects transformations (in world coordinates) for all clutter meshes within the generated cells and puts them to the specified buffer.
Notice
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

  • Vector< Math::Mat4 > & transforms - Buffer to store transformations of clutter meshes, in world coordinates.

Return value

Number of clutter meshes, for which the transformations were collected; or 0, if there are no clutter meshes found.

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.
Last update: 2018-06-04
Build: ()