Skip to main content

MeshGeometry

The MeshGeometry class represents the geometric structure of a 3D mesh, including its vertices, indices, attributes, joints, and materials. It allows for defining and manipulating the geometry hierarchical relationships, such as setting parent-child relationships between geometries, with support for two parent geometries to create seamless Level of Detail (LOD) transitions. This structure facilitates smooth blending of multiple geometric details based on distance or camera view, ensuring efficient rendering by dynamically adjusting the complexity of the mesh. The class provides methods for managing attributes like positions, normals, tangents, and texcoords, along with supporting operations for creating normals, tangents, and tangent basis. It also includes functionality for creating, optimizing, and managing materials, bounds, and visibility ranges.

#include <format/TellusimMesh.h>

Constructors

explicit MeshGeometry(const char *name = nullptr)
explicit MeshGeometry(Mesh &mesh, const char *name = nullptr)

Methods

Clear geometry.

void clear()

Geometry name.

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

Geometry index.

uint32_t getIndex() const

Geometry mesh.

void setMesh(Mesh &mesh, bool check = true)
const Mesh getMesh() const
Mesh getMesh()

Geometry parent.

uint32_t setParent0(MeshGeometry &parent, bool check = true)
uint32_t setParent1(MeshGeometry &parent, bool check = true)
const MeshGeometry getParent0() const
const MeshGeometry getParent1() const
MeshGeometry getParent0()
MeshGeometry getParent1()
bool isRoot() const

Geometry children.

void reserveChildren(uint32_t num_children)
uint32_t addChild0(MeshGeometry &child, bool check = true)
uint32_t addChild1(MeshGeometry &child, bool check = true)
bool removeChild(MeshGeometry &child)
void releaseChildren()
uint32_t findChild(const MeshGeometry &child) const
uint32_t getNumChildren() const
const Array<MeshGeometry> getChildren() const
Array<MeshGeometry> getChildren()
const MeshGeometry getChild(uint32_t index) const
MeshGeometry getChild(uint32_t index)

Geometry indices.

void clearIndices()
void reserveIndices(uint32_t num_indices)
uint32_t addIndices(MeshIndices &indices, bool check = true)
bool removeIndices(MeshIndices &indices)
bool replaceIndices(MeshIndices &old_indices, MeshIndices &indices)
uint32_t findIndices(const MeshIndices &indices) const
uint32_t findIndices(Type type) const
bool hasIndices(Type type) const
bool hasSolidIndices() const
uint32_t getNumIndices(Type type) const
const MeshIndices getIndices(Type type) const
MeshIndices getIndices(Type type)
uint32_t getNumIndices() const
const Array<MeshIndices> getIndices() const
Array<MeshIndices> getIndices()
const MeshIndices getIndices(uint32_t index) const
MeshIndices getIndices(uint32_t index)

Geometry attributes.

void clearAttributes()
void reserveAttributes(uint32_t num_attributes)
uint32_t addAttribute(MeshAttribute &attribute, bool check = true)
uint32_t addAttribute(MeshAttribute &attribute, MeshIndices &indices, bool check = true)
bool removeAttribute(MeshAttribute &attribute)
bool replaceAttribute(MeshAttribute &old_attribute, MeshAttribute &attribute)
bool replaceAttributeIndices(const MeshIndices &old_indices, MeshIndices &indices)
uint32_t findAttribute(Type type, Format format, uint32_t index = 0) const
uint32_t findAttribute(Type type, uint32_t index = 0) const
uint32_t findAttribute(const char *name, uint32_t index = 0) const
uint32_t findAttribute(const MeshAttribute &attribute) const
bool hasAttribute(Type type, Format format, uint32_t index = 0) const
bool hasAttribute(Type type, uint32_t index = 0) const
bool hasAttribute(const char *name, uint32_t index = 0) const
bool hasAttribute(const MeshAttribute &attribute) const
uint32_t getNumAttributes(Type type) const
uint32_t getNumAttributes(const MeshIndices &indices) const
const MeshAttribute getAttribute(Type type, uint32_t index = 0) const
MeshAttribute getAttribute(Type type, uint32_t index = 0)
uint32_t getNumAttributes() const
const Array<MeshAttribute> getAttributes() const
Array<MeshAttribute> getAttributes()
const MeshAttribute getAttribute(uint32_t index) const
MeshAttribute getAttribute(uint32_t index)

Geometry joints.

void clearJoints()
void reserveJoints(uint32_t num_joints)
uint32_t addJoint(MeshJoint &joint, bool check = true)
uint32_t addJoint(MeshJoint &joint, MeshNode &node, bool check = true)
bool removeJoint(MeshJoint &joint)
bool replaceJoint(MeshJoint &old_joint, MeshJoint &joint)
uint32_t findJoint(const MeshJoint &joint) const
uint32_t findJoint(const MeshNode &node) const
uint32_t findJoint(const char *name) const
uint32_t getNumJoints() const
const Array<MeshJoint> getJoints() const
Array<MeshJoint> getJoints()
const MeshJoint getJoint(uint32_t index) const
MeshJoint getJoint(uint32_t index)

Geometry materials.

void clearMaterials()
void reserveMaterials(uint32_t num_materials)
uint32_t addMaterial(MeshMaterial &material, bool check = true)
uint32_t addMaterial(MeshMaterial &material, MeshIndices &indices, bool check = true)
bool removeMaterial(MeshMaterial &material)
bool replaceMaterial(MeshMaterial &old_material, MeshMaterial &material)
uint32_t findMaterial(const MeshMaterial &material) const
uint32_t findMaterial(const char *name) const
uint32_t getNumMaterials() const
const Array<MeshMaterial> getMaterials() const
Array<MeshMaterial> getMaterials()
const MeshMaterial getMaterial(uint32_t index) const
MeshMaterial getMaterial(uint32_t index)

Geometry bound box.

void setBoundBox(BoundBoxf box)
const BoundBoxf getBoundBox() const

Geometry bound sphere.

void setBoundSphere(BoundSpheref sphere)
const BoundSpheref getBoundSphere() const

Geometry transform.

bool setTransform(Vector3f scale)
bool setTransform(Matrix4x3f transform, bool apply = false)
const Matrix4x3f getTransform() const

Geometry inverse joint transform.

void setJointITransform(Matrix4x3f itransform)
const Matrix4x3f getJointITransform() const

Visibility range.

void setMinVisibility(float32_t distance)
void setMaxVisibility(float32_t distance)
void setVisibilityRange(float32_t min, float32_t max)
float32_t getMinVisibility() const
float32_t getMaxVisibility() const
bool hasVisibilityRange() const

Visibility error.

void setVisibilityError(float32_t error)
float32_t getVisibilityError() const

Create bounds.

bool createBounds(bool force = false, uint32_t position = Maxu32)
TypeNameDescription
boolforceForce bounding creation.
uint32_tpositionPosition attribute index.

Create tangent basis.

uint32_t createBasis(bool force = false, uint32_t position = Maxu32, uint32_t normal = Maxu32, uint32_t tangent = Maxu32, bool append = false)
uint32_t createBasis(float32_t angle, bool force = false, uint32_t position = Maxu32, uint32_t normal = Maxu32, uint32_t tangent = Maxu32, bool append = false)
TypeNameDescription
boolforceForce basis creation.
uint32_tpositionPosition attribute index.
uint32_tnormalNormal attribute index.
uint32_ttangentTangent attribute index.
boolappendAppend new basis attribute.

Create normals.

uint32_t createNormals(bool force = false, uint32_t position = Maxu32, bool append = false)
uint32_t createNormals(float32_t angle, bool force = false, uint32_t position = Maxu32, bool append = false)
TypeNameDescription
boolforceForce normals creation.
uint32_tpositionPosition attribute index.
float32_tangleSmoothing angle in degrees.
boolappendAppend new normal attribute.

Create tangents.

uint32_t createTangents(bool force = false, uint32_t position = Maxu32, uint32_t normal = Maxu32, uint32_t texcoord = Maxu32, bool append = false)
TypeNameDescription
boolforceForce tangents creation.
uint32_tpositionPosition attribute index.
uint32_tnormalNormal attribute index.
uint32_ttexcoordTexCoord attribute index.
boolappendAppend new tangent attribute.

Create islands.

uint32_t createIslands(uint32_t max_attributes, uint32_t max_primitives, bool force = false, uint32_t index = Maxu32, uint32_t position = Maxu32, bool append = false)
TypeNameDescription
uint32_tmax_attributesMaximum number of attributes per island.
uint32_tmax_primitivesMaximum number of primitives per island.
uint32_tindexIndices index to update.
uint32_tpositionPosition attribute index.
boolappendAppend new island indices.

Optimize indices.

bool optimizeIndices(uint32_t cache = 32, bool transparent = false, uint32_t index = Maxu32, uint32_t position = Maxu32)
TypeNameDescription
uint32_tcacheVertex cache size.
booltransparentOptimize for transparency.
uint32_tindexIndices index to optimize.
uint32_tpositionPosition attribute index.

Optimize attributes and make single indices.

bool optimizeAttributes(uint32_t material = Maxu32)
TypeNameDescription
uint32_tmaterialmaterial index.

Optimize materials remove duplicates.

void optimizeMaterials()

Pack attributes (morph targets, texture coordinates and vertex colors).

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

Compare geometries.

int32_t compare(const MeshGeometry &geometry, Matrix4x3f transform = Matrix4x3f::identity, float32_t threshold = 1e-6f, bool spatial = true) const

Optimized geometry flag (if geometry contains single indices).

bool isOptimized() const

Validate geometry.

bool validate() const

Memory usage.

size_t getMemory() const