CameraFlyer.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. #pragma once
  4. #include "BsPrerequisites.h"
  5. #include "Scene/BsComponent.h"
  6. #include "Math/BsMath.h"
  7. #include "Input/BsVirtualInput.h"
  8. namespace bs
  9. {
  10. /**
  11. * Component that controls movement and rotation of a Camera component. The Camera component must be attached to the
  12. * same SceneObject this component is on.
  13. */
  14. class CameraFlyer : public Component
  15. {
  16. public:
  17. CameraFlyer(const HSceneObject& parent);
  18. /** Triggered once per frame. Allows the component to handle input and move. */
  19. virtual void update();
  20. private:
  21. float mCurrentSpeed; /**< Current speed of the camera. */
  22. Degree mPitch; /**< Current pitch rotation of the camera (looking up or down). */
  23. Degree mYaw; /**< Current yar rotation of the camera (looking left or right). */
  24. bool mLastButtonState; /**< Determines was the user rotating the camera last frame. */
  25. VirtualButton mMoveForward; /**< Key binding for moving the camera forward. */
  26. VirtualButton mMoveBack; /**< Key binding for moving the camera backward. */
  27. VirtualButton mMoveLeft; /**< Key binding for moving the camera left. */
  28. VirtualButton mMoveRight; /**< Key binding for moving the camera right. */
  29. VirtualButton mFastMove; /**< Key that speeds up movement while held. */
  30. VirtualButton mRotateCam; /**< Key that allows camera to be rotated while held. */
  31. VirtualAxis mVerticalAxis; /**< Input device axis used for controlling camera's pitch rotation (up/down). */
  32. VirtualAxis mHorizontalAxis; /**< Input device axis used for controlling camera's yaw rotation (left/right). */
  33. static const float START_SPEED; /**< Initial movement speed. */
  34. static const float TOP_SPEED; /**< Maximum movement speed. */
  35. static const float ACCELERATION; /**< Acceleration that determines how quickly to go from starting to top speed. */
  36. static const float FAST_MODE_MULTIPLIER; /**< Multiplier applied to the speed when the fast move button is held. */
  37. static const float ROTATION_SPEED; /**< Determines speed for rotation, in degrees per second. */
  38. };
  39. }