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 MeshPath#
The path to the source .mesh-file of mesh handled by the Mesh Cluster.
bool IsMeshLoadedVRAM#
The value indicating if the source mesh used for the object is loaded to video memory (VRAM).
bool IsMeshLoadedRAM#
The value indicating if the source mesh used for the object is loaded to memory (RAM).
bool IsMeshNull#
The value indicating if the source mesh used for the object is null (does not exist, unassigned, not loaded, etc.).
bool MeshProceduralMode#
The value indicating if the source mesh used for the object is procedural. A procedural mesh is a mesh created via code, such meshes have a specific streaming mode - they are always kept in memory after creation and never unloaded until the object is destroyed via code or the mesh returns to its normal mode (streaming from a source file). Changing of the static mesh is possible only if it is in the procedural mode.
Members
ObjectMeshCluster ( string path ) #
ObjectMeshCluster constructor. Creates a mesh cluster with a source mesh loaded from the specified file.Arguments
- string path - Path to the source mesh file.
ObjectMeshCluster ( ) #
ObjectMeshCluster constructor. Creates an empty mesh clusterint AddMeshTransform ( ) #
Adds a new mesh instance transformation to the Mesh 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 ClearMeshes ( ) #
Deletes all meshes currently baked into mesh cluster.void CreateMeshes ( mat4[] world_transforms ) #
Creates meshes in 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[] world_transforms - Transformations vector in world coordinates.
void AppendMeshes ( mat4[] world_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[] world_transforms - Transformations vector in world coordinates.
bool ApplyMeshProcedural ( Mesh mesh ) #
Sets the specified mesh as the source mesh for the object. The object must be in the procedural mesh mode.ObjectMeshCluster my_mesh_cluster;
// ...
// switch the object to procedural mesh mode
my_mesh_cluster.MeshProceduralMode = true;
// update the source mesh of the "my_mesh_cluster" object via the source_mesh instance
my_mesh_cluster.ApplyMeshProcedural(source_mesh);
Arguments
- Mesh mesh - Mesh to be applied.
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[] OUT_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[]
OUT_transforms - Buffer to store transformations of detached cluster meshes.This output buffer is to be filled by the Engine as a result of executing the method.
Return value
true if cluster meshes have been detached from the cluster; otherwise false.bool DetachClusterWorldTransforms ( WorldBoundBox bb, mat4[] OUT_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[]
OUT_transforms - Buffer to store transformations of detached cluster meshes.This output buffer is to be filled by the Engine as a result of executing the method.
Return value
true if cluster meshes have been detached from the cluster; otherwise false.bool DetachClusterWorldTransformsFromSphere ( WorldBoundSphere bb, mat4[] OUT_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[]
OUT_transforms - Buffer to store transformations of cluster meshes, in world coordinates.This output buffer is to be filled by the Engine as a result of executing the method.
Return value
true if cluster meshes have been detached from the cluster; otherwise false.bool GetClusterTransforms ( WorldBoundBox bounds, mat4[] OUT_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[]
OUT_transforms - Buffer to store transformations of cluster meshes.This output buffer is to be filled by the Engine as a result of executing the method.
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[] OUT_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[]
OUT_transforms - Buffer to store transformations of cluster meshes, in world coordinates.This output buffer is to be filled by the Engine as a result of executing the method.
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[] OUT_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[]
OUT_transforms - Buffer to store transformations of cluster meshes, in world coordinates.This output buffer is to be filled by the Engine as a result of executing the method.
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[] OUT_instances ) #
Returns the indices of instances inside the bounding sphere.The returned list of instance indices is unsorted.
Arguments
- WorldBoundSphere bb - Bounding sphere defining the area within which instances are to be collected.
- int[]
OUT_instances - Vector containing instance indices.This output buffer is to be filled by the Engine as a result of executing the method.
Return value
true, if there is at least one instance inside the bounding sphere; or false.Mesh GetMeshCurrentRAM ( ) #
Returns the current source mesh used for the object and loaded to memory (RAM).Return value
A current source mesh used for the object.MeshRender GetMeshCurrentVRAM ( ) #
Returns the current render mesh used for the object and loaded to video memory (VRAM).Return value
A current render mesh used for the object.Mesh GetMeshForceRAM ( ) #
Returns the source mesh used for the object and loads it to memory (RAM) immediately.Return value
A source mesh used for the object.MeshRender GetMeshForceVRAM ( ) #
Returns the render mesh used for the object and loads it to video memory (VRAM) immediately. At that, the static mesh will also be loaded to memory (RAM).Loading to VRAM must be performed in the main thread only.
Return value
A render mesh used for the object.Mesh GetMeshAsyncRAM ( ) #
Returns the source mesh used for the object and loads it to memory (RAM) asynchronously.Return value
A source mesh used for the object.MeshRender GetMeshAsyncVRAM ( ) #
Returns the render mesh used for the object and loads it to video memory (VRAM) asynchronously. At that, the static mesh will also be loaded to memory (RAM).Loading to VRAM must be performed in the main thread only.
Return value
A render mesh used for the object.Mesh GetMeshProceduralRAM ( ) #
Returns the procedural source mesh used for the object and loads it to memory (RAM) using the specific streaming mode for procedural meshes. A procedural mesh is a mesh created via code, such meshes have a specific streaming mode — they are always kept in memory after creation and never unloaded until the object is destroyed via code or the mesh returns to its normal mode (streaming from a source file). Changing of the static mesh is possible only if it is in the procedural mode.Return value
A procedural source mesh used for the object.MeshRender GetMeshProceduralVRAM ( ) #
Returns the procedural render mesh used for the object and loads it to video memory (VRAM) using the specific streaming mode for procedural meshes. A procedural mesh is a mesh created via code, such meshes have a specific streaming mode — they are always kept in memory after creation and never unloaded until the object is destroyed via code or the mesh returns to its normal mode (streaming from a source file). Changing of the static mesh is possible only if it is in the procedural mode.Return value
A procedural render mesh used for the object.bool LoadAsyncVRAM ( ) #
Asynchronously loads the mesh to video memory (VRAM) if the async streaming mode for meshes is enabled. Otherwise, the forced loading is performed. This method is recommended for implementing your own prefetch system (i.e. asynchronous pre-loading of meshes to video memory before they are used).Loading to VRAM must be performed in the main thread only.
Return value
true if the mesh is loaded successfully, otherwise false. If the mesh is already loaded to VRAM, true will be returned.bool LoadAsyncRAM ( ) #
Asynchronously loads the mesh to memory (RAM) if the async streaming mode for meshes is enabled. Otherwise, the forced loading is performed. This method is recommended for implementing your own prefetch system (i.e. asynchronous pre-loading of meshes to memory before they are used).Return value
true if the mesh is loaded successfully, otherwise false. If the mesh is already loaded to RAM, true will be returned.bool LoadForceVRAM ( ) #
Performs force-loading of the mesh to video memory (VRAM) immediately. The forced loading to VRAM is performed in the main thread.Loading to VRAM must be performed in the main thread only.
Return value
true if the mesh is loaded successfully, otherwise false. If the mesh is already loaded to VRAM, true will be returned.bool LoadForceRAM ( ) #
Performs force-loading of the mesh to memory (RAM) immediately.Return value
true if the mesh is loaded successfully, otherwise false. If the mesh is already loaded to RAM, true will be returned.bool AsyncCalculateNodes ( int surface ) #
Asynchronously calculates the mesh surface internal spatial tree used for quick calculation of collisions and intersections. This method is recommended for implementing your own prefetch system (i.e. asynchronous pre-loading of meshes to memory before they are used).Arguments
- int surface - Mesh surface number.
Return value
true if the internal tree is calculated successfully; otherwise, false.bool AsyncCalculateEdges ( int surface ) #
Asynchronously calculates the edges of the mesh surface geometry. This method is recommended for implementing your own prefetch system (i.e. asynchronous pre-loading of meshes to memory before they are used).Arguments
- int surface - Mesh surface number.
Return value
true if the edges are calculated successfully; otherwise, false.Last update:
2024-11-06
Help improve this article
Was this article helpful?
(or select a word/phrase and press Ctrl+Enter)