From 3a8f7c5d03225a73611ff60999e31c2a459c58ae Mon Sep 17 00:00:00 2001 From: sippeangelo Date: Fri, 4 Mar 2016 02:48:03 +0100 Subject: [PATCH] First attempt at AssaultWeapon animations! --- assets | 2 +- .../Systems/Weapon/AssaultWeaponBehaviour.h | 1 + .../Schema/Entities/AssaultBlendTree.xml | 513 ------------- resources/Schema/Entities/BlendTreeAim.xml | 41 ++ .../Schema/Entities/BlendTreeAssault.xml | 445 ++++++++++++ .../Entities/BlendTreeAssaultWeapon.xml | 65 ++ .../Entities/BlendTreeSidearmWeapon.xml | 10 + resources/Schema/Entities/MovementTest.xml | 20 +- resources/Schema/Entities/Player.xml | 684 ++++++++++++++++-- src/Game/Systems/PlayerMovementSystem.cpp | 89 +-- .../Systems/Weapon/AssaultWeaponBehaviour.cpp | 46 ++ 11 files changed, 1253 insertions(+), 663 deletions(-) delete mode 100644 resources/Schema/Entities/AssaultBlendTree.xml create mode 100644 resources/Schema/Entities/BlendTreeAim.xml create mode 100644 resources/Schema/Entities/BlendTreeAssault.xml create mode 100644 resources/Schema/Entities/BlendTreeAssaultWeapon.xml create mode 100644 resources/Schema/Entities/BlendTreeSidearmWeapon.xml diff --git a/assets b/assets index c82b5716..4205e927 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit c82b5716d98a0c9fb3914367e9b08cc2e7dbca43 +Subproject commit 4205e92755aa67c90db6d272047cd92037ae9f11 diff --git a/include/Game/Systems/Weapon/AssaultWeaponBehaviour.h b/include/Game/Systems/Weapon/AssaultWeaponBehaviour.h index 69bd15e1..d577e22f 100644 --- a/include/Game/Systems/Weapon/AssaultWeaponBehaviour.h +++ b/include/Game/Systems/Weapon/AssaultWeaponBehaviour.h @@ -5,6 +5,7 @@ #include "Collision/Collision.h" #include "Core/EPlayerDamage.h" #include "Sound/EPlaySoundOnEntity.h" +#include "Rendering/EAutoAnimationBlend.h" class AssaultWeaponBehaviour : public WeaponBehaviour { diff --git a/resources/Schema/Entities/AssaultBlendTree.xml b/resources/Schema/Entities/AssaultBlendTree.xml deleted file mode 100644 index e8dcff8a..00000000 --- a/resources/Schema/Entities/AssaultBlendTree.xml +++ /dev/null @@ -1,513 +0,0 @@ - - - - - - AimBlend - FinalBlend - - - 5 - Models/Characters/Assault/AssaultBlue.mesh - - - - - - - - - R_Arm_Weapon_Joint - - - Models/Weapons/Blue/AssaultWeaponBlue.mesh - - - - - - - - - - - - - AimPrimary - AimSecondary - 0 - true - - - - - - - - AimSecWepA - - false - true - - - - - - - - - AimRifleA - - false - true - - - - - - - - - - - ReloadSwitchBlend - MovementBlend - - - - - - - - StandCrouchBlend - JumpDashBlend - 2.5146881298480398e-63 - true - - - - - - - - StandMovement - CrouchMovement - 0.012867419418159054 - true - - - - - - - - MovementBlend - Idle - 1 - - - - - - - - RunWalkBlend - StrafeLRBlend - 2.4565650245976452e-16 - - - - - - - - Walk - Run - 1.2938206818383024e-24 - - - - - - - - WalkF - - 1 - true - - - - - - - - - RunF - - 1 - true - - - - - - - - - - - Left - Right - 0.033793529385008014 - - - - - - - - StrafeLeftF - - 1 - true - - - - - - - - - StrafeRightF - - 1 - true - - - - - - - - - - - - - IdleF - - 1 - true - - - - - - - - - - - MovementBlend - Idle - 0 - - - - - - - - Walk - StrafeLRBlend - 2.4565650245976452e-16 - - - - - - - - Left - Right - 0.033793529385008014 - - - - - - - - CrouchStrafeLeftF - - 1 - true - - - - - - - - - CrouchStrafeRightF - - 1 - true - - - - - - - - - - - CrouchWalkF - - 1 - true - - - - - - - - - - - CrouchF - - 1 - - - - - - - - - - - - - Jump - DashBlend - 1 - true - - - - - - - - JumpF - - 1 - false - - - - - - - - - DashFBBlend - DashLRBlend - 0.014621149736541383 - - - - - - - - DashForward - DashBackward - 0.014363533804961248 - - - - - - - - DashForwardF - - 1 - false - - - - - - - - - DashBackwardF - - 1 - false - - - - - - - - - - - DashLeft - DashRight - 4.3244885367500671e-16 - - - - - - - - DashLeftF - - 1 - false - - - - - - - - - DashRightF - - 1 - false - - - - - - - - - - - - - - - - - ReloadSwitch - WeaponActionBlend - 1 - true - - - - - - - - ReloadSwitchU - - 1 - - - - - - - - - IdleBlend - ShootBlend - 0 - - - - - - - - IdlePrimary - IdleSecondary - 0 - - - - - - - - IdleAssaultRifleU - - 1 - true - - - - - - - - - IdleSecWepU - - 1 - true - - - - - - - - - - - ShootPrimary - ShootSecondary - 0 - - - - - - - - ShootFastRifleU - - 1 - - - - - - - - - ShootSecWepFastU - - - - - - - - - - - - - - - - diff --git a/resources/Schema/Entities/BlendTreeAim.xml b/resources/Schema/Entities/BlendTreeAim.xml new file mode 100644 index 00000000..a340c8d5 --- /dev/null +++ b/resources/Schema/Entities/BlendTreeAim.xml @@ -0,0 +1,41 @@ + + + + + + AimPrimary + AimSecondary + 0 + true + + + + + + + + + AimSecWepA + + false + true + + + + + + + + + AimRifleA + + false + true + + + + + + + + diff --git a/resources/Schema/Entities/BlendTreeAssault.xml b/resources/Schema/Entities/BlendTreeAssault.xml new file mode 100644 index 00000000..1cd121eb --- /dev/null +++ b/resources/Schema/Entities/BlendTreeAssault.xml @@ -0,0 +1,445 @@ + + + + + + ReloadSwitchBlend + MovementBlend + + + + + + + + + StandCrouchBlend + JumpDashBlend + 2.5146881298480398e-63 + true + + + + + + + + StandMovement + CrouchMovement + 0 + true + + + + + + + + MovementBlend + Idle + 1 + + + + + + + + Walk + StrafeLRBlend + 0 + + + + + + + + Left + Right + 0.033793529385008014 + + + + + + + + CrouchStrafeLeftF + + 1 + true + + + + + + + + + CrouchStrafeRightF + + 1 + true + + + + + + + + + + + CrouchWalkF + + 1 + true + + + + + + + + + + + CrouchF + + 1 + + + + + + + + + + + MovementBlend + Idle + 1 + + + + + + + + RunWalkBlend + StrafeLRBlend + 2.4565650245976452e-16 + + + + + + + + Walk + Run + 1.2938206818383024e-24 + + + + + + + + WalkF + + 1 + true + + + + + + + + + RunF + + 1 + true + + + + + + + + + + + Left + Right + 0.033793529385008014 + + + + + + + + StrafeLeftF + + 1 + true + + + + + + + + + StrafeRightF + + 1 + true + + + + + + + + + + + + + IdleF + + 1 + true + + + + + + + + + + + + + Jump + DashBlend + 1 + true + + + + + + + + JumpF + + 1 + false + + + + + + + + + DashFBBlend + DashLRBlend + 0.014621149736541383 + + + + + + + + DashForward + DashBackward + 0.014363533804961248 + + + + + + + + DashForwardF + + 1 + false + + + + + + + + + DashBackwardF + + 1 + false + + + + + + + + + + + DashLeft + DashRight + 4.3244885367500671e-16 + + + + + + + + DashLeftF + + 1 + false + + + + + + + + + DashRightF + + 1 + false + + + + + + + + + + + + + + + + + ReloadSwitch + WeaponActionBlend + 1 + true + + + + + + + + ReloadSwitchU + + 1 + + + + + + + + + IdleBlend + ShootBlend + 0 + + + + + + + + IdlePrimary + IdleSecondary + 0 + + + + + + + + IdleAssaultRifleU + + 1 + true + + + + + + + + + IdleSecWepU + + 1 + true + + + + + + + + + + + ShootPrimary + ShootSecondary + 0 + + + + + + + + ShootFastRifleU + + 1 + + + + + + + + + ShootSecWepFastU + + + + + + + + + + + + + + diff --git a/resources/Schema/Entities/BlendTreeAssaultWeapon.xml b/resources/Schema/Entities/BlendTreeAssaultWeapon.xml new file mode 100644 index 00000000..a68175a2 --- /dev/null +++ b/resources/Schema/Entities/BlendTreeAssaultWeapon.xml @@ -0,0 +1,65 @@ + + + + + + Idle + WeaponAction + 0 + true + + + + + + + + + Fire + Reload + 1 + + + + + + + + ShootShotgunF + 1 + true + false + + + + + + + + + ReloadSwitchF + + 1 + true + + + + + + + + + + + IdleF + + 1 + true + + + + + + + + diff --git a/resources/Schema/Entities/BlendTreeSidearmWeapon.xml b/resources/Schema/Entities/BlendTreeSidearmWeapon.xml new file mode 100644 index 00000000..627829e5 --- /dev/null +++ b/resources/Schema/Entities/BlendTreeSidearmWeapon.xml @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/resources/Schema/Entities/MovementTest.xml b/resources/Schema/Entities/MovementTest.xml index 7bbaf21d..90c943ef 100644 --- a/resources/Schema/Entities/MovementTest.xml +++ b/resources/Schema/Entities/MovementTest.xml @@ -8,15 +8,15 @@ - - - Schema/Entities/PlayerAssaultFallbackRed.xml - + + + Schema/Entities/PlayerAssaultFallbackRed.xml + @@ -76,15 +76,15 @@ - - - Schema/Entities/PlayerAssaultFallbackBlue.xml - + + + Schema/Entities/Player.xml + @@ -98,7 +98,7 @@ - + @@ -111,7 +111,7 @@ - + diff --git a/resources/Schema/Entities/Player.xml b/resources/Schema/Entities/Player.xml index affe9f79..d34dba32 100644 --- a/resources/Schema/Entities/Player.xml +++ b/resources/Schema/Entities/Player.xml @@ -6,11 +6,12 @@ - - - - - + + + + + + @@ -22,11 +23,6 @@ 5 - - - - - @@ -173,6 +169,40 @@ + + + + + + + + Textures/Core/White.png + + false + + + + + + + + + + + 0.0 + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + @@ -219,12 +249,12 @@ - - 2 - + + 2 + Textures/Core/UnitHexagon_Rotated.png @@ -253,12 +283,12 @@ - - 3 - + + 3 + Textures/Core/UnitHexagon_Rotated.png @@ -287,13 +317,13 @@ - - 4 - 1 + + 4 + Textures/Core/UnitHexagon_Rotated.png @@ -322,12 +352,12 @@ - - 1 - + + 1 + Textures/Core/UnitHexagon_Rotated.png @@ -356,11 +386,11 @@ - 1 + Textures/Core/UnitHexagon_Rotated.png @@ -433,15 +463,15 @@ - - - Models/Widgets/Arrows/Arrow5.mesh - + + + Models/Widgets/Arrows/Arrow5.mesh + @@ -454,16 +484,14 @@ - - Idle - 1.8348644854054612 - 1 - - - + + BlendTreeAssaultWeapon + BlendTreeSecondaryWeapon + 0 + true + - Models/Characters/Assault/Test/FirstPerson.mesh - + Models/Characters/Defender/FirstPersonDefenderBlue.mesh @@ -477,11 +505,11 @@ AssaultWeapon - Schema/Entities/AssaultWeaponView.xml + Schema/Entities/WeaponAssaultBlueView.xml - - + + @@ -498,12 +526,79 @@ Schema/Entities/SidearmWeaponView.xml - - + + + + + + Idle + WeaponAction + 0 + true + + + + + + + + Fire + Reload + 1 + + + + + + + + ShootShotgunF + 1 + true + false + + + + + + + + + ReloadSwitchF + + 1 + true + + + + + + + + + + + IdleF + + 1 + true + + + + + + + + + + + + + @@ -527,27 +622,25 @@ - - IdleF - 1 - - - - - AimRifle - - + + BlendTreeAim + BlendTreeAssault + Models/Characters/Assault/AssaultBlue.mesh + false + + R_Arm_Weapon_Joint + AssaultWeapon @@ -555,9 +648,12 @@ - Schema/Entities/AssaultWeaponWorld.xml + Schema/Entities/WeaponAssaultBlueWorld.xml - + + + + @@ -576,12 +672,490 @@ Schema/Entities/SidearmWeaponWorld.xml - - + + + + + + AimPrimary + AimSecondary + 0 + true + + + + + + + + AimSecWepA + + false + true + + + + + + + + + AimRifleA + + false + true + + + + + + + + + + + ReloadSwitchBlend + MovementBlend + + + + + + + + StandCrouchBlend + JumpDashBlend + 2.5146881298480398e-63 + true + + + + + + + + StandMovement + CrouchMovement + 0 + true + + + + + + + + MovementBlend + Idle + 1 + + + + + + + + Walk + StrafeLRBlend + 0 + + + + + + + + Left + Right + 0.033793529385008014 + + + + + + + + CrouchStrafeLeftF + + 1 + true + + + + + + + + + CrouchStrafeRightF + + 1 + true + + + + + + + + + + + CrouchWalkF + + 1 + true + + + + + + + + + + + CrouchF + + 1 + + + + + + + + + + + MovementBlend + Idle + 1 + + + + + + + + RunWalkBlend + StrafeLRBlend + 2.4565650245976452e-16 + + + + + + + + Walk + Run + 1.2938206818383024e-24 + + + + + + + + WalkF + + 1 + true + + + + + + + + + RunF + + 1 + true + + + + + + + + + + + Left + Right + 0.033793529385008014 + + + + + + + + StrafeLeftF + + 1 + true + + + + + + + + + StrafeRightF + + 1 + true + + + + + + + + + + + + + IdleF + + 1 + true + + + + + + + + + + + + + Jump + DashBlend + 1 + true + + + + + + + + JumpF + + 1 + false + + + + + + + + + DashFBBlend + DashLRBlend + 0.014621149736541383 + + + + + + + + DashForward + DashBackward + 0.014363533804961248 + + + + + + + + DashForwardF + + 1 + false + + + + + + + + + DashBackwardF + + 1 + false + + + + + + + + + + + DashLeft + DashRight + 4.3244885367500671e-16 + + + + + + + + DashLeftF + + 1 + false + + + + + + + + + DashRightF + + 1 + false + + + + + + + + + + + + + + + + + ReloadSwitch + WeaponActionBlend + 1 + true + + + + + + + + ReloadSwitchU + + 1 + + + + + + + + + IdleBlend + ShootBlend + 0 + + + + + + + + IdlePrimary + IdleSecondary + 0 + + + + + + + + IdleAssaultRifleU + + 1 + true + + + + + + + + + IdleSecWepU + + 1 + true + + + + + + + + + + + ShootPrimary + ShootSecondary + 0 + + + + + + + + ShootFastRifleU + + 1 + + + + + + + + + ShootSecWepFastU + + + + + + + + + + + + + diff --git a/src/Game/Systems/PlayerMovementSystem.cpp b/src/Game/Systems/PlayerMovementSystem.cpp index b116bcd9..d67e77bd 100644 --- a/src/Game/Systems/PlayerMovementSystem.cpp +++ b/src/Game/Systems/PlayerMovementSystem.cpp @@ -43,10 +43,10 @@ void PlayerMovementSystem::updateMovementControllers(double dt) // Set third person model aim pitch EntityWrapper playerModel = player.FirstChildByName("PlayerModel"); if (playerModel.Valid()) { - ComponentWrapper cAnimationOffset = playerModel["AnimationOffset"]; - float pitch = cameraOrientation.x + 0.2f; - double time = (pitch + glm::half_pi()) / glm::pi(); - cAnimationOffset["Time"] = time; + //ComponentWrapper cAnimationOffset = playerModel["AnimationOffset"]; + //float pitch = cameraOrientation.x + 0.2f; + //double time = (pitch + glm::half_pi()) / glm::pi(); + //cAnimationOffset["Time"] = time; } } @@ -166,81 +166,7 @@ void PlayerMovementSystem::updateMovementControllers(double dt) } } - // Animations - EntityWrapper playerModel = player.FirstChildByName("PlayerModel"); - if (playerModel.Valid()) { - ComponentWrapper cAnimation = playerModel["Animation"]; - std::string& animationName1 = cAnimation["AnimationName1"]; - std::string& animationName2 = cAnimation["AnimationName2"]; - double& animationTime1 = cAnimation["Time1"]; - double& animationTime2 = cAnimation["Time2"]; - double& animationSpeed1 = cAnimation["Speed1"]; - double& animationSpeed2 = cAnimation["Speed2"]; - double& animationWeight1 = cAnimation["Weight1"]; - double& animationWeight2 = cAnimation["Weight2"]; - - float movementLength = glm::length(groundVelocity); - //TODO: add assault dash animation here - if (glm::length(controller->Movement()) > 0.f) { - double forwardMovement = controller->Movement().z; - double strafeMovement = controller->Movement().x; - - if (controller->Crouching() && animationName1 != "CrouchWalk") { - animationName1 = "CrouchWalk"; - animationSpeed1 = 1.0 * -glm::sign(controller->Movement().z); - } else { - if (glm::abs(forwardMovement) > 0) { - if (animationName1 != "Run") { - animationName1 = "Run"; - if (animationName2 == "StrafeLeft" || animationName2 == "StrafeRight") { - animationTime1 = animationTime2; - } else { - animationTime1 = 0.0; - } - } - animationSpeed1 = 2.f * -glm::sign(forwardMovement); - } - - if (glm::abs(strafeMovement) > 0) { - if (animationName2 != "StrafeLeft" && animationName2 != "StrafeRight") { - if (strafeMovement < 0) { - animationName2 = "StrafeLeft"; - } - if (strafeMovement > 0) { - animationName2 = "StrafeRight"; - } - if (animationName1 == "Run") { - animationTime2 = animationTime1; - } else { - animationTime2 = 0.0; - } - } - animationSpeed2 = 2.f * glm::abs(strafeMovement); - } - - double strafeWeight = glm::abs(strafeMovement) / (glm::abs(forwardMovement) + glm::abs(strafeMovement)); - animationWeight2 = strafeWeight; - animationWeight1 = 1.0 - strafeWeight; - } - } else { - if (controller->Crouching()) { - animationName1 = "Crouch"; - animationName2 = ""; - animationSpeed1 = 1.0; - animationSpeed2 = 0.0; - animationWeight1 = 1.0; - animationWeight2 = 0.0; - } else { - animationName1 = "Idle"; - animationName2 = ""; - animationSpeed1 = 1.f; - animationSpeed2 = 0.0; - animationWeight1 = 1.0; - animationWeight2 = 0.0; - //cAnimation["AnimationName2"] = "Idle"; - } - } - } + // TODO: Animations } controller->Reset(); @@ -354,10 +280,5 @@ bool PlayerMovementSystem::OnDashAbility(Events::DashAbility & e) playerEntityAnimation.Copy(dashEffect["Animation"]); dashEffect["ExplosionEffect"]["EndColor"] = (glm::vec4)playerEntityModel["Color"]; ((glm::vec4&)dashEffect["ExplosionEffect"]["EndColor"]).w = 0.f; - dashEffect["Animation"]["Speed1"] = 0.0; - dashEffect["Animation"]["Speed2"] = 0.0; - dashEffect["Animation"]["Speed3"] = 0.0; - dashEffect["Transform"]["Position"] = (glm::vec3)player["Transform"]["Position"]; - dashEffect["Transform"]["Orientation"] = (glm::vec3)player["Transform"]["Orientation"]; return true; } diff --git a/src/Game/Systems/Weapon/AssaultWeaponBehaviour.cpp b/src/Game/Systems/Weapon/AssaultWeaponBehaviour.cpp index 4d0f2258..4f5b2b05 100644 --- a/src/Game/Systems/Weapon/AssaultWeaponBehaviour.cpp +++ b/src/Game/Systems/Weapon/AssaultWeaponBehaviour.cpp @@ -99,6 +99,29 @@ void AssaultWeaponBehaviour::OnReload(ComponentWrapper cWeapon, WeaponInfo& wi) // Start reload reloadQueued = true; reloadTimer = reloadTime; + + // Play animation + EntityWrapper modelEntity = wi.FirstPersonEntity.Parent().Parent(); + if (modelEntity.Valid()) { + EntityWrapper blendTree = modelEntity.FirstChildByName("PrimaryBlendTree"); + EntityWrapper reloadBlend = blendTree.FirstChildByName("Reload"); + + Events::AutoAnimationBlend eFireBlend; + eFireBlend.RootNode = modelEntity; + eFireBlend.NodeName = "Reload"; + eFireBlend.Restart = true; + eFireBlend.Start = true; + eFireBlend.Duration = 0.0001; + m_EventBroker->Publish(eFireBlend); + + Events::AutoAnimationBlend eIdleBlend; + eIdleBlend.RootNode = modelEntity; + eIdleBlend.NodeName = "Idle"; + eIdleBlend.AnimationEntity = reloadBlend; + eIdleBlend.Delay = -0.2; + eIdleBlend.Duration = 0.2; + m_EventBroker->Publish(eIdleBlend); + } } void AssaultWeaponBehaviour::OnEquip(ComponentWrapper cWeapon, WeaponInfo& wi) @@ -177,6 +200,29 @@ void AssaultWeaponBehaviour::fireBullet(ComponentWrapper cWeapon, WeaponInfo& wi m_EventBroker->Publish(e); } } + + // Play animation + EntityWrapper modelEntity = wi.FirstPersonEntity.Parent().Parent(); + if (modelEntity.Valid()) { + EntityWrapper blendTree = modelEntity.FirstChildByName("PrimaryBlendTree"); + EntityWrapper fireBlend = blendTree.FirstChildByName("Fire"); + + Events::AutoAnimationBlend eFireBlend; + eFireBlend.RootNode = modelEntity; + eFireBlend.NodeName = "Fire"; + eFireBlend.Restart = true; + eFireBlend.Start = true; + eFireBlend.Duration = 0.0001; + m_EventBroker->Publish(eFireBlend); + + Events::AutoAnimationBlend eIdleBlend; + eIdleBlend.RootNode = modelEntity; + eIdleBlend.NodeName = "Idle"; + eIdleBlend.AnimationEntity = fireBlend; + eIdleBlend.Delay = -0.2; + eIdleBlend.Duration = 0.2; + m_EventBroker->Publish(eIdleBlend); + } } bool AssaultWeaponBehaviour::canFire(ComponentWrapper cWeapon, WeaponInfo& wi)