|
Momentum
A library for solving nonlinear optimization problems related to human body kinematics
|
Skinning class that combines blend shape vectors with a base shape. More...
#include <blend_shape.h>
Public Member Functions | |
| BlendShape () | |
| BlendShape (momentum::span< const Vector3f > baseShape, size_t numShapes, momentum::span< const std::string > shapeNames={}) | |
| void | setBaseShape (momentum::span< const Vector3f > baseShape) |
| const std::vector< Vector3f > & | getBaseShape () const |
| bool | getFactorizationValid () const |
| Whether SVD factorization is up-to-date. | |
| template<typename T> | |
| std::vector< Eigen::Vector3< T > > | computeShape (const BlendWeightsT< T > &coefficients) const |
| Applies blend weights to create a deformed shape. | |
| template<typename T> | |
| void | computeShape (const BlendWeightsT< T > &coefficients, std::vector< Eigen::Vector3< T > > &output) const |
| Output parameter version of computeShape, for callers that want to reuse a preallocated buffer. | |
| VectorXf | estimateCoefficients (momentum::span< const Vector3f > vertices, float regularization=1.0f, const VectorXf &weights=VectorXf()) const |
| Solves for blend weights that best approximate a target shape. | |
| void | setShapeVector (size_t index, momentum::span< const Vector3f > shapeVector, std::string_view name="") |
| Overrides base method to also invalidate the cached SVD factorization used by estimateCoefficients. | |
| bool | isApprox (const BlendShape &blendShape) const |
| Compares all components of two blend shapes. | |
| Public Member Functions inherited from momentum::BlendShapeBase | |
| BlendShapeBase ()=default | |
| BlendShapeBase (const BlendShapeBase &)=default | |
| BlendShapeBase & | operator= (const BlendShapeBase &)=default |
| BlendShapeBase (BlendShapeBase &&)=default | |
| BlendShapeBase & | operator= (BlendShapeBase &&)=default |
| BlendShapeBase (size_t modelSize, size_t numShapes, momentum::span< const std::string > shapeNames={}) | |
| virtual | ~BlendShapeBase ()=default |
| void | setShapeVectors (const MatrixXf &shapeVectors, momentum::span< const std::string > shapeNames={}) |
| const MatrixXf & | getShapeVectors () const |
| template<typename T> | |
| VectorX< T > | computeDeltas (const BlendWeightsT< T > &blendWeights) const |
| Calculates weighted combination of shape vectors. | |
| template<typename T> | |
| void | applyDeltas (const BlendWeightsT< T > &blendWeights, std::vector< Eigen::Vector3< T > > &result) const |
| Adds weighted shape vectors to existing vertices. | |
| void | setShapeVector (size_t index, momentum::span< const Vector3f > shapeVector, std::string_view name="") |
| Eigen::Index | shapeSize () const |
| size_t | modelSize () const |
| const std::vector< std::string > & | getShapeNames () const |
| std::string_view | getShapeName (size_t index) const |
| void | setShapeName (size_t index, std::string_view name) |
Additional Inherited Members | |
| Protected Attributes inherited from momentum::BlendShapeBase | |
| MatrixXf | shapeVectors_ |
| std::vector< std::string > | shapeNames_ |
Skinning class that combines blend shape vectors with a base shape.
Extends BlendShapeBase by adding a base shape (e.g., PCA mean) and functionality for computing deformed shapes and estimating blend coefficients. Primarily used to model identity-dependent shape deformations.
Definition at line 19 of file blend_shape.h.
|
inline |
Definition at line 21 of file blend_shape.h.
Referenced by isApprox().
| momentum::BlendShape::BlendShape | ( | momentum::span< const Vector3f > | baseShape, |
| size_t | numShapes, | ||
| momentum::span< const std::string > | shapeNames = {} ) |
| baseShape | Base shape vertices |
| numShapes | Number of blend shapes |
| shapeNames | Names of the blend shapes (will be automatically generated if empty or not the right size) |
Definition at line 96 of file blend_shape.cpp.
References momentum::BlendShapeBase::BlendShapeBase().
|
nodiscard |
Applies blend weights to create a deformed shape.
Adds weighted shape vectors to the base shape
| T | Scalar type (float or double) |
| coefficients | Weights for each shape vector |
Definition at line 17 of file blend_shape.cpp.
References computeShape().
Referenced by computeShape().
| void momentum::BlendShape::computeShape | ( | const BlendWeightsT< T > & | coefficients, |
| std::vector< Eigen::Vector3< T > > & | output ) const |
Output parameter version of computeShape, for callers that want to reuse a preallocated buffer.
| T | Scalar type (float or double) |
| coefficients | Weights for each shape vector |
| output | [out] Resulting deformed shape; resized to the base shape's vertex count. |
Definition at line 25 of file blend_shape.cpp.
References momentum::cast(), momentum::BlendShapeBase::computeDeltas(), MT_CHECK, and momentum::BlendShapeBase::shapeVectors_.
|
nodiscard |
Solves for blend weights that best approximate a target shape.
Uses a thin SVD of the shape vectors when no per-vertex weights are supplied (the factorization is cached and reused across calls). When weights are supplied, builds a weighted normal-equation system with Tikhonov regularization on each call.
| vertices | Target shape to approximate, in the same vertex order as the base shape. |
| regularization | Tikhonov regularization weight; higher values bias coefficients toward zero. Only used when per-vertex weights are supplied. |
| weights | Optional per-vertex importance weights. Ignored unless its size equals vertices.size(); when ignored, the cached unweighted SVD path is used. |
Definition at line 41 of file blend_shape.cpp.
References MT_CHECK, and momentum::BlendShapeBase::shapeVectors_.
|
inlinenodiscard |
Definition at line 36 of file blend_shape.h.
Referenced by isApprox(), and momentum::saveBlendShape().
|
inlinenodiscard |
Whether SVD factorization is up-to-date.
Definition at line 41 of file blend_shape.h.
Referenced by isApprox().
|
nodiscard |
Compares all components of two blend shapes.
| blendShape | Other blend shape to compare with |
Definition at line 115 of file blend_shape.cpp.
References BlendShape(), getBaseShape(), getFactorizationValid(), momentum::BlendShapeBase::getShapeVectors(), isApprox(), and momentum::BlendShapeBase::shapeVectors_.
Referenced by isApprox().
|
inline |
Definition at line 32 of file blend_shape.h.
| void momentum::BlendShape::setShapeVector | ( | size_t | index, |
| momentum::span< const Vector3f > | shapeVector, | ||
| std::string_view | name = "" ) |
Overrides base method to also invalidate the cached SVD factorization used by estimateCoefficients.
| index | Index of the shape vector to set |
| shapeVector | Vector of vertex offsets |
| name | Optional name for the shape vector; if empty, the name is auto-generated as "shape_<index>". |
Definition at line 104 of file blend_shape.cpp.
References momentum::BlendShapeBase::setShapeVector().