ObjectRotator.h 1.3 KB

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