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)
Type | Name | Description |
---|---|---|
Matrix4x3d | itransform | Global to Local transformation matrix |
Matrix4x3d | transform | Local 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)
Type | Name | Description |
---|---|---|
bool | force | Force 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)
Type | Name | Description |
---|---|---|
bool | force | Force 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)
Type | Name | Description |
---|---|---|
bool | force | Force normals creation. |
float32_t | angle | Smoothing angle in degrees. |
Create tangents.
bool createTangents(bool force, Async *async = nullptr)
bool createTangents(Async *async = nullptr)
Type | Name | Description |
---|---|---|
bool | force | Force 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)
Type | Name | Description |
---|---|---|
uint32_t | max_attributes | Maximum number of attributes per island. |
uint32_t | max_primitives | Maximum number of primitives per island. |
bool | force | Force 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)
Type | Name | Description |
---|---|---|
bool | clockwise | Optimize for clockwise winding. |
Optimize geometries remove duplicates.
void optimizeGeometries(float32_t threshold = 1e-3f, uint32_t depth = 16)
Type | Name | Description |
---|---|---|
float32_t | threshold | Spatial compare threshold. |
uint32_t | depth | Number of geometries to compare. |
Optimize animation transforms.
void optimizeAnimations(float32_t threshold = 1e-6f)
Type | Name | Description |
---|---|---|
float32_t | threshold | Compare 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.
Name | Value | Description |
---|---|---|
FlagNone | 0 | |
FlagEmbed | (1 << 0) | Embed resources. |
Flag32Bit | (1 << 1) | 32-bit precision. |
Basis
Mesh basis.
Name | Value | Description |
---|---|---|
BasisUnknown | 0 | Front right up. |
BasisXUpRight | 1 | +Y +Z +X. |
BasisYUpRight | 2 | +Z +X +Y. |
BasisZUpRight | 3 | +X +Y +Z. |
BasisXUpLeft | 4 | +Y -Z +X. |
BasisYUpLeft | 5 | +Z -X +Y. |
BasisZUpLeft | 6 | +X -Y +Z. |
BasisZUpMaya | 7 | -Y +X +Z. |
NumBases | 8 |
Axis
Name | Value |
---|---|
AxisUnknown | 0 |
AxisPX | 1 |
AxisPY | 2 |
AxisPZ | 3 |
AxisNX | 4 |
AxisNY | 5 |
AxisNZ | 6 |
NumAxes | 7 |