MotorcycleTest.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334
  1. // Jolt Physics Library (https://github.com/jrouwe/JoltPhysics)
  2. // SPDX-FileCopyrightText: 2023 Jorrit Rouwe
  3. // SPDX-License-Identifier: MIT
  4. #pragma once
  5. #include <Tests/Vehicle/VehicleTest.h>
  6. #include <Jolt/Physics/Vehicle/VehicleConstraint.h>
  7. // This test shows how a motorcycle could be made with the vehicle constraint.
  8. /// Note: The motor cycle controller is still in development and may need a lot of tweaks/hacks to work properly!
  9. class MotorcycleTest : public VehicleTest
  10. {
  11. public:
  12. JPH_DECLARE_RTTI_VIRTUAL(MotorcycleTest)
  13. // Destructor
  14. virtual ~MotorcycleTest() override;
  15. // See: Test
  16. virtual void Initialize() override;
  17. virtual void PrePhysicsUpdate(const PreUpdateParams &inParams) override;
  18. virtual void SaveState(StateRecorder& inStream) const override;
  19. virtual void RestoreState(StateRecorder& inStream) override;
  20. virtual void GetInitialCamera(CameraState &ioState) const override;
  21. virtual RMat44 GetCameraPivot(float inCameraHeading, float inCameraPitch) const override;
  22. private:
  23. Body * mMotorcycleBody; ///< The vehicle
  24. Ref<VehicleConstraint> mVehicleConstraint; ///< The vehicle constraint
  25. float mPreviousForward = 1.0f; ///< Keeps track of last motorcycle direction so we know when to brake and when to accelerate
  26. float mCurrentRight = 0.0f; ///< Keeps track of the current steering angle (radians)
  27. };