This page has been translated automatically.
Video Tutorials
Interface
Essentials
Advanced
How To
Rendering
Professional (SIM)
UnigineEditor
Interface Overview
Assets Workflow
Version Control
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
Animations-Related Classes
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
VR-Related Classes
Content Creation
Content Optimization
Materials
Material Nodes Library
Miscellaneous
Input
Math
Matrix
Textures
Art Samples
Tutorials

ObjectMeshCluster Class

Warning
The scope of applications for UnigineScript is limited to implementing materials-related logic (material expressions, scriptable materials, brush materials). Do not use UnigineScript as a language for application logic, please consider C#/C++ instead, as these APIs are the preferred ones. Availability of new Engine features in UnigineScript (beyond its scope of applications) is not guaranteed, as the current level of support assumes only fixing critical issues.
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

Members


static ObjectMeshCluster ( string path ) #

ObjectMeshCluster constructor. Creates a mesh cluster with a base mesh loaded from the specified file.

Arguments

  • string path - Path to the base mesh file.

static ObjectMeshCluster ( ) #

ObjectMeshCluster constructor. Creates an empty mesh cluster

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 visibility 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 handled by the mesh cluster are fading out (that is, fewer meshes will be rendered instead of all). The distance is measured starting from the visibility distance.
Notice
In order for a fade distance to be applied, visibility distance should not be infinite.

Return value

Fade distance, in units.

void setMeshPath ( string path ) #

Sets a path to the mesh hadled by the Mesh Cluster. Does not update mesh immediately using the new path. If the mesh is in the procedural mode, it will be reset.

Arguments

  • string path - New path to the source .mesh-file to be set.

string getMeshPath ( ) #

Returns the path to the source .mesh-file of the base mesh handled by Mesh Cluster.

Return value

Path to the source .mesh-file.

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

int getNumMeshes ( ) #

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

Return value

Number of meshes.

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 currently baked into mesh cluster.

void createMeshes ( ) #

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

    void applyMeshProcedural ( Mesh mesh ) #

    Sets the specified mesh as the base mesh for the object. The object must be in the procedural mesh mode.

    Arguments

    • Mesh mesh - Mesh to be applied.

    int 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

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

    int 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

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

    int detachClusterWorldTransformsFromSphere ( WorldBoundSphere bb, Vector<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.
    • Vector<Mat4>& OUT_transforms - Buffer to store transformations of cluster meshes, in world coordinates.
      Notice
      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.

    int getClusterWorldTransformsFromSphere ( WorldBoundSphere bounds, Vector<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.
    • Vector<Mat4>& OUT_transforms - Buffer to store transformations of cluster meshes, in world coordinates.
      Notice
      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.

    int getInstancesFromSphere ( WorldBoundSphere bb, Vector<int>& OUT_instances ) #

    Returns the indices of instances inside the bounding sphere.
    Notice
    The returned list of instance indices is unsorted.

    Arguments

    • WorldBoundSphere bb - Bounding sphere defining the area within which instances are to be collected.
    • Vector<int>& OUT_instances - Vector containing instance indices.
      Notice
      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.

    MeshStatic getMeshInfo ( ) #

    Returns the base mesh that stores data on mesh bounds, surfaces, their number, names, and bounds, but doesn't contain any geometry.
    Notice
    It's highly recommended NOT to edit the returned mesh.

    Return value

    A base static mesh used for the object.

    MeshStatic getMeshForce ( ) #

    Returns the base mesh used for the object. The returned static mesh won't be loaded to VRAM.
    Notice
    It's highly recommended NOT to edit the returned mesh.

    Return value

    A base static mesh used for the object.

    MeshStatic getMeshAsync ( ) #

    Returns the base mesh used for the object asynchronously. This function can be called if the mesh hasn't been loaded yet.
    Notice
    It's highly recommended NOT to edit the returned mesh.

    Return value

    A base static mesh used for the object.

    MeshStatic getMeshForceVRAM ( ) #

    Returns the base mesh used for the object and loads it to video memory (VRAM). At that, the static mesh will also be loaded to memory (RAM).
    Notice
    Loading to VRAM must be performed in the main thread only.

    Return value

    A base static mesh used for the object.

    MeshStatic getMeshAsyncVRAM ( ) #

    Returns the base mesh used for the object asynchronously and loads it to video memory (VRAM). At that, the static mesh will also be loaded to memory (RAM).
    Notice
    Loading to VRAM must be performed in the main thread only.

    Return value

    A base static mesh used for the object.

    int 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).
    Notice
    Loading to VRAM must be performed in the main thread only.

    Return value

    1 if the mesh is loaded successfully, otherwise 0. If the mesh is already loaded to VRAM, 1 will be returned.

    int 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

    1 if the mesh is loaded successfully, otherwise 0. If the mesh is already loaded to RAM, 1 will be returned.

    int loadForceVRAM ( ) #

    Performs force-loading of the mesh to video memory (VRAM) immediately. The forced loading to VRAM is performed in the main thread.
    Notice
    Loading to VRAM must be performed in the main thread only.

    Return value

    1 if the mesh is loaded successfully, otherwise 0. If the mesh is already loaded to VRAM, 1 will be returned.

    int loadForceRAM ( ) #

    Performs force-loading of the mesh to memory (RAM) immediately.

    Return value

    1 if the mesh is loaded successfully, otherwise 0. If the mesh is already loaded to RAM, 1 will be returned.

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

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

    void setMeshProceduralMode ( int meshproceduralmode ) #

    Sets a value indicating if the base 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 base static mesh is possible only if it is in the procedural mode.

    Arguments

    • int meshproceduralmode - 1 to switch the base mesh used for the object to procedural mode; otherwise, 0 - normal mode (the base mesh is streamed from a source file).

    int isMeshProceduralMode ( ) #

    Returns a value indicating if the base 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 base static mesh is possible only if it is in the procedural mode.

    Return value

    1 if the base mesh used for the object is procedural; otherwise, 0 - normal mode (the base mesh is streamed from a source file).

    int isMeshNull ( ) #

    Returns a value indicating if the base mesh used for the object is null (does not exist, unassigned, not loaded, etc.).

    Return value

    1 if the base mesh used for the object is null; otherwise, 0.

    int isMeshLoadedRAM ( ) #

    Returns a value indicating if the base mesh used for the object is loaded to memory (RAM).

    Return value

    1 if the base mesh used for the object is loaded to RAM; otherwise, 0.

    int isMeshLoadedVRAM ( ) #

    Returns a value indicating if the base mesh used for the object is loaded to video memory (VRAM).

    Return value

    1 if the base mesh used for the object is loaded to VRAM; otherwise, 0.

    void setMeshStreamingModeRAM ( int meshstreamingmoderam ) #

    Sets the streaming mode for loading the mesh to memory (RAM).

    Arguments

    • int meshstreamingmoderam - Mesh streaming mode.

    int getMeshStreamingModeRAM ( ) #

    Returns the current streaming mode for loading the mesh to memory (RAM).

    Return value

    Mesh streaming mode.

    void setMeshStreamingModeVRAM ( int meshstreamingmodevram ) #

    Sets the streaming mode for loading the mesh to video memory (VRAM).

    Arguments

    • int meshstreamingmodevram - Mesh streaming mode.

    int getMeshStreamingModeVRAM ( ) #

    Returns the current streaming mode for loading the mesh to video memory (VRAM).

    Return value

    Mesh streaming mode.
    Last update: 2023-11-30
    Build: ()