CharacterTest.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. // SPDX-FileCopyrightText: 2021 Jorrit Rouwe
  2. // SPDX-License-Identifier: MIT
  3. #pragma once
  4. #include <Tests/Test.h>
  5. #include <Physics/Character/Character.h>
  6. // Simple test that test the Character class. Allows the user to move around with the arrow keys and jump with the J button.
  7. class CharacterTest : public Test
  8. {
  9. public:
  10. JPH_DECLARE_RTTI_VIRTUAL(CharacterTest)
  11. // Destructor
  12. virtual ~CharacterTest() override;
  13. // Number used to scale the terrain and camera movement to the scene
  14. virtual float GetWorldScale() const override { return 0.2f; }
  15. // Initialize the test
  16. virtual void Initialize() override;
  17. // Update the test, called before the physics update
  18. virtual void PrePhysicsUpdate(const PreUpdateParams &inParams) override;
  19. // Update the test, called after the physics update
  20. virtual void PostPhysicsUpdate(float inDeltaTime) override;
  21. // Override to specify the initial camera state (local to GetCameraPivot)
  22. virtual void GetInitialCamera(CameraState &ioState) const override;
  23. // Override to specify a camera pivot point and orientation (world space)
  24. virtual Mat44 GetCameraPivot(float inCameraHeading, float inCameraPitch) const override;
  25. // Optional settings menu
  26. virtual bool HasSettingsMenu() const override { return true; }
  27. virtual void CreateSettingsMenu(DebugUI *inUI, UIElement *inSubMenu) override;
  28. private:
  29. // List of possible scene names
  30. static const char * sScenes[];
  31. // Filename of animation to load for this test
  32. static const char * sSceneName;
  33. // The 'player' character
  34. Ref<Character> mCharacter;
  35. // The different stances for the character
  36. RefConst<Shape> mStandingShape;
  37. RefConst<Shape> mCrouchingShape;
  38. };