Fixed support for new animation structure, not done yet

This commit is contained in:
viktorljung
2016-02-05 10:07:22 +01:00
parent 571c41589a
commit b6e0332574
4 changed files with 55 additions and 152 deletions
+14 -49
View File
@@ -20,6 +20,15 @@ void AnimationSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& a
return;
}
ImGui::SliderFloat("Angle", &angle, -100.f, 100.f);
{
int id = skeleton->GetBoneID("Spine_3");
auto it = skeleton->Bones.find(id);
if (it != skeleton->Bones.end()) {
it->second->ModificationMatrix = glm::mat4(glm::quat(glm::vec3(glm::radians(angle), 0.f, 0.f)));
}
}
const Skeleton::Animation* animation = skeleton->GetAnimation(animationComponent["AnimationName"]);
@@ -51,55 +60,10 @@ void AnimationSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& a
/*
ImGui::SliderFloat("Angle", &angle, -180.f, 180.f);
int id = skeleton->GetBoneID("Spine_2");
auto it = skeleton->Bones.find(id);
if (it != skeleton->Bones.end()) {
int currentKeyframeIndex = skeleton->GetKeyframe(*animation, entity["Animation"]["Time"]);
const Skeleton::Animation::Keyframe& currentFrame = animation->Keyframes[currentKeyframeIndex];
const Skeleton::Animation::Keyframe& nextFrame = animation->Keyframes[(currentKeyframeIndex + 1) % animation->Keyframes.size()];
float alpha = ((double)entity["Animation"]["Time"] - currentFrame.Time) / (nextFrame.Time - currentFrame.Time);
glm::mat4 parentBoneTransform = skeleton->GetBoneTransform(it->second->Parent, currentFrame, nextFrame, alpha, glm::mat4(1));
glm::vec3 scale;
glm::quat rotation;
glm::vec3 translation;
glm::vec3 skew;
glm::vec4 perspective;
glm::decompose(parentBoneTransform, scale, rotation, translation, skew, perspective);
glm::vec3 rot;
rot = glm::vec3(1, 0, 0);
rot = glm::normalize(rot) * glm::radians(angle);
glm::mat4 modmat = glm::mat4(glm::quat(rot)) * glm::inverse(glm::mat4(rotation));
it->second->ModificationMatrix = modmat;
}
*/
/*
{
int id = skeleton->GetBoneID("Neck");
auto it = skeleton->Bones.find(id);
if (it != skeleton->Bones.end()) {
it->second->ModificationMatrix = glm::mat4(glm::quat(glm::vec3(glm::radians(angle/2.f), 0.f, 0.f)));
}
}
{
/* {
int id = skeleton->GetBoneID("Spine_2");
auto it = skeleton->Bones.find(id);
if (it != skeleton->Bones.end()) {
@@ -119,8 +83,9 @@ void AnimationSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& a
if (it != skeleton->Bones.end()) {
it->second->ModificationMatrix = glm::mat4(glm::quat(glm::vec3(glm::radians(angle/2.f), 0.f, 0.f)));
}
}*
}*/
/*
if (entity.HasComponent("Player")) {
EntityWrapper cameraEntity = entity.FirstChildByName("Camera");
if (cameraEntity.Valid()) {
@@ -128,7 +93,7 @@ void AnimationSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& a
}
}
*/
}*/
}