MeshAttribute
The MeshAttribute class represents per-vertex attribute data in a mesh, such as positions, normals, texture coordinates, colors, and joint weights. Each attribute has a type, format, name, index (used for distinguishing between multiple attributes of the same type), and size. The class allows setting and retrieving attribute values, either directly or via associated index data (MeshIndices), and supports various utilities for transformation, morphing, packing/unpacking, and optimization.
#include <format/TellusimMesh.h>
Constructors
explicit MeshAttribute(const char *name = nullptr, uint32_t index = 0)
MeshAttribute(Type type, Format format, const char *name = nullptr, uint32_t index = 0)
MeshAttribute(Type type, Format format, uint32_t size, const char *name = nullptr, uint32_t index = 0)
MeshAttribute(Type type, Format format, uint32_t size, uint32_t index)
Methods
Clear attributes.
void clear()
Attribute name.
void setName(const char *name)
String getName() const
Create attribute.
void create(Type type, Format format, uint32_t size = 0)
Attribute type.
Type getType() const
static const char *getTypeName(Type type)
const char *getTypeName() const
bool isUnknown() const
bool isPosition() const
bool isBasis() const
bool isNormal() const
bool isTangent() const
bool isBinormal() const
bool isSpatial() const
bool isNormalized() const
bool isTexCoord() const
bool isWeights() const
bool isJoints() const
bool isColor() const
bool isVertex() const
bool isCrease() const
Attribute format.
Format getFormat() const
const char *getFormatName() const
uint32_t getComponents() const
bool isPacked() const
Attribute index.
void setIndex(uint32_t index)
uint32_t getIndex() const
Attribute indices.
void setIndices(MeshIndices &indices)
const MeshIndices getIndices() const
MeshIndices getIndices()
Attribute geometry.
void setGeometry(MeshGeometry &geometry, bool check = true)
const MeshGeometry getGeometry() const
MeshGeometry getGeometry()
Attribute size.
void setSize(uint32_t size, bool discard = true, bool clear = false)
uint32_t getSize() const
uint32_t getStride() const
size_t getBytes() const
Attribute data.
void setData(const void *src, uint32_t size = 0, uint32_t stride = 0)
void setData(const void *src, Array<uint32_t> indices, uint32_t stride = 0)
void getData(void *dest, uint32_t size = 0, uint32_t stride = 0) const
void getData(void *dest, const MeshIndices &indices, uint32_t stride = 0) const
void getData(void *dest, Array<uint32_t> indices, uint32_t stride = 0) const
const void *getData() const
void *getData()
Attribute values.
template<> void set(const Type &value)
template<> void set(uint32_t index, const Type &value)
template<> const Type &get(uint32_t index) const
template<> Type &get(uint32_t index)
Attribute value.
void setValue(uint32_t index, const void *src, size_t size)
void getValue(uint32_t index, void *dest, size_t size) const
Attribute pointers.
const void *getPtr(uint32_t index) const
void *getPtr(uint32_t index)
Compare attributes.
int32_t compare(const MeshAttribute &attribute, Matrix4x3f transform = Matrix4x3f::identity, float32_t threshold = 1e-6f, bool spatial = true) const
Add attribute.
void addAttribute(const MeshAttribute &attribute)
Apply transform.
bool setTransform(Matrix4x3f transform)
Morph attribute.
bool morphAttribute(const MeshAttribute &attribute, float32_t k)
Pack attributes.
bool packAttributes(const MeshAttribute &attribute_0, const MeshAttribute &attribute_1, Format format)
bool unpackAttributes(MeshAttribute &attribute_0, MeshAttribute &attribute_1) const
Optimize attribute by removing duplicates.
MeshAttribute optimizeAttribute(MeshIndices &indices) const
Convert attribute to direct.
MeshAttribute toDirect(const MeshIndices &indices) const
Convert attribute to format.
MeshAttribute toFormat(Format format) const
Convert attribute to type.
MeshAttribute toType(Type type) const
Covariance matrix.
Matrix4x3f getCovarianceMatrix() const
Minimal bound transform.
Matrix4x3f getMinTransform() const
Attribute bound box.
BoundBoxf getBoundBox() const
Attribute bound sphere.
BoundSpheref getBoundSphere() const
Memory usage.
size_t getMemory() const
Enums
Type
Attribute types.
Name | Value | Description |
---|---|---|
TypeUnknown | 0 | |
TypePosition | 1 | Position attribute. |
TypeBasis | 2 | Basis attribute. |
TypeNormal | 3 | Normal attribute. |
TypeTangent | 4 | Tangent attribute. |
TypeBinormal | 5 | Binormal attribute. |
TypeTexCoord | 6 | Texcoord attribute. |
TypeWeights | 7 | Weights attribute. |
TypeJoints | 8 | Joints attribute. |
TypeColor | 9 | Color attribute. |
TypeCrease | 10 | Crease attribute. |
TypeIndex | 11 | Index attribute. |
NumTypes | 12 |