Dem Bones  1.0
Skinning Decomposition Library
Dem::DemBones< _Scalar, _AniMeshScalar > Class Template Reference

Smooth skinning decomposition with rigid bones and sparse, convex weights. More...

#include "DemBones/DemBones.h"

Inheritance diagram for Dem::DemBones< _Scalar, _AniMeshScalar >:
Dem::DemBonesExt< _Scalar, _AniMeshScalar >

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.
 
void clear ()
 Clear all data.
 
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.
 
virtual void cbInitSplitEnd ()
 Callback function invoked after each spliting of bone clusters in initialization.
 
virtual void cbIterBegin ()
 Callback function invoked before each global iteration update.
 
virtual void cbIterEnd ()
 Callback function invoked after each global iteration update.
 
virtual void cbWeightsBegin ()
 Callback function invoked before each skinning weights update.
 
virtual void cbWeightsEnd ()
 Callback function invoked after each skinning weights update.
 
virtual void cbTranformationsBegin ()
 Callback function invoked before each bone transformations update.
 
virtual void cbTransformationsEnd ()
 Callback function invoked after each bone transformations update.
 
virtual void cbTransformationsIterBegin ()
 Callback function invoked before each local bone transformations update iteration.
 
virtual void cbTransformationsIterEnd ()
 Callback function invoked after each local bone transformations update iteration.
 
virtual void cbWeightsIterBegin ()
 Callback function invoked before each local weights update iteration.
 
virtual void cbWeightsIterEnd ()
 Callback function invoked after each local weights update iteration.
 

Public Attributes

int nIters
 [parameter] Number of global iterations, default = 30
 
int nInitIters
 [parameter] Number of clustering update iterations in the initalization, default = 10
 
int nTransIters
 [parameter] Number of bone transformations update iterations per global iteration, default = 5
 
_Scalar transAffine
 [parameter] Translations affinity soft constraint, default = 10.0
 
_Scalar transAffineNorm
 [parameter] p-norm for bone translations affinity soft constraint, default = 4.0
 
int nWeightsIters
 [parameter] Number of weights update iterations per global iteration, default = 3
 
int nnz
 [parameter] Number of non-zero weights per vertex, default = 8
 
_Scalar weightsSmooth
 [parameter] Weights smoothness soft constraint, default = 1e-4
 
_Scalar weightsSmoothStep
 [parameter] Step size for the weights smoothness soft constraint, default = 1.0
 
_Scalar weightEps
 [parameter] Epsilon for weights solver, default = 1e-15
 
int nV
 Number of vertices, typically indexed by i.
 
int nB
 Number of bones, typically indexed by j.
 
int nS
 Number of subjects, typically indexed by s.
 
int nF
 Number of total frames, typically indexed by k, nF = fStart(nS)
 
Eigen::VectorXi fStart
 Start frame indices, size = nS+1, fStart(s), fStart(s+1) are data frames for subject s.
 
Eigen::VectorXi subjectID
 Subject index of the frame, size = nF, subjectID(k)=s, where fStart(s) <= k < fStart(s+1)
 
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.
 
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.
 
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::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.
 
std::vector< std::vector< int > > fv
 Mesh topology, size=[number of polygons], fv[p] is the vector of vertex indices of polygon p.
 
const int & iter
 [zero indexed, read only] Current global iteration number that can be used for callback functions
 
const int & iterTransformations
 [zero indexed, read only] Current bone transformations update iteration number that can be used for callback functions
 
const int & iterWeights
 [zero indexed, read only] Current weights update iteration number that can be used for callback functions
 

Detailed Description

template<class _Scalar, class _AniMeshScalar>
class Dem::DemBones< _Scalar, _AniMeshScalar >

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: 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.

Member Function Documentation

◆ compute()

template<class _Scalar, class _AniMeshScalar>
void Dem::DemBones< _Scalar, _AniMeshScalar >::compute ( )
inline

Skinning decomposition by nIters iterations of alternative updating weights and bone transformations.

Required input data:

Optional input data:

  • Skinning weights: w
  • Bone transformations: m

Output: w, m. Missing w and/or m (with zero size) will be initialized by init().

◆ computeTranformations()

template<class _Scalar, class _AniMeshScalar>
void Dem::DemBones< _Scalar, _AniMeshScalar >::computeTranformations ( )
inline

Update bone transformations by running nTransIters iterations with transAffine and transAffineNorm regularizers.

Required input data:

Optional input data:

  • Skinning weights: w
  • Bone transformations: m

Output: m. Missing w and/or m (with zero size) will be initialized by init().

◆ computeWeights()

template<class _Scalar, class _AniMeshScalar>
void Dem::DemBones< _Scalar, _AniMeshScalar >::computeWeights ( )
inline

Update skinning weights by running nWeightsIters iterations with weightsSmooth and weightsSmoothStep regularizers.

Required input data:

Optional input data:

  • Skinning weights: w
  • Bone transformations: m

Output: w. Missing w and/or m (with zero size) will be initialized by init().

◆ init()

template<class _Scalar, class _AniMeshScalar>
void Dem::DemBones< _Scalar, _AniMeshScalar >::init ( )
inline

Initialize missing skinning weights and/or bone transformations.

Depending on the status of w and m, this function will:

  • Both w and m are already set: do nothing
  • Only one in w or m is missing (zero size): initialize missing matrix, i.e. w (or m)
  • Both w and m are missing (zero size): initialize both with rigid skinning using approximately nB bones, i.e. values of w are 0 or 1. LBG-VQ clustering is peformed using mesh sequence v, rest pose geometries u and topology fv. Note: as the initialization does not use exactly nB bones, the value of nB could be changed when both w and m are missing.

This function is called at the begining of every compute update functions as a safeguard.

◆ rmse()

template<class _Scalar, class _AniMeshScalar>
_Scalar Dem::DemBones< _Scalar, _AniMeshScalar >::rmse ( )
inline
Returns
Root mean squared reconstruction error

Member Data Documentation

◆ m

template<class _Scalar, class _AniMeshScalar>
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.


The documentation for this class was generated from the following file: