-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSkeleton.cpp
44 lines (34 loc) · 964 Bytes
/
Skeleton.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include "Skeleton.h"
Skeleton::Skeleton() { }
Skeleton::Skeleton(const Pose& rest, const Pose& bind, const std::vector<std::string>& names) {
Set(rest, bind, names);
}
void Skeleton::Set(const Pose& rest, const Pose& bind, const std::vector<std::string>& names) {
mRestPose = rest;
mBindPose = bind;
mJointNames = names;
UpdateInverseBindPose();
}
void Skeleton::UpdateInverseBindPose() {
unsigned int size = mBindPose.Size();
mInvBindPose.resize(size);
for (unsigned int i = 0; i < size; ++i) {
Transform world = mBindPose.GetGlobalTransform(i);
mInvBindPose[i] = inverse(transformToMat4(world));
}
}
Pose& Skeleton::GetBindPose() {
return mBindPose;
}
Pose& Skeleton::GetRestPose() {
return mRestPose;
}
std::vector<mat4>& Skeleton::GetInvBindPose() {
return mInvBindPose;
}
std::vector<std::string>& Skeleton::GetJointNames() {
return mJointNames;
}
std::string& Skeleton::GetJointName(unsigned int idx) {
return mJointNames[idx];
}