Momentum
A library for solving nonlinear optimization problems related to human body kinematics
Loading...
Searching...
No Matches
linear_skinning.h
Go to the documentation of this file.
1/*
2 * Copyright (c) Meta Platforms, Inc. and affiliates.
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 */
7
8#pragma once
9
13#include <momentum/math/fwd.h>
15#include <momentum/math/types.h>
16
17#include <vector>
18
19namespace momentum {
20
40
41// clang-format off
56// clang-format on
57
65template <typename T>
66std::vector<Eigen::Matrix4<T>> computeSkinningTransforms(
67 typename DeduceSpanType<const JointStateT<T>>::type jointState,
68 const TransformationListT<T>& inverseBindPose);
69
79template <typename T>
80std::vector<Vector3<T>> applySSD(
81 const SkinWeights& skin,
82 typename DeduceSpanType<const Vector3<T>>::type points,
83 typename DeduceSpanType<const Eigen::Matrix4<T>>::type skinningTransforms);
84
95template <typename T>
96std::vector<Vector3<T>> applySSD(
97 const TransformationListT<T>& inverseBindPose,
98 const SkinWeights& skin,
99 typename DeduceSpanType<const Vector3<T>>::type points,
100 typename DeduceSpanType<const JointStateT<T>>::type jointState);
101
112template <typename T>
113std::vector<Vector3<T>> applySSD(
114 const TransformationListT<T>& inverseBindPose,
115 const SkinWeights& skin,
116 typename DeduceSpanType<const Vector3<T>>::type points,
117 const SkeletonStateT<T>& state);
118
129template <typename T>
130std::vector<Vector3<T>> applySSD(
131 const TransformationListT<T>& inverseBindPose,
132 const SkinWeights& skin,
133 typename DeduceSpanType<const Vector3<T>>::type points,
134 const TransformationListT<T>& worldTransforms);
135
146template <typename T>
147std::vector<Vector3<T>> applySSD(
148 const TransformationListT<T>& inverseBindPose,
149 const SkinWeights& skin,
150 typename DeduceSpanType<const Vector3<T>>::type points,
151 typename DeduceSpanType<const TransformT<T>>::type worldTransforms);
152
162template <typename T>
163void applySSD(
164 const SkinWeights& skin,
165 const MeshT<T>& mesh,
166 typename DeduceSpanType<const Eigen::Matrix4<T>>::type skinningTransforms,
167 MeshT<T>& outputMesh);
168
179template <typename T>
180void applySSD(
181 const TransformationListT<T>& inverseBindPose,
182 const SkinWeights& skin,
183 const MeshT<T>& mesh,
184 typename DeduceSpanType<const JointStateT<T>>::type jointState,
185 MeshT<T>& outputMesh);
186
197template <typename T>
198void applySSD(
199 const TransformationListT<T>& inverseBindPose,
200 const SkinWeights& skin,
201 const MeshT<T>& mesh,
202 const SkeletonStateT<T>& state,
203 MeshT<T>& outputMesh);
204
215template <typename T>
216void applySSD(
217 const TransformationListT<T>& inverseBindPose,
218 const SkinWeights& skin,
219 const MeshT<T>& mesh,
220 const TransformationListT<T>& worldTransforms,
221 MeshT<T>& outputMesh);
222
233template <typename T>
234void applySSD(
235 const TransformationListT<T>& inverseBindPose,
236 const SkinWeights& skin,
237 const MeshT<T>& mesh,
238 typename DeduceSpanType<const TransformT<T>>::type worldTransforms,
239 MeshT<T>& outputMesh);
240
252 const TransformationList& inverseBindPose,
253 const SkinWeights& skin,
254 const SkeletonState& state,
255 size_t index);
256
267std::vector<Vector3f> applyInverseSSD(
268 const TransformationList& inverseBindPose,
269 const SkinWeights& skin,
271 const SkeletonState& state);
272
283void applyInverseSSD(
284 const TransformationList& inverseBindPose,
285 const SkinWeights& skin,
287 const SkeletonState& state,
288 Mesh& mesh);
289
302template <typename T>
304 const SkinnedLocator& locator,
305 const Vector3<T>& restPosition,
306 const TransformationList& inverseBindPose,
307 const SkeletonStateT<T>& state);
308
317template <typename T>
319 const SkinnedLocator& locator,
320 const TransformationList& inverseBindPose,
321 const SkeletonStateT<T>& state);
322
323} // namespace momentum
Affine3< float > Affine3f
Definition types.h:405
Affine3f getInverseSSDTransformation(const TransformationList &inverseBindPose, const SkinWeights &skin, const SkeletonState &state, const size_t index)
Computes the inverse SSD transformation for a specific vertex.
Vector3< T > getSkinnedLocatorPosition(const SkinnedLocator &locator, const Vector3< T > &restPosition, const TransformationList &inverseBindPose, const SkeletonStateT< T > &state)
Computes the world position of a skinned locator using linear blend skinning.
std::vector< Affine3f > TransformationList
One affine transform per joint, indexed by joint id.
Definition types.h:410
MeshT< float > Mesh
Definition fwd.h:20
SkeletonStateT< float > SkeletonState
Definition fwd.h:282
void applyInverseSSD(const TransformationList &inverseBindPose, const SkinWeights &skin, momentum::span< const Vector3f > points, const SkeletonState &state, Mesh &mesh)
Applies inverse SSD to points, storing results in a mesh.
std::vector< Vector3< T > > applySSD(const SkinWeights &skin, typename DeduceSpanType< const Vector3< T > >::type points, typename DeduceSpanType< const Eigen::Matrix4< T > >::type skinningTransforms)
Applies forward SSD (linear blend skinning) to points using precomputed skinning transforms.
gsl::span< T > span
Span type alias using gsl::span (C++17 fallback).
Definition span_compat.h:54
Vector< T, 3 > Vector3
Definition types.h:236
std::vector< Eigen::Matrix4< T > > computeSkinningTransforms(typename DeduceSpanType< const JointStateT< T > >::type jointState, const TransformationListT< T > &inverseBindPose)
Computes the skinning transforms from joint states and inverse bind poses.
std::vector< Affine3< T > > TransformationListT
Scalar-templated counterpart of TransformationList.
Definition types.h:413
Provides a C++17-compatible span type alias.
A utility struct that facilitates the deduction of a momentum::span type from a given type.
Definition types.h:453
Represents the state of a joint with local and global transformations.
Definition joint_state.h:50
A generic mesh representation with support for vertices, faces, lines, and texture coordinates.
Definition mesh.h:20
Represents the complete state of a skeleton.
Linear blend skinning weights for a character mesh: per-vertex joint indices and influence weights.
A locator attached to multiple joints, with its runtime position determined by blending the skinning ...
Lightweight transform with separate rotation, translation, and uniform scaling.
Definition transform.h:36