Dem Bones  1.2.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. 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...
 

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

Member Typedef Documentation

◆ Matrix3

template<class _Scalar, class _AniMeshScalar>
using Dem::DemBones< _Scalar, _AniMeshScalar >::Matrix3 = Eigen::Matrix<_Scalar, 3, 3>

Definition at line 72 of file DemBones.h.

◆ Matrix4

template<class _Scalar, class _AniMeshScalar>
using Dem::DemBones< _Scalar, _AniMeshScalar >::Matrix4 = Eigen::Matrix<_Scalar, 4, 4>

Definition at line 71 of file DemBones.h.

◆ MatrixX

template<class _Scalar, class _AniMeshScalar>
using Dem::DemBones< _Scalar, _AniMeshScalar >::MatrixX = Eigen::Matrix<_Scalar, Eigen::Dynamic, Eigen::Dynamic>

Definition at line 70 of file DemBones.h.

◆ SparseMatrix

template<class _Scalar, class _AniMeshScalar>
using Dem::DemBones< _Scalar, _AniMeshScalar >::SparseMatrix = Eigen::SparseMatrix<_Scalar>

Definition at line 76 of file DemBones.h.

◆ Triplet

template<class _Scalar, class _AniMeshScalar>
using Dem::DemBones< _Scalar, _AniMeshScalar >::Triplet = Eigen::Triplet<_Scalar>

Definition at line 77 of file DemBones.h.

◆ Vector3

template<class _Scalar, class _AniMeshScalar>
using Dem::DemBones< _Scalar, _AniMeshScalar >::Vector3 = Eigen::Matrix<_Scalar, 3, 1>

Definition at line 75 of file DemBones.h.

◆ Vector4

template<class _Scalar, class _AniMeshScalar>
using Dem::DemBones< _Scalar, _AniMeshScalar >::Vector4 = Eigen::Matrix<_Scalar, 4, 1>

Definition at line 74 of file DemBones.h.

◆ VectorX

template<class _Scalar, class _AniMeshScalar>
using Dem::DemBones< _Scalar, _AniMeshScalar >::VectorX = Eigen::Matrix<_Scalar, Eigen::Dynamic, 1>

Definition at line 73 of file DemBones.h.

Constructor & Destructor Documentation

◆ DemBones()

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

Constructor and setting default parameters.

Definition at line 105 of file DemBones.h.

105  : nIters(30), nInitIters(10),
106  nTransIters(5), transAffine(_Scalar(10)), transAffineNorm(_Scalar(4)),
107  nWeightsIters(3), nnz(8), weightsSmooth(_Scalar(1e-4)), weightsSmoothStep(_Scalar(1)),
108  weightEps(_Scalar(1e-15)),
109  iter(_iter), iterTransformations(_iterTransformations), iterWeights(_iterWeights) {
110  clear();
111  }

Member Function Documentation

◆ cbInitSplitBegin()

template<class _Scalar, class _AniMeshScalar>
virtual void Dem::DemBones< _Scalar, _AniMeshScalar >::cbInitSplitBegin ( )
inlinevirtual

Callback function invoked before each spliting of bone clusters in initialization.

Definition at line 374 of file DemBones.h.

374 {}

◆ cbInitSplitEnd()

template<class _Scalar, class _AniMeshScalar>
virtual void Dem::DemBones< _Scalar, _AniMeshScalar >::cbInitSplitEnd ( )
inlinevirtual

Callback function invoked after each spliting of bone clusters in initialization.

Definition at line 376 of file DemBones.h.

376 {}

◆ cbIterBegin()

template<class _Scalar, class _AniMeshScalar>
virtual void Dem::DemBones< _Scalar, _AniMeshScalar >::cbIterBegin ( )
inlinevirtual

Callback function invoked before each global iteration update.

Definition at line 379 of file DemBones.h.

379 {}

◆ cbIterEnd()

template<class _Scalar, class _AniMeshScalar>
virtual bool Dem::DemBones< _Scalar, _AniMeshScalar >::cbIterEnd ( )
inlinevirtual

Callback function invoked after each global iteration update, stop iteration if return true.

Definition at line 381 of file DemBones.h.

381 { return false; }

◆ cbTranformationsBegin()

template<class _Scalar, class _AniMeshScalar>
virtual void Dem::DemBones< _Scalar, _AniMeshScalar >::cbTranformationsBegin ( )
inlinevirtual

Callback function invoked before each bone transformations update.

Definition at line 389 of file DemBones.h.

389 {}

◆ cbTransformationsEnd()

template<class _Scalar, class _AniMeshScalar>
virtual void Dem::DemBones< _Scalar, _AniMeshScalar >::cbTransformationsEnd ( )
inlinevirtual

Callback function invoked after each bone transformations update.

Definition at line 391 of file DemBones.h.

391 {}

◆ cbTransformationsIterBegin()

template<class _Scalar, class _AniMeshScalar>
virtual void Dem::DemBones< _Scalar, _AniMeshScalar >::cbTransformationsIterBegin ( )
inlinevirtual

Callback function invoked before each local bone transformations update iteration.

Definition at line 394 of file DemBones.h.

394 {}

◆ cbTransformationsIterEnd()

template<class _Scalar, class _AniMeshScalar>
virtual bool Dem::DemBones< _Scalar, _AniMeshScalar >::cbTransformationsIterEnd ( )
inlinevirtual

Callback function invoked after each local bone transformations update iteration, stop iteration if return true.

Definition at line 396 of file DemBones.h.

396 { return false; }

◆ cbWeightsBegin()

template<class _Scalar, class _AniMeshScalar>
virtual void Dem::DemBones< _Scalar, _AniMeshScalar >::cbWeightsBegin ( )
inlinevirtual

Callback function invoked before each skinning weights update.

Definition at line 384 of file DemBones.h.

384 {}

◆ cbWeightsEnd()

template<class _Scalar, class _AniMeshScalar>
virtual void Dem::DemBones< _Scalar, _AniMeshScalar >::cbWeightsEnd ( )
inlinevirtual

Callback function invoked after each skinning weights update.

Definition at line 386 of file DemBones.h.

386 {}

◆ cbWeightsIterBegin()

template<class _Scalar, class _AniMeshScalar>
virtual void Dem::DemBones< _Scalar, _AniMeshScalar >::cbWeightsIterBegin ( )
inlinevirtual

Callback function invoked before each local weights update iteration.

Definition at line 399 of file DemBones.h.

399 {}

◆ cbWeightsIterEnd()

template<class _Scalar, class _AniMeshScalar>
virtual bool Dem::DemBones< _Scalar, _AniMeshScalar >::cbWeightsIterEnd ( )
inlinevirtual

Callback function invoked after each local weights update iteration, stop iteration if return true.

Definition at line 401 of file DemBones.h.

401 { return false; }

◆ clear()

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

Clear all data.

Definition at line 161 of file DemBones.h.

161  {
162  nV=nB=nS=nF=0;
163  fStart.resize(0);
164  subjectID.resize(0);
165  u.resize(0, 0);
166  w.resize(0, 0);
167  lockW.resize(0);
168  m.resize(0, 0);
169  lockM.resize(0);
170  v.resize(0, 0);
171  fv.resize(0);
172  modelSize=-1;
173  laplacian.resize(0, 0);
174  }

◆ 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().

Definition at line 344 of file DemBones.h.

344  {
345  init();
346 
347  for (_iter=0; _iter<nIters; _iter++) {
348  cbIterBegin();
350  computeWeights();
351  if (cbIterEnd()) break;
352  }
353  }

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

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

Definition at line 237 of file DemBones.h.

237  {
238  if (nTransIters==0) return;
239 
240  init();
242 
243  compute_vuT();
244  compute_uuT();
245 
246  for (_iterTransformations=0; _iterTransformations<nTransIters; _iterTransformations++) {
248  #pragma omp parallel for
249  for (int k=0; k<nF; k++)
250  for (int j=0; j<nB; j++)
251  if (lockM(j)==0) {
252  Matrix4 qpT=vuT.blk4(k, j);
253  for (int it=uuT.outerIdx(j); it<uuT.outerIdx(j+1); it++)
254  if (uuT.innerIdx(it)!=j) qpT-=m.blk4(k, uuT.innerIdx(it))*uuT.val.blk4(subjectID(k), it);
255  qpT2m(qpT, k, j);
256  }
257  if (cbTransformationsIterEnd()) return;
258  }
259 
261  }

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

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

Definition at line 276 of file DemBones.h.

276  {
277  if (nWeightsIters==0) return;
278 
279  init();
280  cbWeightsBegin();
281 
282  compute_mTm();
283 
284  aTb=MatrixX::Zero(nB, nV);
285  wSolver.init(nnz);
286  std::vector<Triplet, Eigen::aligned_allocator<Triplet>> trip;
287  trip.reserve(nV*nnz);
288 
289  for (_iterWeights=0; _iterWeights<nWeightsIters; _iterWeights++) {
291 
292  compute_ws();
293  compute_aTb();
294 
295  double reg_scale=pow(modelSize, 2)*nF;
296 
297  trip.clear();
298  #pragma omp parallel for
299  for (int i=0; i<nV; i++) {
300  MatrixX aTai;
301  compute_aTa(i, aTai);
302  aTai=(1-lockW(i))*(aTai/reg_scale+weightsSmooth*MatrixX::Identity(nB, nB))+lockW(i)*MatrixX::Identity(nB, nB);
303  VectorX aTbi=(1-lockW(i))*(aTb.col(i)/reg_scale+weightsSmooth*ws.col(i))+lockW(i)*w.col(i);
304 
305  VectorX x=(1-lockW(i))*ws.col(i)+lockW(i)*w.col(i);
306  Eigen::ArrayXi idx=Eigen::ArrayXi::LinSpaced(nB, 0, nB-1);
307  std::sort(idx.data(), idx.data()+nB, [&x](int i1, int i2) { return x(i1)>x(i2); });
308  int nnzi=std::min(nnz, nB);
309  while (x(idx(nnzi-1))<weightEps) nnzi--;
310 
311  VectorX x0=w.col(i).toDense().cwiseMax(0.0);
312  x=indexing_vector(x0, idx.head(nnzi));
313  _Scalar s=x.sum();
314  if (s>_Scalar(0.1)) x/=s; else x=VectorX::Constant(nnzi, _Scalar(1)/nnzi);
315 
316  wSolver.solve(indexing_row_col(aTai, idx.head(nnzi), idx.head(nnzi)), indexing_vector(aTbi, idx.head(nnzi)), x, true, true);
317 
318  #pragma omp critical
319  for (int j=0; j<nnzi; j++)
320  if (x(j)!=0) trip.push_back(Triplet(idx[j], i, x(j)));
321  }
322 
323  w.resize(nB, nV);
324  w.setFromTriplets(trip.begin(), trip.end());
325 
326  if (cbWeightsIterEnd()) return;
327  }
328 
329  cbWeightsEnd();
330  }

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

Definition at line 186 of file DemBones.h.

186  {
187  if (modelSize<0) modelSize=sqrt((u-(u.rowwise().sum()/nV).replicate(1, nV)).squaredNorm()/nV/nS);
188  if (laplacian.cols()!=nV) computeSmoothSolver();
189 
190  if (((int)w.rows()!=nB)||((int)w.cols()!=nV)) { //No skinning weight
191  if (((int)m.rows()!=nF*4)||((int)m.cols()!=nB*4)) { //No transformation
192  int targetNB=nB;
193  //LBG-VQ
194  nB=1;
195  label=Eigen::VectorXi::Zero(nV);
196  computeTransFromLabel();
197 
198  bool cont=true;
199  while (cont) {
201  int prev=nB;
202  split(targetNB, 3);
203  for (int rep=0; rep<nInitIters; rep++) {
204  computeTransFromLabel();
205  computeLabel();
206  pruneBones(3);
207  }
208  cont=(nB<targetNB)&&(nB>prev);
209  cbInitSplitEnd();
210  }
211  lockM=Eigen::VectorXi::Zero(nB);
212  labelToWeights();
213  } else initWeights(); //Has transformations
214  } else { //Has skinning weights
215  if (((int)m.rows()!=nF*4)||((int)m.cols()!=nB*4)) { //No transformation
216  m=Matrix4::Identity().replicate(nF, nB);
217  lockM=Eigen::VectorXi::Zero(nB);
218  }
219  }
220 
221  if (lockW.size()!=nV) lockW=VectorX::Zero(nV);
222  if (lockM.size()!=nB) lockM=Eigen::VectorXi::Zero(nB);
223  }

◆ rmse()

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

Definition at line 356 of file DemBones.h.

356  {
357  _Scalar e=0;
358  #pragma omp parallel for
359  for (int i=0; i<nV; i++) {
360  _Scalar ei=0;
361  Matrix4 mki;
362  for (int k=0; k<nF; k++) {
363  mki.setZero();
364  for (typename SparseMatrix::InnerIterator it(w, i); it; ++it) mki+=it.value()*m.blk4(k, it.row());
365  ei+=(mki.template topLeftCorner<3, 3>()*u.vec3(subjectID(k), i)+mki.template topRightCorner<3, 1>()-v.vec3(k, i).template cast<_Scalar>()).squaredNorm();
366  }
367  #pragma omp atomic
368  e+=ei;
369  }
370  return std::sqrt(e/nF/nV);
371  }

Member Data Documentation

◆ fStart

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

◆ fv

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

◆ iter

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

◆ iterTransformations

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

◆ iterWeights

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

◆ lockM

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

◆ lockW

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

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

Definition at line 139 of file DemBones.h.

◆ nB

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

Number of bones, typically indexed by j.

Definition at line 116 of file DemBones.h.

◆ nF

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

◆ nInitIters

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

◆ nIters

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

[parameter] Number of global iterations, default = 30

Definition at line 80 of file DemBones.h.

◆ nnz

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

[parameter] Number of non-zero weights per vertex, default = 8

Definition at line 95 of file DemBones.h.

◆ nS

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

Number of subjects, typically indexed by s.

Definition at line 118 of file DemBones.h.

◆ nTransIters

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

◆ nV

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

Number of vertices, typically indexed by i.

Definition at line 114 of file DemBones.h.

◆ nWeightsIters

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

◆ subjectID

template<class _Scalar, class _AniMeshScalar>
Eigen::VectorXi Dem::DemBones< _Scalar, _AniMeshScalar >::subjectID

Subject index of the frame, size = nF, subjectID(k)=s, where fStart(s) <= k < fStart(s+1)

Definition at line 125 of file DemBones.h.

◆ transAffine

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

[parameter] Translations affinity soft constraint, default = 10.0

Definition at line 88 of file DemBones.h.

◆ transAffineNorm

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

◆ u

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

◆ v

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

◆ w

template<class _Scalar, class _AniMeshScalar>
SparseMatrix Dem::DemBones< _Scalar, _AniMeshScalar >::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.

Definition at line 131 of file DemBones.h.

◆ weightEps

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

[parameter] Epsilon for weights solver, default = 1e-15

Definition at line 101 of file DemBones.h.

◆ weightsSmooth

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

[parameter] Weights smoothness soft constraint, default = 1e-4

Definition at line 97 of file DemBones.h.

◆ weightsSmoothStep

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


The documentation for this class was generated from the following file:
Dem::DemBones::m
MatrixX m
Bone transformations, size = [4*nF*4, 4*nB], m.blk4(k, j) is the 4*4 relative transformation matrix o...
Definition: DemBones.h:139
Dem::DemBones::lockW
VectorX lockW
Skinning weights lock control, size = nV, lockW(i) is the amount of input skinning weights will be ke...
Definition: DemBones.h:134
Dem::DemBones::weightsSmooth
_Scalar weightsSmooth
[parameter] Weights smoothness soft constraint, default = 1e-4
Definition: DemBones.h:97
Dem::DemBones::cbTransformationsEnd
virtual void cbTransformationsEnd()
Callback function invoked after each bone transformations update.
Definition: DemBones.h:391
Dem::DemBones::iterTransformations
const int & iterTransformations
[zero indexed, read only] Current bone transformations update iteration number that can be used for c...
Definition: DemBones.h:154
Dem::DemBones::nV
int nV
Number of vertices, typically indexed by i.
Definition: DemBones.h:114
Dem::DemBones::init
void init()
Initialize missing skinning weights and/or bone transformations.
Definition: DemBones.h:186
Dem::DemBones::cbWeightsIterEnd
virtual bool cbWeightsIterEnd()
Callback function invoked after each local weights update iteration, stop iteration if return true.
Definition: DemBones.h:401
Dem::DemBones::transAffineNorm
_Scalar transAffineNorm
[parameter] p-norm for bone translations affinity soft constraint, default = 4.0
Definition: DemBones.h:90
Dem::DemBones::u
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 ...
Definition: DemBones.h:128
Dem::DemBones::computeTranformations
void computeTranformations()
Update bone transformations by running nTransIters iterations with transAffine and transAffineNorm re...
Definition: DemBones.h:237
Dem::DemBones::transAffine
_Scalar transAffine
[parameter] Translations affinity soft constraint, default = 10.0
Definition: DemBones.h:88
Dem::DemBones::fv
std::vector< std::vector< int > > fv
Mesh topology, size=[number of polygons], fv[p] is the vector of vertex indices of polygon p.
Definition: DemBones.h:148
Dem::DemBones::iterWeights
const int & iterWeights
[zero indexed, read only] Current weights update iteration number that can be used for callback funct...
Definition: DemBones.h:157
Dem::indexing_vector
Eigen::CwiseNullaryOp< indexing_functor_vector< ArgType, IndexType >, typename indexing_functor_vector< ArgType, IndexType >::VectorType > indexing_vector(const Eigen::MatrixBase< ArgType > &arg, const IndexType &indices)
Definition: Indexing.h:115
Dem::DemBones::cbInitSplitBegin
virtual void cbInitSplitBegin()
Callback function invoked before each spliting of bone clusters in initialization.
Definition: DemBones.h:374
Dem::DemBones::subjectID
Eigen::VectorXi subjectID
Subject index of the frame, size = nF, subjectID(k)=s, where fStart(s) <= k < fStart(s+1)
Definition: DemBones.h:125
Dem::DemBones::fStart
Eigen::VectorXi fStart
Start frame indices, size = nS+1, fStart(s), fStart(s+1) are data frames for subject s.
Definition: DemBones.h:123
Dem::DemBones::cbTranformationsBegin
virtual void cbTranformationsBegin()
Callback function invoked before each bone transformations update.
Definition: DemBones.h:389
Dem::DemBones::nIters
int nIters
[parameter] Number of global iterations, default = 30
Definition: DemBones.h:80
Dem::DemBones::nnz
int nnz
[parameter] Number of non-zero weights per vertex, default = 8
Definition: DemBones.h:95
Dem::DemBones::weightsSmoothStep
_Scalar weightsSmoothStep
[parameter] Step size for the weights smoothness soft constraint, default = 1.0
Definition: DemBones.h:99
Dem::DemBones::nS
int nS
Number of subjects, typically indexed by s.
Definition: DemBones.h:118
Dem::DemBones::VectorX
Eigen::Matrix< _Scalar, Eigen::Dynamic, 1 > VectorX
Definition: DemBones.h:73
Dem::DemBones::nTransIters
int nTransIters
[parameter] Number of bone transformations update iterations per global iteration,...
Definition: DemBones.h:86
Dem::DemBones::nF
int nF
Number of total frames, typically indexed by k, nF = fStart(nS)
Definition: DemBones.h:120
Dem::DemBones::cbWeightsEnd
virtual void cbWeightsEnd()
Callback function invoked after each skinning weights update.
Definition: DemBones.h:386
Dem::DemBones::iter
const int & iter
[zero indexed, read only] Current global iteration number that can be used for callback functions
Definition: DemBones.h:151
Dem::DemBones::cbWeightsBegin
virtual void cbWeightsBegin()
Callback function invoked before each skinning weights update.
Definition: DemBones.h:384
Dem::DemBones::Triplet
Eigen::Triplet< _Scalar > Triplet
Definition: DemBones.h:77
Dem::DemBones::w
SparseMatrix w
Skinning weights, size = [nB, nV], w.col(i) are the skinning weights of vertex i, w(j,...
Definition: DemBones.h:131
Dem::DemBones::nInitIters
int nInitIters
[parameter] Number of clustering update iterations in the initalization, default = 10
Definition: DemBones.h:83
Dem::DemBones::weightEps
_Scalar weightEps
[parameter] Epsilon for weights solver, default = 1e-15
Definition: DemBones.h:101
Dem::DemBones::MatrixX
Eigen::Matrix< _Scalar, Eigen::Dynamic, Eigen::Dynamic > MatrixX
Definition: DemBones.h:70
Dem::DemBones::nB
int nB
Number of bones, typically indexed by j.
Definition: DemBones.h:116
Dem::DemBones::Matrix4
Eigen::Matrix< _Scalar, 4, 4 > Matrix4
Definition: DemBones.h:71
Dem::DemBones::v
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 fr...
Definition: DemBones.h:145
Dem::DemBones::cbIterEnd
virtual bool cbIterEnd()
Callback function invoked after each global iteration update, stop iteration if return true.
Definition: DemBones.h:381
Dem::DemBones::cbTransformationsIterEnd
virtual bool cbTransformationsIterEnd()
Callback function invoked after each local bone transformations update iteration, stop iteration if r...
Definition: DemBones.h:396
Dem::DemBones::cbInitSplitEnd
virtual void cbInitSplitEnd()
Callback function invoked after each spliting of bone clusters in initialization.
Definition: DemBones.h:376
Dem::DemBones::lockM
Eigen::VectorXi lockM
Bone transformation lock control, size = nB, lockM(j) is the amount of input transformations will be ...
Definition: DemBones.h:142
Dem::DemBones::computeWeights
void computeWeights()
Update skinning weights by running nWeightsIters iterations with weightsSmooth and weightsSmoothStep ...
Definition: DemBones.h:276
Dem::indexing_row_col
Eigen::CwiseNullaryOp< indexing_functor_row_col< ArgType, RowIndexType, ColIndexType >, typename indexing_functor_row_col< ArgType, RowIndexType, ColIndexType >::MatrixType > indexing_row_col(const Eigen::MatrixBase< ArgType > &arg, const RowIndexType &row_indices, const ColIndexType &col_indices)
Definition: Indexing.h:47
Dem::DemBones::cbWeightsIterBegin
virtual void cbWeightsIterBegin()
Callback function invoked before each local weights update iteration.
Definition: DemBones.h:399
Dem::DemBones::clear
void clear()
Clear all data.
Definition: DemBones.h:161
Dem::DemBones::nWeightsIters
int nWeightsIters
[parameter] Number of weights update iterations per global iteration, default = 3
Definition: DemBones.h:93
Dem::DemBones::cbIterBegin
virtual void cbIterBegin()
Callback function invoked before each global iteration update.
Definition: DemBones.h:379
Dem::DemBones::cbTransformationsIterBegin
virtual void cbTransformationsIterBegin()
Callback function invoked before each local bone transformations update iteration.
Definition: DemBones.h:394