Model that has animations is now visible when it does not play an animation (T-pose)
This commit is contained in:
@@ -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];
|
||||
|
||||
Reference in New Issue
Block a user