From 2ba245368b6ecad9e4f83905bf77aa40a8c66be9 Mon Sep 17 00:00:00 2001 From: viktorljung Date: Tue, 8 Mar 2016 11:21:40 +0100 Subject: [PATCH 1/6] Improved movement animaitons Added a SetBlendWeight event that sets the weight for all nodes with a name. --- .../Engine/Input/FirstPersonInputController.h | 57 +++-- include/Engine/Rendering/AnimationSystem.h | 9 + include/Engine/Rendering/AutoBlendQueue.h | 2 + include/Engine/Rendering/BlendTree.h | 9 +- .../Engine/Rendering/EAutoAnimationBlend.h | 1 - include/Engine/Rendering/ESetBlendWeight.h | 20 ++ resources/Schema/Entities/DashEffect.xml | 11 +- resources/Schema/Entities/Player.xml | 14 +- src/Engine/Rendering/AnimationSystem.cpp | 197 ++++++++++++++---- src/Engine/Rendering/AutoBlendQueue.cpp | 3 +- src/Engine/Rendering/BlendTree.cpp | 57 ++++- src/Engine/Rendering/Skeleton.cpp | 2 + src/Game/Systems/PlayerMovementSystem.cpp | 30 ++- 13 files changed, 331 insertions(+), 81 deletions(-) create mode 100644 include/Engine/Rendering/ESetBlendWeight.h diff --git a/include/Engine/Input/FirstPersonInputController.h b/include/Engine/Input/FirstPersonInputController.h index 00f36ac7..d9b0d3e8 100644 --- a/include/Engine/Input/FirstPersonInputController.h +++ b/include/Engine/Input/FirstPersonInputController.h @@ -7,6 +7,7 @@ #include "../Game/Events/EDashAbility.h" #include "InputHandler.h" #include "Rendering/EAutoAnimationBlend.h" +#include "Rendering/ESetBlendWeight.h" template class FirstPersonInputController : public InputController @@ -45,7 +46,6 @@ protected: bool m_Crouching = false; //assault dash membervariables - needed to calculate the doubletap- and dashlogic double m_AssaultDashDoubleTapDeltaTime = 0.0; - double m_DashEffectResetTimer = 0.0; //i will let m_AssaultDashDoubleTapSensitivityTimer stay hardcoded, its not really a gamevariable (more an inputvariable), //and its very unlikely that someone wants to change that value const float m_AssaultDashDoubleTapSensitivityTimer = 0.25f; @@ -137,6 +137,7 @@ bool FirstPersonInputController::OnCommand(const Events::InputComm } aeb.RootNode = playerModel; aeb.Start = true; + aeb.SingleLevelBlend = true; m_EventBroker->Publish(aeb); } else if (val < 0) { Events::AutoAnimationBlend aeb; @@ -148,6 +149,7 @@ bool FirstPersonInputController::OnCommand(const Events::InputComm } aeb.RootNode = playerModel; aeb.Start = true; + aeb.SingleLevelBlend = true; aeb.Reverse = true; m_EventBroker->Publish(aeb); } else { @@ -169,6 +171,7 @@ bool FirstPersonInputController::OnCommand(const Events::InputComm aeb.Duration = 0.1; aeb.NodeName = "Right"; aeb.RootNode = playerModel; + aeb.SingleLevelBlend = true; aeb.Start = true; m_EventBroker->Publish(aeb); } else if (val < 0) { @@ -176,6 +179,7 @@ bool FirstPersonInputController::OnCommand(const Events::InputComm aeb.Duration = 0.1; aeb.NodeName = "Left"; aeb.RootNode = playerModel; + aeb.SingleLevelBlend = true; aeb.Start = true; m_EventBroker->Publish(aeb); } else { @@ -186,16 +190,28 @@ bool FirstPersonInputController::OnCommand(const Events::InputComm } } - if (glm::length2(m_Movement) > 0) { - m_Movement = glm::normalize(m_Movement); + + + if (glm::length2(m_Movement) < 0.1f) { + if (m_PlayerEntity.Valid()) { + EntityWrapper playerModel = m_PlayerEntity.FirstChildByName("PlayerModel"); + + if (playerModel.Valid()) { + Events::AutoAnimationBlend aeb; + aeb.Duration = 0.2; + aeb.NodeName = "Idle"; + aeb.RootNode = playerModel; + m_EventBroker->Publish(aeb); + } + } } else { if (m_PlayerEntity.Valid()) { EntityWrapper playerModel = m_PlayerEntity.FirstChildByName("PlayerModel"); if (playerModel.Valid()) { Events::AutoAnimationBlend aeb; - aeb.Duration = 0.1; - aeb.NodeName = "Idle"; + aeb.Duration = 0.2; + aeb.NodeName = "MovementBlend"; aeb.RootNode = playerModel; m_EventBroker->Publish(aeb); } @@ -203,6 +219,29 @@ bool FirstPersonInputController::OnCommand(const Events::InputComm } } + + if (glm::length2(m_Movement) > 0) { + m_Movement = glm::normalize(m_Movement); + + if (m_PlayerEntity.Valid()) { + EntityWrapper playerModel = m_PlayerEntity.FirstChildByName("PlayerModel"); + + if (playerModel.Valid()) { + glm::vec2 direction = glm::normalize(glm::vec2(m_Movement.x, m_Movement.z)); + + double weight = glm::abs(glm::dot(glm::vec2(1, 0), direction)); + LOG_INFO("Weight %f", weight); + Events::SetBlendWeight sbw; + sbw.NodeName = "MovementBlend"; + sbw.Weight = weight; + sbw.RootNode = playerModel; + m_EventBroker->Publish(sbw); + } + } + } + + + if (e.Command == "Forward" || e.Command == "Right") { if (e.Value != 0) { m_CurrentDirectionVector = e.Command == "Right" ? (e.Value > 0 ? "Right" : "Left") : (e.Value > 0 ? "Forward" : "Backward"); @@ -288,17 +327,10 @@ bool FirstPersonInputController::OnLockMouse(const Events::LockMou template void FirstPersonInputController::AssaultDashCheck(double dt, bool isJumping, double assaultDashCoolDownMaxTimer, double& assaultDashCoolDownTimer, EntityID playerID) { m_AssaultDashDoubleTapDeltaTime += dt; - m_DashEffectResetTimer += dt; assaultDashCoolDownTimer -= dt; //cooldown = assaultDashCoolDownMaxTimer sec, pretend the dash lasts 0.25 sec (for friction to do its work) if (assaultDashCoolDownTimer > (assaultDashCoolDownMaxTimer - 0.25f)) { m_PlayerIsDashing = true; - if (m_DashEffectResetTimer > 0.05) { - Events::DashAbility e; - e.Player = playerID; - m_EventBroker->Publish(e); - m_DashEffectResetTimer = 0.0; - } } else { m_PlayerIsDashing = false; } @@ -310,6 +342,7 @@ void FirstPersonInputController::AssaultDashCheck(double dt, bool assaultDashCoolDownTimer = assaultDashCoolDownMaxTimer; m_AssaultDashDoubleTapped = true; m_AssaultDashDoubleTapDeltaTime = 0.f; + Events::DashAbility e; e.Player = playerID; m_EventBroker->Publish(e); diff --git a/include/Engine/Rendering/AnimationSystem.h b/include/Engine/Rendering/AnimationSystem.h index 30c6fce5..0305e7c7 100644 --- a/include/Engine/Rendering/AnimationSystem.h +++ b/include/Engine/Rendering/AnimationSystem.h @@ -13,6 +13,8 @@ #include "../Core/EntityWrapper.h" #include "Rendering/AutoBlendQueue.h" #include "../Input/EInputCommand.h" +#include "../Core/EEntityDeleted.h" +#include "Rendering/ESetBlendWeight.h" #include "imgui/imgui.h" class AnimationSystem : public ImpureSystem @@ -28,6 +30,13 @@ private: EventRelay m_EAutoAnimationBlend; bool OnAutoAnimationBlend(Events::AutoAnimationBlend& e); + + EventRelay m_EEntityDeleted; + bool OnEntityDeleted(Events::EntityDeleted& e); + + EventRelay m_ESetBlendWeight; + bool OnSetBlendWeight(Events::SetBlendWeight& e); + std::unordered_map m_AutoBlendQueues; }; diff --git a/include/Engine/Rendering/AutoBlendQueue.h b/include/Engine/Rendering/AutoBlendQueue.h index 3c808408..71fe46d8 100644 --- a/include/Engine/Rendering/AutoBlendQueue.h +++ b/include/Engine/Rendering/AutoBlendQueue.h @@ -37,6 +37,8 @@ public: std::shared_ptr GetBlendTree(); AutoBlendQueue::AutoBlendJob& GetActiveBlendJob(); + + bool Empty() { return m_BlendQueue.empty(); } private: std::list m_BlendQueue; diff --git a/include/Engine/Rendering/BlendTree.h b/include/Engine/Rendering/BlendTree.h index 02f4a348..502a1cc9 100644 --- a/include/Engine/Rendering/BlendTree.h +++ b/include/Engine/Rendering/BlendTree.h @@ -75,7 +75,6 @@ public: std::vector GetFinalPose() { return m_FinalPose; } glm::mat4 GetBoneTransform(int boneID); bool IsValid() { return (m_Root == nullptr ? false : true); } - void PrintTree(); BlendTree::AutoBlendInfo AutoBlendStep(AutoBlendInfo blendInfo); @@ -84,16 +83,20 @@ public: EntityWrapper GetSubTreeRoot(std::string nodeName); + std::vector GetSingleLevelRoots(std::string name); + std::vector GetEntitesByName(std::string name); + + void SetWeightByName(std::string name, double weight); + private: Skeleton* m_Skeleton = nullptr; Node* m_Root = nullptr; std::vector m_FinalPose; std::map m_FinalBoneTransforms; - + std::vector FindNodesByName(std::string name); std::vector AccumulateFinalPose(); BlendTree::Node* FillTreeByName(Node* parentNode, std::string name, EntityWrapper parentEntity); - std::vector FindNodesByName(std::string name); void Blend(std::map& pose); }; diff --git a/include/Engine/Rendering/EAutoAnimationBlend.h b/include/Engine/Rendering/EAutoAnimationBlend.h index 29d3d612..86921f0f 100644 --- a/include/Engine/Rendering/EAutoAnimationBlend.h +++ b/include/Engine/Rendering/EAutoAnimationBlend.h @@ -18,7 +18,6 @@ struct AutoAnimationBlend : Event bool Reverse = false; bool Restart = false; bool SingleLevelBlend = false; - double Weight = -1.0; EntityWrapper AnimationEntity = EntityWrapper::Invalid; diff --git a/include/Engine/Rendering/ESetBlendWeight.h b/include/Engine/Rendering/ESetBlendWeight.h new file mode 100644 index 00000000..2a455d88 --- /dev/null +++ b/include/Engine/Rendering/ESetBlendWeight.h @@ -0,0 +1,20 @@ +#ifndef Events_SetBlendWeight_h__ +#define Events_SetBlendWeight_h__ + +#include "../Core/EventBroker.h" +#include "../Core/EntityWrapper.h" + +namespace Events +{ + +//Sets the blend weight for all nodes with "NodeName" +struct SetBlendWeight : Event +{ + EntityWrapper RootNode = EntityWrapper::Invalid; + std::string NodeName; + double Weight; +}; + +} + +#endif diff --git a/resources/Schema/Entities/DashEffect.xml b/resources/Schema/Entities/DashEffect.xml index 9dfdc14c..6f28784d 100644 --- a/resources/Schema/Entities/DashEffect.xml +++ b/resources/Schema/Entities/DashEffect.xml @@ -2,17 +2,12 @@ - 0.5 - - - 0 - 0.5 - - - + + + diff --git a/resources/Schema/Entities/Player.xml b/resources/Schema/Entities/Player.xml index 475acf78..16b7ccd1 100644 --- a/resources/Schema/Entities/Player.xml +++ b/resources/Schema/Entities/Player.xml @@ -875,7 +875,7 @@ RunF - 1 + 1.5 true @@ -899,7 +899,7 @@ StrafeRightF - 1 + 2 true @@ -911,7 +911,7 @@ StrafeLeftF - 1 + 2 true @@ -986,7 +986,7 @@ DashForwardF - 2 + 3 false @@ -998,7 +998,7 @@ DashBackwardF - 2 + 3 false @@ -1022,7 +1022,7 @@ DashLeftF - 2 + 3 false @@ -1034,7 +1034,7 @@ DashRightF - 2 + 3 false diff --git a/src/Engine/Rendering/AnimationSystem.cpp b/src/Engine/Rendering/AnimationSystem.cpp index 005778e7..be00a0f4 100644 --- a/src/Engine/Rendering/AnimationSystem.cpp +++ b/src/Engine/Rendering/AnimationSystem.cpp @@ -4,6 +4,8 @@ AnimationSystem::AnimationSystem(SystemParams params) : System(params) { EVENT_SUBSCRIBE_MEMBER(m_EAutoAnimationBlend, &AnimationSystem::OnAutoAnimationBlend); + EVENT_SUBSCRIBE_MEMBER(m_EEntityDeleted, &AnimationSystem::OnEntityDeleted); + EVENT_SUBSCRIBE_MEMBER(m_ESetBlendWeight, &AnimationSystem::OnSetBlendWeight); } void AnimationSystem::Update(double dt) @@ -122,16 +124,13 @@ void AnimationSystem::UpdateAnimations(double dt) } } - void AnimationSystem::UpdateWeights(double dt) { - for (auto& autoBlendQueue : m_AutoBlendQueues) { - - if(autoBlendQueue.second.HasActiveBlendJob()) { - AutoBlendQueue::AutoBlendJob& blendJob = autoBlendQueue.second.GetActiveBlendJob(); - - std::shared_ptr blendTree = autoBlendQueue.second.GetBlendTree(); + for (auto it = m_AutoBlendQueues.begin(); it != m_AutoBlendQueues.end(); ) { + if(it->second.HasActiveBlendJob()) { + AutoBlendQueue::AutoBlendJob& blendJob = it->second.GetActiveBlendJob(); + std::shared_ptr blendTree = it->second.GetBlendTree(); if (blendTree != nullptr) { if (blendJob.Duration != 0.0) { blendJob.BlendInfo.progress = glm::clamp(blendJob.CurrentTime / blendJob.Duration, 0.0, 1.0); @@ -140,10 +139,17 @@ void AnimationSystem::UpdateWeights(double dt) } blendJob.BlendInfo = blendTree->AutoBlendStep(blendJob.BlendInfo); + } else { + it = m_AutoBlendQueues.erase(it); + } + it++; + } else { + if (it->second.Empty()) { + it = m_AutoBlendQueues.erase(it); + } else { + it++; } - } - } } @@ -177,46 +183,163 @@ bool AnimationSystem::OnAutoAnimationBlend(Events::AutoAnimationBlend& e) return false; } + EntityWrapper subTreeRoot; - EntityWrapper subTreeRoot = blendTree->GetSubTreeRoot(e.NodeName); + if (e.SingleLevelBlend) { + subTreeRoot = blendTree->GetSubTreeRoot(e.NodeName); - if (!subTreeRoot.Valid()) { - return false; - } + if (!subTreeRoot.Valid()) { + return false; + } - AutoBlendQueue::AutoBlendJob abj; - abj.AnimationEntity = e.AnimationEntity; - abj.CurrentTime = 0.0; - abj.Delay = e.Delay; - abj.Duration = e.Duration; - abj.RootNode = e.RootNode; + AutoBlendQueue::AutoBlendJob abj; + abj.AnimationEntity = e.AnimationEntity; + abj.CurrentTime = 0.0; + abj.Delay = e.Delay; + abj.Duration = e.Duration; + abj.RootNode = e.RootNode; - abj.BlendInfo.NodeName = e.NodeName; - abj.BlendInfo.progress = 0.0; - abj.BlendInfo.Start = e.Start; - abj.BlendInfo.SingleBlend = e.SingleLevelBlend; - abj.BlendInfo.Weight = e.Weight; + abj.BlendInfo.NodeName = e.NodeName; + abj.BlendInfo.progress = 0.0; + abj.BlendInfo.Start = e.Start; + abj.BlendInfo.SingleBlend = e.SingleLevelBlend; + abj.BlendInfo.Weight = e.Weight; - EntityWrapper nodeEntity = subTreeRoot.FirstChildByName(e.NodeName); // more than one - if (nodeEntity.Valid()) { - if (nodeEntity.HasComponent("Animation")) { - const Skeleton::Animation* animation = skeleton->GetAnimation(nodeEntity["Animation"]["AnimationName"]); - (bool&)nodeEntity["Animation"]["Reverse"] = e.Reverse; + std::vector animationEntities = blendTree->GetEntitesByName(e.NodeName); // more than one + for(auto entity : animationEntities) + if (entity.Valid()) { + if (entity.HasComponent("Animation")) { + const Skeleton::Animation* animation = skeleton->GetAnimation(entity["Animation"]["AnimationName"]); + (bool&)entity["Animation"]["Reverse"] = e.Reverse; - if (e.Restart) { - if (animation != nullptr) { - if (e.Restart) { - if (e.Reverse) { - (double&)nodeEntity["Animation"]["Time"] = animation->Duration; - } else { - (double&)nodeEntity["Animation"]["Time"] = 0.0; + if (e.Restart) { + if (animation != nullptr) { + if (e.Restart) { + if (e.Reverse) { + (double&)entity["Animation"]["Time"] = animation->Duration; + } else { + (double&)entity["Animation"]["Time"] = 0.0; + } } } } } } + m_AutoBlendQueues[subTreeRoot].Insert(abj); + } else { + std::vector subtreeroots = blendTree->GetSingleLevelRoots(e.NodeName); + + for(auto entity : subtreeroots) { + subTreeRoot = entity; + + if (!subTreeRoot.Valid()) { + return false; + } + + AutoBlendQueue::AutoBlendJob abj; + abj.AnimationEntity = e.AnimationEntity; + abj.CurrentTime = 0.0; + abj.Delay = e.Delay; + abj.Duration = e.Duration; + abj.RootNode = e.RootNode; + + abj.BlendInfo.NodeName = e.NodeName; + abj.BlendInfo.progress = 0.0; + abj.BlendInfo.Start = e.Start; + abj.BlendInfo.SingleBlend = e.SingleLevelBlend; + abj.BlendInfo.Weight = e.Weight; + m_AutoBlendQueues[subTreeRoot].Insert(abj); + } + + std::vector animationEntities = blendTree->GetEntitesByName(e.NodeName); // more than one + for (auto entity : animationEntities) + if (entity.Valid()) { + if (entity.HasComponent("Animation")) { + const Skeleton::Animation* animation = skeleton->GetAnimation(entity["Animation"]["AnimationName"]); + (bool&)entity["Animation"]["Reverse"] = e.Reverse; + + if (e.Restart) { + if (animation != nullptr) { + if (e.Restart) { + if (e.Reverse) { + (double&)entity["Animation"]["Time"] = animation->Duration; + } else { + (double&)entity["Animation"]["Time"] = 0.0; + } + } + } + } + } + } } - m_AutoBlendQueues[subTreeRoot].Insert(abj); + + return true; } + +bool AnimationSystem::OnEntityDeleted(Events::EntityDeleted& e) +{ + EntityWrapper entity = EntityWrapper(m_World, e.DeletedEntity); + + if (entity.HasComponent("Model")) { + Model* model; + try { + model = ResourceManager::Load<::Model, true>(entity["Model"]["Resource"]); + } catch (const std::exception&) { + return false; + } + + Skeleton* skeleton = model->m_RawModel->m_Skeleton; + if (skeleton == nullptr) { + return false; + } + + if (skeleton->BlendTrees.find(entity) != skeleton->BlendTrees.end()) { + skeleton->BlendTrees.erase(entity); + } + + + } + +} + +bool AnimationSystem::OnSetBlendWeight(Events::SetBlendWeight& e) +{ + if (!e.RootNode.Valid()) { + return false; + } + + if (!e.RootNode.HasComponent("Model")) { + return false; + } + + Model* model; + try { + model = ResourceManager::Load<::Model, true>((std::string)e.RootNode["Model"]["Resource"]); + } catch (const std::exception&) { + return false; + } + + Skeleton* skeleton = model->m_RawModel->m_Skeleton; + if (skeleton == nullptr) { + return false; + } + + std::shared_ptr blendTree; + if (skeleton->BlendTrees.find(e.RootNode) != skeleton->BlendTrees.end()) { + blendTree = skeleton->BlendTrees.at(e.RootNode); + } else { + return false; + } + + if(e.Weight >= 0 && e.Weight <= 1) { + + blendTree->SetWeightByName(e.NodeName, e.Weight); + + return true; + } else { + return false; + } + +} diff --git a/src/Engine/Rendering/AutoBlendQueue.cpp b/src/Engine/Rendering/AutoBlendQueue.cpp index cafb7ee5..1c6907e8 100644 --- a/src/Engine/Rendering/AutoBlendQueue.cpp +++ b/src/Engine/Rendering/AutoBlendQueue.cpp @@ -75,7 +75,6 @@ void AutoBlendQueue::Insert(AutoBlendJob autoBlendJob) } } - m_BlendQueue.clear(); m_BlendQueue.push_back(blendNode); } @@ -124,7 +123,7 @@ bool AutoBlendQueue::HasActiveBlendJob() try { model = ResourceManager::Load<::Model, true>(blendJob.RootNode["Model"]["Resource"]); } catch (const std::exception&) { - m_BlendQueue.pop_front(); + //m_BlendQueue.pop_front(); return HasActiveBlendJob(); } diff --git a/src/Engine/Rendering/BlendTree.cpp b/src/Engine/Rendering/BlendTree.cpp index 29bbe7e6..1ecafc56 100644 --- a/src/Engine/Rendering/BlendTree.cpp +++ b/src/Engine/Rendering/BlendTree.cpp @@ -2,11 +2,8 @@ BlendTree::BlendTree(EntityWrapper ModelEntity, Skeleton* skeleton) { - m_Skeleton = skeleton; - - if (ModelEntity.HasComponent("Animation")) { const Skeleton::Animation* animation = skeleton->GetAnimation(ModelEntity["Animation"]["AnimationName"]); if (animation == nullptr) { @@ -270,7 +267,7 @@ BlendTree::AutoBlendInfo BlendTree::AutoBlendStep(AutoBlendInfo blendInfo) currentNode = currentNode->Parent; if (blendInfo.SingleBlend) { - break; + return blendInfo;; } } } else if(goalNodes.size() >= 2) { @@ -331,6 +328,9 @@ BlendTree::AutoBlendInfo BlendTree::AutoBlendStep(AutoBlendInfo blendInfo) lastNode = currentNode; currentNode = currentNode->Parent; + if (blendInfo.SingleBlend) { + return blendInfo; + } } } @@ -427,6 +427,55 @@ EntityWrapper BlendTree::GetSubTreeRoot(std::string nodeName) return subTreeRoots.front()->Entity; } + +std::vector BlendTree::GetSingleLevelRoots(std::string name) +{ + std::vector nodes = FindNodesByName(name); + std::vector entities; + + for (auto it = nodes.begin(); it != nodes.end(); it++) { + Node* currentNode = (*it)->Parent; + + if(currentNode->Entity.Valid()) { + entities.push_back(currentNode->Entity); + } + } + + return entities; +} + + +std::vector BlendTree::GetEntitesByName(std::string name) +{ + std::vector nodes = FindNodesByName(name); + std::vector entities; + + for (auto it = nodes.begin(); it != nodes.end(); it++) { + Node* currentNode = (*it); + + if (currentNode->Entity.Valid()) { + entities.push_back(currentNode->Entity); + } + } + + return entities; +} + + +void BlendTree::SetWeightByName(std::string name, double weight) +{ + std::vector nodes = FindNodesByName(name); + + for (auto node : nodes) { + EntityWrapper entity = node->Entity; + + if(entity.HasComponent("Blend")) { + entity["Blend"]["Weight"] = weight; + node->Weight = weight; + } + } +} + void BlendTree::Blend(std::map& pose) { Node* currentNode; diff --git a/src/Engine/Rendering/Skeleton.cpp b/src/Engine/Rendering/Skeleton.cpp index 592279ed..2883c53d 100644 --- a/src/Engine/Rendering/Skeleton.cpp +++ b/src/Engine/Rendering/Skeleton.cpp @@ -321,6 +321,8 @@ Skeleton::~Skeleton() for (auto &kv : Bones) { delete kv.second; } + + BlendTrees.clear(); } const Skeleton::Animation* Skeleton::GetAnimation(std::string name) diff --git a/src/Game/Systems/PlayerMovementSystem.cpp b/src/Game/Systems/PlayerMovementSystem.cpp index 3d897bf7..dbf3d889 100644 --- a/src/Game/Systems/PlayerMovementSystem.cpp +++ b/src/Game/Systems/PlayerMovementSystem.cpp @@ -443,18 +443,34 @@ bool PlayerMovementSystem::OnDashAbility(Events::DashAbility & e) } } } + + + /* EntityWrapper dashEffectModel; + dashEffectModel = playerModel.Clone(dashEffect); + player["Transform"].Copy(dashEffectModel["Transform"]); + + + dashEffectModel.AttachComponent("ExplosionEffect"); + dashEffectModel["ExplosionEffect"]["EndColor"] = (glm::vec4)playerModel["Model"]["Color"]; + ((glm::vec4&)dashEffectModel["ExplosionEffect"]["EndColor"]).w = 0.f; + (double&)dashEffectModel["ExplosionEffect"]["ExplosionDuration"] = dashEffect["Lifetime"]["Lifetime"]; + (glm::vec3&)dashEffectModel["ExplosionEffect"]["ExplosionOrigin"] = glm::vec3(0, 1, 0) + (0.2f * controller->Movement()); + + + + auto animationChildren = dashEffectModel.ChildrenWithComponent("Animation"); + + for (auto animationEntity : animationChildren) { + (bool&)animationEntity["Animation"]["Play"] = false; + }*/ } } } -/* - auto playerEntityAnimation = playerModel["Animation"]; - playerEntityModel.Copy(dashEffect["Model"]); - playerEntityAnimation.Copy(dashEffect["Animation"]); - dashEffect["ExplosionEffect"]["EndColor"] = (glm::vec4)playerEntityModel["Color"]; - ((glm::vec4&)dashEffect["ExplosionEffect"]["EndColor"]).w = 0.f; -*/ + + + From f77a6105195a65b7dce492b216b5a64f3c4e6f78 Mon Sep 17 00:00:00 2001 From: viktorljung Date: Tue, 8 Mar 2016 13:26:01 +0100 Subject: [PATCH 2/6] Dash now looking good --- .../Engine/Input/FirstPersonInputController.h | 114 +++++++++--------- resources/Schema/Entities/Player.xml | 8 +- src/Engine/Rendering/AnimationSystem.cpp | 2 + src/Engine/Rendering/AutoBlendQueue.cpp | 11 +- src/Game/Systems/PlayerMovementSystem.cpp | 48 +++----- 5 files changed, 88 insertions(+), 95 deletions(-) diff --git a/include/Engine/Input/FirstPersonInputController.h b/include/Engine/Input/FirstPersonInputController.h index d9b0d3e8..75726fd3 100644 --- a/include/Engine/Input/FirstPersonInputController.h +++ b/include/Engine/Input/FirstPersonInputController.h @@ -110,7 +110,6 @@ bool FirstPersonInputController::OnCommand(const Events::InputComm if (e.Command == "Pitch") { float val = glm::radians(e.Value); m_Rotation.x += -val; - //m_Rotation.x = glm::clamp(m_Rotation.x, -glm::half_pi(), glm::half_pi()); } if (e.Command == "Yaw") { @@ -123,14 +122,14 @@ bool FirstPersonInputController::OnCommand(const Events::InputComm float val = glm::clamp(e.Value, -1.f, 1.f); m_Movement.z = -val; + //Animation if (m_PlayerEntity.Valid()) { EntityWrapper playerModel = m_PlayerEntity.FirstChildByName("PlayerModel"); if (playerModel.Valid()) { - if (val > 0) { + if (val > 0) { // Walk/Run Events::AutoAnimationBlend aeb; aeb.Duration = 0.1; - - if(m_Crouching) { + if (m_Crouching) { aeb.NodeName = "Walk"; } else { aeb.NodeName = "Run"; @@ -139,7 +138,7 @@ bool FirstPersonInputController::OnCommand(const Events::InputComm aeb.Start = true; aeb.SingleLevelBlend = true; m_EventBroker->Publish(aeb); - } else if (val < 0) { + } else if (val < 0) { // Walk/run Backwards Events::AutoAnimationBlend aeb; aeb.Duration = 0.1; if (m_Crouching) { @@ -152,8 +151,6 @@ bool FirstPersonInputController::OnCommand(const Events::InputComm aeb.SingleLevelBlend = true; aeb.Reverse = true; m_EventBroker->Publish(aeb); - } else { - } } } @@ -162,10 +159,11 @@ bool FirstPersonInputController::OnCommand(const Events::InputComm float val = glm::clamp(e.Value, -1.f, 1.f); m_Movement.x = val; + + //Animation if (m_PlayerEntity.Valid()) { EntityWrapper playerModel = m_PlayerEntity.FirstChildByName("PlayerModel"); - - if (playerModel.Valid()) { + if (playerModel.Valid()) { //Right Strafe if (val > 0) { Events::AutoAnimationBlend aeb; aeb.Duration = 0.1; @@ -174,7 +172,7 @@ bool FirstPersonInputController::OnCommand(const Events::InputComm aeb.SingleLevelBlend = true; aeb.Start = true; m_EventBroker->Publish(aeb); - } else if (val < 0) { + } else if (val < 0) { //LeftStrafe Events::AutoAnimationBlend aeb; aeb.Duration = 0.1; aeb.NodeName = "Left"; @@ -182,63 +180,59 @@ bool FirstPersonInputController::OnCommand(const Events::InputComm aeb.SingleLevelBlend = true; aeb.Start = true; m_EventBroker->Publish(aeb); - } else { - - } } } - - } - - - if (glm::length2(m_Movement) < 0.1f) { - if (m_PlayerEntity.Valid()) { - EntityWrapper playerModel = m_PlayerEntity.FirstChildByName("PlayerModel"); - - if (playerModel.Valid()) { - Events::AutoAnimationBlend aeb; - aeb.Duration = 0.2; - aeb.NodeName = "Idle"; - aeb.RootNode = playerModel; - m_EventBroker->Publish(aeb); - } - } - } else { - if (m_PlayerEntity.Valid()) { - EntityWrapper playerModel = m_PlayerEntity.FirstChildByName("PlayerModel"); - - if (playerModel.Valid()) { - Events::AutoAnimationBlend aeb; - aeb.Duration = 0.2; - aeb.NodeName = "MovementBlend"; - aeb.RootNode = playerModel; - m_EventBroker->Publish(aeb); - } - } } } - - if (glm::length2(m_Movement) > 0) { - m_Movement = glm::normalize(m_Movement); - - if (m_PlayerEntity.Valid()) { - EntityWrapper playerModel = m_PlayerEntity.FirstChildByName("PlayerModel"); - - if (playerModel.Valid()) { - glm::vec2 direction = glm::normalize(glm::vec2(m_Movement.x, m_Movement.z)); - - double weight = glm::abs(glm::dot(glm::vec2(1, 0), direction)); - LOG_INFO("Weight %f", weight); - Events::SetBlendWeight sbw; - sbw.NodeName = "MovementBlend"; - sbw.Weight = weight; - sbw.RootNode = playerModel; - m_EventBroker->Publish(sbw); - } + //Animation + if (glm::length2(m_Movement) < 0.1f) { + //Blend to Idle + if (m_PlayerEntity.Valid()) { + EntityWrapper playerModel = m_PlayerEntity.FirstChildByName("PlayerModel"); + if (playerModel.Valid()) { + Events::AutoAnimationBlend aeb; + aeb.Duration = 0.2; + aeb.NodeName = "Idle"; + aeb.RootNode = playerModel; + m_EventBroker->Publish(aeb); } } + } else { + + //Blend to movement + if (m_PlayerEntity.Valid()) { + EntityWrapper playerModel = m_PlayerEntity.FirstChildByName("PlayerModel"); + if (playerModel.Valid()) { + Events::AutoAnimationBlend aeb; + aeb.Duration = 0.2; + aeb.NodeName = "MovementBlend"; + aeb.RootNode = playerModel; + m_EventBroker->Publish(aeb); + } + } + } + + + if (glm::length2(m_Movement) > 0) { + m_Movement = glm::normalize(m_Movement); + + //Animation + // movement direction blend + if (m_PlayerEntity.Valid()) { + EntityWrapper playerModel = m_PlayerEntity.FirstChildByName("PlayerModel"); + if (playerModel.Valid()) { + glm::vec2 direction = glm::normalize(glm::vec2(m_Movement.x, m_Movement.z)); + double weight = glm::abs(glm::dot(glm::vec2(1, 0), direction)); + Events::SetBlendWeight sbw; + sbw.NodeName = "MovementBlend"; + sbw.Weight = weight; + sbw.RootNode = playerModel; + m_EventBroker->Publish(sbw); + } + } + } @@ -274,6 +268,8 @@ bool FirstPersonInputController::OnCommand(const Events::InputComm if (e.Command == "Crouch") { m_Crouching = e.Value > 0; + + //Animation if (m_PlayerEntity.Valid()) { EntityWrapper playerModel = m_PlayerEntity.FirstChildByName("PlayerModel"); if (playerModel.Valid()) { diff --git a/resources/Schema/Entities/Player.xml b/resources/Schema/Entities/Player.xml index 16b7ccd1..d51b8cc5 100644 --- a/resources/Schema/Entities/Player.xml +++ b/resources/Schema/Entities/Player.xml @@ -986,7 +986,7 @@ DashForwardF - 3 + 1.7999999523162842 false @@ -998,7 +998,7 @@ DashBackwardF - 3 + 1.7999999523162842 false @@ -1022,7 +1022,7 @@ DashLeftF - 3 + 1.7999999523162842 false @@ -1034,7 +1034,7 @@ DashRightF - 3 + 1.7999999523162842 false diff --git a/src/Engine/Rendering/AnimationSystem.cpp b/src/Engine/Rendering/AnimationSystem.cpp index be00a0f4..f6c91d46 100644 --- a/src/Engine/Rendering/AnimationSystem.cpp +++ b/src/Engine/Rendering/AnimationSystem.cpp @@ -127,6 +127,7 @@ void AnimationSystem::UpdateAnimations(double dt) void AnimationSystem::UpdateWeights(double dt) { for (auto it = m_AutoBlendQueues.begin(); it != m_AutoBlendQueues.end(); ) { + it->second.PrintQueue(); if(it->second.HasActiveBlendJob()) { AutoBlendQueue::AutoBlendJob& blendJob = it->second.GetActiveBlendJob(); @@ -151,6 +152,7 @@ void AnimationSystem::UpdateWeights(double dt) } } } + LOG_INFO(""); } bool AnimationSystem::OnAutoAnimationBlend(Events::AutoAnimationBlend& e) diff --git a/src/Engine/Rendering/AutoBlendQueue.cpp b/src/Engine/Rendering/AutoBlendQueue.cpp index 1c6907e8..f4a854ec 100644 --- a/src/Engine/Rendering/AutoBlendQueue.cpp +++ b/src/Engine/Rendering/AutoBlendQueue.cpp @@ -38,11 +38,14 @@ void AutoBlendQueue::Insert(AutoBlendJob autoBlendJob) double animationSpeed = (double)autoBlendJob.AnimationEntity["Animation"]["Speed"]; double animationTime = (double)autoBlendJob.AnimationEntity["Animation"]["Time"]; - - if ((bool)autoBlendJob.AnimationEntity["Animation"]["Reverse"]) { - AnimationDuration = (animation->Duration * animationSpeed) - (animation->Duration - animationTime); + if (animationSpeed != 0) { + if ((bool)autoBlendJob.AnimationEntity["Animation"]["Reverse"]) { + AnimationDuration = (animation->Duration / animationSpeed) - (animation->Duration - animationTime); + } else { + AnimationDuration = (animation->Duration / animationSpeed) - animationTime; + } } else { - AnimationDuration = (animation->Duration * animationSpeed) - animationTime; + return; } blendNode.StartTime += AnimationDuration; diff --git a/src/Game/Systems/PlayerMovementSystem.cpp b/src/Game/Systems/PlayerMovementSystem.cpp index dbf3d889..dad84932 100644 --- a/src/Game/Systems/PlayerMovementSystem.cpp +++ b/src/Game/Systems/PlayerMovementSystem.cpp @@ -358,7 +358,7 @@ bool PlayerMovementSystem::OnDashAbility(Events::DashAbility & e) if (controller->Movement().x > 0) { { Events::AutoAnimationBlend aeb; - aeb.Duration = 0.3; + aeb.Duration = 0.1; aeb.NodeName = "DashRight"; aeb.RootNode = playerModel; aeb.Restart = true; @@ -367,19 +367,19 @@ bool PlayerMovementSystem::OnDashAbility(Events::DashAbility & e) } { Events::AutoAnimationBlend aeb; - aeb.Duration = 0.3; + aeb.Duration = 0.2; aeb.NodeName = "StandCrouchBlend"; aeb.RootNode = playerModel; - aeb.Delay = -0.3; + aeb.Delay = 0.2; aeb.Start = true; aeb.Restart = false; - aeb.AnimationEntity = playerModel.FirstChildByName("DashForward"); + aeb.AnimationEntity = playerModel.FirstChildByName("DashRight"); m_EventBroker->Publish(aeb); } } else { { Events::AutoAnimationBlend aeb; - aeb.Duration = 0.3; + aeb.Duration = 0.1; aeb.NodeName = "DashLeft"; aeb.RootNode = playerModel; aeb.Restart = true; @@ -388,13 +388,13 @@ bool PlayerMovementSystem::OnDashAbility(Events::DashAbility & e) } { Events::AutoAnimationBlend aeb; - aeb.Duration = 0.3; + aeb.Duration = 0.2; aeb.NodeName = "StandCrouchBlend"; aeb.RootNode = playerModel; - aeb.Delay = -0.3; + aeb.Delay = 0.2; aeb.Start = true; aeb.Restart = false; - aeb.AnimationEntity = playerModel.FirstChildByName("DashForward"); + aeb.AnimationEntity = playerModel.FirstChildByName("DashLeft"); m_EventBroker->Publish(aeb); } } @@ -402,7 +402,7 @@ bool PlayerMovementSystem::OnDashAbility(Events::DashAbility & e) if (controller->Movement().z < 0) { { Events::AutoAnimationBlend aeb; - aeb.Duration = 0.3; + aeb.Duration = 0.1; aeb.NodeName = "DashForward"; aeb.RootNode = playerModel; aeb.Restart = true; @@ -411,10 +411,10 @@ bool PlayerMovementSystem::OnDashAbility(Events::DashAbility & e) } { Events::AutoAnimationBlend aeb; - aeb.Duration = 0.3; + aeb.Duration = 0.2; aeb.NodeName = "StandCrouchBlend"; aeb.RootNode = playerModel; - aeb.Delay = -0.3; + aeb.Delay = 0.2; aeb.Start = true; aeb.Restart = false; aeb.AnimationEntity = playerModel.FirstChildByName("DashForward"); @@ -423,7 +423,7 @@ bool PlayerMovementSystem::OnDashAbility(Events::DashAbility & e) } else { { Events::AutoAnimationBlend aeb; - aeb.Duration = 0.3; + aeb.Duration = 0.1; aeb.NodeName = "DashBackward"; aeb.RootNode = playerModel; aeb.Restart = true; @@ -432,29 +432,30 @@ bool PlayerMovementSystem::OnDashAbility(Events::DashAbility & e) } { Events::AutoAnimationBlend aeb; - aeb.Duration = 0.3; + aeb.Duration = 0.2; aeb.NodeName = "StandCrouchBlend"; aeb.RootNode = playerModel; - aeb.Delay = -0.3; + aeb.Delay = 0.2; aeb.Start = true; aeb.Restart = false; - aeb.AnimationEntity = playerModel.FirstChildByName("DashForward"); + aeb.AnimationEntity = playerModel.FirstChildByName("DashBackward"); m_EventBroker->Publish(aeb); } } } - /* EntityWrapper dashEffectModel; - dashEffectModel = playerModel.Clone(dashEffect); + EntityWrapper dashEffectModel; + dashEffectModel = playerModel.Clone(); player["Transform"].Copy(dashEffectModel["Transform"]); - dashEffectModel.AttachComponent("ExplosionEffect"); + /* dashEffectModel.AttachComponent("ExplosionEffect"); dashEffectModel["ExplosionEffect"]["EndColor"] = (glm::vec4)playerModel["Model"]["Color"]; ((glm::vec4&)dashEffectModel["ExplosionEffect"]["EndColor"]).w = 0.f; (double&)dashEffectModel["ExplosionEffect"]["ExplosionDuration"] = dashEffect["Lifetime"]["Lifetime"]; (glm::vec3&)dashEffectModel["ExplosionEffect"]["ExplosionOrigin"] = glm::vec3(0, 1, 0) + (0.2f * controller->Movement()); +*/ @@ -462,18 +463,9 @@ bool PlayerMovementSystem::OnDashAbility(Events::DashAbility & e) for (auto animationEntity : animationChildren) { (bool&)animationEntity["Animation"]["Play"] = false; - }*/ + } } } } - - - - - - - - - return true; } From 8d1877321a808848c0b4d048fe507b3b154b16b2 Mon Sep 17 00:00:00 2001 From: viktorljung Date: Tue, 8 Mar 2016 14:32:50 +0100 Subject: [PATCH 3/6] Fixed BoneAttachment offset rotation --- assets | 2 +- .../Schema/Entities/ModelCollisionTest.xml | 164 ++++++++++++++---- resources/Schema/Entities/MovementTest.xml | 47 ++++- src/Engine/Rendering/AnimationSystem.cpp | 2 - src/Engine/Rendering/BoneAttachmentSystem.cpp | 11 +- src/Game/Systems/PlayerMovementSystem.cpp | 8 +- 6 files changed, 193 insertions(+), 41 deletions(-) diff --git a/assets b/assets index 4205e927..22ccaf7a 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit 4205e92755aa67c90db6d272047cd92037ae9f11 +Subproject commit 22ccaf7a8d51c4aee6b0a0a3cb1cff6945c01151 diff --git a/resources/Schema/Entities/ModelCollisionTest.xml b/resources/Schema/Entities/ModelCollisionTest.xml index c4a3f81b..2adcc989 100644 --- a/resources/Schema/Entities/ModelCollisionTest.xml +++ b/resources/Schema/Entities/ModelCollisionTest.xml @@ -2,64 +2,168 @@ - - - + - + - - + + + + + + + + Schema/Entities/PlayerAssaultFallbackRed.xml + - - - - - - - - - - - ../assets/Models/Core/Tri.obj - - - - - + + - ../assets/Models/Core/Tri.obj + Models/Characters/Assault/AssaultRed.mesh - + + + + + + + + + + Models/Characters/Assault/AssaultRed.mesh + + + + - + - - + + 0.5 + 4 + + - ../assets/Models/Core/UnitCube.obj + sModels/Widgets/Lights/DirectionalLightWidget.mesh - - + + + + + + + Models/Test/ObstacleCourse.mesh + + + + + + + + + + + + + + + Schema/Entities/Player.xml + + + + + + + + + + + Models/Characters/Assault/AssaultBlue.mesh + + + + + + + + + + + + + Models/Characters/Assault/AssaultBlue.mesh + + + + + + + + + + + + + + ActivateDeactive + + + + Models/Characters/Defender/FirstPersonDefenderBlue.mesh + + + + + + + + + + ActivateDeactiveShieldF + + 1 + true + + + + + + + + + R_Arm_Weapon_Joint + + + Models/Weapons/Blue/DefenderWeaponBlue.mesh + + + + + + + + + + diff --git a/resources/Schema/Entities/MovementTest.xml b/resources/Schema/Entities/MovementTest.xml index 90c943ef..ea34db86 100644 --- a/resources/Schema/Entities/MovementTest.xml +++ b/resources/Schema/Entities/MovementTest.xml @@ -98,7 +98,7 @@ - + @@ -111,7 +111,50 @@ - + + + + + + + + + + + ActivateDeactive + + + + Models/Characters/Defender/FirstPersonDefenderBlue.mesh + + + + + + + + + + ActivateDeactiveShieldF + + 1 + true + + + + + + + + + R_Arm_Weapon_Joint + + + Models/Weapons/Blue/DefenderWeaponBlue.mesh + + + + diff --git a/src/Engine/Rendering/AnimationSystem.cpp b/src/Engine/Rendering/AnimationSystem.cpp index f6c91d46..be00a0f4 100644 --- a/src/Engine/Rendering/AnimationSystem.cpp +++ b/src/Engine/Rendering/AnimationSystem.cpp @@ -127,7 +127,6 @@ void AnimationSystem::UpdateAnimations(double dt) void AnimationSystem::UpdateWeights(double dt) { for (auto it = m_AutoBlendQueues.begin(); it != m_AutoBlendQueues.end(); ) { - it->second.PrintQueue(); if(it->second.HasActiveBlendJob()) { AutoBlendQueue::AutoBlendJob& blendJob = it->second.GetActiveBlendJob(); @@ -152,7 +151,6 @@ void AnimationSystem::UpdateWeights(double dt) } } } - LOG_INFO(""); } bool AnimationSystem::OnAutoAnimationBlend(Events::AutoAnimationBlend& e) diff --git a/src/Engine/Rendering/BoneAttachmentSystem.cpp b/src/Engine/Rendering/BoneAttachmentSystem.cpp index 43dc8634..6c8eb338 100644 --- a/src/Engine/Rendering/BoneAttachmentSystem.cpp +++ b/src/Engine/Rendering/BoneAttachmentSystem.cpp @@ -49,14 +49,19 @@ void BoneAttachmentSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapp glm::vec3 skew; glm::vec4 perspective; glm::decompose(boneTransform, scale, rotation, translation, skew, perspective); - - glm::vec3 angles = glm::vec3(-glm::pitch(rotation), -glm::yaw(rotation), -glm::roll(rotation)); + + + rotation = rotation * glm::quat((glm::vec3)entity["BoneAttachment"]["OrientationOffset"]); + + rotation.w = -rotation.w; + glm::vec3 angles = glm::eulerAngles(rotation); + if ((bool)entity["BoneAttachment"]["InheritPosition"]) { (glm::vec3&)entity["Transform"]["Position"] = translation + (glm::vec3)entity["BoneAttachment"]["PositionOffset"]; } if ((bool)entity["BoneAttachment"]["InheritOrientation"]) { - (glm::vec3&)entity["Transform"]["Orientation"] = angles + (glm::vec3)entity["BoneAttachment"]["OrientationOffset"]; + (glm::vec3&)entity["Transform"]["Orientation"] = angles; } if ((bool)entity["BoneAttachment"]["InheritScale"]) { (glm::vec3&)entity["Transform"]["Scale"] = scale * (glm::vec3)entity["BoneAttachment"]["ScaleOffset"]; diff --git a/src/Game/Systems/PlayerMovementSystem.cpp b/src/Game/Systems/PlayerMovementSystem.cpp index dad84932..5ab9f19d 100644 --- a/src/Game/Systems/PlayerMovementSystem.cpp +++ b/src/Game/Systems/PlayerMovementSystem.cpp @@ -444,18 +444,18 @@ bool PlayerMovementSystem::OnDashAbility(Events::DashAbility & e) } } - +/* EntityWrapper dashEffectModel; dashEffectModel = playerModel.Clone(); player["Transform"].Copy(dashEffectModel["Transform"]); - /* dashEffectModel.AttachComponent("ExplosionEffect"); + dashEffectModel.AttachComponent("ExplosionEffect"); dashEffectModel["ExplosionEffect"]["EndColor"] = (glm::vec4)playerModel["Model"]["Color"]; ((glm::vec4&)dashEffectModel["ExplosionEffect"]["EndColor"]).w = 0.f; (double&)dashEffectModel["ExplosionEffect"]["ExplosionDuration"] = dashEffect["Lifetime"]["Lifetime"]; (glm::vec3&)dashEffectModel["ExplosionEffect"]["ExplosionOrigin"] = glm::vec3(0, 1, 0) + (0.2f * controller->Movement()); -*/ + @@ -464,7 +464,9 @@ bool PlayerMovementSystem::OnDashAbility(Events::DashAbility & e) for (auto animationEntity : animationChildren) { (bool&)animationEntity["Animation"]["Play"] = false; } + */ } + } } return true; From 70ec075887f6221d7e41f1443169ece14331a285 Mon Sep 17 00:00:00 2001 From: viktorljung Date: Wed, 9 Mar 2016 13:19:56 +0100 Subject: [PATCH 4/6] 3rd person aim improvements --- resources/Schema/Entities/MovementTest.xml | 16 +- .../Schema/Entities/PlayerAssaultBlue.xml | 138 ++--- resources/Schema/Entities/ShootingRange.xml | 273 +++++++++ .../Schema/Entities/ThirdPersonBlendTree.xml | 528 ++++++++++++++++++ src/Game/Systems/PlayerMovementSystem.cpp | 9 +- 5 files changed, 853 insertions(+), 111 deletions(-) create mode 100644 resources/Schema/Entities/ShootingRange.xml create mode 100644 resources/Schema/Entities/ThirdPersonBlendTree.xml diff --git a/resources/Schema/Entities/MovementTest.xml b/resources/Schema/Entities/MovementTest.xml index 8ad34c93..8a99df55 100644 --- a/resources/Schema/Entities/MovementTest.xml +++ b/resources/Schema/Entities/MovementTest.xml @@ -54,7 +54,10 @@ - + + 0.49999982118606567 + 2.5599997043609619 + sModels/Widgets/Lights/DirectionalLightWidget.mesh @@ -100,7 +103,7 @@ - + @@ -113,7 +116,7 @@ - + @@ -138,8 +141,7 @@ ActivateDeactiveShieldF - - 1 + true @@ -155,8 +157,8 @@ Models/Weapons/Blue/DefenderWeaponBlue.mesh - - + + diff --git a/resources/Schema/Entities/PlayerAssaultBlue.xml b/resources/Schema/Entities/PlayerAssaultBlue.xml index 8bceb701..cad75d5b 100644 --- a/resources/Schema/Entities/PlayerAssaultBlue.xml +++ b/resources/Schema/Entities/PlayerAssaultBlue.xml @@ -6,9 +6,7 @@ - - 0.5 - + @@ -31,7 +29,6 @@ - @@ -577,8 +574,8 @@ Schema/Entities/WeaponAssaultBlueWorld.xml - - + + @@ -598,8 +595,8 @@ Schema/Entities/SidearmWeaponWorld.xml - - + + @@ -644,7 +641,7 @@ - ReloadSwitchBlend + UpperBody FinalMovementBlend @@ -706,8 +703,7 @@ CrouchStrafeLeftF - - 1 + true @@ -718,8 +714,7 @@ CrouchStrafeRightF - - 1 + true @@ -732,8 +727,7 @@ CrouchWalkF - - 1 + true @@ -747,7 +741,6 @@ CrouchF - 1 @@ -789,8 +782,7 @@ WalkF - - 1 + true @@ -801,8 +793,7 @@ RunF - - 1 + true @@ -825,8 +816,7 @@ StrafeLeftF - - 1 + true @@ -837,8 +827,7 @@ StrafeRightF - - 1 + true @@ -853,8 +842,7 @@ IdleF - - 1 + true @@ -881,7 +869,6 @@ JumpF - 1 false @@ -976,105 +963,58 @@ - + - ReloadSwitch - WeaponActionBlend - 1 - true + Idle + FireReload - + - ReloadSwitchU - - 1 + IdleAssaultRifleU + + true - + - IdleBlend - ShootBlend + Fire + Reload 0 + true - + - - IdlePrimary - IdleSecondary - 0 - + + ReloadSwitchU + + 0.5 + false + - - - - - IdleAssaultRifleU - - 1 - true - - - - - - - - - IdleSecWepU - - 1 - true - - - - - - + - + - - ShootPrimary - ShootSecondary - 0 - + + ShootFastRifleU + + - - - - - ShootFastRifleU - - 1 - - - - - - - - - ShootSecWepFastU - - - - - - + diff --git a/resources/Schema/Entities/ShootingRange.xml b/resources/Schema/Entities/ShootingRange.xml new file mode 100644 index 00000000..a05403c0 --- /dev/null +++ b/resources/Schema/Entities/ShootingRange.xml @@ -0,0 +1,273 @@ + + + + + + + + + + + + + + + + + + + + + + Models/Core/UnitCylinder.mesh + + + + + + + + + + + Models/Core/UnitCylinder.mesh + + + + + + + + + + + Models/Core/UnitCylinder.mesh + + + + + + + + + + + Models/Core/UnitCylinder.mesh + + + + + + + + + + + Models/Core/UnitCylinder.mesh + + + + + + + + + + + Models/Core/UnitCylinder.mesh + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Models/Core/UnitCylinder.mesh + + + + + + + + + + + Models/Core/UnitCylinder.mesh + + + + + + + + + + + Models/Core/UnitCylinder.mesh + + + + + + + + + + + Models/Core/UnitCylinder.mesh + + + + + + + + + + + Models/Core/UnitCylinder.mesh + + + + + + + + + + + Models/Core/UnitCylinder.mesh + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Models/Core/UnitCylinder.mesh + + + + + + + + + + + Models/Core/UnitCylinder.mesh + + + + + + + + + + + Models/Core/UnitCylinder.mesh + + + + + + + + + + + Models/Core/UnitCylinder.mesh + + + + + + + + + + + Models/Core/UnitCylinder.mesh + + + + + + + + + + + Models/Core/UnitCylinder.mesh + + + + + + + + + + + + + + + + + + + + + + + diff --git a/resources/Schema/Entities/ThirdPersonBlendTree.xml b/resources/Schema/Entities/ThirdPersonBlendTree.xml new file mode 100644 index 00000000..eb6f319e --- /dev/null +++ b/resources/Schema/Entities/ThirdPersonBlendTree.xml @@ -0,0 +1,528 @@ + + + + + + BlendTreeAim + BlendTreeAssault + + + + + Models/Characters/Assault/AssaultBlue.mesh + + + + + + + + + + R_Arm_Weapon_Joint + + + AssaultWeapon + + + + + + Schema/Entities/WeaponAssaultBlueWorld.xml + + + + + + + + + + + + R_Arm_Weapon_Joint + + + SidearmWeapon + + + + + + Schema/Entities/SidearmWeaponWorld.xml + + + + + + + + + + + + AimPrimary + AimSecondary + 0 + true + + + + + + + + AimSecWepA + + false + true + + + + + + + + + AimRifleA + + false + true + + + + + + + + + + + ReloadSwitchBlend + FinalMovementBlend + + + + + + + + StandCrouchBlend + JumpDashBlend + 2.5146881298480398e-63 + true + + + + + + + + StandMovement + CrouchMovement + 0 + true + + + + + + + + MovementBlend + Idle + 1 + + + + + + + + Walk + StrafeLRBlend + 0 + + + + + + + + Left + Right + 0.033793529385008014 + + + + + + + + CrouchStrafeLeftF + + true + + + + + + + + + CrouchStrafeRightF + + true + + + + + + + + + + + CrouchWalkF + + true + + + + + + + + + + + CrouchF + + + + + + + + + + + + MovementBlend + Idle + 1 + + + + + + + + RunWalkBlend + StrafeLRBlend + 0 + + + + + + + + Walk + Run + 1 + + + + + + + + WalkF + + true + + + + + + + + + RunF + + true + true + + + + + + + + + + + Left + Right + 0.033793529385008014 + + + + + + + + StrafeLeftF + + true + + + + + + + + + StrafeRightF + + true + + + + + + + + + + + + + IdleF + + true + + + + + + + + + + + + + Jump + DashBlend + 1 + true + + + + + + + + JumpF + + false + + + + + + + + + DashFBBlend + DashLRBlend + 0.014621149736541383 + + + + + + + + DashForward + DashBackward + 0.014363533804961248 + + + + + + + + DashForwardF + + 2 + false + + + + + + + + + DashBackwardF + + 2 + false + + + + + + + + + + + DashLeft + DashRight + 4.3244885367500671e-16 + + + + + + + + DashLeftF + + 2 + false + + + + + + + + + DashRightF + + 2 + false + + + + + + + + + + + + + + + + + ReloadSwitch + WeaponActionBlend + 1 + true + + + + + + + + ReloadSwitchU + + + + + + + + + + IdleBlend + ShootBlend + 0 + + + + + + + + IdlePrimary + IdleSecondary + 0 + + + + + + + + IdleAssaultRifleU + + true + + + + + + + + + IdleSecWepU + + true + + + + + + + + + + + ShootPrimary + ShootSecondary + 0 + + + + + + + + ShootFastRifleU + + + + + + + + + + ShootSecWepFastU + + + + + + + + + + + + + + + + diff --git a/src/Game/Systems/PlayerMovementSystem.cpp b/src/Game/Systems/PlayerMovementSystem.cpp index 96061079..99edef2c 100644 --- a/src/Game/Systems/PlayerMovementSystem.cpp +++ b/src/Game/Systems/PlayerMovementSystem.cpp @@ -81,23 +81,22 @@ void PlayerMovementSystem::updateMovementControllers(double dt) cameraOrientation.x += controller->Rotation().x; // Limit camera pitch so we don't break our necks cameraOrientation.x = glm::clamp(cameraOrientation.x, -glm::half_pi(), glm::half_pi()); + // Set third person model aim pitch EntityWrapper playerModel = player.FirstChildByName("PlayerModel"); - - //Third-person aim if (playerModel.Valid()) { EntityWrapper aimPrimaryEntity = playerModel.FirstChildByName("AimPrimary"); if(aimPrimaryEntity.Valid()){ if(aimPrimaryEntity.HasComponent("Animation")) { - float pitch = cameraOrientation.x + 0.2f; - double time = (pitch + glm::half_pi()) / glm::pi(); + float pitch = cameraOrientation.x; + double time = ((pitch + glm::half_pi()) / glm::pi()); (double&)aimPrimaryEntity["Animation"]["Time"] = time; } } EntityWrapper aimSecondaryEntity = playerModel.FirstChildByName("AimSecondary"); if (aimSecondaryEntity.Valid()) { if (aimSecondaryEntity.HasComponent("Animation")) { - float pitch = cameraOrientation.x + 0.2f; + float pitch = cameraOrientation.x; double time = (pitch + glm::half_pi()) / glm::pi(); (double&)aimSecondaryEntity["Animation"]["Time"] = time; } From d42d886dcc22604394b11d19a72b391795119e50 Mon Sep 17 00:00:00 2001 From: viktorljung Date: Wed, 9 Mar 2016 18:27:09 +0100 Subject: [PATCH 5/6] 3rd person animations synced with 1st person animations --- include/Engine/Core/EntityWrapper.h | 2 +- .../Engine/Input/FirstPersonInputController.h | 46 ++++++++-- .../Schema/Entities/PlayerAssaultBlue.xml | 92 ++++++++++--------- src/Engine/Core/EntityWrapper.cpp | 2 +- src/Engine/Rendering/AnimationSystem.cpp | 5 +- src/Engine/Rendering/BlendTree.cpp | 2 - src/Game/Systems/PlayerMovementSystem.cpp | 34 +++---- .../Systems/Weapon/AssaultWeaponBehaviour.cpp | 11 +-- 8 files changed, 107 insertions(+), 87 deletions(-) diff --git a/include/Engine/Core/EntityWrapper.h b/include/Engine/Core/EntityWrapper.h index dfa835f7..305fc21f 100644 --- a/include/Engine/Core/EntityWrapper.h +++ b/include/Engine/Core/EntityWrapper.h @@ -23,7 +23,7 @@ struct EntityWrapper static const EntityWrapper Invalid; - const std::string Name(); + const std::string Name() const; bool HasComponent(const std::string& componentType); void AttachComponent(const char* componentName); EntityWrapper Parent(); diff --git a/include/Engine/Input/FirstPersonInputController.h b/include/Engine/Input/FirstPersonInputController.h index 75726fd3..30d1f945 100644 --- a/include/Engine/Input/FirstPersonInputController.h +++ b/include/Engine/Input/FirstPersonInputController.h @@ -153,6 +153,31 @@ bool FirstPersonInputController::OnCommand(const Events::InputComm m_EventBroker->Publish(aeb); } } + + + EntityWrapper firstPersonModel = m_PlayerEntity.FirstChildByName("Hands"); + if (firstPersonModel.Valid()) { + if (val > 0) { // Walk/Run + if (!m_Crouching) { + Events::AutoAnimationBlend aeb; + aeb.Duration = 0.1; + aeb.NodeName = "Run"; + aeb.RootNode = firstPersonModel; + aeb.Start = true; + m_EventBroker->Publish(aeb); + } + } else if (val < 0) { // Walk/run Backwards + if (!m_Crouching) { + Events::AutoAnimationBlend aeb; + aeb.Duration = 0.1; + aeb.NodeName = "Run"; + aeb.RootNode = firstPersonModel; + aeb.Start = true; + aeb.Reverse = true; + m_EventBroker->Publish(aeb); + } + } + } } } if (e.Command == "Right") { @@ -187,27 +212,36 @@ bool FirstPersonInputController::OnCommand(const Events::InputComm } //Animation - if (glm::length2(m_Movement) < 0.1f) { + if (glm::length2(m_Movement) < 0.25f) { //Blend to Idle if (m_PlayerEntity.Valid()) { EntityWrapper playerModel = m_PlayerEntity.FirstChildByName("PlayerModel"); if (playerModel.Valid()) { Events::AutoAnimationBlend aeb; - aeb.Duration = 0.2; + aeb.Duration = 0.1; aeb.NodeName = "Idle"; aeb.RootNode = playerModel; + aeb.Start = true; + m_EventBroker->Publish(aeb); + } + EntityWrapper firstPersonModel = m_PlayerEntity.FirstChildByName("Hands"); + if (firstPersonModel.Valid()) { + Events::AutoAnimationBlend aeb; + aeb.Duration = 0.1; + aeb.NodeName = "Idle"; + aeb.RootNode = firstPersonModel; + aeb.Start = true; m_EventBroker->Publish(aeb); } } } else { - //Blend to movement if (m_PlayerEntity.Valid()) { EntityWrapper playerModel = m_PlayerEntity.FirstChildByName("PlayerModel"); if (playerModel.Valid()) { Events::AutoAnimationBlend aeb; - aeb.Duration = 0.2; - aeb.NodeName = "MovementBlend"; + aeb.Duration = 0.1; + aeb.NodeName = "DirectionBlend"; aeb.RootNode = playerModel; m_EventBroker->Publish(aeb); } @@ -226,7 +260,7 @@ bool FirstPersonInputController::OnCommand(const Events::InputComm glm::vec2 direction = glm::normalize(glm::vec2(m_Movement.x, m_Movement.z)); double weight = glm::abs(glm::dot(glm::vec2(1, 0), direction)); Events::SetBlendWeight sbw; - sbw.NodeName = "MovementBlend"; + sbw.NodeName = "DirectionBlend"; sbw.Weight = weight; sbw.RootNode = playerModel; m_EventBroker->Publish(sbw); diff --git a/resources/Schema/Entities/PlayerAssaultBlue.xml b/resources/Schema/Entities/PlayerAssaultBlue.xml index 780d3531..64141757 100644 --- a/resources/Schema/Entities/PlayerAssaultBlue.xml +++ b/resources/Schema/Entities/PlayerAssaultBlue.xml @@ -2,7 +2,6 @@ - @@ -22,6 +21,7 @@ + @@ -463,7 +463,7 @@ - Textures/Icons/Abilities/Superman-01.png + Textures\Icons\Abilities\Superman-01.png false @@ -504,25 +504,25 @@ - - AssaultWeapon - Schema/Entities/WeaponAssaultBlueView.xml + + AssaultWeapon + - - DefenderWeapon - Schema/Entities/WeaponDefenderBlueView.xml + + DefenderWeapon + @@ -566,19 +566,19 @@ R_Arm_Weapon_Joint + + Schema/Entities/WeaponAssaultBlueWorld.xml + + + + + AssaultWeapon - - Schema/Entities/WeaponAssaultBlueWorld.xml - - - - - @@ -587,26 +587,26 @@ R_Arm_Weapon_Joint + + Schema/Entities/SidearmWeaponWorld.xml + + + + + SidearmWeapon - - Schema/Entities/SidearmWeaponWorld.xml - - - - - - StandCrouchBlend + MovementBlend JumpDashBlend 2.5146881298480398e-63 true @@ -628,7 +628,7 @@ - MovementBlend + DirectionBlend Idle 1 @@ -659,7 +659,7 @@ CrouchStrafeLeftF - + true @@ -670,7 +670,7 @@ CrouchStrafeRightF - + true @@ -683,7 +683,7 @@ CrouchWalkF - + true @@ -696,7 +696,8 @@ CrouchF - + + true @@ -707,7 +708,7 @@ - MovementBlend + DirectionBlend Idle 1 @@ -738,7 +739,7 @@ WalkF - + true @@ -749,7 +750,8 @@ RunF - + + 2 true @@ -772,7 +774,8 @@ StrafeLeftF - + + 2 true @@ -783,7 +786,8 @@ StrafeRightF - + + 2 true @@ -798,7 +802,7 @@ IdleF - + true @@ -856,7 +860,7 @@ DashForwardF - 2 + 1.7999999523162842 false @@ -868,7 +872,7 @@ DashBackwardF - 2 + 1.7999999523162842 false @@ -887,24 +891,24 @@ - + - DashLeftF + DashRightF - 2 + 1.7999999523162842 false - + - DashRightF + DashLeftF - 2 + 1.7999999523162842 false @@ -981,7 +985,7 @@ - + Idle @@ -995,6 +999,7 @@ IdleAssaultRifleU + true true @@ -1006,6 +1011,7 @@ IdleAssaultRifleU + true true diff --git a/src/Engine/Core/EntityWrapper.cpp b/src/Engine/Core/EntityWrapper.cpp index cba90ded..a85127ad 100644 --- a/src/Engine/Core/EntityWrapper.cpp +++ b/src/Engine/Core/EntityWrapper.cpp @@ -3,7 +3,7 @@ const EntityWrapper EntityWrapper::Invalid = EntityWrapper(nullptr, EntityID_Invalid); -const std::string EntityWrapper::Name() +const std::string EntityWrapper::Name() const { return World->GetName(ID); } diff --git a/src/Engine/Rendering/AnimationSystem.cpp b/src/Engine/Rendering/AnimationSystem.cpp index be00a0f4..93a603a7 100644 --- a/src/Engine/Rendering/AnimationSystem.cpp +++ b/src/Engine/Rendering/AnimationSystem.cpp @@ -127,9 +127,12 @@ void AnimationSystem::UpdateAnimations(double dt) void AnimationSystem::UpdateWeights(double dt) { for (auto it = m_AutoBlendQueues.begin(); it != m_AutoBlendQueues.end(); ) { + LOG_INFO("%s", it->first.Name().c_str()); + it->second.PrintQueue(); + if(it->second.HasActiveBlendJob()) { AutoBlendQueue::AutoBlendJob& blendJob = it->second.GetActiveBlendJob(); - + LOG_INFO("%s", blendJob.RootNode.Name().c_str()); std::shared_ptr blendTree = it->second.GetBlendTree(); if (blendTree != nullptr) { if (blendJob.Duration != 0.0) { diff --git a/src/Engine/Rendering/BlendTree.cpp b/src/Engine/Rendering/BlendTree.cpp index 1ecafc56..ca22cd74 100644 --- a/src/Engine/Rendering/BlendTree.cpp +++ b/src/Engine/Rendering/BlendTree.cpp @@ -214,7 +214,6 @@ BlendTree::AutoBlendInfo BlendTree::AutoBlendStep(AutoBlendInfo blendInfo) } } } - return blendInfo; } @@ -333,7 +332,6 @@ BlendTree::AutoBlendInfo BlendTree::AutoBlendStep(AutoBlendInfo blendInfo) } } } - } return blendInfo; diff --git a/src/Game/Systems/PlayerMovementSystem.cpp b/src/Game/Systems/PlayerMovementSystem.cpp index 99edef2c..cfe7356c 100644 --- a/src/Game/Systems/PlayerMovementSystem.cpp +++ b/src/Game/Systems/PlayerMovementSystem.cpp @@ -85,7 +85,7 @@ void PlayerMovementSystem::updateMovementControllers(double dt) // Set third person model aim pitch EntityWrapper playerModel = player.FirstChildByName("PlayerModel"); if (playerModel.Valid()) { - EntityWrapper aimPrimaryEntity = playerModel.FirstChildByName("AimPrimary"); + EntityWrapper aimPrimaryEntity = playerModel.FirstChildByName("Aim"); if(aimPrimaryEntity.Valid()){ if(aimPrimaryEntity.HasComponent("Animation")) { float pitch = cameraOrientation.x; @@ -93,14 +93,6 @@ void PlayerMovementSystem::updateMovementControllers(double dt) (double&)aimPrimaryEntity["Animation"]["Time"] = time; } } - EntityWrapper aimSecondaryEntity = playerModel.FirstChildByName("AimSecondary"); - if (aimSecondaryEntity.Valid()) { - if (aimSecondaryEntity.HasComponent("Animation")) { - float pitch = cameraOrientation.x; - double time = (pitch + glm::half_pi()) / glm::pi(); - (double&)aimSecondaryEntity["Animation"]["Time"] = time; - } - } } } @@ -212,7 +204,7 @@ void PlayerMovementSystem::updateMovementControllers(double dt) { Events::AutoAnimationBlend aeb; aeb.Duration = 0.25; - aeb.NodeName = "StandCrouchBlend"; + aeb.NodeName = "MovementBlend"; aeb.RootNode = playerModel; aeb.Start = true; aeb.Restart = false; @@ -243,11 +235,11 @@ void PlayerMovementSystem::updateMovementControllers(double dt) { Events::AutoAnimationBlend aeb; aeb.Duration = 0.25; - aeb.NodeName = "StandCrouchBlend"; + aeb.NodeName = "MovementBlend"; aeb.RootNode = playerModel; aeb.Start = true; aeb.Restart = false; - aeb.AnimationEntity = playerModel.FirstChildByName("Jump"); + aeb.AnimationEntity = playerModel.FirstChildByName("BlendTreeLower").FirstChildByName("Jump"); m_EventBroker->Publish(aeb); } } @@ -376,12 +368,12 @@ void PlayerMovementSystem::spawnHexagon(EntityWrapper target) bool PlayerMovementSystem::OnDashAbility(Events::DashAbility & e) { EntityWrapper player(m_World, e.Player); - if (!player.Valid() || !IsClient){// || player.ID == LocalPlayer.ID) { + if (!player.Valid()){// || !IsClient || player.ID == LocalPlayer.ID) { return false; } - auto entityFile = ResourceManager::Load("Schema/Entities/DashEffect.xml"); - EntityWrapper dashEffect = entityFile->MergeInto(m_World); +// auto entityFile = ResourceManager::Load("Schema/Entities/DashEffect.xml"); + // EntityWrapper dashEffect = entityFile->MergeInto(m_World); EntityWrapper playerModel = player.FirstChildByName("PlayerModel"); for (auto& kv : m_PlayerInputControllers) { @@ -409,9 +401,8 @@ bool PlayerMovementSystem::OnDashAbility(Events::DashAbility & e) { Events::AutoAnimationBlend aeb; aeb.Duration = 0.2; - aeb.NodeName = "StandCrouchBlend"; + aeb.NodeName = "MovementBlend"; aeb.RootNode = playerModel; - aeb.Delay = 0.2; aeb.Start = true; aeb.Restart = false; aeb.AnimationEntity = playerModel.FirstChildByName("DashRight"); @@ -430,9 +421,8 @@ bool PlayerMovementSystem::OnDashAbility(Events::DashAbility & e) { Events::AutoAnimationBlend aeb; aeb.Duration = 0.2; - aeb.NodeName = "StandCrouchBlend"; + aeb.NodeName = "MovementBlend"; aeb.RootNode = playerModel; - aeb.Delay = 0.2; aeb.Start = true; aeb.Restart = false; aeb.AnimationEntity = playerModel.FirstChildByName("DashLeft"); @@ -453,9 +443,8 @@ bool PlayerMovementSystem::OnDashAbility(Events::DashAbility & e) { Events::AutoAnimationBlend aeb; aeb.Duration = 0.2; - aeb.NodeName = "StandCrouchBlend"; + aeb.NodeName = "MovementBlend"; aeb.RootNode = playerModel; - aeb.Delay = 0.2; aeb.Start = true; aeb.Restart = false; aeb.AnimationEntity = playerModel.FirstChildByName("DashForward"); @@ -474,9 +463,8 @@ bool PlayerMovementSystem::OnDashAbility(Events::DashAbility & e) { Events::AutoAnimationBlend aeb; aeb.Duration = 0.2; - aeb.NodeName = "StandCrouchBlend"; + aeb.NodeName = "MovementBlend"; aeb.RootNode = playerModel; - aeb.Delay = 0.2; aeb.Start = true; aeb.Restart = false; aeb.AnimationEntity = playerModel.FirstChildByName("DashBackward"); diff --git a/src/Game/Systems/Weapon/AssaultWeaponBehaviour.cpp b/src/Game/Systems/Weapon/AssaultWeaponBehaviour.cpp index dddf5fdd..8c92b35b 100644 --- a/src/Game/Systems/Weapon/AssaultWeaponBehaviour.cpp +++ b/src/Game/Systems/Weapon/AssaultWeaponBehaviour.cpp @@ -133,11 +133,6 @@ void AssaultWeaponBehaviour::OnReload(ComponentWrapper cWeapon, WeaponInfo& wi) b1.Restart = true; b1.Start = true; m_EventBroker->Publish(b1); - Events::AutoAnimationBlend b2; - b2.RootNode = wi.ThirdPersonPlayerModel; - b2.NodeName = "MovementBlend"; - b2.AnimationEntity = wi.ThirdPersonPlayerModel.FirstChildByName("AssaultWeaponBlend").FirstChildByName("Reload"); - m_EventBroker->Publish(b2); // Spawn explosion effect if (wi.FirstPersonEntity.Valid()) { @@ -247,6 +242,7 @@ void AssaultWeaponBehaviour::fireBullet(ComponentWrapper cWeapon, WeaponInfo& wi // Play animation playAnimationAndReturn(wi.FirstPersonEntity, "ActionBlend", "Fire"); + // Third person anim Events::AutoAnimationBlend b1; b1.RootNode = wi.ThirdPersonPlayerModel; @@ -254,11 +250,6 @@ void AssaultWeaponBehaviour::fireBullet(ComponentWrapper cWeapon, WeaponInfo& wi b1.Restart = true; b1.Start = true; m_EventBroker->Publish(b1); - Events::AutoAnimationBlend b2; - b2.RootNode = wi.ThirdPersonPlayerModel; - b2.NodeName = "MovementBlend"; - b2.AnimationEntity = wi.ThirdPersonPlayerModel.FirstChildByName("AssaultWeaponBlend").FirstChildByName("Fire"); - m_EventBroker->Publish(b2); // Sound Events::PlaySoundOnEntity e; From 1bfd0cce5eed54cddd4861232c5ed52f1b4a918c Mon Sep 17 00:00:00 2001 From: viktorljung Date: Wed, 9 Mar 2016 18:36:53 +0100 Subject: [PATCH 6/6] Idel --- resources/Schema/Entities/WeaponAssaultBlueView.xml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/resources/Schema/Entities/WeaponAssaultBlueView.xml b/resources/Schema/Entities/WeaponAssaultBlueView.xml index 05b65bbb..49015151 100644 --- a/resources/Schema/Entities/WeaponAssaultBlueView.xml +++ b/resources/Schema/Entities/WeaponAssaultBlueView.xml @@ -72,7 +72,7 @@ - IdleF + IdelF true true @@ -91,8 +91,8 @@ Models/Weapons/Blue/AssaultWeaponBlue.mesh - - + + @@ -127,9 +127,9 @@ true - - - + + +