TankTest.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435
  1. // SPDX-FileCopyrightText: 2021 Jorrit Rouwe
  2. // SPDX-License-Identifier: MIT
  3. #pragma once
  4. #include <Tests/Vehicle/VehicleTest.h>
  5. #include <Jolt/Physics/Vehicle/VehicleConstraint.h>
  6. #include <Jolt/Physics/Constraints/HingeConstraint.h>
  7. // This test shows how a tank could be made with the vehicle constraint.
  8. class TankTest : public VehicleTest
  9. {
  10. public:
  11. JPH_DECLARE_RTTI_VIRTUAL(TankTest)
  12. // Destructor
  13. virtual ~TankTest() override;
  14. // See: Test
  15. virtual void Initialize() override;
  16. virtual void PrePhysicsUpdate(const PreUpdateParams &inParams) override;
  17. virtual void GetInitialCamera(CameraState &ioState) const override;
  18. virtual Mat44 GetCameraPivot(float inCameraHeading, float inCameraPitch) const override;
  19. private:
  20. Body * mTankBody; ///< The body of the tank
  21. Body * mTurretBody; ///< The body of the turret of the tank
  22. Body * mBarrelBody; ///< The body of the barrel of the tank
  23. Ref<VehicleConstraint> mVehicleConstraint; ///< The vehicle constraint
  24. Ref<HingeConstraint> mTurretHinge; ///< Hinge connecting tank body and turret
  25. Ref<HingeConstraint> mBarrelHinge; ///< Hinge connecting tank turret and barrel
  26. float mPreviousForward = 1.0f; ///< Keeps track of last car direction so we know when to brake and when to accelerate
  27. float mReloadTime = 0.0f; ///< How long it still takes to reload the main gun
  28. };