Skip to main content

Mesh

The Mesh class provides a comprehensive interface for loading, saving, editing, and optimizing 3D mesh data. It supports operations on mesh components such as nodes, geometries, animations, and bounding boxes. The class enables loading from file names or streams with optional asynchronous processing. It offers methods to validate mesh structure, set coordinate system bases, and manage transformation hierarchies. The class includes optimization features such as index reordering, attribute unification, material deduplication, and transform simplification. Additionally, it supports mesh packing, attribute compression, and applying scale transformations, making it a versatile tool for preparing and managing complex 3D models efficiently.

#include <format/TellusimMesh.h>

Constructors

Mesh()

Methods

Clear mesh.

void clear()

Check mesh.

bool isLoaded() const

Info mesh.

bool info(const char *name, Flags flags = FlagNone, Async *async = nullptr)
bool info(const String &name, Flags flags = FlagNone, Async *async = nullptr)
bool info(Stream &stream, Flags flags = FlagNone, Async *async = nullptr)
bool info(const char *name, Async *async)
bool info(const String &name, Async *async)
bool info(Stream &stream, Async *async)

Load mesh.

bool load(const char *name, Flags flags = FlagNone, Async *async = nullptr)
bool load(const String &name, Flags flags = FlagNone, Async *async = nullptr)
bool load(Stream &stream, Flags flags = FlagNone, Async *async = nullptr)
bool load(const char *name, Async *async)
bool load(const String &name, Async *async)
bool load(Stream &stream, Async *async)

Save mesh.

bool save(const char *name, Flags flags = FlagNone) const
bool save(const String &name, Flags flags = FlagNone) const
bool save(Stream &stream, Flags flags = FlagNone) const

Mesh name.

void setName(const char *name)
String getName() const

Brep basis.

bool setBasis(Axis front, Axis right, Axis up)
bool setBasis(Basis basis)
Axis getFrontAxis() const
Axis getRightAxis() const
Axis getUpAxis() const
Basis getBasis() const
const char *getFrontAxisName() const
const char *getRightAxisName() const
const char *getUpAxisName() const
String getBasisName() const

Mesh nodes.

void clearNodes()
void reserveNodes(uint32_t num_nodes)
uint32_t addNode(MeshNode &node, bool check = true)
bool removeNode(MeshNode &node)
uint32_t findNode(const MeshNode &node) const
uint32_t findNode(const char *name) const
uint32_t getNumNodes() const
const Array<MeshNode> getNodes() const
Array<MeshNode> getNodes()
const MeshNode getNode(uint32_t index) const
MeshNode getNode(uint32_t index)

Create node transformations.

void createLocalTransforms(Matrix4x3d itransform = Matrix4x3d::identity)
void createGlobalTransforms(Matrix4x3d transform = Matrix4x3d::identity)
TypeNameDescription
Matrix4x3ditransformGlobal to Local transformation matrix
Matrix4x3dtransformLocal to Global transformation matrix

Mesh geometries.

void clearGeometries()
void reserveGeometries(uint32_t num_geometries)
uint32_t addGeometry(MeshGeometry &geometry, bool check = true)
uint32_t addGeometry(MeshGeometry &geometry, MeshNode &node, bool check = true)
bool removeGeometry(MeshGeometry &geometry)
bool replaceGeometry(MeshGeometry &old_geometry, MeshGeometry &geometry)
uint32_t findGeometry(const MeshGeometry &geometry) const
uint32_t findGeometry(const char *name) const
uint32_t getNumGeometries() const
const Array<MeshGeometry> getGeometries() const
Array<MeshGeometry> getGeometries()
const MeshGeometry getGeometry(uint32_t index) const
MeshGeometry getGeometry(uint32_t index)
bool hasGeometryIndices(Type type) const
bool hasGeometryAttribute(Type type) const
size_t getNumGeometryPositions() const
size_t getNumGeometryPrimitives() const

Mesh animations.

void clearAnimations()
void reserveAnimations(uint32_t num_animations)
uint32_t addAnimation(MeshAnimation &animation, bool check = true)
bool removeAnimation(MeshAnimation &animation)
bool replaceAnimation(MeshAnimation &old_animation, MeshAnimation &animation)
uint32_t findAnimation(const MeshAnimation &animation) const
uint32_t findAnimation(const char *name) const
uint32_t getNumAnimations() const
const Array<MeshAnimation> getAnimations() const
Array<MeshAnimation> getAnimations()
const MeshAnimation getAnimation(uint32_t index) const
MeshAnimation getAnimation(uint32_t index)

Mesh bound box.

BoundBoxd getBoundBox() const
BoundBoxd getBoundBox(const MeshNode &node) const
BoundBoxd getBoundBox(const MeshGeometry &geometry) const

Create bounds.

bool createBounds(bool force, Async *async = nullptr)
bool createBounds(Async *async = nullptr)
TypeNameDescription
boolforceForce bounding creation.

Create tangent basis.

bool createBasis(bool force, Async *async = nullptr)
bool createBasis(float32_t angle, bool force, Async *async = nullptr)
bool createBasis(Async *async = nullptr)
bool createBasis(float32_t angle, Async *async = nullptr)
TypeNameDescription
boolforceForce basis creation.

Create normals.

bool createNormals(bool force, Async *async = nullptr)
bool createNormals(float32_t angle, bool force, Async *async = nullptr)
bool createNormals(Async *async = nullptr)
bool createNormals(float32_t angle, Async *async = nullptr)
TypeNameDescription
boolforceForce normals creation.
float32_tangleSmoothing angle in degrees.

Create tangents.

bool createTangents(bool force, Async *async = nullptr)
bool createTangents(Async *async = nullptr)
TypeNameDescription
boolforceForce tangents creation.

Create islands.

bool createIslands(uint32_t max_attributes, uint32_t max_primitives, bool force, Async *async = nullptr)
bool createIslands(uint32_t max_attributes, uint32_t max_primitives, Async *async = nullptr)
TypeNameDescription
uint32_tmax_attributesMaximum number of attributes per island.
uint32_tmax_primitivesMaximum number of primitives per island.
boolforceForce islands creation.

Optimize indices order for cache.

bool optimizeIndices(uint32_t cache, bool transparent, Async *async = nullptr)
bool optimizeIndices(Async *async = nullptr)
bool optimizeIndices(uint32_t cache, Async *async = nullptr)

Optimize attributes and make single indices.

bool optimizeAttributes(Async *async = nullptr)

Optimize materials remove duplicates.

void optimizeMaterials()

Optimize winding based on node transforms.

bool optimizeWinding(bool clockwise = false)
TypeNameDescription
boolclockwiseOptimize for clockwise winding.

Optimize geometries remove duplicates.

void optimizeGeometries(float32_t threshold = 1e-3f, uint32_t depth = 16)
TypeNameDescription
float32_tthresholdSpatial compare threshold.
uint32_tdepthNumber of geometries to compare.

Optimize animation transforms.

void optimizeAnimations(float32_t threshold = 1e-6f)
TypeNameDescription
float32_tthresholdCompare threshold.

Optimize node and geometry order.

bool optimizeOrder()

Merge geometries.

void mergeGeometries()

Pack attributes.

bool packAttributes(bool remove = true)
bool unpackAttributes(bool remove = true)

Apply transform.

bool setTransform(Vector3d scale)

Memory usage.

size_t getMemory() const

Enums

Flags

Mesh flags.

NameValueDescription
FlagNone0
FlagEmbed(1 << 0)Embed resources.
Flag32Bit(1 << 1)32-bit precision.

Basis

Mesh basis.

NameValueDescription
BasisUnknown0Front right up.
BasisXUpRight1+Y +Z +X.
BasisYUpRight2+Z +X +Y.
BasisZUpRight3+X +Y +Z.
BasisXUpLeft4+Y -Z +X.
BasisYUpLeft5+Z -X +Y.
BasisZUpLeft6+X -Y +Z.
BasisZUpMaya7-Y +X +Z.
NumBases8

Axis

NameValue
AxisUnknown0
AxisPX1
AxisPY2
AxisPZ3
AxisNX4
AxisNY5
AxisNZ6
NumAxes7