This page has been translated automatically.
Видеоуроки
Interface
Essentials
Advanced
Подсказки и советы
Основы
Программирование на C#
Рендеринг
Professional (SIM)
Принципы работы
Свойства (properties)
Компонентная Система
Рендер
Физика
Редактор UnigineEditor
Обзор интерфейса
Работа с ассетами
Настройки и предпочтения
Работа с проектами
Настройка параметров ноды
Setting Up Materials
Настройка свойств
Освещение
Landscape Tool
Sandworm
Использование инструментов редактора для конкретных задач
Расширение функционала редактора
Встроенные объекты
Ноды (Nodes)
Объекты (Objects)
Эффекты
Декали
Источники света
Geodetics
World Nodes
Звуковые объекты
Объекты поиска пути
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
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::ObjectMeshStatic Class

Header: #include <UnigineObjects.h>
Inherits from: Object

This class is used for handling static meshes.

See Also#

A set UnigineScript API samples located in the <UnigineSDK>/data/samples/objects/ folder:

ObjectMeshStatic Class

Enums

LIGHTMAP_QUALITY#

Lightmap baking quality preset to be used.
NameDescription
LIGHTMAP_QUALITY_GLOBAL = 0Global quality preset set in the Bake Lighting settings.
LIGHTMAP_QUALITY_DRAFT = 1Draft quality preset for lightmaps.
LIGHTMAP_QUALITY_LOW = 2Low quality preset for lightmaps.
LIGHTMAP_QUALITY_MEDIUM = 3Medium quality preset for lightmaps.
LIGHTMAP_QUALITY_HIGH = 4High quality preset for lightmaps.
LIGHTMAP_QUALITY_ULTRA = 5Ultra quality preset for lightmaps.

LIGHTMAP_MODE#

NameDescription
LIGHTMAP_MODE_UNIQUE = 0Bake a unique lightmap texture for the surface.
LIGHTMAP_MODE_CUSTOM = 1Use a custom lightmap texture for the surface.
LIGHTMAP_MODE_SURFACE = 2Reuse an already baked lightmap texture from another surface. Can be used for LODs.

Members


static ObjectMeshStaticPtr create ( const Ptr<Mesh> & mesh ) #

ObjectMeshStatic constructor. Creates a new mesh object from a given file.

Arguments

  • const Ptr<Mesh> & mesh - A mesh smart pointer.

static ObjectMeshStaticPtr create ( const char * path, bool unique = 0 ) #

ObjectMeshStatic constructor. Creates a new mesh object from a given file.

Arguments

  • const char * path - Path to the mesh file.
  • bool unique - When you create several objects out of a single .mesh file, the instance of the mesh geometry is created. If you then change the source geometry, its instances will be changed as well. To avoid this, set the unique flag to true (1), so a copy of the mesh geometry will be created and changes won't be applied.

void setCIndex ( int num, int index, int surface ) #

Sets the new coordinate index for the given vertex of the given surface.

Arguments

  • int num - Vertex number in the range from 0 to the total number of coordinate indices for the given surface.
    Notice
    To get the total number of coordinate indices for the given surface, use the getNumCIndices() method.
  • int index - Coordinate index to be set in the range from 0 to the total number of coordinate vertices for the given surface.
    Notice
    To get the total number of coordinate vertices for the given surface, use the getNumVertex() method.
  • int surface - Mesh surface number.

int getCIndex ( int num, int surface ) const#

Returns the coordinate index for the given vertex of the given surface.

Arguments

  • int num - Vertex number in the range from 0 to the total number of coordinate indices for the given surface.
    Notice
    To get the total number of coordinate indices for the given surface, use the getNumCIndices() method.
  • int surface - Mesh surface number.

Return value

Coordinate index.

void setColor ( int num, const Math::vec4 & color, int surface ) #

Sets the color for the given triangle vertex of the given surface.

Arguments

  • int num - Triangle vertex number in the range from 0 to the total number of vertex color entries of the given surface.
    Notice
    To get the total number of vertex color entries for the surface, call the getNumColors() method.
  • const Math::vec4 & color - Vertex color to be set.
  • int surface - Mesh surface number.

Math::vec4 getColor ( int num, int surface ) const#

Returns the color of the given triangle vertex of the given surface.

Arguments

  • int num - Triangle vertex number in the range from 0 to the total number of vertex color entries of the given surface.
    Notice
    To get the total number of vertex color entries for the surface, call the getNumColors() method.
  • int surface - Mesh surface number.

Return value

Vertex color.

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

Copies the current mesh into the destination mesh. For example, you can obtain geometry of the static mesh and then change it:
Source code (C++)
// a static mesh from which geometry will be obtained
ObjectMeshStaticPtr staticMesh = ObjectMeshStatic::create("box.mesh");
// create a new mesh
MeshPtr mesh = Mesh::create();
// copy geometry to the created mesh
if (staticMesh->getMesh(mesh)) {
	// do something with the obtained mesh
}
else {
	Log::error("Failed to copy a mesh\n");
}

Arguments

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

Return value

true if the mesh is copied successfully; otherwise, false.

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

Copies a given source mesh into the current mesh. For example, you can copy a mesh into another one as follows:
Source code (C++)
// create ObjectMeshStatic instances 
ObjectMeshStaticPtr staticMesh = ObjectMeshStatic::create("box.mesh");
ObjectMeshStaticPtr staticMesh_2 = ObjectMeshStatic::create("capsule.mesh");

// create a Mesh instance
MeshPtr firstMesh = Mesh::create();

// get the mesh of the ObjectMeshStatic and copy it to the Mesh class instance
staticMesh->getMesh(firstMesh);

// put the firstMesh mesh to the staticMesh_2 instance
staticMesh_2->setMesh(firstMesh);

Arguments

  • const Ptr<Mesh> & mesh - Source mesh to be copied.
  • bool unique - Unique flag used when you create several objects out of a single Mesh instance :
    • false (0) - An instance of source mesh geometry is created. If the source geometry is changed at runtime, its instances will be changed as well.
    • true (1) - A copy of source mesh geometry is created and changes made to the source geometry do not affect the mesh.

Return value

true if the mesh is copied successfully; otherwise, false.

void setMeshName ( const char * name ) #

Sets the new path to the mesh. Does not update mesh immediately using the new path, unlike the setMeshNameForce() method

Arguments

  • const char * name - Path to the mesh file.

void setMeshNameForce ( const char * path ) #

Sets the new path to the mesh and forces mesh creation using the new path. The new mesh is created from the specified path immediately with the unique flag set to 0.

Arguments

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

const char * getMeshName ( ) const#

Returns the path to the current mesh file.

Return value

Path to the mesh file.

int getMeshSurface ( const Ptr<Mesh> & mesh, int surface, int target = -1 ) const#

Copies the specified mesh surface into the destination mesh.

Arguments

  • const Ptr<Mesh> & mesh - Destination mesh pointer to copy a surface into.
  • int surface - Number of the mesh surface to be copied.
  • int target - Number of the surface target to be copied. The default value is -1 (all targets).

Return value

Number of the added mesh surface.

Math::vec3 getNormal ( int num, int surface, int target = 0 ) const#

Returns the normal for the given triangle vertex of the given surface target.

Arguments

  • int num - Triangle vertex number in the range from 0 to the total number of vertex tangent entries of the given surface target.
    Notice
    Vertex normals are calculated using vertex tangents. To get the total number of vertex tangent entries for the surface target, call the getNumTangents() method.
  • int surface - Mesh surface number.
  • int target - Surface target number. The default value is 0.

Return value

Vertex normal.

int getNumCIndices ( int surface ) const#

Returns the number of coordinate indices for the given mesh surface.

Arguments

  • int surface - Mesh surface number.

Return value

Number of coordinate indices.

int getNumColors ( int surface ) const#

Returns the total number of vertex color entries for the given surface.
Notice
Colors are specified for triangle vertices.

Arguments

  • int surface - Surface number.

Return value

Number of vertex color entries.

int getNumSurfaceTargets ( int surface ) const#

Returns the number of surface targets for the given mesh surface.

Arguments

  • int surface - Mesh surface number.

Return value

Number of surface targets.

int getNumTangents ( int surface ) const#

Returns the number of vertex tangent entries of the given mesh surface.
Notice
Tangents are specified for triangle vertices.

Arguments

  • int surface - Mesh surface number.

Return value

Number of surface tangent vectors.

void setNumTexCoords0 ( int num, int surface ) #

Sets the number of the first UV map texture coordinates for the given mesh surface.
Notice
First UV map texture coordinates are specified for triangle vertices.

Arguments

  • int num - Number of the first UV map texture coordinates to be set.
  • int surface - Mesh surface number.

int getNumTexCoords0 ( int surface ) const#

Returns the number of the first UV map texture coordinates for the given mesh surface.
Notice
First UV map texture coordinates are specified for triangle vertices.

Arguments

  • int surface - Mesh surface number.

Return value

Number of the first UV map texture coordinates.

void setNumTexCoords1 ( int num, int surface ) #

Sets the number of the second UV map texture coordinates for the given mesh surface.
Notice
Second UV map texture coordinates are specified for triangle vertices.

Arguments

  • int num - Number of the second UV map texture coordinates to be set.
  • int surface - Mesh surface number.

int getNumTexCoords1 ( int surface ) const#

Returns the number of the second UV map texture coordinates for the given mesh surface.
Notice
Second UV map texture coordinates are specified for triangle vertices.

Arguments

  • int surface - Mesh surface number.

Return value

Number of the second UV map texture coordinates.

int getNumTIndices ( int surface ) const#

Returns the number of triangle indices for the given mesh surface.

Arguments

  • int surface - Mesh surface number.

Return value

Number of triangle indices.

int getNumVertex ( int surface ) const#

Returns the number of coordinate vertices for the given mesh surface.

Arguments

  • int surface - Mesh surface number.

Return value

Number of the surface vertices.

const char * getSurfaceTargetName ( int surface, int target ) const#

Returns the name of the target for the given mesh surface by the target number.

Arguments

  • int surface - Mesh surface number.
  • int target - Number of the surface target.

Return value

Surface target name.

void setSurfaceTransform ( const Math::mat4 & transform, int surface, int target = -1 ) #

Updates the transformation of the specified mesh surface.

Arguments

  • const Math::mat4 & transform - Transformation matrix.
  • int surface - Mesh surface number.
  • int target - Number of the surface target. The default value is -1 (all targets).

void setTangent ( int num, const Math::quat & tangent, int surface, int target = 0 ) #

Sets the new tangent for the given triangle vertex of the given surface target.

Arguments

  • int num - Triangle vertex number in the range from 0 to the total number of vertex tangent entries of the given surface.
    Notice
    To get the total number of vertex tangent entries for the surface, call the getNumTangents() method.
  • const Math::quat & tangent - Tangent to be set.
  • int surface - Mesh surface number.
  • int target - Surface target number. The default value is 0.

Math::quat getTangent ( int num, int surface, int target = 0 ) const#

Returns the tangent for the given triangle vertex of the given surface target.

Arguments

  • int num - Triangle vertex number in the range from 0 to the total number of vertex tangent entries of the given surface.
    Notice
    To get the total number of vertex tangent entries for the surface, call the getNumTangents() method.
  • int surface - Mesh surface number.
  • int target - Surface target number. The default value is 0.

Return value

Vertex tangent.

void setTexCoord0 ( int num, const Math::vec2 & texcoord, int surface ) #

Sets first UV map texture coordinates for the given triangle vertex of the given surface.

Arguments

  • int num - Triangle vertex number in the range from 0 to the total number of first UV map texture coordinate entries of the given surface.
    Notice
    To get the total number of first UV map texture coordinate entries for the surface, call the getNumTexCoords0() method.
  • const Math::vec2 & texcoord - First UV map texture coordinates to be set.
  • int surface - Mesh surface number.

Math::vec2 getTexCoord0 ( int num, int surface ) const#

Returns first UV map texture coordinates for the given triangle vertex of the given surface.

Arguments

  • int num - Triangle vertex number in the range from 0 to the total number of first UV map texture coordinate entries of the given surface.
    Notice
    To get the total number of first UV map texture coordinate entries for the surface, call the getNumTexCoords0() method.
  • int surface - Mesh surface number.

Return value

First UV map texture coordinates.

void setTexCoord1 ( int num, const Math::vec2 & texcoord, int surface ) #

Sets second UV map texture coordinates for the given triangle vertex of the given surface.

Arguments

  • int num - Triangle vertex number in the range from 0 to the total number of second UV map texture coordinate entries of the given surface.
    Notice
    To get the total number of second UV map texture coordinate entries for the surface, call the getNumTexCoords1() method.
  • const Math::vec2 & texcoord - Second UV map texture coordinates to be set.
  • int surface - Mesh surface number.

Math::vec2 getTexCoord1 ( int num, int surface ) const#

Returns second UV map texture coordinates for the given triangle vertex of the given surface.

Arguments

  • int num - Triangle vertex number in the range from 0 to the total number of second UV map texture coordinate entries of the given surface.
    Notice
    To get the total number of second UV map texture coordinate entries for the surface, call the getNumTexCoords1() method.
  • int surface - Mesh surface number.

Return value

Second UV map texture coordinates.

void setTIndex ( int num, int index, int surface ) #

Sets the new triangle index for the given vertex of the given surface.

Arguments

int getTIndex ( int num, int surface ) const#

Returns the triangle index for the given surface by using the index number.

Arguments

Return value

Triangle index.

void setVertex ( int num, const Math::vec3 & vertex, int surface, int target = 0 ) #

Sets the coordinates of the given coordinate vertex of the given surface target.

Arguments

  • int num - Coordinate vertex number in the range from 0 to the total number of coordinate vertices for the given surface.
    Notice
    To get the total number of coordinate vertices for the given surface, use the getNumCVertex() method.
  • const Math::vec3 & vertex - Vertex coordinates to be set.
  • int surface - Mesh surface number.
  • int target - Surface target number. The default value is 0.

Math::vec3 getVertex ( int num, int surface, int target = 0 ) const#

Returns coordinates of the given coordinate vertex of the given surface target.

Arguments

  • int num - Coordinate vertex number in the range from 0 to the total number of coordinate vertices for the given surface.
    Notice
    To get the total number of coordinate vertices for the given surface, use the getNumCVertex() method.
  • int surface - Mesh surface number.
  • int target - Surface target number. The default value is 0.

Return value

Vertex coordinates.

int addEmptySurface ( const char * name, int num_vertex, int num_indices ) #

Appends a new empty surface to the current mesh.

Arguments

  • const char * name - The name of the new surface.
  • int num_vertex - Number of the new surface vertices.
  • int num_indices - Number of the new surface indices.

Return value

Number of the appended surface.

int addMeshSurface ( int dest_surface, const Ptr<ObjectMeshStatic> & mesh, int surface, int target = -1 ) #

Appends a new mesh surface to the current mesh.

Arguments

  • int dest_surface - Number of the surface to copy the mesh to.
  • const Ptr<ObjectMeshStatic> & mesh - Source ObjectMeshStatic to copy a surface from.
  • int surface - Mesh surface number to copy.
  • int target - Mesh target number to copy. The default value is -1 (all targets).

Return value

Number of the last added surface.

int addMeshSurface ( const char * name, const Ptr<Mesh> & mesh, int surface, int target = -1 ) #

Appends a new mesh surface to the current mesh.

Arguments

  • const char * name - Name of the new surface of the current mesh.
  • const Ptr<Mesh> & mesh - Mesh pointer to copy a surface from.
  • int surface - Mesh surface number to copy.
  • int target - Mesh target number to copy. The default value is -1 (all targets).

Return value

Number of the last added surface.

int addMeshSurface ( const char * name, const Ptr<ObjectMeshStatic> & mesh, int surface, int target = -1 ) #

Appends a new mesh surface to the current mesh.

Arguments

  • const char * name - Name of the new surface of the current mesh.
  • const Ptr<ObjectMeshStatic> & mesh - Mesh pointer to copy a surface from.
  • int surface - Mesh surface number to copy.
  • int target - Mesh target number to copy. The default value is -1 (all targets).

Return value

Number of the last added surface.

int addSurfaceTarget ( int surface, const char * name = 0 ) #

Adds a new target to the specified surface of the current mesh.

Arguments

  • int surface - Surface number.
  • const char * name - The name of the new target.

Return value

Number of the added target.

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

Creates the static mesh with the specified parameters.

Arguments

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

Return value

true if the mesh is created successfully; otherwise - false.

int findSurfaceTarget ( const char * name, int surface ) const#

Searches for the target number by the target name.

Arguments

  • const char * name - The name of the target.
  • int surface - Mesh surface number.

Return value

Target number if it is exists; otherwise, -1.

void flushMesh ( ) #

Flushes the mesh geometry into the video memory.

bool loadMesh ( const char * path ) #

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

Arguments

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

Return value

true if the mesh is loaded successfully; otherwise, false.

bool saveMesh ( const char * path ) const#

Saves the mesh to the .mesh format.
Notice
Before saving the mesh to a file, you should set a name for it via the setMeshName() method.
Source code (C++)
// setting mesh name from the desired path
UGUID &guid = Unigine::FileSystem::getGUID(path);
object_mesh_static->setMeshName(guid.getFileSystemString());

// saving the mesh to the desired path
object_mesh_static->saveMesh(path);

Arguments

  • const char * path - Path to the file, to which the mesh is to be saved.

Return value

true if the mesh is saved successfully; otherwise, false.

static int type ( ) #

Returns the type of the node.

Return value

Node type identifier.

void updateSurfaceBounds ( int surface = -1 ) #

Updates mesh bounds. This method is to be called to recalculate bounds after changing a mesh surface (e.g. modifying positions of coordinate vertices).

Arguments

  • int surface - Surface number (use -1 for all surfaces).

Ptr<MeshStatic> getMeshStatic ( ) const#

Returns a MeshStatic class instance for the object.

Return value

MeshStatic class instance for the object.

bool isFlushed ( ) const#

Returns a value indicating if vertex data of the mesh was flushed (create/upload operation) to video memory.

Return value

true if vertex data of the mesh was flushed (create/upload operation) to video memory; otherwise, false.

void setLightmapEnabled ( bool enabled, int surface ) #

Sets a value indicating if lightmapping is to be enabled for the surface with the specified number.

Arguments

  • bool enabled - true to enable lightmapping for the surface with the specified number, or false - to disable.
  • int surface - Mesh surface number.

bool isLightmapEnabled ( int surface ) const#

Returns a value indicating if lightmapping is enabled for the surface with the specified number.

Arguments

  • int surface - Mesh surface number.

Return value

true if lightmapping is enabled for the surface with the specified number;otherwise, false.

void setLightmapMode ( ObjectMeshStatic::LIGHTMAP_MODE mode, int surface ) #

Sets a new lightmap mode for the surface with the specified number.

Arguments

ObjectMeshStatic::LIGHTMAP_MODE getLightmapMode ( int surface ) const#

Returns the current lightmap mode for the surface with the specified number.

Arguments

  • int surface - Mesh surface number.

Return value

Current lightmap mode for the surface with the specified number. One of the LIGHTMAP_MODE values.

void setLightmapTextureSurface ( int texture_surface, int surface ) #

Sets a new source mesh surface number for the surface with the specified number. A lightmap texture generated for the source mesh surface shall be used for the specified surface (available only when the lightmap mode for the surface is set to LIGHTMAP_MODE_SURFACE mode. This can be used as optimization for LODs.

Arguments

  • int texture_surface - Source mesh surface number.
  • int surface - Mesh surface number.

int getLightmapTextureSurface ( int surface ) const#

Returns the current source mesh surface number for the surface with the specified number. A lightmap texture generated for the source mesh surface is used for the specified surface (available only when the lightmap mode for the surface is set to LIGHTMAP_MODE_SURFACE mode. This can be used as optimization for LODs.

Arguments

  • int surface - Mesh surface number.

Return value

Source mesh surface number.

bool isLightmapCompression ( int surface ) #

Returns a value indicating if the lightmap texture baked for the surface with the specified number is to be compressed. Compressed lightmaps are lightweight, but please note that some compression artifacts may appear.

Arguments

  • int surface - Mesh surface number.

Return value

true if the lightmap texture baked for the surface with the specified number is to be compressed; otherwise, false.

void setLightmapCompression ( bool enabled, int surface ) #

Sets a value indicating if the lightmap texture baked for the surface with the specified number is to be compressed. Compressed lightmaps are lightweight, but please note that some compression artifacts may appear.

Arguments

  • bool enabled
  • int surface - Mesh surface number.

void setLightmapQuality ( ObjectMeshStatic::LIGHTMAP_QUALITY quality, int surface ) #

Sets a new lightmap baking quality preset for the surface with the specified number.

Arguments

ObjectMeshStatic::LIGHTMAP_QUALITY getLightmapQuality ( int surface ) const#

Returns the current lightmap baking quality preset for the surface with the specified number.

Arguments

  • int surface - Mesh surface number.

Return value

Current lightmap baking quality preset for the surface with the specified number. One of the LIGHTMAP_QUALITY values.

void setLightmapTexturePath ( const char * path, int surface ) #

Sets a new path to the baked lightmap texture to be used for the surface with the specified number. You can use this method to specify a lightmap texture generated in a third-party software.

Arguments

  • const char * path - Path to the baked lightmap texture to be used for the surface with the specified number.
  • int surface - Mesh surface number.

const char * getLightmapTexturePath ( int surface ) const#

Returns the path to the baked lightmap texture currently used for the surface with the specified number.

Arguments

  • int surface - Mesh surface number.

Return value

Path to the baked lightmap texture currently used for the surface with the specified number.
Last update: 11.04.2022
Build: ()