Unigine.DecalMesh Class
Inherits from: | Decal |
This class describes how to create and modify mesh decals.
See Also#
A set of UnigineScript API samples located in the <UnigineSDK>/data/samples/decals/ folder:
- mesh_00
- mesh_01
- mesh_02
Creating a Mesh Decal#
The following code illustrates how to create a mesh decal, set its parameters and add the node to UnigineEditor.
Source code (C#)
using Unigine;
namespace UnigineApp
{
class AppWorldLogic : WorldLogic
{
private DecalMesh decal_mesh;
public override bool Init()
{
// create a mesh with a surface (e.g. a box primitive)
Mesh mesh = new Mesh();
mesh.addBoxSurface("box_0", new vec3(1.0f));
// create a mesh decal using created mesh and setting its radius to 10, material to "decal_base_0"
decal_mesh = new DecalMesh();
decal_mesh.SetMesh(mesh);
decal_mesh.Radius = 10.0f;
decal_mesh.MaterialPath = "decal_base_0.mat";
// set the name and position of the decal
decal_mesh.setName("Mesh Decal");
decal_mesh.setWorldPosition(new Vec3(0.0f, 0.0f, 5.0f));
return true;
}
public override bool Shutdown()
{
// clear pointer
decal_mesh.clearPtr();
return true;
}
}
}
DecalMesh Class
Properties
string MeshPath#
The path to the source .mesh-file used as a base for the decal.
bool IsMeshLoadedVRAM#
The value indicating if the base mesh used for the object is loaded to video memory (VRAM).
bool IsMeshLoadedRAM#
The value indicating if the base mesh used for the object is loaded to memory (RAM).
bool IsMeshNull#
The value indicating if the base mesh used for the object is null (does not exist, unassigned, not loaded, etc.).
bool MeshProceduralMode#
The 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.
Members
DecalMesh ( ) #
Constructor. Creates a new Mesh Decal.DecalMesh ( string path ) #
DecalMesh constructor. Creates a Mesh Decal with a base mesh loaded from the specified file.Arguments
- string path - Path to the base mesh file.
static int type ( ) #
Returns a DecalMesh type identifier.Return value
Type identifier.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.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).Notice
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 video 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.Notice
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.void ApplyMeshProcedural ( Mesh mesh ) #
Sets the specified mesh as the source mesh for the object.Source code (C#)
DecalMesh my_decal_mesh;
// ...
// switch the object to procedural mesh mode
my_decal_mesh.MeshProceduralMode = true;
// update the source mesh of the "my_decal_mesh" object via the source_mesh instance
my_decal_mesh.ApplyMeshProcedural(source_mesh);
Arguments
- Mesh mesh - Source mesh to be applied.
int GetStatDrawCalls ( ) #
Returns the number of draw calls (DIP) for the decal during the last frame.Return value
Number of draw calls (DIP) for the decal during the last frame.int GetStatDrawCountViewport ( ) #
Returns the number of times the decal was drawn in the viewport last frame.Return value
Number of times the decal was drawn in the viewport last frame.int GetStatDrawCountReflection ( ) #
Returns the number of times the decal was drawn during reflections rendering in the last frame.Return value
Number of times the decal was drawn during rendering in the last frame.int GetStatDrawCountShadow ( ) #
Returns the number of times the decal was drawn during shadows rendering in the last frame.Return value
Number of times the decal was drawn during shadows rendering in the last frame.long GetStatFrame ( ) #
Returns the number of Engine frame, in which the decal was drawn last time.Return value
Number of frame, in which the decal was drawn last time.Last update:
2023-12-19
Help improve this article
Was this article helpful?
(or select a word/phrase and press Ctrl+Enter)