CameraController.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. #pragma once
  2. #include "EmulatorComponent.h"
  3. #include "../Constants.h"
  4. #include "../Input/Bindings/Binding.h"
  5. #include "../Utilities/Math.h"
  6. namespace TLAC::Components
  7. {
  8. struct Camera
  9. {
  10. Utilities::Vec3 Position;
  11. Utilities::Vec3 Focus;
  12. float Rotation;
  13. float HorizontalFov;
  14. float VerticalFov;
  15. };
  16. class CameraController : public EmulatorComponent
  17. {
  18. public:
  19. Input::Binding* ToggleBinding;
  20. Input::Binding* ForwardBinding;
  21. Input::Binding* BackwardBinding;
  22. Input::Binding* LeftBinding;
  23. Input::Binding* RightBinding;
  24. Input::Binding* UpBinding;
  25. Input::Binding* DownBinding;
  26. Input::Binding* FastBinding;
  27. Input::Binding* SlowBinding;
  28. Input::Binding* ClockwiseBinding;
  29. Input::Binding* CounterClockwiseBinding;
  30. Input::Binding* ZoomInBinding;
  31. Input::Binding* ZoomOutBinding;
  32. CameraController();
  33. ~CameraController();
  34. virtual const char* GetDisplayName() override;
  35. virtual void Initialize(ComponentsManager*) override;
  36. virtual void Update() override;
  37. virtual void UpdateInput() override;
  38. void SetControls(bool value);
  39. bool GetIsEnabled();
  40. private:
  41. const float fastSpeed = 0.1f;
  42. const float slowSpeed = 0.0005f;
  43. const float normalSpeed = 0.005f;
  44. const float defaultRotation = 0.0f;
  45. const float defaultFov = 70.0f;
  46. const float sensitivity = 0.25f;
  47. ComponentsManager* componentsManager;
  48. float verticalRotation;
  49. float horizontalRotation;
  50. bool isEnabled;
  51. Camera* camera;
  52. uint8_t originalSetterBytes[4];
  53. void* cameraSetterAddresses[4] =
  54. {
  55. (void*)CAMERA_POS_SETTER_ADDRESS,
  56. (void*)CAMERA_INTR_SETTER_ADDRESS,
  57. (void*)CAMERA_ROT_SETTER_ADDRESS,
  58. (void*)CAMERA_PERS_SETTER_ADDRESS,
  59. };
  60. void SetMouseWindowCenter();
  61. void SetIsEnabled(bool value);
  62. };
  63. }