BsObjectRotator.h 1.1 KB

123456789101112131415161718192021222324252627282930
  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 rotation of its scene object. */
  9. class ObjectRotator : public Component
  10. {
  11. public:
  12. ObjectRotator(const HSceneObject& parent);
  13. /** Triggered once per frame. Allows the component to handle input and move. */
  14. void update() override;
  15. private:
  16. Degree mPitch; /**< Current pitch rotation of the object (up or down). */
  17. Degree mYaw; /**< Current yar rotation of the object (left or right). */
  18. bool mLastButtonState; /**< Determines was the user rotating the object last frame. */
  19. VirtualButton mRotateObj; /**< Key that allows object to be rotated while held. */
  20. VirtualAxis mVerticalAxis; /**< Input device axis used for controlling object's pitch rotation (up/down). */
  21. VirtualAxis mHorizontalAxis; /**< Input device axis used for controlling object's yaw rotation (left/right). */
  22. static const float ROTATION_SPEED; /**< Determines speed for rotation, in degrees per second. */
  23. };
  24. }