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

DecalMesh 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: 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 (UnigineScript)
#include <core/unigine.h>

int init() {
	
	DecalMesh decal_mesh;
	
	// create a mesh
	Mesh mesh = new Mesh();
	mesh.addBoxSurface("box_0", 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.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(vec3(0.0f, 0.0f, 5.0f));

	return 1;
}

DecalMesh Class

Members


static DecalMesh ( ) #

Constructor. Creates a new mesh decal.

int setMesh ( Mesh mesh, int unique = 1 ) #

Copies a given source mesh into the current decal mesh.
Source code (UnigineScript)
// create an empty decal mesh
DecalMesh decalMesh = new DecalMesh();
decalMesh.setRadius(8.0f);
decalMesh.setMaterialPath("decal_base_0.mat");
// create a mesh
Mesh mesh = new Mesh("decal.mesh");
// copy the mesh into the decal mesh
decalMesh.setMesh(mesh);

Arguments

  • Mesh mesh - Mesh to be set.
    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.
  • int unique - Unique flag used when you create several objects out of a single Mesh instance:
    • 0 - An instance of source mesh geometry is created. If the source geometry is changed at runtime, its instances will be changed as well.
    • 1 - A copy of source mesh geometry is created and changes made to the source geometry do not affect the mesh.

Return value

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

int getMesh ( Mesh mesh ) #

Copies the current decal mesh into the received mesh. For example, you can obtain geometry of the decal mesh and then change it:
Source code (UnigineScript)
// a decal mesh from which geometry will be obtained
DecalMesh decalMesh = new DecalMesh();
decalMesh.setMeshName("decal.mesh",1);
decalMesh.setRadius(8.0f);
decalMesh.setMaterialPath("decal_base_0.mat");

// create a new mesh
Mesh mesh = new Mesh();
// copy geometry to the created mesh
if (decalMesh.getMesh(mesh)) {
	// do something with the obtained mesh
}
else {
	log.error("Failed to copy a mesh\n");
}

Arguments

  • Mesh mesh - Current mesh.

Return value

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

void setMeshName ( string path, int force_load = 0 ) #

Sets a new name for the mesh and forces loading of the mesh with the new name for the current decal mesh.
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

  • string path - A new name to be set for the mesh.
  • int force_load - Force flag.
    • If 1 is specified, the mesh with the new name will be loaded immediately with the unique flag set to 0.
    • If 0 is specified, only the mesh name will be updated.

void setMeshName ( string name ) #

Sets a name for the mesh.

Arguments

  • string name - New name to be set for the mesh.

string getMeshName ( ) #

Returns a name of the mesh used as a base for the decal.

Return value

Name of the mesh.

void loadMesh ( string path, int unique = 0 ) #

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

Arguments

  • string path - The name of the mesh file.
    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.
  • int unique - Unique flag used when you create several objects out of a single .mesh file:
    • 0 - An instance of source mesh geometry is created. If the source geometry is changed at runtime, its instances will be changed as well.
    • 1 - A copy of source mesh geometry is created and changes made to the source geometry do not affect the mesh.

int saveMesh ( string path ) #

Saves the decal mesh into a file.

Arguments

  • string path - Mesh file name.

Return value

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

static int type ( ) #

Returns a DecalMesh type identifier.

Return value

Type identifier.
Last update: 2022-02-18
Build: ()