diff --git a/include/Engine/Rendering/Skeleton.h b/include/Engine/Rendering/Skeleton.h index 3a7231d6..3f9331ca 100644 --- a/include/Engine/Rendering/Skeleton.h +++ b/include/Engine/Rendering/Skeleton.h @@ -76,9 +76,9 @@ public: }; struct JointFrameTransform { - glm::vec3 PositionInterp = glm::vec3(0); - glm::quat RotationInterp = glm::quat(); - glm::vec3 ScaleInterp = glm::vec3(0); + glm::vec3 Position = glm::vec3(0); + glm::quat Rotation = glm::quat(); + glm::vec3 Scale = glm::vec3(0); float Weight; }; @@ -108,7 +108,7 @@ 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); + glm::mat4 AdditiveBlend(glm::mat4 differencePose, glm::mat4 targetPose); void PrintSkeleton(); void PrintSkeleton(const Bone* parent, int depthCount); diff --git a/resources/Schema/Entities/AnimationTests2.xml b/resources/Schema/Entities/AnimationTests2.xml index 7ce357f4..c36c5c02 100644 --- a/resources/Schema/Entities/AnimationTests2.xml +++ b/resources/Schema/Entities/AnimationTests2.xml @@ -29,10 +29,10 @@ - AimRifle - 0.94417153407339605 + Idle + 1.1429797894322036 + 1 1 - 0.032904333143131348 0.093923612201312068 1 @@ -44,24 +44,7 @@ - - - - - R_Arm_Weapon_Joint - - - - Models/Weapons/Red/AssaultWeaponRed.mesh - - - - - - - - - + @@ -103,43 +86,32 @@ Idle - 0.17120540274882234 + 1.1429797894322036 1 0.10000000149011612 StrafeRigh 0.5 - 0.518960175468406 + 0.67154243305829331 0.5 0.32167823998061529 1 AimRifle + Models/Characters/Assault/AssaultAnimations.mesh - - - - - R_Arm_Weapon_Joint - - - Models/Weapons/Red/AssaultWeaponRed.mesh - - - - - - + AimRifle + 0.5 Models/Characters/Assault/AssaultAnimations.mesh @@ -148,23 +120,7 @@ - - - - - R_Arm_Weapon_Joint - - - Models/Weapons/Red/AssaultWeaponRed.mesh - - - - - - - - - + diff --git a/src/Engine/Rendering/Skeleton.cpp b/src/Engine/Rendering/Skeleton.cpp index bd994a08..0e9483d6 100644 --- a/src/Engine/Rendering/Skeleton.cpp +++ b/src/Engine/Rendering/Skeleton.cpp @@ -127,23 +127,23 @@ void Skeleton::AccumulateBoneTransforms(bool noRootMotion, std::vectorID] = parentMatrix; } } else if (JointTransforms.size() == 1) { - boneMatrix = parentMatrix *(glm::translate(JointTransforms.at(0).PositionInterp) * glm::toMat4(JointTransforms.at(0).RotationInterp) * glm::scale(JointTransforms.at(0).ScaleInterp)); + boneMatrix = parentMatrix *(glm::translate(JointTransforms.at(0).Position) * glm::toMat4(JointTransforms.at(0).Rotation) * glm::scale(JointTransforms.at(0).Scale)); boneMatrices[bone->ID] = boneMatrix * bone->OffsetMatrix; } else { @@ -178,14 +178,14 @@ void Skeleton::AccumulateBoneTransforms(bool noRootMotion, std::vectorID] = boneMatrix * bone->OffsetMatrix; @@ -321,16 +335,10 @@ void Skeleton::AccumulateBoneTransforms(bool noRootMotion, std::vectorOffsetMatrix) * childMatrix; } } else if (JointTransforms.size() == 1) { - boneMatrix = (glm::translate(JointTransforms.at(0).PositionInterp) * glm::toMat4(JointTransforms.at(0).RotationInterp) * glm::scale(JointTransforms.at(0).ScaleInterp)) * childMatrix; + boneMatrix = (glm::translate(JointTransforms.at(0).Position) * glm::toMat4(JointTransforms.at(0).Rotation) * glm::scale(JointTransforms.at(0).Scale)) * childMatrix; } else { glm::vec3 finalPosInterp; @@ -676,14 +684,14 @@ glm::mat4 Skeleton::GetBoneTransform(bool noRootMotion, const Bone* bone, std::v for (JointFrameTransform jointTransform : JointTransforms) { if (jointTransform.Weight == 1.0f) { - finalPosInterp = jointTransform.PositionInterp; - finalRotInterp = jointTransform.RotationInterp; - finalScaleInterp = jointTransform.ScaleInterp; + finalPosInterp = jointTransform.Position; + finalRotInterp = jointTransform.Rotation; + finalScaleInterp = jointTransform.Scale; break; } else { - finalPosInterp += jointTransform.PositionInterp * (jointTransform.Weight/totalWeight); - finalRotInterp *= glm::slerp(glm::quat(), jointTransform.RotationInterp, (jointTransform.Weight/totalWeight)); - finalScaleInterp += jointTransform.ScaleInterp * (jointTransform.Weight/totalWeight); + finalPosInterp += jointTransform.Position * (jointTransform.Weight/totalWeight); + finalRotInterp *= glm::slerp(glm::quat(), jointTransform.Rotation, (jointTransform.Weight/totalWeight)); + finalScaleInterp += jointTransform.Scale * (jointTransform.Weight/totalWeight); } }