![]() |
Dem Bones
1.2.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. More... | |
void | clear () |
Clear all data. More... | |
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. 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 | |
Eigen::VectorXd | fTime |
Timestamps for bone transformations m, [size ] = nS, fTime(k ) is the timestamp of frame k . More... | |
std::vector< std::string > | boneName |
Name of bones, [size ] = nB, boneName(j ) is the name bone of j . More... | |
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. More... | |
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. More... | |
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 . More... | |
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 More... | |
MatrixX | orient |
Orientations of bones, [size ] = [3*nS, nB], orient .col(j ).segment<3>(3*s ) is the(rx , ry , rz ) orientation of bone j in degree. More... | |
int | bindUpdate |
Bind transformation update, 0=keep original, 1=set translations to p-norm centroids (using transAffineNorm) and rotations to identity, 2=do 1 and group joints. More... | |
![]() | |
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... | |
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.
Definition at line 31 of file DemBonesExt.h.
using Dem::DemBonesExt< _Scalar, _AniMeshScalar >::Matrix3 = Eigen::Matrix<_Scalar, 3, 3> |
Definition at line 37 of file DemBonesExt.h.
using Dem::DemBonesExt< _Scalar, _AniMeshScalar >::Matrix4 = Eigen::Matrix<_Scalar, 4, 4> |
Definition at line 36 of file DemBonesExt.h.
using Dem::DemBonesExt< _Scalar, _AniMeshScalar >::MatrixX = Eigen::Matrix<_Scalar, Eigen::Dynamic, Eigen::Dynamic> |
Definition at line 35 of file DemBonesExt.h.
using Dem::DemBonesExt< _Scalar, _AniMeshScalar >::SparseMatrix = Eigen::SparseMatrix<_Scalar> |
Definition at line 41 of file DemBonesExt.h.
using Dem::DemBonesExt< _Scalar, _AniMeshScalar >::Triplet = Eigen::Triplet<_Scalar> |
Definition at line 42 of file DemBonesExt.h.
using Dem::DemBonesExt< _Scalar, _AniMeshScalar >::Vector3 = Eigen::Matrix<_Scalar, 3, 1> |
Definition at line 40 of file DemBonesExt.h.
using Dem::DemBonesExt< _Scalar, _AniMeshScalar >::Vector4 = Eigen::Matrix<_Scalar, 4, 1> |
Definition at line 39 of file DemBonesExt.h.
using Dem::DemBonesExt< _Scalar, _AniMeshScalar >::VectorX = Eigen::Matrix<_Scalar, Eigen::Dynamic, 1> |
Definition at line 38 of file DemBonesExt.h.
|
inline |
Constructor and setting default parameters.
Definition at line 99 of file DemBonesExt.h.
|
inline |
Clear all data.
Definition at line 105 of file DemBonesExt.h.
|
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 missing attributes:
size
] = nBsize
] = [4*nS, 4*nB]size
] = [3*nS, 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*k ) is the (tx , ty , tz ) of bone j |
[in] | degreeRot=true | will output rotations in degree, otherwise output in radian |
Definition at line 133 of file DemBonesExt.h.
MatrixX Dem::DemBonesExt< _Scalar, _AniMeshScalar >::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.
Definition at line 83 of file DemBonesExt.h.
int Dem::DemBonesExt< _Scalar, _AniMeshScalar >::bindUpdate |
Bind transformation update, 0=keep original, 1=set translations to p-norm centroids (using transAffineNorm) and rotations to identity, 2=do 1 and group joints.
Definition at line 95 of file DemBonesExt.h.
std::vector<std::string> Dem::DemBonesExt< _Scalar, _AniMeshScalar >::boneName |
Name of bones, [size
] = nB, boneName(j
) is the name bone of j
.
Definition at line 77 of file DemBonesExt.h.
Eigen::VectorXd Dem::DemBonesExt< _Scalar, _AniMeshScalar >::fTime |
Timestamps for bone transformations m, [size
] = nS, fTime(k
) is the timestamp of frame k
.
Definition at line 74 of file DemBonesExt.h.
MatrixX Dem::DemBonesExt< _Scalar, _AniMeshScalar >::orient |
Orientations of bones, [size
] = [3*nS, nB], orient
.col(j
).segment<3>(3*s
) is the(rx
, ry
, rz
) orientation of bone j
in degree.
Definition at line 92 of file DemBonesExt.h.
Eigen::VectorXi Dem::DemBonesExt< _Scalar, _AniMeshScalar >::parent |
Parent bone index, [size
] = nB, parent(j
) is the index of parent bone of j
, parent(j
) = -1 if j
has no parent.
Definition at line 80 of file DemBonesExt.h.
MatrixX Dem::DemBonesExt< _Scalar, _AniMeshScalar >::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
.
Definition at line 86 of file DemBonesExt.h.
Eigen::MatrixXi Dem::DemBonesExt< _Scalar, _AniMeshScalar >::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
Definition at line 89 of file DemBonesExt.h.