EditorModularViewportCameraComposer.h 3.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #pragma once
  9. #include <AtomToolsFramework/Viewport/ModularViewportCameraController.h>
  10. #include <AzCore/Component/TickBus.h>
  11. #include <AzFramework/Entity/EntityDebugDisplayBus.h>
  12. #include <AzFramework/Viewport/CameraInput.h>
  13. #include <AzToolsFramework/API/EditorCameraBus.h>
  14. #include <EditorModularViewportCameraComposerBus.h>
  15. #include <SandboxAPI.h>
  16. namespace SandboxEditor
  17. {
  18. //! Type responsible for building the editor's modular viewport camera controller.
  19. class EditorModularViewportCameraComposer
  20. : private EditorModularViewportCameraComposerNotificationBus::Handler
  21. , private Camera::EditorCameraNotificationBus::Handler
  22. , private AzFramework::ViewportDebugDisplayEventBus::Handler
  23. , private AZ::TickBus::Handler
  24. {
  25. public:
  26. SANDBOX_API explicit EditorModularViewportCameraComposer(AzFramework::ViewportId viewportId);
  27. SANDBOX_API ~EditorModularViewportCameraComposer();
  28. //! Build a ModularViewportCameraController from the associated camera inputs.
  29. SANDBOX_API AZStd::shared_ptr<AtomToolsFramework::ModularViewportCameraController> CreateModularViewportCameraController();
  30. private:
  31. //! Display style/state for the pivot
  32. enum class PivotDisplayState
  33. {
  34. Hidden, //!< Orbit camera inactive.
  35. Faded, //!< Orbit camera active but not rotating.
  36. Full //!< Orbit camera active and rotating.
  37. };
  38. // AzFramework::ViewportDebugDisplayEventBus overrides ...
  39. void DisplayViewport(const AzFramework::ViewportInfo& viewportInfo, AzFramework::DebugDisplayRequests& debugDisplay) override;
  40. // AZ::TickBus overrides ...
  41. void OnTick(float deltaTime, AZ::ScriptTimePoint time) override;
  42. //! Setup all internal camera inputs.
  43. void SetupCameras();
  44. // EditorModularViewportCameraComposerNotificationBus overrides ...
  45. void OnEditorModularViewportCameraComposerSettingsChanged() override;
  46. // EditorCameraNotificationBus overrides ...
  47. void OnViewportViewEntityChanged(const AZ::EntityId& viewEntityId) override;
  48. AZStd::shared_ptr<AzFramework::RotateCameraInput> m_firstPersonRotateCamera;
  49. AZStd::shared_ptr<AzFramework::PanCameraInput> m_firstPersonPanCamera;
  50. AZStd::shared_ptr<AzFramework::TranslateCameraInput> m_firstPersonTranslateCamera;
  51. AZStd::shared_ptr<AzFramework::LookScrollTranslationCameraInput> m_firstPersonScrollCamera;
  52. AZStd::shared_ptr<AzFramework::FocusCameraInput> m_firstPersonFocusCamera;
  53. AZStd::shared_ptr<AzFramework::OrbitCameraInput> m_orbitCamera;
  54. AZStd::shared_ptr<AzFramework::RotateCameraInput> m_orbitRotateCamera;
  55. AZStd::shared_ptr<AzFramework::TranslateCameraInput> m_orbitTranslateCamera;
  56. AZStd::shared_ptr<AzFramework::OrbitScrollDollyCameraInput> m_orbitScrollDollyCamera;
  57. AZStd::shared_ptr<AzFramework::OrbitMotionDollyCameraInput> m_orbitMotionDollyCamera;
  58. AZStd::shared_ptr<AzFramework::PanCameraInput> m_orbitPanCamera;
  59. AZStd::shared_ptr<AzFramework::FocusCameraInput> m_orbitFocusCamera;
  60. AzFramework::ViewportId m_viewportId;
  61. AZStd::optional<AZ::Vector3> m_pivot; //!< The picked pivot to orbit about in the viewport.
  62. float m_orbitOpacity = 0.0f; //!< The picked pivot opacity (to fade in and out).
  63. PivotDisplayState m_pivotDisplayState; //!< The state of the pivot for the orbit camera.
  64. };
  65. } // namespace SandboxEditor