20 Pose(std::vector<Vec3f> t, std::vector<Vec3f> s, std::vector<Quat1f> r)
69 std::vector<int>& allJoints,
70 std::map<
joint, std::vector<joint>>& jointDir,
71 std::map<joint, Vec3f>& bindPoseTranslation,
72 std::map<joint, Vec3f>& bindPoseScale,
73 std::map<joint, Quat1f>& bindPoseRotation
80 std::vector<Mat4f>& LocalMatrix,
82 std::vector<int>& allJoints,
83 std::map<
joint, std::vector<joint>>& jointDir,
84 std::map<joint, Vec3f>& bindPoseTranslation,
85 std::map<joint, Vec3f>& bindPoseScale,
86 std::map<joint, Quat1f>& bindPoseRotation
106 std::vector<Mat4f>& InverseBindMatrix,
107 std::vector<Mat4f>& LocalMatrix,
108 std::vector<Mat4f>& WorldMatrix,
109 std::vector<int>& allJoints,
110 std::map<
joint, std::vector<joint>>& jointDir,
111 std::map<joint, Vec3f>& bindPoseTranslation,
112 std::map<joint, Vec3f>& bindPoseScale,
113 std::map<joint, Vec3f>& bindPoseRotation,
114 std::map<joint, Vec3f>& bindPosePreRotation
140 if (pair.second == value)
150 std::vector<Mat4f> localMatrix(this->
mMaxJointID + 1);
156 for (
size_t i = 0; i <
mAllJoints.size(); i++)
162 (scale[
joint][0], 0, 0, 0,
163 0, scale[
joint][1], 0, 0,
164 0, 0, scale[
joint][2], 0,
168 (1, 0, 0, translation[
joint][0],
169 0, 1, 0, translation[
joint][1],
170 0, 0, 1, translation[
joint][2],
173 localMatrix[
joint] = t * s * r;
222 std::map<
joint, std::vector<Vec3f>>& jointTranslation,
223 std::map<
joint, std::vector<Real>>& jointTimeCodeTranslation,
224 std::map<
joint, std::vector<Vec3f>>& jointScale,
225 std::map<
joint, std::vector<Real>>& jointIndexTimeCodeScale,
226 std::map<
joint, std::vector<Quat1f>>& jointRotation,
227 std::map<
joint, std::vector<Real>>& jointIndexRotation,
228 std::shared_ptr<JointInfo> skeleton,
316 std::vector<int>
getJointDir(
int Index, std::map<
int, std::vector<int>> joint_Dir);
324 auto pose = this->
getPose(inTime);
352 for (
auto& it : timeCodes) {
353 for (
auto& time : it.second) {
373 if (tId >= all_R.size() - 1)
379 float weight = (time - tTimeCode[tId]) / (tTimeCode[tId + 1] - tTimeCode[tId]);
387 void updateCurrentPose(
int select,
Real time, std::vector<Vec3f>& currentData,std::vector<Vec3f>& bindPoseData,std::map<
joint, std::vector<Real>>& animationData,std::map<
joint, std::vector<Real>>& TimeCode,
int channel)
390 auto iter = animationData.find(select);
391 if (iter == animationData.end())
392 currentData[select][channel] = bindPoseData[select][channel];
394 if (iter != animationData.end())
396 const std::vector<Real>& all_R = animationData[select];
397 const std::vector<Real>& tTimeCode = TimeCode[select];
401 if (tId >= all_R.size() - 1)
403 currentData[select][channel] = all_R[all_R.size() - 1];
407 float weight = (time - tTimeCode[tId]) / (tTimeCode[tId + 1] - tTimeCode[tId]);
408 currentData[select][channel] =
lerp(all_R[tId], all_R[tId + 1], weight);
int findMaxSmallerIndex(const std::vector< float > &arr, float v)
void offsetTimeCodes(std::map< joint, std::vector< Real > > &timeCodes, Real offset)
std::vector< Vec3f > getJointsScale(float time)
Quat< Real > nlerp(const Quat< Real > &q1, const Quat< Real > &q2, float weight)
std::vector< Vec3f > mScale
std::map< joint, std::vector< Real > > mJoint_KeyId_R_Y
std::map< joint, std::vector< Real > > mJoint_KeyId_R_Z
std::map< joint, std::vector< Real > > mJoint_KeyId_T_Z
std::map< joint, std::vector< Real > > mJoint_KeyId_tS_X
float & getBlendOutTime()
std::vector< Quat1f > getJointsRotation(float time)
std::vector< int > getJointDir(int Index, std::map< int, std::vector< int > > joint_Dir)
float getCurrentAnimationTime()
std::map< joint, std::vector< Real > > mJoint_KeyId_tT_Z
void setGLTFAnimationData(std::map< joint, std::vector< Vec3f > > &jointTranslation, std::map< joint, std::vector< Real > > &jointTimeCodeTranslation, std::map< joint, std::vector< Vec3f > > &jointScale, std::map< joint, std::vector< Real > > &jointIndexTimeCodeScale, std::map< joint, std::vector< Quat1f > > &jointRotation, std::map< joint, std::vector< Real > > &jointIndexRotation, std::shared_ptr< JointInfo > skeleton, bool loop=true)
Quat< Real > slerp(const Quat< Real > &q1, const Quat< Real > &q2, float weight)
void updateCurrentPose(int select, Real time, std::vector< Vec3f > ¤tData, std::vector< Vec3f > &bindPoseData, std::map< joint, std::vector< Real > > &animationData, std::map< joint, std::vector< Real > > &TimeCode, int channel)
std::map< joint, std::vector< Real > > mJoint_KeyId_T_Y
std::vector< Vec3f > getJointsTranslation(float time)
void updateJointsTransform(float time)
std::map< joint, std::vector< Real > > mJoint_KeyId_R_X
std::map< joint, std::vector< Real > > mJoint_KeyId_S_Y
std::map< joint, std::vector< Real > > mJoint_KeyId_tS_Z
std::map< joint, std::vector< Real > > mJoint_KeyId_tQuatRotation
Real calculateMinTime(const std::map< joint, std::vector< Real > > &timeCodes)
std::map< joint, std::vector< Real > > mJoint_KeyId_S_Z
std::shared_ptr< JointInfo > mSkeleton
std::shared_ptr< JointInfo > & getSkeleton()
void updateAnimationPose(float inTime)
std::map< joint, std::vector< Real > > mJoint_KeyId_tT_Y
Pose getPose(float inTime)
std::map< joint, std::vector< Real > > mJoint_KeyId_tR_X
std::map< joint, std::vector< Real > > mJoint_KeyId_tS_Y
std::map< joint, std::vector< Real > > mJoint_KeyId_T_X
void setSkeleton(std::shared_ptr< JointInfo > sk)
Transform3f updateTransform(joint jId, float time)
void resizeJointsData(int size)
std::map< joint, std::vector< Real > > mJoint_KeyId_tR_Z
Vec3f lerp(Vec3f v0, Vec3f v1, float weight)
Real lerp(Real v0, Real v1, float weight)
DArray< Mat4f > mJointWorldMatrix
std::map< joint, std::vector< Quat1f > > mJoint_KeyId_QuatRotation
Real calculateMaxTime(const std::map< joint, std::vector< Real > > &timeCodes)
std::vector< Vec3f > mTranslation
std::map< joint, std::vector< Real > > mJoint_KeyId_S_X
std::vector< Vec3f > mRotator
Quat< Real > normalize(const Quat< Real > &q)
std::vector< Quat1f > mQuatRotation
std::map< joint, std::vector< Real > > mJoint_KeyId_tR_Y
void updateGLTFRotation(int select, Real time)
std::map< joint, std::vector< Real > > mJoint_KeyId_tT_X
void setLeftHandedCoordSystem(bool islLeft)
void updateWorldMatrixByTransform()
DArray< Mat4f > mJointInverseBindMatrix
std::vector< Mat4f > mJointLocalMatrix
std::vector< Vec3f > mBindPosePreRotator
std::vector< Mat4f > getLocalMatrix(Pose &pose)
void setJoint(const JointInfo &j)
void setGltfJointInfo(DArray< Mat4f > &InverseBindMatrix, std::vector< Mat4f > &LocalMatrix, DArray< Mat4f > &WorldMatrix, std::vector< int > &allJoints, std::map< joint, std::vector< joint > > &jointDir, std::map< joint, Vec3f > &bindPoseTranslation, std::map< joint, Vec3f > &bindPoseScale, std::map< joint, Quat1f > &bindPoseRotation)
std::map< joint, std::vector< joint > > mJointDir
std::vector< Vec3f > mBindPoseScale
std::vector< joint > mAllJoints
DArray< Mat4f > mJointWorldMatrix
std::vector< Quat< Real > > mBindPoseRotation
std::map< int, std::string > mJointName
JointInfo(DArray< Mat4f > &InverseBindMatrix, DArray< Mat4f > &LocalMatrix, DArray< Mat4f > &WorldMatrix, std::vector< int > &allJoints, std::map< joint, std::vector< joint > > &jointDir, std::map< joint, Vec3f > &bindPoseTranslation, std::map< joint, Vec3f > &bindPoseScale, std::map< joint, Quat1f > &bindPoseRotation)
bool useLeftHandedCoordSystem
std::vector< Vec3f > mBindPoseRotator
int findJointIndexByName(const std::string &value)
std::vector< Vec3f > mBindPoseTranslation
void SetJointInfo(std::vector< Mat4f > &InverseBindMatrix, std::vector< Mat4f > &LocalMatrix, std::vector< Mat4f > &WorldMatrix, std::vector< int > &allJoints, std::map< joint, std::vector< joint > > &jointDir, std::map< joint, Vec3f > &bindPoseTranslation, std::map< joint, Vec3f > &bindPoseScale, std::map< joint, Vec3f > &bindPoseRotation, std::map< joint, Vec3f > &bindPosePreRotation)
void setJointName(const std::map< int, std::string > name)
This is an implementation of AdditiveCCD based on peridyno.
Array< T, DeviceType::GPU > DArray
Transform< float, 3 > Transform3f
std::vector< int > getJointDirByJointIndex(int Index, std::map< int, std::vector< int > > jointId_joint_Dir)
SquareMatrix< float, 4 > Mat4f
Pose(std::vector< Vec3f > t, std::vector< Vec3f > s, std::vector< Quat1f > r)
std::vector< Vec3f > mScale
std::vector< Quat1f > mQuatRotation
Pose & operator=(const Pose &other)
std::vector< Vec3f > mTranslation