![]() |
Dem Bones
1.2.0
Skinning Decomposition Library
|
Smooth skinning decomposition with rigid bones and sparse, convex weights. More...
#include "DemBones/DemBones.h"
Public Types | |
using | MatrixX = Eigen::Matrix< _Scalar, Eigen::Dynamic, Eigen::Dynamic > |
using | Matrix4 = Eigen::Matrix< _Scalar, 4, 4 > |
using | Matrix3 = Eigen::Matrix< _Scalar, 3, 3 > |
using | VectorX = Eigen::Matrix< _Scalar, Eigen::Dynamic, 1 > |
using | Vector4 = Eigen::Matrix< _Scalar, 4, 1 > |
using | Vector3 = Eigen::Matrix< _Scalar, 3, 1 > |
using | SparseMatrix = Eigen::SparseMatrix< _Scalar > |
using | Triplet = Eigen::Triplet< _Scalar > |
Public Member Functions | |
DemBones () | |
Constructor and setting default parameters. More... | |
void | clear () |
Clear all data. More... | |
void | init () |
Initialize missing skinning weights and/or bone transformations. More... | |
void | computeTranformations () |
Update bone transformations by running nTransIters iterations with transAffine and transAffineNorm regularizers. More... | |
void | computeWeights () |
Update skinning weights by running nWeightsIters iterations with weightsSmooth and weightsSmoothStep regularizers. More... | |
void | compute () |
Skinning decomposition by nIters iterations of alternative updating weights and bone transformations. More... | |
_Scalar | rmse () |
virtual void | cbInitSplitBegin () |
Callback function invoked before each spliting of bone clusters in initialization. More... | |
virtual void | cbInitSplitEnd () |
Callback function invoked after each spliting of bone clusters in initialization. More... | |
virtual void | cbIterBegin () |
Callback function invoked before each global iteration update. More... | |
virtual bool | cbIterEnd () |
Callback function invoked after each global iteration update, stop iteration if return true. More... | |
virtual void | cbWeightsBegin () |
Callback function invoked before each skinning weights update. More... | |
virtual void | cbWeightsEnd () |
Callback function invoked after each skinning weights update. More... | |
virtual void | cbTranformationsBegin () |
Callback function invoked before each bone transformations update. More... | |
virtual void | cbTransformationsEnd () |
Callback function invoked after each bone transformations update. More... | |
virtual void | cbTransformationsIterBegin () |
Callback function invoked before each local bone transformations update iteration. More... | |
virtual bool | cbTransformationsIterEnd () |
Callback function invoked after each local bone transformations update iteration, stop iteration if return true. More... | |
virtual void | cbWeightsIterBegin () |
Callback function invoked before each local weights update iteration. More... | |
virtual bool | cbWeightsIterEnd () |
Callback function invoked after each local weights update iteration, stop iteration if return true. More... | |
Public Attributes | |
int | nIters |
[parameter ] Number of global iterations, default = 30 More... | |
int | nInitIters |
[parameter ] Number of clustering update iterations in the initalization, default = 10 More... | |
int | nTransIters |
[parameter ] Number of bone transformations update iterations per global iteration, default = 5 More... | |
_Scalar | transAffine |
[parameter ] Translations affinity soft constraint, default = 10.0 More... | |
_Scalar | transAffineNorm |
[parameter ] p-norm for bone translations affinity soft constraint, default = 4.0 More... | |
int | nWeightsIters |
[parameter ] Number of weights update iterations per global iteration, default = 3 More... | |
int | nnz |
[parameter ] Number of non-zero weights per vertex, default = 8 More... | |
_Scalar | weightsSmooth |
[parameter ] Weights smoothness soft constraint, default = 1e-4 More... | |
_Scalar | weightsSmoothStep |
[parameter ] Step size for the weights smoothness soft constraint, default = 1.0 More... | |
_Scalar | weightEps |
[parameter ] Epsilon for weights solver, default = 1e-15 More... | |
int | nV |
Number of vertices, typically indexed by i . More... | |
int | nB |
Number of bones, typically indexed by j . More... | |
int | nS |
Number of subjects, typically indexed by s . More... | |
int | nF |
Number of total frames, typically indexed by k , nF = fStart(nS) More... | |
Eigen::VectorXi | fStart |
Start frame indices, size = nS+1, fStart(s ), fStart(s+1 ) are data frames for subject s . More... | |
Eigen::VectorXi | subjectID |
Subject index of the frame, size = nF, subjectID(k )=s , where fStart(s ) <= k < fStart(s +1) More... | |
MatrixX | u |
Geometry at the rest poses, size = [3*nS, nV], u.col(i ).segment(3*s , 3) is the rest pose of vertex i of subject s . More... | |
SparseMatrix | w |
Skinning weights, size = [nB, nV], w.col(i ) are the skinning weights of vertex i , w(j , i ) is the influence of bone j to vertex i . More... | |
VectorX | lockW |
Skinning weights lock control, size = nV, lockW(i ) is the amount of input skinning weights will be kept for vertex i , where 0 (no lock) <= lockW(i ) <= 1 (full lock) More... | |
MatrixX | m |
Bone transformations, size = [4*nF*4, 4*nB], m.blk4(k , j ) is the 4*4 relative transformation matrix of bone j at frame k . More... | |
Eigen::VectorXi | lockM |
Bone transformation lock control, size = nB, lockM(j ) is the amount of input transformations will be kept for bone j , where lockM(j ) = 0 (no lock) or 1 (lock) More... | |
Eigen::Matrix< _AniMeshScalar, Eigen::Dynamic, Eigen::Dynamic > | v |
Animated mesh sequence, size = [3*nF, nV], v.col(i ).segment(3*k , 3) is the position of vertex i at frame k . More... | |
std::vector< std::vector< int > > | fv |
Mesh topology, size= [number of polygons ], fv[p ] is the vector of vertex indices of polygon p . More... | |
const int & | iter |
[zero indexed , read only ] Current global iteration number that can be used for callback functions More... | |
const int & | iterTransformations |
[zero indexed , read only ] Current bone transformations update iteration number that can be used for callback functions More... | |
const int & | iterWeights |
[zero indexed , read only ] Current weights update iteration number that can be used for callback functions More... | |
Smooth skinning decomposition with rigid bones and sparse, convex weights.
Setup the required data, parameters, and call either compute(), computeWeights(), computeTranformations(), or init().
Callback functions and read-only values can be used to report progress and stop on convergence: cbInitSplitBegin(), cbInitSplitEnd(), cbIterBegin(), cbIterEnd(), cbWeightsBegin(), cbWeightsEnd(), cbTranformationsBegin(), cbTransformationsEnd(), cbTransformationsIterBegin(), cbTransformationsIterEnd(), cbWeightsIterBegin(), cbWeightsIterEnd(), rmse(), iter, iterTransformations, iterWeights.
_Scalar is the floating-point data type. _AniMeshScalar is the floating-point data type of mesh sequence v.
Definition at line 66 of file DemBones.h.
using Dem::DemBones< _Scalar, _AniMeshScalar >::Matrix3 = Eigen::Matrix<_Scalar, 3, 3> |
Definition at line 72 of file DemBones.h.
using Dem::DemBones< _Scalar, _AniMeshScalar >::Matrix4 = Eigen::Matrix<_Scalar, 4, 4> |
Definition at line 71 of file DemBones.h.
using Dem::DemBones< _Scalar, _AniMeshScalar >::MatrixX = Eigen::Matrix<_Scalar, Eigen::Dynamic, Eigen::Dynamic> |
Definition at line 70 of file DemBones.h.
using Dem::DemBones< _Scalar, _AniMeshScalar >::SparseMatrix = Eigen::SparseMatrix<_Scalar> |
Definition at line 76 of file DemBones.h.
using Dem::DemBones< _Scalar, _AniMeshScalar >::Triplet = Eigen::Triplet<_Scalar> |
Definition at line 77 of file DemBones.h.
using Dem::DemBones< _Scalar, _AniMeshScalar >::Vector3 = Eigen::Matrix<_Scalar, 3, 1> |
Definition at line 75 of file DemBones.h.
using Dem::DemBones< _Scalar, _AniMeshScalar >::Vector4 = Eigen::Matrix<_Scalar, 4, 1> |
Definition at line 74 of file DemBones.h.
using Dem::DemBones< _Scalar, _AniMeshScalar >::VectorX = Eigen::Matrix<_Scalar, Eigen::Dynamic, 1> |
Definition at line 73 of file DemBones.h.
|
inline |
|
inlinevirtual |
Callback function invoked before each spliting of bone clusters in initialization.
Definition at line 374 of file DemBones.h.
|
inlinevirtual |
Callback function invoked after each spliting of bone clusters in initialization.
Definition at line 376 of file DemBones.h.
|
inlinevirtual |
Callback function invoked before each global iteration update.
Definition at line 379 of file DemBones.h.
|
inlinevirtual |
Callback function invoked after each global iteration update, stop iteration if return true.
Definition at line 381 of file DemBones.h.
|
inlinevirtual |
Callback function invoked before each bone transformations update.
Definition at line 389 of file DemBones.h.
|
inlinevirtual |
Callback function invoked after each bone transformations update.
Definition at line 391 of file DemBones.h.
|
inlinevirtual |
Callback function invoked before each local bone transformations update iteration.
Definition at line 394 of file DemBones.h.
|
inlinevirtual |
Callback function invoked after each local bone transformations update iteration, stop iteration if return true.
Definition at line 396 of file DemBones.h.
|
inlinevirtual |
Callback function invoked before each skinning weights update.
Definition at line 384 of file DemBones.h.
|
inlinevirtual |
Callback function invoked after each skinning weights update.
Definition at line 386 of file DemBones.h.
|
inlinevirtual |
Callback function invoked before each local weights update iteration.
Definition at line 399 of file DemBones.h.
|
inlinevirtual |
Callback function invoked after each local weights update iteration, stop iteration if return true.
Definition at line 401 of file DemBones.h.
|
inline |
Clear all data.
Definition at line 161 of file DemBones.h.
|
inline |
|
inline |
Update bone transformations by running nTransIters iterations with transAffine and transAffineNorm regularizers.
Required input data:
Optional input data:
Output: m. Missing w and/or m (with zero size) will be initialized by init().
Definition at line 237 of file DemBones.h.
|
inline |
Update skinning weights by running nWeightsIters iterations with weightsSmooth and weightsSmoothStep regularizers.
Required input data:
Optional input data:
Output: w. Missing w and/or m (with zero size) will be initialized by init().
Definition at line 276 of file DemBones.h.
|
inline |
Initialize missing skinning weights and/or bone transformations.
Depending on the status of w and m, this function will:
This function is called at the begining of every compute update functions as a safeguard.
Definition at line 186 of file DemBones.h.
|
inline |
Definition at line 356 of file DemBones.h.
Eigen::VectorXi Dem::DemBones< _Scalar, _AniMeshScalar >::fStart |
Start frame indices, size
= nS+1, fStart(s
), fStart(s+1
) are data frames for subject s
.
Definition at line 123 of file DemBones.h.
std::vector<std::vector<int> > Dem::DemBones< _Scalar, _AniMeshScalar >::fv |
Mesh topology, size=
[number of polygons
], fv[p
] is the vector of vertex indices of polygon p
.
Definition at line 148 of file DemBones.h.
const int& Dem::DemBones< _Scalar, _AniMeshScalar >::iter |
[zero indexed
, read only
] Current global iteration number that can be used for callback functions
Definition at line 151 of file DemBones.h.
const int& Dem::DemBones< _Scalar, _AniMeshScalar >::iterTransformations |
[zero indexed
, read only
] Current bone transformations update iteration number that can be used for callback functions
Definition at line 154 of file DemBones.h.
const int& Dem::DemBones< _Scalar, _AniMeshScalar >::iterWeights |
[zero indexed
, read only
] Current weights update iteration number that can be used for callback functions
Definition at line 157 of file DemBones.h.
Eigen::VectorXi Dem::DemBones< _Scalar, _AniMeshScalar >::lockM |
Bone transformation lock control, size
= nB, lockM(j
) is the amount of input transformations will be kept for bone j
, where lockM(j
) = 0 (no lock) or 1 (lock)
Definition at line 142 of file DemBones.h.
VectorX Dem::DemBones< _Scalar, _AniMeshScalar >::lockW |
Skinning weights lock control, size
= nV, lockW(i
) is the amount of input skinning weights will be kept for vertex i
, where 0 (no lock) <= lockW(i
) <= 1 (full lock)
Definition at line 134 of file DemBones.h.
MatrixX Dem::DemBones< _Scalar, _AniMeshScalar >::m |
Bone transformations, size
= [4*nF*4, 4*nB], m.blk4(k
, j
) is the 4*4 relative transformation matrix of bone j
at frame k
.
Note that the transformations are relative, that is m.blk4(k
, j
) brings the global transformation of bone j
from the rest pose to the pose at frame k
.
Definition at line 139 of file DemBones.h.
int Dem::DemBones< _Scalar, _AniMeshScalar >::nB |
Number of bones, typically indexed by j
.
Definition at line 116 of file DemBones.h.
int Dem::DemBones< _Scalar, _AniMeshScalar >::nF |
Number of total frames, typically indexed by k
, nF = fStart(nS)
Definition at line 120 of file DemBones.h.
int Dem::DemBones< _Scalar, _AniMeshScalar >::nInitIters |
[parameter
] Number of clustering update iterations in the initalization, default
= 10
Definition at line 83 of file DemBones.h.
int Dem::DemBones< _Scalar, _AniMeshScalar >::nIters |
[parameter
] Number of global iterations, default
= 30
Definition at line 80 of file DemBones.h.
int Dem::DemBones< _Scalar, _AniMeshScalar >::nnz |
[parameter
] Number of non-zero weights per vertex, default
= 8
Definition at line 95 of file DemBones.h.
int Dem::DemBones< _Scalar, _AniMeshScalar >::nS |
Number of subjects, typically indexed by s
.
Definition at line 118 of file DemBones.h.
int Dem::DemBones< _Scalar, _AniMeshScalar >::nTransIters |
[parameter
] Number of bone transformations update iterations per global iteration, default
= 5
Definition at line 86 of file DemBones.h.
int Dem::DemBones< _Scalar, _AniMeshScalar >::nV |
Number of vertices, typically indexed by i
.
Definition at line 114 of file DemBones.h.
int Dem::DemBones< _Scalar, _AniMeshScalar >::nWeightsIters |
[parameter
] Number of weights update iterations per global iteration, default
= 3
Definition at line 93 of file DemBones.h.
Eigen::VectorXi Dem::DemBones< _Scalar, _AniMeshScalar >::subjectID |
_Scalar Dem::DemBones< _Scalar, _AniMeshScalar >::transAffine |
[parameter
] Translations affinity soft constraint, default
= 10.0
Definition at line 88 of file DemBones.h.
_Scalar Dem::DemBones< _Scalar, _AniMeshScalar >::transAffineNorm |
[parameter
] p-norm for bone translations affinity soft constraint, default
= 4.0
Definition at line 90 of file DemBones.h.
MatrixX Dem::DemBones< _Scalar, _AniMeshScalar >::u |
Geometry at the rest poses, size
= [3*nS, nV], u.col(i
).segment(3*s
, 3) is the rest pose of vertex i
of subject s
.
Definition at line 128 of file DemBones.h.
Eigen::Matrix<_AniMeshScalar, Eigen::Dynamic, Eigen::Dynamic> Dem::DemBones< _Scalar, _AniMeshScalar >::v |
Animated mesh sequence, size
= [3*nF, nV], v.col(i
).segment(3*k
, 3) is the position of vertex i
at frame k
.
Definition at line 145 of file DemBones.h.
SparseMatrix Dem::DemBones< _Scalar, _AniMeshScalar >::w |
_Scalar Dem::DemBones< _Scalar, _AniMeshScalar >::weightEps |
[parameter
] Epsilon for weights solver, default
= 1e-15
Definition at line 101 of file DemBones.h.
_Scalar Dem::DemBones< _Scalar, _AniMeshScalar >::weightsSmooth |
[parameter
] Weights smoothness soft constraint, default
= 1e-4
Definition at line 97 of file DemBones.h.
_Scalar Dem::DemBones< _Scalar, _AniMeshScalar >::weightsSmoothStep |
[parameter
] Step size for the weights smoothness soft constraint, default
= 1.0
Definition at line 99 of file DemBones.h.