BsCameraFlyer.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #pragma once
  2. #include "BsPrerequisites.h"
  3. #include "Scene/BsComponent.h"
  4. #include "Math/BsMath.h"
  5. #include "Input/BsVirtualInput.h"
  6. namespace bs
  7. {
  8. /** Component that controls movement and rotation of the scene object it's attached to. */
  9. class CameraFlyer : public Component
  10. {
  11. public:
  12. CameraFlyer(const HSceneObject& parent);
  13. /** Triggered once per frame. Allows the component to handle input and move. */
  14. void update() override;
  15. private:
  16. float mCurrentSpeed; /**< Current speed of the camera. */
  17. Degree mPitch = Degree(0.0f); /**< Current pitch rotation of the camera (looking up or down). */
  18. Degree mYaw = Degree(0.0f); /**< Current yaw rotation of the camera (looking left or right). */
  19. bool mLastButtonState = false; /**< Determines was the user rotating the camera last frame. */
  20. VirtualButton mMoveForward; /**< Key binding for moving the camera forward. */
  21. VirtualButton mMoveBack; /**< Key binding for moving the camera backward. */
  22. VirtualButton mMoveLeft; /**< Key binding for moving the camera left. */
  23. VirtualButton mMoveRight; /**< Key binding for moving the camera right. */
  24. VirtualButton mFastMove; /**< Key that speeds up movement while held. */
  25. VirtualButton mRotateCam; /**< Key that allows camera to be rotated while held. */
  26. VirtualAxis mVerticalAxis; /**< Input device axis used for controlling camera's pitch rotation (up/down). */
  27. VirtualAxis mHorizontalAxis; /**< Input device axis used for controlling camera's yaw rotation (left/right). */
  28. static const float START_SPEED; /**< Initial movement speed. */
  29. static const float TOP_SPEED; /**< Maximum movement speed. */
  30. static const float ACCELERATION; /**< Acceleration that determines how quickly to go from starting to top speed. */
  31. static const float FAST_MODE_MULTIPLIER; /**< Multiplier applied to the speed when the fast move button is held. */
  32. static const float ROTATION_SPEED; /**< Determines speed of camera rotation. */
  33. };
  34. }