PhysicalSkyComponentController.h 3.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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 <AzCore/Component/Component.h>
  10. #include <AzCore/Component/TransformBus.h>
  11. #include <AtomLyIntegration/CommonFeatures/SkyBox/PhysicalSkyComponentConfig.h>
  12. #include <AtomLyIntegration/CommonFeatures/SkyBox/PhysicalSkyBus.h>
  13. #include <Atom/Feature/SkyBox/SkyBoxFogBus.h>
  14. #include <Atom/Feature/SkyBox/SkyBoxFeatureProcessorInterface.h>
  15. namespace AZ
  16. {
  17. namespace Render
  18. {
  19. class PhysicalSkyComponentController final
  20. : public TransformNotificationBus::Handler
  21. , public PhysicalSkyRequestBus::Handler
  22. , public SkyBoxFogRequestBus::Handler
  23. {
  24. public:
  25. friend class EditorPhysicalSkyComponent;
  26. AZ_TYPE_INFO(AZ::Render::PhysicalSkyComponentController, "{C3EEB94D-AEB9-4727-9493-791F86924804}");
  27. static void Reflect(AZ::ReflectContext* context);
  28. static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided);
  29. static void GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible);
  30. static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required);
  31. PhysicalSkyComponentController() = default;
  32. PhysicalSkyComponentController(const PhysicalSkyComponentConfig& config);
  33. void Activate(EntityId entityId);
  34. void Deactivate();
  35. void SetConfiguration(const PhysicalSkyComponentConfig& config);
  36. const PhysicalSkyComponentConfig& GetConfiguration() const;
  37. private:
  38. AZ_DISABLE_COPY(PhysicalSkyComponentController);
  39. // TransformNotificationBus::Handler overrides ...
  40. void OnTransformChanged(const AZ::Transform& local, const AZ::Transform& world) override;
  41. // PhysicalSkyRequestBus::Handler overrides ...
  42. void SetTurbidity(int turbidity) override;
  43. int GetTurbidity() override;
  44. void SetSunRadiusFactor(float factor) override;
  45. float GetSunRadiusFactor() override;
  46. void SetSkyIntensity(float intensity, PhotometricUnit unit) override;
  47. void SetSkyIntensity(float intensity) override;
  48. float GetSkyIntensity(PhotometricUnit unit) override;
  49. float GetSkyIntensity() override;
  50. void SetSunIntensity(float intensity, PhotometricUnit unit) override;
  51. void SetSunIntensity(float intensity) override;
  52. float GetSunIntensity(PhotometricUnit unit) override;
  53. float GetSunIntensity() override;
  54. // SkyBoxFogRequestBus::Handler overrides ...
  55. void SetEnabled(bool enable) override;
  56. bool IsEnabled() const override;
  57. void SetColor(const AZ::Color& color) override;
  58. const AZ::Color& GetColor() const override;
  59. void SetTopHeight(float topHeight) override;
  60. float GetTopHeight() const override;
  61. void SetBottomHeight(float bottomHeight) override;
  62. float GetBottomHeight() const override;
  63. //! Get Sun azimuth and altitude from entity transform, without scale
  64. SunPosition GetSunTransform(const AZ::Transform& world);
  65. TransformInterface* m_transformInterface = nullptr;
  66. SkyBoxFeatureProcessorInterface* m_featureProcessorInterface = nullptr;
  67. PhysicalSkyComponentConfig m_configuration;
  68. EntityId m_entityId;
  69. bool m_isActive = false;
  70. // For light unit update on UI
  71. PhotometricValue m_skyPhotometricValue;
  72. PhotometricValue m_sunPhotometricValue;
  73. };
  74. }
  75. }