From 8d1877321a808848c0b4d048fe507b3b154b16b2 Mon Sep 17 00:00:00 2001 From: viktorljung Date: Tue, 8 Mar 2016 14:32:50 +0100 Subject: [PATCH] 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;