From 2ec5023752da427968e7e17ccb13e756de7cb730 Mon Sep 17 00:00:00 2001 From: viktorljung Date: Wed, 27 Jan 2016 17:27:34 +0100 Subject: [PATCH] Changed Animation and BoneAttachment "Name" field to "AnimationName" and "BoneName" --- include/Engine/Rendering/ModelJob.h | 2 +- resources/Schema/Components/Animation.xml | 2 +- resources/Schema/Components/Animation.xsd | 2 +- .../Schema/Components/BoneAttachment.xml | 2 +- .../Schema/Components/BoneAttachment.xsd | 2 +- resources/Schema/Entities/AnimationTests.xml | 20 +++++++++---------- src/Engine/Rendering/AnimationSystem.cpp | 4 ++-- src/Engine/Rendering/BoneAttachmentSystem.cpp | 4 ++-- src/Engine/Rendering/DrawFinalPass.cpp | 8 -------- 9 files changed, 19 insertions(+), 27 deletions(-) diff --git a/include/Engine/Rendering/ModelJob.h b/include/Engine/Rendering/ModelJob.h index df7f1aec..21f7c1ca 100644 --- a/include/Engine/Rendering/ModelJob.h +++ b/include/Engine/Rendering/ModelJob.h @@ -46,7 +46,7 @@ struct ModelJob : RenderJob if (world->HasComponent(Entity, "Animation") && Skeleton != nullptr) { auto animationComponent = world->GetComponent(Entity, "Animation"); - Animation = model->m_RawModel->m_Skeleton->GetAnimation(animationComponent["Name"]); + Animation = model->m_RawModel->m_Skeleton->GetAnimation(animationComponent["AnimationName"]); AnimationTime = (double)animationComponent["Time"]; } }; diff --git a/resources/Schema/Components/Animation.xml b/resources/Schema/Components/Animation.xml index 66d2865d..ab589698 100644 --- a/resources/Schema/Components/Animation.xml +++ b/resources/Schema/Components/Animation.xml @@ -1,6 +1,6 @@ - + 0 true diff --git a/resources/Schema/Components/Animation.xsd b/resources/Schema/Components/Animation.xsd index 0dd21f29..388dfc07 100644 --- a/resources/Schema/Components/Animation.xsd +++ b/resources/Schema/Components/Animation.xsd @@ -6,7 +6,7 @@ - + diff --git a/resources/Schema/Components/BoneAttachment.xml b/resources/Schema/Components/BoneAttachment.xml index c8a8971a..47df9e40 100644 --- a/resources/Schema/Components/BoneAttachment.xml +++ b/resources/Schema/Components/BoneAttachment.xml @@ -1,6 +1,6 @@ - + diff --git a/resources/Schema/Components/BoneAttachment.xsd b/resources/Schema/Components/BoneAttachment.xsd index bc1dc444..aee1868f 100644 --- a/resources/Schema/Components/BoneAttachment.xsd +++ b/resources/Schema/Components/BoneAttachment.xsd @@ -6,7 +6,7 @@ - + diff --git a/resources/Schema/Entities/AnimationTests.xml b/resources/Schema/Entities/AnimationTests.xml index cdb80769..8a757639 100644 --- a/resources/Schema/Entities/AnimationTests.xml +++ b/resources/Schema/Entities/AnimationTests.xml @@ -34,8 +34,8 @@ - Run - + Walk + 0.5 @@ -75,8 +75,8 @@ + L_Foot - L_Foot true @@ -84,9 +84,9 @@ - - - + + + @@ -94,8 +94,8 @@ + R_Foot - R_Foot true @@ -103,9 +103,9 @@ - - - + + + diff --git a/src/Engine/Rendering/AnimationSystem.cpp b/src/Engine/Rendering/AnimationSystem.cpp index e164c7fb..c79b5a36 100644 --- a/src/Engine/Rendering/AnimationSystem.cpp +++ b/src/Engine/Rendering/AnimationSystem.cpp @@ -15,7 +15,7 @@ void AnimationSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& a Skeleton* skeleton = model->m_RawModel->m_Skeleton; - const Skeleton::Animation* animation = skeleton->GetAnimation(animationComponent["Name"]); + const Skeleton::Animation* animation = skeleton->GetAnimation(animationComponent["AnimationName"]); if(animation != nullptr) { double animationSpeed = (double)animationComponent["Speed"]; @@ -29,7 +29,7 @@ void AnimationSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& a (double&)animationComponent["Speed"] = 0.0; Events::AnimationComplete e; e.Entity = entity; - e.Name = (std::string)animationComponent["Name"]; + e.Name = (std::string)animationComponent["AnimationName"]; m_EventBroker->Publish(e); } else { if (glm::abs(nextTime) > animation->Duration) { diff --git a/src/Engine/Rendering/BoneAttachmentSystem.cpp b/src/Engine/Rendering/BoneAttachmentSystem.cpp index 82ef7764..2a2e5c7d 100644 --- a/src/Engine/Rendering/BoneAttachmentSystem.cpp +++ b/src/Engine/Rendering/BoneAttachmentSystem.cpp @@ -20,13 +20,13 @@ void BoneAttachmentSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapp Skeleton* skeleton = model->m_RawModel->m_Skeleton; - const Skeleton::Animation* animation = skeleton->GetAnimation(parent["Animation"]["Name"]); + const Skeleton::Animation* animation = skeleton->GetAnimation(parent["Animation"]["AnimationName"]); if (!animation) { return; } - int id = skeleton->GetBoneID(entity["BoneAttachment"]["Name"]); + int id = skeleton->GetBoneID(entity["BoneAttachment"]["BoneName"]); if(id == -1) { return; diff --git a/src/Engine/Rendering/DrawFinalPass.cpp b/src/Engine/Rendering/DrawFinalPass.cpp index 006790cd..72329f5b 100644 --- a/src/Engine/Rendering/DrawFinalPass.cpp +++ b/src/Engine/Rendering/DrawFinalPass.cpp @@ -156,17 +156,9 @@ void DrawFinalPass::Draw(RenderScene& scene) glBindTexture(GL_TEXTURE_2D, m_BlackTexture->m_Texture); }*/ - //TODO: Fixa så att modelsJobs kan spela upp olika animationer och så att den kan få in en tid istället för 1.0f - Hälsningar Johan och Andreas :) if (modelJob->Model->m_RawModel->m_Skeleton != nullptr) { if (modelJob->Animation != nullptr) { std::vector frameBones = modelJob->Skeleton->GetFrameBones(*modelJob->Animation, modelJob->AnimationTime); -// std::vector frameBones2 = modelJob->Skeleton->GetFrameBones(*modelJob->Skeleton->GetAnimation("Walk"), modelJob->AnimationTime); -// -// -// for (int i = 0; i < frameBones.size(); i++) { -// frameBones[i] = frameBones[i] * glm::mat4(glm::quat(glm::vec3(0.f, 0.f, 0.f)));//* frameBones2[i]; -// } - glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); } }