3DCoat Core API
The 3DCoat API documentation.
Loading...
Searching...
No Matches
coat::Mesh Class Reference

The mesh reference. More...

#include <CoreAPI.h>

Public Member Functions

 Mesh (const Mesh &m)
 
 Mesh (const Model &m)
 
Meshoperator= (const Mesh &m)
 
Meshoperator= (const Model &m)
 
Mesh MakeCopy ()
 
bool Read (const char *name)
 Load the mesh from the file.
 
bool Write (const char *name)
 Save the mesh to file.
 
bool valid () const
 Check if mesh is valid.
 
comms::cMeshContainer * geometry ()
 The low-level mesh reference allows to create, operate over individual faces, vertices, objects.
 
comms::cMeshContainer * geometry () const
 
void clear ()
 clear the mesh
 
Meshoperator+= (const Mesh &m)
 concatenate with the other mesh
 
Meshoperator+= (const Model &m)
 concatenate with the Model
 
void addTransformed (const Mesh &m, const mat4 &t)
 concatenate the transformed mesh with the current one
 
void boolean (const Mesh &m, BoolOpType op)
 boolean operation
 
void transform (const mat4 &transform)
 transform the mesh
 
void rotateToXYAxis (const vec3 &axisX, const vec3 &axisY)
 rotate the mesh so that X axis will be aligned with axisX, Y axis will be aligned with axisY
 
void rotateToYZAxis (const vec3 &axisY, const vec3 &axisZ)
 rotate the mesh so that Y axis will be aligned with axisY, Z axis will be aligned with axisZ
 
void rotateToZXAxis (const vec3 &axisZ, const vec3 &axisX)
 rotate the mesh so that Z axis will be aligned with axisZ, X axis will be aligned with axisX
 
int vertsCount () const
 returns the amount of verts in the mesh
 
int vertsUvCount () const
 returns the amount of UV - verts in the mesh
 
int vertsNormalCount () const
 returns the amount of normal - verts in the mesh
 
int facesCount ()
 returns the faces amount
 
vec3 getVertex (int idx) const
 get the vertex coordinate
 
void setVertex (int idx, const vec3 &v)
 set the vertex coordinate
 
int createNewVertex (const vec3 &position)
 create the positional vertex
 
vec2 getVertexUV (int idx) const
 get the UV coordinate of the vertex, pay attention position verts and UV verts are different, they have different indices
 
void setVertexUV (int idx, const vec2 &v)
 set the UV coordinate of the vertex, pay attention position verts and UV verts are different, they have different indices
 
int createNewUvVertex (const vec2 &uv)
 create new UV vertex to be used for faces
 
vec3 getVertexNormal (int idx) const
 get the normal of the vertex, pay attention position verts and normal verts are different, they have different indices
 
void setVertexNormal (int idx, const vec3 &v)
 set the normal of the vertex, pay attention position verts and normal verts are different, they have different indices
 
void calcNormals ()
 re-calculate normals over the mesh
 
void calcNormalsIgnoreSharpEdges ()
 re-calculate normals over the mesh, ignore the sharp edges
 
int getFaceVertsCount (int face)
 get the amount of vertices over the face
 
int getFaceUvVertsCount (int face)
 get the amount of UV vertices over the face
 
int getFaceVertex (int faceIndex, int faceVertexIndex)
 get the positional vertex index over the face
 
std::vector< int > getFaceVerts (int face)
 get the list of UV vertex indices over the face, pay attention UV vertices are not same as position vertices
 
void getFaceVerts (int face, list< int > &vertices)
 
void setFaceVerts (int face, const std::vector< int > &vertices)
 set the list of positional vertex indices over the face
 
void setFaceVerts (int face, const list< int > &vertices)
 
int getFaceUvVertex (int faceIndex, int faceVertexIndex)
 get the UV vertex index over the face
 
void setFaceUvVertex (int faceIndex, int faceVertexIndex, int uvVertexIndex)
 set the UV vertex index over the face
 
int getFaceNormalVertex (int faceIndex, int faceVertexIndex)
 get the normal vertex index over the face
 
void setFaceNormalVertex (int faceIndex, int faceVertexIndex, int normalVertexIndex)
 set the normal vertex index over the face
 
std::vector< int > getFaceUvVerts (int face)
 get the list of UV vertices indices over the face
 
void getFaceUvVerts (int face, list< int > &vertices)
 
int getFaceObject (int faceIndex)
 get the object index over the face, see the getObjectsCount(), getObjectName()
 
void setFaceObject (int faceIndex, int objectIndex)
 set the object index for the face, see the getObjectsCount(), getObjectName()
 
int getFaceMaterial (int faceIndex)
 get the material index over the face, see the getMaterialsCount(), getMaterialName()
 
void setFaceMaterial (int faceIndex, int materialIndex)
 set the material index over the face, see the getMaterialsCount(), getMaterialName()
 
int getObjectsCount ()
 returns the objects count in the mesh
 
std::string getObjectName (int idx)
 get the name of the object
 
void setObjectName (int idx, const std::string &name)
 set object name
 
int addObject (const char *name)
 add new object to the mesh
 
void removeObject (int idx)
 remove object from the mesh
 
void unifyAllObjects (const std::string &name="")
 unify all objects in the mesh, i.e. make one object
 
int getMaterialsCount ()
 get the materials count in the mesh
 
int addMaterial (const char *name)
 add new material to the mesh
 
void removeMaterial (int idx)
 remove the material (and corresponding faces) from the mesh
 
std::string getMaterialName (int idx)
 get the name of the material
 
void setMaterialName (int idx, const std::string &name)
 set material name
 
std::string getMaterialTexture (int idx, int texture_layer)
 get the texture name of the material
 
void setMaterialTexture (int idx, int texture_layer, const std::string &texture_path)
 set the texture layer filename of the material
 
void fromVolume (Volume &v, bool with_subtree=false, bool all_selected=false)
 extract the mesh from the volume
 
void fromReducedVolume (Volume &v, float reduction_percent, bool with_subtree=false, bool all_selected=false)
 extract the mesh from the volume and reduce it by the given percent
 
void fromVolumeWithMaxPolycount (Volume &v, int max_polycount, bool with_subtree=false, bool all_selected=false)
 extract the mesh from the volume and reduce to the given polycount
 
void toVolume (Volume &v, const mat4 &transform=mat4::Identity, BoolOpType op=BOOL_MERGE)
 merge this mesh to the volume object
 
void insertInVolume (Volume &v, const mat4 &transform=mat4::Identity)
 insert without boolean operation, if the volume is not in surface mode (volumetric) the boolean ADD will be performed anyway
 
void addToVolume (Volume &v, const mat4 &transform=mat4::Identity)
 boolean add to volume
 
void subtractFromVolume (Volume &v, const mat4 &transform=mat4::Identity)
 boolean subtraction of the mesh from the volume
 
void intersectWithVolume (Volume &v, const mat4 &transform=mat4::Identity)
 boolean intersection of the mesh with the volume
 
void fromRetopo ()
 take the whole mesh from the retopo room
 
void fromPaintRoom ()
 get the mesh from the paint room
 
void reduceToPolycount (int destination_triangles_count)
 reduce the mesh to the given polycount, mesh will be triangulated
 
void triangulate ()
 triangulate the mesh
 
void booleanOp (Mesh &With, BoolOpType op)
 Perform the boolean operation with the given mesh.
 
std::vector< vec3getMeshVertices ()
 get the list of all positional vertices of the mesh
 
std::vector< vec3getMeshNormals ()
 get the list of all normal vertices of the mesh
 
std::vector< vec2getMeshUVs ()
 get the list of all UV vertices of the mesh
 
void setMeshVertices (const std::vector< vec3 > &positions)
 set the list of all positional vertices for the mesh
 
void setMeshNormals (const std::vector< vec3 > &normals)
 set the list of all normal vertices for the mesh
 
void setMeshUVs (const std::vector< vec2 > &uvs)
 set the list of all UV vertices for the mesh
 
void setMeshFaces (const std::vector< int > &faces)
 set the complete list of faces for the mesh
 
void addMeshVertices (const std::vector< vec3 > &positions)
 add the list of all positional vertices for the mesh
 
void addMeshNormals (const std::vector< vec3 > &normals)
 add the list of all normal vertices for the mesh
 
void addMeshUVs (const std::vector< vec2 > &uvs)
 add the list of all UV vertices for the mesh
 
void addMeshFaces (const std::vector< int > &faces)
 add the list of faces for the mesh, pay attention, all vertex indices are global over the whole mesh!
 
void clearVerts ()
 clear all positional vertices of the mesh
 
void clearUvVerts ()
 clear all uv vertices of the mesh
 
void clearNormals ()
 clear all normal vertices of the mesh
 
void clearFaces ()
 clear all faces of the mesh
 
void removeFaces (const std::vector< int > &faces)
 remove the set of vertices from the mesh
 
void clearObject ()
 clear all objects
 
void clearMaterials ()
 clear all materials
 
void ensureMaterialsAndObjectsExist ()
 ensure that at least one material and one object exist in the mesh
 
int addObject (const std::string &name)
 add the named object
 
int addMaterial (const std::string &name)
 add the named material
 
void removeUnusedObjectsAndMaterials ()
 remove all unused objects and materials
 
void removeUnusedVerts ()
 remove all unused vertices
 
void removeUnusedFaces ()
 remove all faces that contain zero vertices
 
void cutByPlane (const vec3 &start, const vec3 &NormalDirection)
 Cut off the mesh by the plane, the result is stored in the current mesh, the part of the mesh that is on the side of the negative normal direction is removed.
 
void cutByDistortedPlane (const vec3 &start, const vec3 &NormalDirection, float noise_degree, float noise_scale, int seed=0)
 Cut off the mesh by the distorted plane (using the Perlin noise), the result is stored in the current mesh, the part of the mesh that is on the side of the negative normal direction is removed.
 
void distortByPerlinNoise (float noise_degree, float noise_scale, bool anisotropic=false, int seed=0)
 distort the mesh by the Perlin noise
 
std::vector< MeshsplitDisconnectedParts ()
 split the mesh into disconnected parts
 
void symmetry (const vec3 &start, const vec3 &NormalDirection, bool resultInQuads)
 apply symmetry to the mesh
 
std::vector< comms::cPlane > autodetectSymmetryPlanes ()
 Detect the symmetry planes of the mesh.
 
void weld (float minimal_relative_distance=0.0001f)
 weld the mesh, remove all vertices that are closer than minimal_relative_distance*mesh_bound_box_diagonal to each other
 
boundbox getBounds () const
 get the mesh bound box
 
float getVolume () const
 get the volume of the mesh
 
float getOpenSurfaceVolume (const vec3 &start, const vec3 &dir) const
 calculate the volume even if the mesh is not closed, in this case we define plane that limits the integration
 
float getSquare () const
 get square of the mesh
 
float getFaceSquare (int face)
 get the squareof the face
 
float getFaceUVSquare (int face)
 get the face square in UV space
 
vec3 getFaceNormal (int face)
 get the face normal
 
void relax (float degree, bool tangent, float crease_angle=180)
 relax the mesh, keep the vertices count
 
void createVDM (int side, const char *path_to_exr, const vec3 &center=vec3::Zero, float radius=1, const vec3 &up=vec3::AxisZ, const vec3 &x=vec3::AxisX, const vec3 &y=vec3::AxisY)
 Create the vector displacement map from the mesh and save it as EXR file. The mesh is put on plane at center and clamped by that plane.
 
void shell (float thickness_out, float thickness_in, int divisions=1)
 add some thickness to the mesh (intrude a bit)
 
std::vector< int > extrudeOpenEdges (float distance, vec3 direction=vec3::Zero)
 extrude open edges of the mesh
 
std::vector< int > expandOpenEdges (float distance)
 extrude open edges of the mesh
 
std::vector< int > getOpenEdges ()
 get the list of open edges
 
float getLengthAlongDirection (const vec3 &dir) const
 get the mesh size along some axis
 
vec3 getCenterMass () const
 calculate the center mass of the mesh
 

Static Public Member Functions

static Mesh box (const vec3 &center=vec3::Zero, const vec3 &size=vec3::One, const vec3 &xAxis=vec3::Zero, const vec3 &yAxis=vec3::Zero, const vec3 &zAxis=vec3::Zero, float detail_size=1, float fillet=0.0f, int nx=0, int ny=0, int nz=0)
 create the box mesh
 
static Mesh sphere (const vec3 &center=vec3::Zero, float radius=1.0f, float detail_size=1)
 create the sphere mesh
 
static Mesh cylinder (const vec3 &center=vec3::Zero, float radius=1, float height=2, float detail_size=1, int slices=0, int caps=0, int rings=0, float fillet=0)
 create the cylinder mesh
 
static Mesh cone (const vec3 &center=vec3::Zero, float radius=1, float height=2, float detail_size=1, const vec3 &topAxis=vec3::AxisY)
 create the cone mesh
 
static Mesh plane (const vec3 &center=vec3::Zero, float sizeX=2, float sizeY=2, int divisionsX=2, int divisionsY=2, const vec3 &xAxis=vec3::AxisX, const vec3 &yAxis=vec3::AxisY)
 create the single-side plane mesh, the faces normals are put toward the vec3.Cross(xAxis, yAxis)
 
static Mesh hexagonal_plane (const vec3 &center=vec3::Zero, float sizeX=2, float sizeY=2, int divisionsX=2, int divisionsY=2, const vec3 &xAxis=vec3::AxisX, const vec3 &yAxis=vec3::AxisY)
 create the single-side triangular plane mesh that consists mostly of quasi equally-sided triangles
 
static Mesh text (const char *string, const char *font="tahoma", float height=10.0f, const vec3 &center=vec3::Zero, const vec3 &text_direction=vec3::AxisX, const vec3 &text_normal=vec3::AxisY, float thickness=1, int align=1)
 Create the text mesh.
 

Protected Member Functions

comms::cMeshContainer * allocate ()
 
void inc_ref (comms::cMeshContainer *m)
 
void dec_ref (comms::cMeshContainer *m)
 
void validate_raws ()
 
void setMesh (const comms::cMeshContainer &mesh)
 

Protected Attributes

comms::cMeshContainer * MeshData
 
list< int > raw_start
 
int raw_count
 

Static Protected Attributes

static std::vector< std::pair< comms::cMeshContainer *, int > > allocated_meshes
 

Friends

class Model
 
class prim
 

Detailed Description

Member Function Documentation

◆ addMaterial() [1/2]

int coat::Mesh::addMaterial ( const char * name)

add new material to the mesh

Parameters
namethe material name
Returns
the material index

◆ addMaterial() [2/2]

int coat::Mesh::addMaterial ( const std::string & name)

add the named material

Parameters
namethe name for the material
Returns
the index of new material in the materials list

◆ addMeshFaces()

void coat::Mesh::addMeshFaces ( const std::vector< int > & faces)

add the list of faces for the mesh, pay attention, all vertex indices are global over the whole mesh!

Parameters
facesthe format of faces is:
amount_ot_vets_in_face1, vertex1_face1, vertex2_face1...vertexN-1_face1,
amount_ot_vets_in_face2, vertex1_face2, vertex2_face2...
...

◆ addMeshNormals()

void coat::Mesh::addMeshNormals ( const std::vector< vec3 > & normals)

add the list of all normal vertices for the mesh

Parameters
normalsthe list of normals (vec3)

◆ addMeshUVs()

void coat::Mesh::addMeshUVs ( const std::vector< vec2 > & uvs)

add the list of all UV vertices for the mesh

Parameters
uvsthe list of UVs (vec2)

◆ addMeshVertices()

void coat::Mesh::addMeshVertices ( const std::vector< vec3 > & positions)

add the list of all positional vertices for the mesh

Parameters
positionsthe list of positions

◆ addObject() [1/2]

int coat::Mesh::addObject ( const char * name)

add new object to the mesh

Parameters
namethe object name
Returns
the object index

◆ addObject() [2/2]

int coat::Mesh::addObject ( const std::string & name)

add the named object

Parameters
namethe name for the object
Returns
the index of new object in the objects list

◆ addToVolume()

void coat::Mesh::addToVolume ( Volume & v,
const mat4 & transform = mat4::Identity )

boolean add to volume

Parameters
vthe destination volume
transformthe transform

◆ addTransformed()

void coat::Mesh::addTransformed ( const Mesh & m,
const mat4 & t )

concatenate the transformed mesh with the current one

Parameters
mthe mesh
tthe transform
Examples
GeneratorExample.cpp, and meshes_surface_merge.cpp.

◆ autodetectSymmetryPlanes()

std::vector< comms::cPlane > coat::Mesh::autodetectSymmetryPlanes ( )

Detect the symmetry planes of the mesh.

Returns
the list of planes

◆ boolean()

void coat::Mesh::boolean ( const Mesh & m,
BoolOpType op )

boolean operation

Parameters
mthe mesh to operate

◆ booleanOp()

void coat::Mesh::booleanOp ( Mesh & With,
BoolOpType op )

Perform the boolean operation with the given mesh.

Parameters
Withthe mesh to perform the operation with over the current mesh
opthe operation, see BoolOpType (-1 means no operation, 0 - add, 1 - subtract, 2 - intersect)

◆ box()

static Mesh coat::Mesh::box ( const vec3 & center = vec3::Zero,
const vec3 & size = vec3::One,
const vec3 & xAxis = vec3::Zero,
const vec3 & yAxis = vec3::Zero,
const vec3 & zAxis = vec3::Zero,
float detail_size = 1,
float fillet = 0.0f,
int nx = 0,
int ny = 0,
int nz = 0 )
static

create the box mesh

Parameters
centerthe box center
sizethe box size
xAxisthe x-axis direction, if zero, the x-axis is default - (1,0,0)
yAxisthe y-axis direction, if zero, the y-axis is default - (0,1,0)
zAxisthe z-axis direction, if zero, the z-axis is default - (0,0,1)
detail_sizethe average length of the edge over the figure. The figure will be divided so that edges length will be approximately the detail_size
filletthe fillet radius
nxthe number of segments along the x-axis (if all of nx, ny, nz are above zero, it overrides the detail_size)
nythe number of segments along the y-axis (if all of nx, ny, nz are above zero, it overrides the detail_size)
nzthe number of segments along the z-axis (if all of nx, ny, nz are above zero, it overrides the detail_size)
Returns
the box mesh

◆ cone()

static Mesh coat::Mesh::cone ( const vec3 & center = vec3::Zero,
float radius = 1,
float height = 2,
float detail_size = 1,
const vec3 & topAxis = vec3::AxisY )
static

create the cone mesh

Parameters
centerthe center of the cone (the cone base center)
radiusthe cone radius
heightthe cone height
detail_sizethe average length of the edge over the figure. The figure will be divided so that edges length will be approximately the detail_size
topAxisthe top axis direction, if zero, the top axis is default - (0,1,0)
Returns
the cone mesh

◆ createNewUvVertex()

int coat::Mesh::createNewUvVertex ( const vec2 & uv)

create new UV vertex to be used for faces

Parameters
uvthe texture coordinates
Returns
the index

◆ createNewVertex()

int coat::Mesh::createNewVertex ( const vec3 & position)

create the positional vertex

Parameters
positionthe position
Returns
the positional vertex index

◆ createVDM()

void coat::Mesh::createVDM ( int side,
const char * path_to_exr,
const vec3 & center = vec3::Zero,
float radius = 1,
const vec3 & up = vec3::AxisZ,
const vec3 & x = vec3::AxisX,
const vec3 & y = vec3::AxisY )

Create the vector displacement map from the mesh and save it as EXR file. The mesh is put on plane at center and clamped by that plane.

Parameters
sidethe EXR file side size
path_to_exrthe path to the EXR file
centerthe center of the plane
radiusthe radius that should include the mesh
upthe up vector of the plane
xthe x vector of the plane
ythe y vector of the plane

◆ cutByDistortedPlane()

void coat::Mesh::cutByDistortedPlane ( const vec3 & start,
const vec3 & NormalDirection,
float noise_degree,
float noise_scale,
int seed = 0 )

Cut off the mesh by the distorted plane (using the Perlin noise), the result is stored in the current mesh, the part of the mesh that is on the side of the negative normal direction is removed.

Parameters
startthe start point of the plane
NormalDirectionthe normal direction of the plane
noise_degreethe degree of the noise
noise_scalethe scale of the noise
seedthe seed for the noise

◆ cutByPlane()

void coat::Mesh::cutByPlane ( const vec3 & start,
const vec3 & NormalDirection )

Cut off the mesh by the plane, the result is stored in the current mesh, the part of the mesh that is on the side of the negative normal direction is removed.

Parameters
startthe start point of the plane
NormalDirectionthe normal direction of the plane

◆ cylinder()

static Mesh coat::Mesh::cylinder ( const vec3 & center = vec3::Zero,
float radius = 1,
float height = 2,
float detail_size = 1,
int slices = 0,
int caps = 0,
int rings = 0,
float fillet = 0 )
static

create the cylinder mesh

Parameters
centerthe center of the cylinder
radiusthe radius of the cylinder
heightthe height of the cylinder
detail_sizethe average length of the edge over the figure. The figure will be divided so that edges length will be approximately the detail_size
slicesthe number of slices, it overrides the detail_size if all of slices, caps, rings are above zero
capsthe number of caps, it overrides the detail_size if all of slices, caps, rings are above zero
ringsthe number of rings, it overrides the detail_size if all of slices, caps, rings are above zero
filletthe fillet radius
Returns
the cylinder mesh

◆ distortByPerlinNoise()

void coat::Mesh::distortByPerlinNoise ( float noise_degree,
float noise_scale,
bool anisotropic = false,
int seed = 0 )

distort the mesh by the Perlin noise

Parameters
noise_degreethe degree of the noise
noise_scalethe scale of the noise
anisotropicif false, the noise will be applied in the direction of the normals, othervice the noise directed in random direction regardless the normals
seedthe seed for the noise

◆ expandOpenEdges()

std::vector< int > coat::Mesh::expandOpenEdges ( float distance)

extrude open edges of the mesh

Parameters
distancethe distance to extrude
Returns
the list of extruded edges, even is the start vertex, odd is the end vertex

◆ extrudeOpenEdges()

std::vector< int > coat::Mesh::extrudeOpenEdges ( float distance,
vec3 direction = vec3::Zero )

extrude open edges of the mesh

Parameters
distancethe distance to extrude
directionthe extrude direction, if zero , the direction is the local vertex normal
Returns
the list of extruded edges, even is the start vertex, odd is the end vertex

◆ facesCount()

int coat::Mesh::facesCount ( )

returns the faces amount

Returns
the amount

◆ fromReducedVolume()

void coat::Mesh::fromReducedVolume ( Volume & v,
float reduction_percent,
bool with_subtree = false,
bool all_selected = false )

extract the mesh from the volume and reduce it by the given percent

Parameters
vthe source volume
reduction_percent0 means no reduction, 100 means 100% reduction, i.e. the mesh will be reduced to a single triangle
with_subtreeif true, the subtree will be extracted, otherwise the single volume taken
all_selectedif true, all selected volumes will be extracted, otherwise only the current volume

◆ fromVolume()

void coat::Mesh::fromVolume ( Volume & v,
bool with_subtree = false,
bool all_selected = false )

extract the mesh from the volume

Parameters
vthe source volume
with_subtreeif true, the subtree will be extracted, otherwise the single volume taken
all_selectedif true, all selected volumes will be extracted, otherwise only the current volume

◆ fromVolumeWithMaxPolycount()

void coat::Mesh::fromVolumeWithMaxPolycount ( Volume & v,
int max_polycount,
bool with_subtree = false,
bool all_selected = false )

extract the mesh from the volume and reduce to the given polycount

Parameters
vthe source volume
max_polycountthe required polycount
with_subtreeif true, the subtree will be extracted, otherwise the single volume taken
all_selectedif true, all selected volumes will be extracted, otherwise only the current volume

◆ geometry()

comms::cMeshContainer * coat::Mesh::geometry ( )

The low-level mesh reference allows to create, operate over individual faces, vertices, objects.

Returns
returns the low-level mesh reference
Examples
TreesGenerator.cpp.

◆ getBounds()

boundbox coat::Mesh::getBounds ( ) const

get the mesh bound box

Returns
the bound box

◆ getCenterMass()

vec3 coat::Mesh::getCenterMass ( ) const

calculate the center mass of the mesh

Returns
the center mass of the surface

◆ getFaceMaterial()

int coat::Mesh::getFaceMaterial ( int faceIndex)

get the material index over the face, see the getMaterialsCount(), getMaterialName()

Parameters
faceIndexthe face index, should be in [0..facesCount() - 1]
Returns
the material index

◆ getFaceNormal()

vec3 coat::Mesh::getFaceNormal ( int face)

get the face normal

Parameters
facethe face index
Returns
the face normal

◆ getFaceNormalVertex()

int coat::Mesh::getFaceNormalVertex ( int faceIndex,
int faceVertexIndex )

get the normal vertex index over the face

Parameters
faceIndexthe face index, should be in [0..facesCount() - 1]
faceVertexIndexthe index of the vertex within the face, should be in [0..getFaceVertsCount(faceIndex) - 1]
Returns
the normal vertex index, -1 if no normals over the face

◆ getFaceObject()

int coat::Mesh::getFaceObject ( int faceIndex)

get the object index over the face, see the getObjectsCount(), getObjectName()

Parameters
faceIndexthe face index, should be in [0..facesCount() - 1]
Returns
the object index

◆ getFaceSquare()

float coat::Mesh::getFaceSquare ( int face)

get the squareof the face

Parameters
facethe face index
Returns
the square

◆ getFaceUVSquare()

float coat::Mesh::getFaceUVSquare ( int face)

get the face square in UV space

Parameters
facethe face index
Returns
the square

◆ getFaceUvVertex()

int coat::Mesh::getFaceUvVertex ( int faceIndex,
int faceVertexIndex )

get the UV vertex index over the face

Parameters
faceIndexthe face index, should be in [0..facesCount() - 1]
faceVertexIndexthe index of the vertex within the face, should be in [0..getFaceVertsCount(faceIndex) - 1]
Returns
the UV vertex index, -1 if no UVs over the face

◆ getFaceUvVerts()

std::vector< int > coat::Mesh::getFaceUvVerts ( int face)

get the list of UV vertices indices over the face

Parameters
facethe face index
Returns
the list of UV vertices indices

◆ getFaceUvVertsCount()

int coat::Mesh::getFaceUvVertsCount ( int face)

get the amount of UV vertices over the face

Parameters
facethe face index
Returns
amount of vertices over the face, 0 if UV-s not assigned

◆ getFaceVertex()

int coat::Mesh::getFaceVertex ( int faceIndex,
int faceVertexIndex )

get the positional vertex index over the face

Parameters
faceIndexthe face index, should be in [0..facesCount() - 1]
faceVertexIndexthe index of the vertex within the face, should be in [0..getFaceVertsCount(faceIndex) - 1]
Returns
the positional vertex index

◆ getFaceVerts()

std::vector< int > coat::Mesh::getFaceVerts ( int face)

get the list of UV vertex indices over the face, pay attention UV vertices are not same as position vertices

Parameters
facethe face index
Returns
the list of vertex indices

◆ getFaceVertsCount()

int coat::Mesh::getFaceVertsCount ( int face)

get the amount of vertices over the face

Parameters
facethe face index, should be in [0..facesCount() - 1]
Returns
the verts amount

◆ getLengthAlongDirection()

float coat::Mesh::getLengthAlongDirection ( const vec3 & dir) const

get the mesh size along some axis

Parameters
dirthe axis direction
Returns
the size along the axis

◆ getMaterialName()

std::string coat::Mesh::getMaterialName ( int idx)

get the name of the material

Parameters
idxthe material index
Returns
the name

◆ getMaterialsCount()

int coat::Mesh::getMaterialsCount ( )

get the materials count in the mesh

Returns
the count

◆ getMaterialTexture()

std::string coat::Mesh::getMaterialTexture ( int idx,
int texture_layer )

get the texture name of the material

Parameters
idxthe material index
texture_layerthe texture layer, 0 - color, 1 - gloss, 2 - bump/displacement, 3 - normalmap, 4 - specular color, 5 - emossive (color), 6 - emissive power
Returns
the texture path (full or relative to 3DCoat documents folder)

◆ getMeshNormals()

std::vector< vec3 > coat::Mesh::getMeshNormals ( )

get the list of all normal vertices of the mesh

Returns
the list of vec3

◆ getMeshUVs()

std::vector< vec2 > coat::Mesh::getMeshUVs ( )

get the list of all UV vertices of the mesh

Returns
the list of vec2

◆ getMeshVertices()

std::vector< vec3 > coat::Mesh::getMeshVertices ( )

get the list of all positional vertices of the mesh

Returns
the list of vec3

◆ getObjectName()

std::string coat::Mesh::getObjectName ( int idx)

get the name of the object

Parameters
idxthe object index
Returns
the name

◆ getObjectsCount()

int coat::Mesh::getObjectsCount ( )

returns the objects count in the mesh

Returns
the count

◆ getOpenEdges()

std::vector< int > coat::Mesh::getOpenEdges ( )

get the list of open edges

Returns
the list of open edges, the even is the start vertex, the odd is the end vertex

◆ getOpenSurfaceVolume()

float coat::Mesh::getOpenSurfaceVolume ( const vec3 & start,
const vec3 & dir ) const

calculate the volume even if the mesh is not closed, in this case we define plane that limits the integration

Parameters
startthe point on that plane
dirthe normalized vector, normal to the plane
Returns
the volume

◆ getSquare()

float coat::Mesh::getSquare ( ) const

get square of the mesh

Returns
the square (area)

◆ getVertex()

vec3 coat::Mesh::getVertex ( int idx) const

get the vertex coordinate

Parameters
idxthe vertex index
Returns
the coordinate

◆ getVertexNormal()

vec3 coat::Mesh::getVertexNormal ( int idx) const

get the normal of the vertex, pay attention position verts and normal verts are different, they have different indices

Parameters
idxthe normal vertex index, [0..vertsNormalCount() - 1]
Returns
the normal

◆ getVertexUV()

vec2 coat::Mesh::getVertexUV ( int idx) const

get the UV coordinate of the vertex, pay attention position verts and UV verts are different, they have different indices

Parameters
idxthe UV vertex index, [0..vertsUvCount() - 1]
Returns
the UV coordinate

◆ getVolume()

float coat::Mesh::getVolume ( ) const

get the volume of the mesh

Returns
the volume

◆ hexagonal_plane()

static Mesh coat::Mesh::hexagonal_plane ( const vec3 & center = vec3::Zero,
float sizeX = 2,
float sizeY = 2,
int divisionsX = 2,
int divisionsY = 2,
const vec3 & xAxis = vec3::AxisX,
const vec3 & yAxis = vec3::AxisY )
static

create the single-side triangular plane mesh that consists mostly of quasi equally-sided triangles

Parameters
centerthe center of the plane
sizeXthe plane size along the X-axis
sizeYthe plane size along the Y-axis
divisionsXamount of divisions along the X-axis
divisionsYamount of divisions along the Y-axis
xAxisthe vector of the X-axis
yAxisthe vector of the Y-axis
Returns
the hexagonal plane mesh

◆ insertInVolume()

void coat::Mesh::insertInVolume ( Volume & v,
const mat4 & transform = mat4::Identity )

insert without boolean operation, if the volume is not in surface mode (volumetric) the boolean ADD will be performed anyway

Parameters
vthe destination volume
transformthe transform

◆ intersectWithVolume()

void coat::Mesh::intersectWithVolume ( Volume & v,
const mat4 & transform = mat4::Identity )

boolean intersection of the mesh with the volume

Parameters
vthe destination volume
transformthe transform

◆ operator+=() [1/2]

Mesh & coat::Mesh::operator+= ( const Mesh & m)

concatenate with the other mesh

Parameters
mthe mesh to be concatenated with this one

◆ operator+=() [2/2]

Mesh & coat::Mesh::operator+= ( const Model & m)

concatenate with the Model

Parameters
mthe mesh to be concatenated with this one

◆ plane()

static Mesh coat::Mesh::plane ( const vec3 & center = vec3::Zero,
float sizeX = 2,
float sizeY = 2,
int divisionsX = 2,
int divisionsY = 2,
const vec3 & xAxis = vec3::AxisX,
const vec3 & yAxis = vec3::AxisY )
static

create the single-side plane mesh, the faces normals are put toward the vec3.Cross(xAxis, yAxis)

Parameters
centerthe center of the plane
sizeXthe plane size along the X-axis
sizeYthe plane size along the Y-axis
divisionsXamount of divisions along the X-axis
divisionsYamount of divisions along the Y-axis
xAxisthe vector of the X-axis
yAxisthe vector of the Y-axis
Returns
the plane mesh

◆ Read()

bool coat::Mesh::Read ( const char * name)

Load the mesh from the file.

Parameters
namethe filename. May contain full path or relative to the coat's install or documents folder.
Returns
true if successful.
Examples
GeneratorExample.cpp, meshes.cpp, and meshes_surface_merge.cpp.

◆ reduceToPolycount()

void coat::Mesh::reduceToPolycount ( int destination_triangles_count)

reduce the mesh to the given polycount, mesh will be triangulated

Parameters
destination_triangles_countthe required triangles count, if it is above the existing, nothing happens

◆ relax()

void coat::Mesh::relax ( float degree,
bool tangent,
float crease_angle = 180 )

relax the mesh, keep the vertices count

Parameters
degreethe degree of relax, may be > 1
tangentshould be tangent relax
crease_anglethe crease angle between faces (degrees), if the angle between faces is less than crease_angle, the edge relaxed

◆ removeFaces()

void coat::Mesh::removeFaces ( const std::vector< int > & faces)

remove the set of vertices from the mesh

Parameters
facesthe list of faces indices to remove

◆ removeMaterial()

void coat::Mesh::removeMaterial ( int idx)

remove the material (and corresponding faces) from the mesh

Parameters
idxthe material index

◆ removeObject()

void coat::Mesh::removeObject ( int idx)

remove object from the mesh

Parameters
idxthe object index

◆ rotateToXYAxis()

void coat::Mesh::rotateToXYAxis ( const vec3 & axisX,
const vec3 & axisY )

rotate the mesh so that X axis will be aligned with axisX, Y axis will be aligned with axisY

Parameters
axisXthe new X axis
axisYthe new Y axis

◆ rotateToYZAxis()

void coat::Mesh::rotateToYZAxis ( const vec3 & axisY,
const vec3 & axisZ )

rotate the mesh so that Y axis will be aligned with axisY, Z axis will be aligned with axisZ

Parameters
axisYthe new Y axis
axisZthe new Z axis

◆ rotateToZXAxis()

void coat::Mesh::rotateToZXAxis ( const vec3 & axisZ,
const vec3 & axisX )

rotate the mesh so that Z axis will be aligned with axisZ, X axis will be aligned with axisX

Parameters
axisZthe new Z axis
axisXthe new X axis

◆ setFaceMaterial()

void coat::Mesh::setFaceMaterial ( int faceIndex,
int materialIndex )

set the material index over the face, see the getMaterialsCount(), getMaterialName()

Parameters
faceIndexthe face index, should be in [0..facesCount() - 1]
materialIndexthe material index to set for the face

◆ setFaceNormalVertex()

void coat::Mesh::setFaceNormalVertex ( int faceIndex,
int faceVertexIndex,
int normalVertexIndex )

set the normal vertex index over the face

Parameters
faceIndexthe face index, should be in [0..facesCount() - 1]
faceVertexIndexthe index of the vertex within the face, should be in [0..getFaceVertsCount(faceIndex) - 1]
normalVertexIndexthe normal vertex index, should be in [0..vertsNormalCount() - 1]

◆ setFaceObject()

void coat::Mesh::setFaceObject ( int faceIndex,
int objectIndex )

set the object index for the face, see the getObjectsCount(), getObjectName()

Parameters
faceIndexthe face index, should be in [0..facesCount() - 1]
objectIndexthe object index to set for the face

◆ setFaceUvVertex()

void coat::Mesh::setFaceUvVertex ( int faceIndex,
int faceVertexIndex,
int uvVertexIndex )

set the UV vertex index over the face

Parameters
faceIndexthe face index, should be in [0..facesCount() - 1]
faceVertexIndexthe index of the vertex within the face, should be in [0..getFaceVertsCount(faceIndex) - 1]
uvVertexIndexthe UV vertex index, should be in [0..vertsUvCount() - 1]

◆ setFaceVerts()

void coat::Mesh::setFaceVerts ( int face,
const std::vector< int > & vertices )

set the list of positional vertex indices over the face

Parameters
facethe face index
verticesthe list of vertex indices

◆ setMaterialName()

void coat::Mesh::setMaterialName ( int idx,
const std::string & name )

set material name

Parameters
idxthe material index
namethe new name

◆ setMaterialTexture()

void coat::Mesh::setMaterialTexture ( int idx,
int texture_layer,
const std::string & texture_path )

set the texture layer filename of the material

Parameters
idxthe material index
texture_layerthe texture layer, 0 - color, 1 - gloss, 2 - bump/displacement, 3 - normalmap, 4 - specular color, 5 - emossive (color), 6 - emissive power
texture_paththe texture path (full or relative to 3DCoat documents folder)

◆ setMeshFaces()

void coat::Mesh::setMeshFaces ( const std::vector< int > & faces)

set the complete list of faces for the mesh

Parameters
facesthe format of faces is:
amount_ot_vets_in_face1, vertex1_face1, vertex2_face1...vertexN-1_face1,
amount_ot_vets_in_face2, vertex1_face2, vertex2_face2...
...

◆ setMeshNormals()

void coat::Mesh::setMeshNormals ( const std::vector< vec3 > & normals)

set the list of all normal vertices for the mesh

Parameters
normalsthe list of normals (vec3)

◆ setMeshUVs()

void coat::Mesh::setMeshUVs ( const std::vector< vec2 > & uvs)

set the list of all UV vertices for the mesh

Parameters
uvsthe list of UVs (vec2)

◆ setMeshVertices()

void coat::Mesh::setMeshVertices ( const std::vector< vec3 > & positions)

set the list of all positional vertices for the mesh

Parameters
positionsthe list of positions

◆ setObjectName()

void coat::Mesh::setObjectName ( int idx,
const std::string & name )

set object name

Parameters
idxthe object index
namethe new name

◆ setVertex()

void coat::Mesh::setVertex ( int idx,
const vec3 & v )

set the vertex coordinate

Parameters
idxthe vertex index
vthe coordinate

◆ setVertexNormal()

void coat::Mesh::setVertexNormal ( int idx,
const vec3 & v )

set the normal of the vertex, pay attention position verts and normal verts are different, they have different indices

Parameters
idxthe normal vertex index, [0..vertsNormalCount() - 1]
vthe normal

◆ setVertexUV()

void coat::Mesh::setVertexUV ( int idx,
const vec2 & v )

set the UV coordinate of the vertex, pay attention position verts and UV verts are different, they have different indices

Parameters
idxthe UV vrertex index, [0..vertsUvCount() - 1]
vthe UV coordinate

◆ shell()

void coat::Mesh::shell ( float thickness_out,
float thickness_in,
int divisions = 1 )

add some thickness to the mesh (intrude a bit)

Parameters
thickness_outthe thickness in the outer direction (extrusion)
thickness_inthe thickness in the inner direction (intrusion)
divisionsthe amount of divisions of the edge

◆ sphere()

static Mesh coat::Mesh::sphere ( const vec3 & center = vec3::Zero,
float radius = 1.0f,
float detail_size = 1 )
static

create the sphere mesh

Parameters
centerthe sphere center
radiusthe sphere radius
detail_sizethe average length of the edge over the figure. The figure will be divided so that edges length will be approximately the detail_size
Returns
the sphere mesh

◆ splitDisconnectedParts()

std::vector< Mesh > coat::Mesh::splitDisconnectedParts ( )

split the mesh into disconnected parts

Returns
the list of meshes

◆ subtractFromVolume()

void coat::Mesh::subtractFromVolume ( Volume & v,
const mat4 & transform = mat4::Identity )

boolean subtraction of the mesh from the volume

Parameters
vthe destination volume
transformthe transform

◆ symmetry()

void coat::Mesh::symmetry ( const vec3 & start,
const vec3 & NormalDirection,
bool resultInQuads )

apply symmetry to the mesh

Parameters
startthe start point of the plane
NormalDirectionthe negative part (regarding the plane normal) of the mesh is removed, replaced with positive part
resultInQuadsthe cut faces will produce quads instead of triangles

◆ text()

static Mesh coat::Mesh::text ( const char * string,
const char * font = "tahoma",
float height = 10.0f,
const vec3 & center = vec3::Zero,
const vec3 & text_direction = vec3::AxisX,
const vec3 & text_normal = vec3::AxisY,
float thickness = 1,
int align = 1 )
static

Create the text mesh.

Parameters
stringthe text string
fontthe font name
heightthe text height
centerthe text center
text_directionthe text direction left to right
text_normalthe normal direction of the text
thicknessthe thickness of the text
alignthe text align, 0 - left, 1 - center, 2 - right
Returns
the text mesh

◆ toVolume()

void coat::Mesh::toVolume ( Volume & v,
const mat4 & transform = mat4::Identity,
BoolOpType op = BOOL_MERGE )

merge this mesh to the volume object

Parameters
vthe destination volume
transformthe applied transformation
opthe boolean operation to be performed, -1 means no operation, raw merge, 0 - 1, 1 - subtract, 2 - intersect

◆ transform()

void coat::Mesh::transform ( const mat4 & transform)

transform the mesh

Parameters
transformthe transformation matrix

◆ unifyAllObjects()

void coat::Mesh::unifyAllObjects ( const std::string & name = "")

unify all objects in the mesh, i.e. make one object

Parameters
namethe name of the new object, if empty, the name of the first object will be used

◆ valid()

bool coat::Mesh::valid ( ) const

Check if mesh is valid.

Returns
true if mesh is valid

◆ vertsCount()

int coat::Mesh::vertsCount ( ) const

returns the amount of verts in the mesh

Returns
the amount

◆ vertsNormalCount()

int coat::Mesh::vertsNormalCount ( ) const

returns the amount of normal - verts in the mesh

Returns
teh amount

◆ vertsUvCount()

int coat::Mesh::vertsUvCount ( ) const

returns the amount of UV - verts in the mesh

Returns
the amount

◆ weld()

void coat::Mesh::weld ( float minimal_relative_distance = 0.0001f)

weld the mesh, remove all vertices that are closer than minimal_relative_distance*mesh_bound_box_diagonal to each other

Parameters
minimal_relative_distancethe minimal distance between vertices, relative to the mesh bound box diagonal

◆ Write()

bool coat::Mesh::Write ( const char * name)

Save the mesh to file.

Parameters
nameFull or relative path
Returns
true if successful

The documentation for this class was generated from the following file: