Touch.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. // Copyright (c) 2008-2023 the Urho3D project
  2. // License: MIT
  3. #pragma once
  4. #include <Urho3D/Core/Object.h>
  5. using namespace Urho3D;
  6. namespace Urho3D
  7. {
  8. class Controls;
  9. }
  10. const float CAMERA_MIN_DIST = 1.0f;
  11. const float CAMERA_INITIAL_DIST = 5.0f;
  12. const float CAMERA_MAX_DIST = 20.0f;
  13. /// Mobile framework for Android/iOS
  14. /// Gamepad from NinjaSnowWar
  15. /// Touches patterns:
  16. /// - 1 finger touch = pick object through raycast
  17. /// - 1 or 2 fingers drag = rotate camera
  18. /// - 2 fingers sliding in opposite direction (up/down) = zoom in/out
  19. ///
  20. /// Setup:
  21. /// - Call the update function 'UpdateTouches()' from HandleUpdate or equivalent update handler function
  22. class Touch : public Object
  23. {
  24. URHO3D_OBJECT(Touch, Object);
  25. public:
  26. /// Construct.
  27. Touch(Context* context, float touchSensitivity);
  28. /// Destruct.
  29. ~Touch() override;
  30. /// Update touch controls for the current frame.
  31. void UpdateTouches(Controls& controls);
  32. /// Touch sensitivity.
  33. float touchSensitivity_;
  34. /// Current camera zoom distance.
  35. float cameraDistance_;
  36. /// Zoom flag.
  37. bool zoom_;
  38. /// Gyroscope on/off flag.
  39. bool useGyroscope_;
  40. };