SkeletonMapperTest.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. // SPDX-FileCopyrightText: 2022 Jorrit Rouwe
  2. // SPDX-License-Identifier: MIT
  3. #pragma once
  4. #include <Tests/Test.h>
  5. #include <Jolt/Skeleton/Skeleton.h>
  6. #include <Jolt/Skeleton/SkeletalAnimation.h>
  7. #include <Jolt/Skeleton/SkeletonPose.h>
  8. #include <Jolt/Skeleton/SkeletonMapper.h>
  9. #include <Utils/RagdollLoader.h>
  10. #include <Jolt/Physics/Ragdoll/Ragdoll.h>
  11. // This test takes shows how you can map a high detail animation skeleton on a low detail physics skeleton and back
  12. class SkeletonMapperTest : public Test
  13. {
  14. public:
  15. JPH_DECLARE_RTTI_VIRTUAL(SkeletonMapperTest)
  16. // Destructor
  17. virtual ~SkeletonMapperTest() override;
  18. // Number used to scale the terrain and camera movement to the scene
  19. virtual float GetWorldScale() const override { return 0.2f; }
  20. virtual void Initialize() override;
  21. virtual void PrePhysicsUpdate(const PreUpdateParams &inParams) override;
  22. // Saving / restoring state for replay
  23. virtual void SaveState(StateRecorder &inStream) const override;
  24. virtual void RestoreState(StateRecorder &inStream) override;
  25. private:
  26. void CalculateRagdollPose();
  27. float mTime = 0.0f;
  28. Ref<RagdollSettings> mRagdollSettings;
  29. Ref<Ragdoll> mRagdoll;
  30. Ref<SkeletalAnimation> mAnimation;
  31. SkeletonMapper mRagdollToAnimated;
  32. SkeletonPose mAnimatedPose;
  33. SkeletonPose mRagdollPose;
  34. };