This page has been translated automatically.
Video Tutorials
Interface
Essentials
Advanced
How To
Basics
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
Objects-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
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::DecalMesh Class

Header: #include <UnigineDecals.h>
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++)
// AppWorldLogic.h

#include <UnigineLogic.h>
#include <UnigineObjects.h>
#include <UnigineEditor.h>
#include <UnigineDecals.h>

class AppWorldLogic : public Unigine::WorldLogic {
	
public:
	AppWorldLogic();
	virtual ~AppWorldLogic();
	
	virtual int init();
	
	virtual int update();
	virtual int postUpdate();
	virtual int updatePhysics();
	
	virtual int shutdown();
	
	virtual int save(const Unigine::StreamPtr &stream);
	virtual int restore(const Unigine::StreamPtr &stream);

private:
	Unigine::DecalMeshPtr decal_mesh;
};
Source code (C++)
// AppWorldLogic.cpp

#include "AppWorldLogic.h";

using namespace Unigine;

int AppWorldLogic::init()
{
	// create a mesh with a surface (e.g. a box primitive)
	MeshPtr mesh = Mesh::create();
	mesh->addBoxSurface("box_0", Math::vec3(1.0f));

	// create a mesh decal using created mesh and setting its radius to 10, material to "decal_base_0"
	decal_mesh = DecalMesh::create();
	decal_mesh->setMesh(mesh);
	decal_mesh->setRadius(10.0f);
	decal_mesh->setMaterialPath("decal_base_0.mat");

	// set the name and position of the decal
	decal_mesh->setName("Mesh Decal");
	decal_mesh->setWorldPosition(Math::Vec3(0.0f, 0.0f, 5.0f));

	return 1;
}

DecalMesh Class

Members


static DecalMeshPtr create ( ) #

Constructor. Creates a new Mesh Decal.

static DecalMeshPtr create ( const char * path ) #

DecalMesh constructor. Creates a Mesh Decal with a source mesh loaded from the specified file.

Arguments

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

void setMeshPath ( const char * path ) #

Sets a new path to the source mesh for the current decal mesh. If the mesh is in the procedural mode, it will be reset.
Notice
The mesh should contain a single surface. In case if the mesh contains several surfaces, only the one with the 0 index will be used. Thus, the area of the decal will differ from the initial mesh.

Arguments

  • const char * path - New path to the source .mesh-file to be set.

const char * getMeshPath ( ) const#

Returns the path to the source .mesh-file currently used for the decal.

Return value

Path to the source .mesh-file.

static int type ( ) #

Returns a DecalMesh type identifier.

Return value

Type identifier.

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

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

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

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

Return value

A render mesh used for the object.

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

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

Return value

A render mesh used for the object.

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

Ptr<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).
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 setMeshProceduralMode ( bool meshproceduralmode ) #

Sets a 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.

Arguments

  • bool meshproceduralmode - true to switch the source mesh used for the object to procedural mode; otherwise, false - normal mode (the source mesh is streamed from a source file).

bool isMeshProceduralMode ( ) const#

Returns a 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.

Return value

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

bool isMeshNull ( ) const#

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

Return value

true if the source mesh used for the object is null; otherwise, false.

bool isMeshLoadedRAM ( ) const#

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

Return value

true if the source mesh used for the object is loaded to RAM; otherwise, false.

bool isMeshLoadedVRAM ( ) const#

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

Return value

true if the source mesh used for the object is loaded to VRAM; otherwise, false.

bool applyMeshProcedural ( const Ptr<Mesh> & mesh ) #

Sets the specified mesh as the source mesh for the object.
Source code (C++)
DecalMeshPtr my_decal_mesh;
// ...

// switch the object to procedural mesh mode
my_decal_mesh->setMeshProceduralMode(true);

// update the source mesh of the "my_decal_mesh" object via the source_mesh instance
my_decal_mesh->applyMeshProcedural(source_mesh);

Arguments

  • const Ptr<Mesh> & mesh - Source mesh to be applied.

int getStatDrawCalls ( ) const#

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 ( ) const#

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 ( ) const#

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 ( ) const#

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 long getStatFrame ( ) const#

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: 2024-09-03
Build: ()