This page has been translated automatically.
UnigineScript
The Language
Core Library
Engine Library
Node-Related Classes
GUI-Related Classes
Plugins Library
High-Level Systems
Samples
C++ API
API Reference
Integration Samples
Usage Examples
C++ Plugins
Content Creation
Materials
Unigine Material Library
Tutorials
注意! 这个版本的文档是过时的,因为它描述了一个较老的SDK版本!请切换到最新SDK版本的文档。
注意! 这个版本的文档描述了一个不再受支持的旧SDK版本!请升级到最新的SDK版本。

ObjectMesh Class

A static mesh that represents geometry and is loaded from a file.

Surfaces of identical meshes which have the same materials assigned to them are automatically instanced to be drawn in one draw call if instancing flag is enabled (by default; see corresponding console commands).

The following samples demonstrate the ObjectMesh class usage:

ObjectMesh Class

This class inherits from Object

Members


ObjectMesh (string name, int dynamic = 0)

Constructor. Creates a new mesh object from a given file. Set Dynamic flag to 1 if vertices of the mesh are going to be modified in run-time. (However, you can modify it only once, when init() or update() is over, it is sent to the GPU and cannot be changed any more.)

Arguments

  • string name - Path to the mesh file.
  • int dynamic = 0 - Dynamic flag for meshes that are going to be modified. This is an optional argument.

int addEmptySurface (string name, int num_vertex, int num_indices)

Appends a new surface to the mesh.

Arguments

  • string name - New surface name.
  • int num_vertex - Number of vertices.
  • int num_indices - Number of indices.

Return value

Mesh surface number.

void addMeshSurface (variable variable, ObjectMesh mesh, int surface)

Adds geometry (a surface) from a donor mesh to the existing surface of the current mesh or into its new surface.

Arguments

  • variable variable - Variable to control to what surface geometry is added:
    • If int, it is a destination surface number. Geometry is added to the existing mesh surface.
    • If string, it is a new surface name. Geometry is added to the new mesh surface.
  • ObjectMesh mesh - Mesh to copy geometry (a surface) from.
  • int surface - Number of the surface to copy geometry from.

int getIndex (int num, int surface)

Returns a index of the vertex from the index buffer.

Arguments

  • int num - Index number.
  • int surface - Surface number.

Return value

Index of the vertex in the index buffer.

string getMeshName ()

Returns the name of the original mesh file.

Return value

Name of the mesh file.

vec3 getNormal (int num, int surface)

Returns a normal vector of a vertex in the given mesh surface.

Arguments

  • int num - Number of the vertex.
  • int surface - Surface number.

Return value

The vertex normal vector.

int getNumIndices (int surface)

Returns the number of vertex indices used in the given mesh surface.

Arguments

  • int surface - Surface number.

Return value

Number of indices.

int getNumVertex (int surface)

Returns the total number of vertices in the given mesh surface.

Arguments

  • int surface - Surface number.

Return value

Number of vertices.

vec4 getTangent (int num, int surface)

Returns a tangent vector of a vertex in the given mesh surface.

Arguments

  • int num - Number of the vertex.
  • int surface - Surface number.

Return value

The vertex tangent vector.

vec4 getTexCoord (int num, int surface)

Returns texture coordinates of a vertex in the given mesh surface.

Arguments

  • int num - Number of the vertex.
  • int surface - Surface number.

Return value

Coordinate pairs for both texture channels.

vec3 getVertex (int num, int surface)

Returns coordinates of a given vertex in the given mesh surface.

Arguments

  • int num - Number of the vertex.
  • int surface - Surface number.

Return value

Coordinates in the mesh system of coordinates.

int save (string name)

Saves a mesh into a specified *.mesh file.

Arguments

  • string name - Path to the mesh file.

Return value

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

void setIndex (int num, int index, int surface)

Updates a vertex index by its number.

Arguments

  • int num - Index number.
  • int index - New index of the vertex in the index buffer.
  • int surface - Surface number.

void setNormal (int num, vec3 normal, int surface)

Updates a normal vector for a given vertex.

Arguments

  • int num - Number of the vertex.
  • vec3 normal - Normal vector.
  • int surface - Number of the surface to which a vertex belongs.

void setSurfaceTransform (mat4 transform, int surface)

Transforms the mesh surface.

Arguments

  • mat4 transform - Transformation matrix.
  • int surface - The surface number.

void setTangent (int num, vec4 tangent, int surface)

Updates a tangent vector for a given vertex.

Arguments

  • int num - Number of the vertex.
  • vec4 tangent - Tangent vector. The vector's w component is set to 0.
  • int surface - Number of the surface to which a vertex belongs.

void setTexCoord (int num, vec4 texcoord, int surface)

Updates texture coordinates for a given vertex.

Arguments

  • int num - Number of the vertex.
  • vec4 texcoord - Texture coordinates (for 2 UV sets).
  • int surface - Number of the surface to which a vertex belongs.

void setVertex (int num, vec3 xyz, int surface)

Updates coordinates of a given vertex.

Arguments

  • int num - Number of the vertex.
  • vec3 xyz - Position coordinates of the vertex.
  • int surface - Number of the surface to which a vertex belongs.

void updateSurfaces ()

Updates mesh surfaces.
Last update: 2017-07-03
Build: ()