![]() |
Dem Bones
1.0
Skinning Decomposition Library
|
Extended class to handle hierarchical skeleton with local rotations/translations and bind matrices. More...
#include "DemBones/DemBonesExt.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 > |
![]() | |
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 | |
DemBonesExt () | |
Constructor and setting default parameters. | |
void | clear () |
Clear all data. | |
void | computeRTB (int s, MatrixX &lr, MatrixX <, MatrixX &gb, MatrixX &lbr, MatrixX &lbt, bool degreeRot=true) |
Local rotations, translations and global bind matrices of a subject. More... | |
![]() | |
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 | |
Eigen::VectorXd | fTime |
Timestamps for bone transformations m, [size ] = nS, fTime(k ) is the timestamp of frame k . | |
std::vector< std::string > | boneName |
Name of bones, [size ] = nB, boneName(j ) is the name bone of j . | |
Eigen::VectorXi | parent |
Parent bone index, [size ] = nB, parent(j ) is the index of parent bone of j , parent(j ) = -1 if j has no parent. | |
MatrixX | bind |
Original bind pre-matrix, [size ] = [4*nS, 4*nB], bind.block(4*s , 4*j , 4, 4) is the global bind matrix of bone j on subject s at the rest pose. | |
MatrixX | preMulInv |
Inverse pre-multiplication matrices, [size ] = [4*nS, 4*nB], preMulInv.block(4*s , 4*j , 4, 4) is the inverse of pre-local transformation of bone j on subject s . | |
Eigen::MatrixXi | rotOrder |
Rotation order, [size ] = [3*nS, nB], rotOrder.col(j ).segment<3>(3*s ) is the rotation order of bone j on subject s , 0=X , 1=Y , 2=Z , e.g. {0, 1, 2} is XYZ order | |
int | bindUpdate |
Bind transformation update, 0=keep original, 1=set translations to p-norm centroids (using transAffineNorm) and rotations to identity. | |
![]() | |
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 | |
Extended class to handle hierarchical skeleton with local rotations/translations and bind matrices.
Call computeRTB() to get local rotations/translations and bind matrices after skinning decomposition is done and other data is set.
_Scalar is the floating-point data type. _AniMeshScalar is the floating-point data type of mesh sequence v.
|
inline |
Local rotations, translations and global bind matrices of a subject.
Required all data in the base class: u, fv, nV, v, nF, fStart, subjectID, nS, m, w, nB
This function will initialize these default values for missing attributes:
size
] = nBsize
] = [4*nS, 4*nB]size
] = [3*nS, nB][in] | s | is the subject index |
[out] | lr | is the [3*nFr , nB] by-reference output local rotations, lr .col(j ).segment<3>(3*k ) is the (rx , ry , rz ) of bone j at frame k |
[out] | lt | is the [3*nFr , nB] by-reference output local translations, lt .col(j ).segment<3>(3*k ) is the (tx , ty , tz ) of bone j at frame k |
[out] | gb | is the [4, 4*nB] by-reference output global bind matrices, gb .block(0, 4*j , 4, 4) is the bind matrix of bone j |
[out] | lbr | is the [3, nB] by-reference output local rotations at bind pose lbr .col(j ).segment<3>(3*k ) is the (rx , ry , rz ) of bone j |
[out] | lbt | is the [3, nB] by-reference output local translations at bind pose, lbt .col(j ).segment<3>(3**3k) is the (tx , ty , tz ) of bone j |
[in] | degreeRot=true | will output rotations in degree, otherwise output in radian |