CameraFlyer.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. HCamera mCamera; /**< Camera component that is influenced by the flyer. */
  26. VirtualButton mMoveForward; /**< Key binding for moving the camera forward. */
  27. VirtualButton mMoveBack; /**< Key binding for moving the camera backward. */
  28. VirtualButton mMoveLeft; /**< Key binding for moving the camera left. */
  29. VirtualButton mMoveRight; /**< Key binding for moving the camera right. */
  30. VirtualButton mFastMove; /**< Key that speeds up movement while held. */
  31. VirtualButton mRotateCam; /**< Key that allows camera to be rotated while held. */
  32. VirtualAxis mVerticalAxis; /**< Input device axis used for controlling camera's pitch rotation (up/down). */
  33. VirtualAxis mHorizontalAxis; /**< Input device axis used for controlling camera's yaw rotation (left/right). */
  34. static const float START_SPEED; /**< Initial movement speed. */
  35. static const float TOP_SPEED; /**< Maximum movement speed. */
  36. static const float ACCELERATION; /**< Acceleration that determines how quickly to go from starting to top speed. */
  37. static const float FAST_MODE_MULTIPLIER; /**< Multiplier applied to the speed when the fast move button is held. */
  38. static const float ROTATION_SPEED; /**< Determines speed for rotation, in degrees per second. */
  39. };
  40. }