From e7118ce8e5eecefffd7f70587ed48a0a98561706 Mon Sep 17 00:00:00 2001 From: viktorljung Date: Wed, 17 Feb 2016 10:52:50 +0100 Subject: [PATCH] WIP --- include/Engine/Rendering/Skeleton.h | 5 +- resources/Schema/Entities/AnimationTests2.xml | 64 ++++++++++++------ src/Engine/Rendering/Skeleton.cpp | 66 +++++++++++-------- 3 files changed, 84 insertions(+), 51 deletions(-) diff --git a/include/Engine/Rendering/Skeleton.h b/include/Engine/Rendering/Skeleton.h index 28a5ef6a..3a7231d6 100644 --- a/include/Engine/Rendering/Skeleton.h +++ b/include/Engine/Rendering/Skeleton.h @@ -108,6 +108,8 @@ public: void AccumulateBoneTransforms(bool noRootMotion, std::vector animations, std::map& frameBones, const Bone* bone, glm::mat4 parentMatrix); void AccumulateBoneTransforms(bool noRootMotion, std::vector animations, AnimationOffset animationOffset, std::map& frameBones, const Bone* bone, glm::mat4 parentMatrix); + glm::mat4 AdditiveBlend(JointFrameTransform addTransform, JointFrameTransform transform); + void PrintSkeleton(); void PrintSkeleton(const Bone* parent, int depthCount); std::map Animations; @@ -118,8 +120,7 @@ public: int GetKeyframe(const Animation& animation, double time); private: - - glm::mat4 GetOffsetTransform(const Bone* bone, AnimationOffset animationOffset); + JointFrameTransform GetOffsetTransform(const Bone* bone, AnimationOffset animationOffset); std::map m_BonesByName; diff --git a/resources/Schema/Entities/AnimationTests2.xml b/resources/Schema/Entities/AnimationTests2.xml index 413c7e67..7ce357f4 100644 --- a/resources/Schema/Entities/AnimationTests2.xml +++ b/resources/Schema/Entities/AnimationTests2.xml @@ -29,25 +29,19 @@ - Run - 0.5 - 0.60188997954429357 - -1 + AimRifle + 0.94417153407339605 1 - 0.5 - 0.96957233017255007 + + 0.032904333143131348 0.093923612201312068 1 - - AimRifle - - Models/Characters/Assault/AssaultAnimations.mesh - + @@ -61,8 +55,8 @@ Models/Weapons/Red/AssaultWeaponRed.mesh - - + + @@ -108,23 +102,52 @@ - ShootFastRifle - 0.056234247235838808 + Idle + 0.17120540274882234 1 - 1 - Idl + 0.10000000149011612 + StrafeRigh 0.5 - 1.8308673495784191 - StrafeRigh + 0.518960175468406 0.5 0.32167823998061529 1 + + AimRifle + Models/Characters/Assault/AssaultAnimations.mesh + + + + + R_Arm_Weapon_Joint + + + Models/Weapons/Red/AssaultWeaponRed.mesh + + + + + + + + + + + AimRifle + + + Models/Characters/Assault/AssaultAnimations.mesh + + + + + @@ -135,7 +158,8 @@ Models/Weapons/Red/AssaultWeaponRed.mesh - + + diff --git a/src/Engine/Rendering/Skeleton.cpp b/src/Engine/Rendering/Skeleton.cpp index e390d694..bd994a08 100644 --- a/src/Engine/Rendering/Skeleton.cpp +++ b/src/Engine/Rendering/Skeleton.cpp @@ -274,26 +274,18 @@ void Skeleton::AccumulateBoneTransforms(bool noRootMotion, std::vectorParent) { - if (offset != glm::mat4(1)) { - boneMatrix = parentMatrix * offset;// *((glm::inverse(bone->OffsetMatrix) * bone->Parent->OffsetMatrix)); - } else { - boneMatrix = parentMatrix *((glm::inverse(bone->OffsetMatrix) * bone->Parent->OffsetMatrix)); - - } + boneMatrix = parentMatrix * (glm::inverse(bone->OffsetMatrix) * bone->Parent->OffsetMatrix); boneMatrices[bone->ID] = boneMatrix * bone->OffsetMatrix; } else { - boneMatrix = offset * glm::inverse(bone->OffsetMatrix); + boneMatrix = glm::inverse(bone->OffsetMatrix); boneMatrices[bone->ID] = parentMatrix; } } else { - glm::vec3 finalPosInterp; - glm::quat finalRotInterp; - glm::vec3 finalScaleInterp; + JointFrameTransform jointFinalTransform; + float totalWeight = 0; for (JointFrameTransform jointTransform : JointTransforms) { @@ -303,26 +295,23 @@ void Skeleton::AccumulateBoneTransforms(bool noRootMotion, std::vectorID] = boneMatrix * bone->OffsetMatrix; } @@ -331,7 +320,20 @@ void Skeleton::AccumulateBoneTransforms(bool noRootMotion, std::vector animations, AnimationOffset animationOffset, glm::mat4 childMatrix) { glm::mat4 boneMatrix; - + /* std::vector JointTransforms; for (const AnimationData animationData : animations) { @@ -569,9 +577,9 @@ glm::mat4 Skeleton::GetBoneTransform(bool noRootMotion, const Bone* bone, std::v if (bone->Parent != nullptr) { return GetBoneTransform(noRootMotion, bone->Parent, animations, animationOffset, boneMatrix); - } else { + } else {*/ return boneMatrix; - } + // } }