This page has been translated automatically.
Видеоуроки
Interface
Essentials
Advanced
Подсказки и советы
Основы
Программирование на C#
Рендеринг
Professional (SIM)
Принципы работы
Свойства (properties)
Компонентная Система
Рендер
Физика
Редактор UnigineEditor
Обзор интерфейса
Работа с ассетами
Настройки и предпочтения
Работа с проектами
Настройка параметров ноды
Setting Up Materials
Настройка свойств
Освещение
Sandworm
Использование инструментов редактора для конкретных задач
Расширение функционала редактора
Встроенные объекты
Ноды (Nodes)
Объекты (Objects)
Эффекты
Декали
Источники света
Geodetics
World-ноды
Звуковые объекты
Объекты поиска пути
Players
Программирование
Основы
Настройка среды разработки
Примеры использования
C++
C#
UnigineScript
UUSL (Unified UNIGINE Shader Language)
Плагины
Форматы файлов
Materials and Shaders
Rebuilding the Engine Tools
Интерфейс пользователя (GUI)
Двойная точность координат
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
Работа с контентом
Оптимизация контента
Материалы
Визуальный редактор материалов
Сэмплы материалов
Material Nodes Library
Miscellaneous
Input
Math
Matrix
Textures
Art Samples
Tutorials
Внимание! Эта версия документация УСТАРЕЛА, поскольку относится к более ранней версии SDK! Пожалуйста, переключитесь на самую актуальную документацию для последней версии SDK.
Внимание! Эта версия документации описывает устаревшую версию SDK, которая больше не поддерживается! Пожалуйста, обновитесь до последней версии SDK.

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.

int setMesh ( const Ptr<Mesh> & mesh, bool unique = 1 ) #

Copies a given source mesh into the current decal mesh.
Source code (C++)
// create an empty decal mesh
DecalMeshPtr decalMesh = DecalMesh::create(NULL,8.0f,"decal_base_0");
// create a mesh
MeshPtr mesh = Mesh::create("decal.mesh");
// copy the mesh into the decal mesh
decalMesh->setMesh(mesh);

Arguments

  • const Ptr<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.
  • bool 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 ( const Ptr<Mesh> & mesh ) const#

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 (C++)
// a decal mesh from which geometry will be obtained
DecalMeshPtr decalMesh = DecalMesh::create();
decalMesh->setMeshName("decal.mesh",1);
decalMesh->setRadius(8.0f);
decalMesh->setMaterialPath("decal_base_0.mat");

// create a new mesh
MeshPtr mesh = Mesh::create();
// 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

  • const Ptr<Mesh> & mesh - Current mesh.

Return value

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

void setMeshName ( const char * path, bool 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

  • const char * path - A new name to be set for the mesh.
  • bool 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 ( const char * name ) #

Sets a name for the mesh.

Arguments

  • const char * name - New name to be set for the mesh.

const char * getMeshName ( ) const#

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

Return value

Name of the mesh.

void loadMesh ( const char * path, bool unique = 0 ) #

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

Arguments

  • const char * 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.
  • bool 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 ( const char * path ) const#

Saves the decal mesh into a file.

Arguments

  • const char * 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: 14.12.2022
Build: ()