|
Momentum
A library for solving nonlinear optimization problems related to human body kinematics
|
A generic mesh representation with support for vertices, faces, lines, and texture coordinates. More...
#include <mesh.h>
Public Member Functions | |
| void | updateNormals () |
| Compute vertex normals by averaging connected face normals. | |
| template<typename T2> | |
| MeshT< T2 > | cast () const |
| Cast the mesh to a different scalar type. | |
| void | reset () |
| Reset the mesh by clearing all data. | |
Public Attributes | |
| std::vector< Eigen::Vector3< T > > | vertices |
| List of mesh vertices in 3D space. | |
| std::vector< Eigen::Vector3< T > > | normals |
| List of vertex normals (same size as vertices when computed). | |
| std::vector< Eigen::Vector3i > | faces |
| List of triangular faces defined by vertex indices. | |
| std::vector< std::vector< int32_t > > | lines |
| List of polylines defined by vertex indices Each inner vector represents a single polyline. | |
| std::vector< Eigen::Vector3b > | colors |
| List of per-vertex RGB colors (0-255 for each channel). | |
| std::vector< T > | confidence |
| List of per-vertex confidence values Higher values typically indicate higher confidence in the vertex position. | |
| std::vector< Eigen::Vector2f > | texcoords |
| List of texture coordinates (UV coordinates). | |
| std::vector< Eigen::Vector3i > | texcoord_faces |
| List of texture coordinate indices per face Maps each face to its corresponding texture coordinates. | |
| std::vector< std::vector< int32_t > > | texcoord_lines |
| List of texture coordinate indices per line Maps each line to its corresponding texture coordinates. | |
| std::vector< uint32_t > | polyFaces |
| Packed polygon face vertex indices (all polygons concatenated back-to-back). | |
| std::vector< uint32_t > | polyFaceSizes |
| Number of vertices in each polygon face. | |
| std::vector< uint32_t > | polyTexcoordFaces |
| Packed polygon face texture coordinate indices (same layout as polyFaces). | |
A generic mesh representation with support for vertices, faces, lines, and texture coordinates.
| T | The scalar type used for vertex coordinates and confidence values (typically float or double) |
|
nodiscard |
Cast the mesh to a different scalar type.
This method creates a new mesh with all numeric data converted to the target type. Vertex positions, normals, and confidence values are cast to the new type. Non-numeric data like faces and lines remain unchanged.
| T2 | The target scalar type |
Definition at line 65 of file mesh.cpp.
References momentum::castVectors(), colors, confidence, faces, lines, normals, polyFaces, polyFaceSizes, polyTexcoordFaces, texcoord_faces, texcoord_lines, texcoords, and vertices.
| void momentum::MeshT< T >::reset | ( | ) |
Reset the mesh by clearing all data.
This method clears all vectors, effectively resetting the mesh to an empty state.
Definition at line 83 of file mesh.cpp.
References colors, confidence, faces, lines, normals, polyFaces, polyFaceSizes, polyTexcoordFaces, texcoord_faces, texcoord_lines, texcoords, and vertices.
| void momentum::MeshT< T >::updateNormals | ( | ) |
Compute vertex normals by averaging connected face normals.
This method calculates normals for each vertex by averaging the normals of all connected faces. The resulting normals are normalized to unit length. If a vertex is part of a degenerate face (e.g., colinear vertices), that face will not contribute to the vertex normal.
Definition at line 17 of file mesh.cpp.
References momentum::cross(), faces, momentum::IsNanNoOpt(), momentum::normal(), normals, and vertices.
Referenced by momentum::generateBoxMesh(), momentum::generateCylinderMesh(), momentum::generateSphereMesh(), and momentum::loadObjMesh().
| std::vector<Eigen::Vector3b> momentum::MeshT< T >::colors |
List of per-vertex RGB colors (0-255 for each channel).
Definition at line 35 of file mesh.h.
Referenced by cast(), momentum::loadMeshFromUsd(), momentum::logMesh(), reset(), momentum::saveMeshToUsd(), and momentum::splitMeshByTextureRegion().
| std::vector<T> momentum::MeshT< T >::confidence |
List of per-vertex confidence values Higher values typically indicate higher confidence in the vertex position.
Definition at line 39 of file mesh.h.
Referenced by cast(), momentum::loadMeshFromUsd(), reset(), momentum::saveMeshToUsd(), and momentum::splitMeshByTextureRegion().
| std::vector<Eigen::Vector3i> momentum::MeshT< T >::faces |
List of triangular faces defined by vertex indices.
Definition at line 28 of file mesh.h.
Referenced by momentum::applySSD(), momentum::buildTriangleAdjacency(), cast(), momentum::classifyTrianglesByTexture(), momentum::closestPointOnMeshMatchingParent(), momentum::createSkinnedLocatorMeshConstraints(), momentum::facesToVertices(), momentum::findCandidateTrianglesDfs(), momentum::generateBoxMesh(), momentum::generateCylinderMesh(), momentum::generateSphereMesh(), momentum::intersectFace(), momentum::intersectMesh(), momentum::intersectMeshBruteForce(), momentum::loadMeshFromUsd(), momentum::loadObjMesh(), momentum::logMesh(), momentum::reduceMeshByFaces(), reset(), momentum::saveMeshToUsd(), momentum::splitMeshByTextureRegion(), updateNormals(), momentum::verticesToFaces(), and momentum::fbx_internal::writePolygonsToFbxMesh().
| std::vector<std::vector<int32_t> > momentum::MeshT< T >::lines |
| std::vector<Eigen::Vector3<T> > momentum::MeshT< T >::normals |
List of vertex normals (same size as vertices when computed).
Definition at line 25 of file mesh.h.
Referenced by momentum::applySSD(), cast(), momentum::loadMeshFromUsd(), momentum::logMesh(), reset(), momentum::saveMeshToUsd(), momentum::splitMeshByTextureRegion(), and updateNormals().
| std::vector<uint32_t> momentum::MeshT< T >::polyFaces |
Packed polygon face vertex indices (all polygons concatenated back-to-back).
For example, a quad followed by a triangle would be: [v0, v1, v2, v3, v4, v5, v6]. This is an optional, redundant representation — the triangulated faces field is always required and used by all downstream code. Polygon data preserves the original topology (quads, n-gons) from source files like FBX.
Definition at line 67 of file mesh.h.
Referenced by cast(), momentum::polysToVertices(), reset(), momentum::verticesToPolys(), momentum::fbx_internal::writePolygonsToFbxMesh(), and momentum::fbx_internal::writeTextureUVIndicesToFbxMesh().
| std::vector<uint32_t> momentum::MeshT< T >::polyFaceSizes |
Number of vertices in each polygon face.
For example, [4, 3] means the first polygon is a quad, the second is a triangle. May be empty if polygon data is not available; see polyFaces.
Definition at line 73 of file mesh.h.
Referenced by cast(), momentum::polysToVertices(), momentum::reduceMeshByPolys(), reset(), momentum::verticesToPolys(), momentum::fbx_internal::writePolygonsToFbxMesh(), and momentum::fbx_internal::writeTextureUVIndicesToFbxMesh().
| std::vector<uint32_t> momentum::MeshT< T >::polyTexcoordFaces |
Packed polygon face texture coordinate indices (same layout as polyFaces).
Uses the same polyFaceSizes array — polygon sizes are identical for geometry and texcoords. May be empty if texture coordinates are not available; see polyFaces.
Definition at line 79 of file mesh.h.
Referenced by cast(), reset(), and momentum::fbx_internal::writeTextureUVIndicesToFbxMesh().
| std::vector<Eigen::Vector3i> momentum::MeshT< T >::texcoord_faces |
List of texture coordinate indices per face Maps each face to its corresponding texture coordinates.
Definition at line 55 of file mesh.h.
Referenced by cast(), momentum::classifyTrianglesByTexture(), reset(), momentum::splitMeshByTextureRegion(), and momentum::fbx_internal::writeTextureUVIndicesToFbxMesh().
| std::vector<std::vector<int32_t> > momentum::MeshT< T >::texcoord_lines |
| std::vector<Eigen::Vector2f> momentum::MeshT< T >::texcoords |
List of texture coordinates (UV coordinates).
The texture coordinates are format-agnostic, and it's the user's responsibility to ensure their consistent use.
For GLTF, Momentum stores and saves the texture coordinates as they are represented by the underlying GLTF parser. When dealing with FBX, the Y-axis is flipped. This distinction is crucial to understand when working with different formats.
Definition at line 51 of file mesh.h.
Referenced by cast(), momentum::classifyTrianglesByTexture(), reset(), and momentum::splitMeshByTextureRegion().
| std::vector<Eigen::Vector3<T> > momentum::MeshT< T >::vertices |
List of mesh vertices in 3D space.
Definition at line 22 of file mesh.h.
Referenced by momentum::applyInverseSSD(), momentum::applySSD(), cast(), momentum::closestPointOnMeshMatchingParent(), momentum::compute_d_targetNormal_d_vertexPos(), momentum::compute_d_targetNormal_d_vertexPos(), momentum::detail_sdf_collision::computeBoneBoundingBox(), momentum::computeTargetBaryPosition(), momentum::computeTargetBaryPosition(), momentum::computeTargetTriangleNormal(), momentum::computeTargetTriangleNormal(), momentum::createSkinnedLocatorMeshConstraints(), momentum::extractBlendShapeFromParams(), momentum::facesToVertices(), momentum::findCandidateTrianglesDfs(), momentum::generateBoxMesh(), momentum::generateCylinderMesh(), momentum::generateSphereMesh(), momentum::intersectFace(), momentum::intersectMesh(), momentum::intersectMeshBruteForce(), momentum::loadMeshFromUsd(), momentum::loadObjMesh(), momentum::logMesh(), momentum::polysToVertices(), momentum::reduceMeshByVertices(), reset(), momentum::saveMeshToUsd(), momentum::SkinningWeightIteratorT< T >::SkinningWeightIteratorT(), momentum::skinWithBlendShapes(), momentum::splitMeshByTextureRegion(), updateNormals(), momentum::verticesToFaces(), and momentum::verticesToPolys().