SkeletonMapperTest.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. // Jolt Physics Library (https://github.com/jrouwe/JoltPhysics)
  2. // SPDX-FileCopyrightText: 2022 Jorrit Rouwe
  3. // SPDX-License-Identifier: MIT
  4. #pragma once
  5. #include <Tests/Test.h>
  6. #include <Jolt/Skeleton/Skeleton.h>
  7. #include <Jolt/Skeleton/SkeletalAnimation.h>
  8. #include <Jolt/Skeleton/SkeletonPose.h>
  9. #include <Jolt/Skeleton/SkeletonMapper.h>
  10. #include <Utils/RagdollLoader.h>
  11. #include <Jolt/Physics/Ragdoll/Ragdoll.h>
  12. class SkeletonMapperTest : public Test
  13. {
  14. public:
  15. JPH_DECLARE_RTTI_VIRTUAL(JPH_NO_EXPORT, SkeletonMapperTest)
  16. // Description of the test
  17. virtual const char * GetDescription() const override
  18. {
  19. return "Shows how you can map a high detail animation skeleton on a low detail physics skeleton and back.";
  20. }
  21. // Destructor
  22. virtual ~SkeletonMapperTest() override;
  23. // Number used to scale the terrain and camera movement to the scene
  24. virtual float GetWorldScale() const override { return 0.2f; }
  25. virtual void Initialize() override;
  26. virtual void PrePhysicsUpdate(const PreUpdateParams &inParams) override;
  27. // Optional settings menu
  28. virtual bool HasSettingsMenu() const override { return true; }
  29. virtual void CreateSettingsMenu(DebugUI *inUI, UIElement *inSubMenu) override;
  30. // Saving / restoring state for replay
  31. virtual void SaveState(StateRecorder &inStream) const override;
  32. virtual void RestoreState(StateRecorder &inStream) override;
  33. private:
  34. inline static bool sLockTranslations = false;
  35. void CalculateRagdollPose();
  36. float mTime = 0.0f;
  37. Ref<RagdollSettings> mRagdollSettings;
  38. Ref<Ragdoll> mRagdoll;
  39. Ref<SkeletalAnimation> mAnimation;
  40. SkeletonMapper mRagdollToAnimated;
  41. SkeletonPose mAnimatedPose;
  42. SkeletonPose mRagdollPose;
  43. };