Model that has animations is now visible when it does not play an animation (T-pose)

This commit is contained in:
viktorljung
2016-02-01 10:24:50 +01:00
parent c9b982bc89
commit 51075aefc8
7 changed files with 72 additions and 52 deletions
+16 -7
View File
@@ -39,20 +39,29 @@ const Skeleton::Animation* Skeleton::GetAnimation(std::string name)
}
}
std::vector<glm::mat4> Skeleton::GetFrameBones(const Animation& animation, double time, bool noRootMotion /*= false*/)
std::vector<glm::mat4> Skeleton::GetFrameBones(const Animation* animation, double time, bool noRootMotion /*= false*/)
{
if(animation == nullptr) {
std::vector<glm::mat4> finalMatrices;
for(auto& b : Bones) {
finalMatrices.push_back(glm::mat4(1));//b.second->OffsetMatrix);
}
return finalMatrices;
}
// HACK: Animation wrap-around
while (time < 0) {
time += animation.Duration;
time += animation->Duration;
}
while (time > animation.Duration) {
time -= animation.Duration;
while (time > animation->Duration) {
time -= animation->Duration;
}
int currentKeyframeIndex = GetKeyframe(animation, time);
int currentKeyframeIndex = GetKeyframe(*animation, time);
const Animation::Keyframe& currentFrame = animation.Keyframes[currentKeyframeIndex];
const Animation::Keyframe& nextFrame = animation.Keyframes[(currentKeyframeIndex + 1) % animation.Keyframes.size()];
const Animation::Keyframe& currentFrame = animation->Keyframes[currentKeyframeIndex];
const Animation::Keyframe& nextFrame = animation->Keyframes[(currentKeyframeIndex + 1) % animation->Keyframes.size()];
float alpha = (time - currentFrame.Time) / (nextFrame.Time - currentFrame.Time);
//auto animationFrame = Animations[""].Keyframes[frame];