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
Programming
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
API
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

Unigine::ObjectMeshCluster Class

Header: #include <UnigineObjects.h>
Inherits: Object

A MeshCluster class allows you to bake identical meshes (with the same material applied to their surfaces) into one object, which provides less cluttered spatial tree, reduces the number of texture fetches and speeds up rendering.

Meshes are rendered within a specified visibility distance from the camera. When moving away from this distance, meshes fade out and then disappear completely.

See Also#

A set of UnigineScript API samples located in the <UnigineSDK>/data/samples/objects/ folder:

ObjectMeshCluster Class

Members


static ObjectMeshClusterPtr create ( const char * path, int unique = 0 ) #

ObjectMeshCluster constructor.

Arguments

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

static Ptr<ObjectMeshCluster> cast ( const Ptr<Node> & node ) #

Casts an ObjectMeshCluster out of the Node instance.

Arguments

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

Return value

Pointer to ObjectMeshCluster.

static Ptr<ObjectMeshCluster> cast ( const Ptr<Object> & base ) #

Casts an ObjectMeshCluster out of the Object instance.

Arguments

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

Return value

Pointer to ObjectMeshCluster.

void setFadeDistance ( float distance ) #

Sets the distance up to which meshes handled by the mesh cluster will be fading out (that is, fewer meshes will be rendered instead of all). The distance is measured starting from the visible distance. The default is 0. Using fade distance allows the objects to disappear one by one until up to the fade distance only a few left. It makes the disappearing smooth and much less noticeable.

Arguments

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

float getFadeDistance ( ) #

Returns the distance up to which meshes handled by the mesh cluster will be fading out. The default is 0.

Return value

Fading distance for meshes in units.

int setMesh ( const Ptr<Mesh> & mesh ) #

Copies the source mesh into the current mesh.

Arguments

  • const Ptr<Mesh> & mesh - 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 target mesh.

Arguments

  • const Ptr<Mesh> & mesh - Target mesh.

Return value

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

void setMeshName ( const char * name, int force_load = 0 ) #

Sets a path to the mesh handled by the mesh cluster and forces creating of the mesh using the new path.

Arguments

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

void setMeshName ( const char * name ) #

Arguments

  • const char * name - Path to the mesh to be set.

const char * getMeshName ( ) #

Returns the path to the mesh handled by a mesh cluster.

Return value

Path to the mesh.

int addMeshTransform ( ) #

Adds a new mesh instance transformation to the cluster. To set the new added transformation pass the return value of this method to the setMeshTransform() method.

Return value

Number of the last added mesh instance.

void setMeshTransform ( int num, const Math::mat4 & transform ) #

Sets the transformation for the given mesh instance.

Arguments

  • int num - Mesh instance number.
  • const Math::mat4 & transform - Mesh transformation matrix.

Math::mat4 getMeshTransform ( int num ) #

Returns the transformation of the given mesh instance.

Arguments

  • int num - Mesh instance number.

Return value

Mesh transformation matrix.

void removeMeshTransform ( int num ) #

Removes the transformation of the specified mesh instance from the cluster.

Arguments

  • int num - Mesh instance number.

void removeMeshTransformFast ( int num ) #

Removes the transformation of the specified mesh instance from the cluster.

Arguments

  • int num - Mesh instance number.

void updateSpatialTree ( ) #

Updates the spatial tree of the mesh cluster. Spatial tree is updated in the next frame, this method can be used to update the tree immediately.

int getNumMeshes ( ) #

Returns the total number of meshes handled by the mesh cluster.

Return value

Number of meshes.

int getNumSurfaceTargets ( int surface ) #

Returns the total number of surface targets.

Arguments

  • int surface - Surface number.

Return value

Total number of surface targets.

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 setVisibleDistance ( float distance ) #

Sets the distance up to which meshes handled by the mesh cluster will be rendered. The default is infinity (in this case, fade distance will be ignored).

Arguments

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

float getVisibleDistance ( ) #

Returns the distance up to which meshes handled by the mesh cluster are rendered. The default is infinity (in this case, fade distance is ignored).

Return value

Visibility distance for meshes in units.

void clearMeshes ( ) #

Deletes all meshes from the mesh cluster.

int createMesh ( const char * path, int unique = 0 ) #

Creates a mesh.

Arguments

  • const char * path - 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

Returns 1 if the mesh is created successfully; otherwise, 0.

void createMeshes ( const Vector< Math::Mat4 > & transforms ) #

Creates meshes is accordance with the transformations vector (world coordinates) and bakes them into the cluster. All baked meshes are identical to the source mesh and have the same material applied to their surfaces.

Arguments

  • const Vector< Math::Mat4 > & transforms - Transformations vector in world coordinates.

void appendMeshes ( const Vector< Math::Mat4 > & transforms ) #

Appends new meshes with transformations stored in the specified vector (world coordinates) and bakes them into the cluster. All baked meshes are identical to the source mesh and have the same material applied to their surfaces.

Arguments

  • const Vector< Math::Mat4 > & transforms - Transformations vector in world coordinates.

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.

int loadMesh ( const char * path ) #

Loads the mesh for the current mesh from the .mesh file. This function doesn't change the mesh name.

Arguments

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

Return value

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

int saveMesh ( const char * path ) #

Saves the cluster mesh to a .mesh file.

Arguments

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

Return value

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

static int type ( ) #

Returns the type of the node.

Return value

Node type identifier.

int removeClusterTransforms ( const UNIGINE_BOUND_BOX & bb ) #

Removes cluster meshes, found within the specified bounding box, from the cluster.

Arguments

  • const UNIGINE_BOUND_BOX & bb - Bounding box, defining the area, within which the cluster meshes are to be removed from the cluster.

Return value

Number of cluster meshes removed from the cluster; or 0, if there are no cluster meshes found within the specified bounding box.

int detachClusterTransforms ( const UNIGINE_BOUND_BOX & bb, Vector< Math::mat4 > & transforms ) #

Detaches cluster meshes, found within the area specified by the given bounding box, from the cluster and puts their transformations (local coordinates) to the specified buffer.

Arguments

  • const UNIGINE_BOUND_BOX & bb - Bounding box, defining the area, within which the cluster meshes are to be detached from the cluster.
  • Vector< Math::mat4 > & transforms - Buffer to store transformations of detached cluster meshes.

Return value

Number of cluster meshes detached from the cluster; or 0, if there are no cluster meshes found within the specified bounding box.

int detachClusterWorldTransforms ( const UNIGINE_BOUND_BOX & bb, Vector< Math::Mat4 > & transforms ) #

Detaches cluster meshes, found within the area specified by the given bounding box, from the cluster and puts their transformations (world coordinates) to the specified buffer.

Arguments

  • const UNIGINE_BOUND_BOX & bb - Bounding box, defining the area, within which the cluster meshes are to be detached from the cluster.
  • Vector< Math::Mat4 > & transforms - Buffer to store transformations of detached cluster meshes.

Return value

Number of cluster meshes detached from the cluster; or 0, if there are no cluster meshes found within the specified bounding box.

int getClusterTransforms ( const UNIGINE_BOUND_BOX & bounds, Vector< Math::mat4 > & transforms ) #

Collects transformations (local coordinates) for all cluster meshes within the area specified by the given bounding box and puts them to the specified buffer.

Arguments

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

Return value

1, if there are transformations of cluster meshes; or 0, if there are no transformations of cluster meshes found.

int getClusterWorldTransforms ( const UNIGINE_BOUND_BOX & bounds, Vector< Math::Mat4 > & transforms ) #

Collects transformations (world coordinates) for all cluster meshes within the area specified by the given bounding box and puts them to the specified buffer.

Arguments

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

Return value

1, if there are transformations of cluster meshes; or 0, if there are no transformations of cluster meshes within the specified area.
Last update: 2019-07-18