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

Unigine.ObjectMeshCluster Class

Inherits from: 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

Properties

int NumMeshes#

The total number of meshes handled by the mesh cluster.

float FadeDistance#

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

float VisibleDistance#

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

string MeshName#

The name of the mesh handled by a mesh cluster.

Members


ObjectMeshCluster ( string path, bool unique = false ) #

ObjectMeshCluster constructor.

Arguments

  • string path - 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 true (1), so a copy of the mesh geometry will be created and changes won't be applied.

int SetMesh ( Mesh mesh ) #

Copies the source mesh into the current mesh.

Arguments

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

Arguments

  • Mesh mesh - Target mesh.

Return value

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

void SetMeshNameForce ( string name ) #

Sets a new path to the mesh handled by the mesh cluster 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 name - Path to the mesh file.

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, mat4 transform ) #

Sets the transformation for the given mesh instance.

Arguments

  • int num - Mesh instance number.
  • mat4 transform - Mesh transformation matrix.

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 GetNumSurfaceTargets ( int surface ) #

Returns the total number of surface targets.

Arguments

  • int surface - Surface number.

Return value

Total number of surface targets.

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.

void ClearMeshes ( ) #

Deletes all meshes currently baked into mesh cluster.

bool CreateMesh ( string path, bool unique = 0 ) #

Creates a mesh.

Arguments

  • string path - 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

true if the mesh is created successfully; otherwise, false.

void CreateMeshes ( 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

  • mat4[] transforms - Transformations vector in world coordinates.

void AppendMeshes ( 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

  • mat4[] transforms - Transformations vector in world coordinates.

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.

bool LoadMesh ( string path ) #

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

Arguments

  • string path - Path to the .mesh file.

Return value

true if the mesh is loaded successfully; otherwise, false.

bool SaveMesh ( string path ) #

Saves the cluster mesh to a .mesh file.

Arguments

  • string path - Path to the .mesh file.

Return value

true if the mesh is saved successfully; otherwise, false.

static int type ( ) #

Returns the type of the node.

Return value

Node type identifier.

bool RemoveClusterTransforms ( WorldBoundBox bb ) #

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

Arguments

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

Return value

true if cluster meshes, found within the specified bounding box are successfully removed; otherwise, false.

bool RemoveClusterTransformsFromSphere ( WorldBoundSphere bb ) #

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

Arguments

  • WorldBoundSphere bb - Bounding sphere defining the area, for which the transformations of cluster meshes are to be collected.

Return value

true if cluster meshes, found within the specified bounding sphere are successfully removed; otherwise, false.

bool DetachClusterTransforms ( WorldBoundBox bb, 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

  • WorldBoundBox bb - Bounding box defining the area, within which the cluster meshes are to be detached from the cluster.
  • mat4[] transforms - Buffer to store transformations of detached cluster meshes.

Return value

true if cluster meshes have been detached from the cluster; otherwise false.

bool DetachClusterWorldTransforms ( WorldBoundBox bb, 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

  • WorldBoundBox bb - Bounding box defining the area, within which the cluster meshes are to be detached from the cluster.
  • mat4[] transforms - Buffer to store transformations of detached cluster meshes.

Return value

true if cluster meshes have been detached from the cluster; otherwise false.

bool DetachClusterWorldTransformsFromSphere ( WorldBoundSphere bb, 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

  • WorldBoundSphere bb - Bounding sphere defining the area, for which the transformations of cluster meshes are to be collected.
  • mat4[] transforms - Buffer to store transformations of cluster meshes, in world coordinates.

Return value

true if cluster meshes have been detached from the cluster; otherwise false.

bool GetClusterTransforms ( WorldBoundBox bounds, 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

  • WorldBoundBox bounds - Bounding box defining the area, for which the transformations of cluster meshes are to be collected.
  • mat4[] transforms - Buffer to store transformations of cluster meshes.

Return value

true, if there are transformations of cluster meshes; or false, if there are no transformations of cluster meshes found.

bool GetClusterWorldTransforms ( WorldBoundBox bounds, 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

  • WorldBoundBox bounds - Bounding box defining the area, for which the transformations of cluster meshes are to be collected.
  • mat4[] transforms - Buffer to store transformations of cluster meshes, in world coordinates.

Return value

true, if there are transformations of cluster meshes; or false, if there are no transformations of cluster meshes within the specified area.

bool GetClusterWorldTransformsFromSphere ( WorldBoundSphere bounds, mat4[] transforms ) #

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

Arguments

  • WorldBoundSphere bounds - Bounding sphere defining the area, for which the transformations of cluster meshes are to be collected.
  • mat4[] transforms - Buffer to store transformations of cluster meshes, in world coordinates.

Return value

true, if there are transformations of cluster meshes; or false, if there are no transformations of cluster meshes within the specified area.

bool GetInstancesFromSphere ( WorldBoundSphere bb, int[] instances ) #

Returns the indices of instances inside the bounding sphere.

Arguments

  • WorldBoundSphere bb - Bounding sphere defining the area within which instances are to be collected.
  • int[] instances - Vector containing instance indices.

Return value

true, if there is at least one instance inside the bounding sphere; or false.
Last update: 2022-12-14
Build: ()