PoweredRigTest.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // SPDX-FileCopyrightText: 2021 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/Physics/Ragdoll/Ragdoll.h>
  9. // This test demonstrates powered constraints. It can either show a ragdoll in a static pose or in an animated pose (e.g. walk).
  10. class PoweredRigTest : public Test
  11. {
  12. public:
  13. JPH_DECLARE_RTTI_VIRTUAL(PoweredRigTest)
  14. // Destructor
  15. virtual ~PoweredRigTest() override;
  16. // Number used to scale the terrain and camera movement to the scene
  17. virtual float GetWorldScale() const override { return 0.2f; }
  18. virtual void Initialize() override;
  19. virtual void PrePhysicsUpdate(const PreUpdateParams &inParams) override;
  20. // Optional settings menu
  21. virtual bool HasSettingsMenu() const override { return true; }
  22. virtual void CreateSettingsMenu(DebugUI *inUI, UIElement *inSubMenu) override;
  23. // Saving / restoring state for replay
  24. virtual void SaveState(StateRecorder &inStream) const override;
  25. virtual void RestoreState(StateRecorder &inStream) override;
  26. private:
  27. // List of possible animation names
  28. static const char * sAnimations[];
  29. // Filename of animation to load for this test
  30. static const char * sAnimationName;
  31. float mTime = 0.0f;
  32. Ref<RagdollSettings> mRagdollSettings;
  33. Ref<Ragdoll> mRagdoll;
  34. Ref<SkeletalAnimation> mAnimation;
  35. SkeletonPose mPose;
  36. };