SkeletonMapperTest.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. // This test takes shows how you can map a high detail animation skeleton on a low detail physics skeleton and back
  13. class SkeletonMapperTest : public Test
  14. {
  15. public:
  16. JPH_DECLARE_RTTI_VIRTUAL(SkeletonMapperTest)
  17. // Destructor
  18. virtual ~SkeletonMapperTest() override;
  19. // Number used to scale the terrain and camera movement to the scene
  20. virtual float GetWorldScale() const override { return 0.2f; }
  21. virtual void Initialize() override;
  22. virtual void PrePhysicsUpdate(const PreUpdateParams &inParams) override;
  23. // Optional settings menu
  24. virtual bool HasSettingsMenu() const override { return true; }
  25. virtual void CreateSettingsMenu(DebugUI *inUI, UIElement *inSubMenu) override;
  26. // Saving / restoring state for replay
  27. virtual void SaveState(StateRecorder &inStream) const override;
  28. virtual void RestoreState(StateRecorder &inStream) override;
  29. private:
  30. inline static bool sLockTranslations = false;
  31. void CalculateRagdollPose();
  32. float mTime = 0.0f;
  33. Ref<RagdollSettings> mRagdollSettings;
  34. Ref<Ragdoll> mRagdoll;
  35. Ref<SkeletalAnimation> mAnimation;
  36. SkeletonMapper mRagdollToAnimated;
  37. SkeletonPose mAnimatedPose;
  38. SkeletonPose mRagdollPose;
  39. };