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;