PoweredRigTest.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. // Jolt Physics Library (https://github.com/jrouwe/JoltPhysics)
  2. // SPDX-FileCopyrightText: 2021 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/Physics/Ragdoll/Ragdoll.h>
  10. class PoweredRigTest : public Test
  11. {
  12. public:
  13. JPH_DECLARE_RTTI_VIRTUAL(JPH_NO_EXPORT, PoweredRigTest)
  14. // Description of the test
  15. virtual const char * GetDescription() const override
  16. {
  17. return "Demonstrates how to use motors to drive a ragdoll to a pose.";
  18. }
  19. // Destructor
  20. virtual ~PoweredRigTest() override;
  21. // Number used to scale the terrain and camera movement to the scene
  22. virtual float GetWorldScale() const override { return 0.2f; }
  23. virtual void Initialize() override;
  24. virtual void PrePhysicsUpdate(const PreUpdateParams &inParams) override;
  25. // Optional settings menu
  26. virtual bool HasSettingsMenu() const override { return true; }
  27. virtual void CreateSettingsMenu(DebugUI *inUI, UIElement *inSubMenu) override;
  28. // Saving / restoring state for replay
  29. virtual void SaveState(StateRecorder &inStream) const override;
  30. virtual void RestoreState(StateRecorder &inStream) override;
  31. private:
  32. // List of possible animation names
  33. static const char * sAnimations[];
  34. // Filename of animation to load for this test
  35. static const char * sAnimationName;
  36. float mTime = 0.0f;
  37. Ref<RagdollSettings> mRagdollSettings;
  38. Ref<Ragdoll> mRagdoll;
  39. Ref<SkeletalAnimation> mAnimation;
  40. SkeletonPose mPose;
  41. };