HDRiSkyboxComponentController.h 3.4 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 <AzCore/Component/Component.h>
  10. #include <AzCore/Component/TransformBus.h>
  11. #include <Atom/Feature/SkyBox/SkyBoxFeatureProcessorInterface.h>
  12. #include <AtomLyIntegration/CommonFeatures/SkyBox/HDRiSkyboxComponentConfig.h>
  13. #include <AtomLyIntegration/CommonFeatures/SkyBox/HDRiSkyboxBus.h>
  14. namespace AZ
  15. {
  16. namespace Render
  17. {
  18. class HDRiSkyboxComponentController final
  19. : public TransformNotificationBus::Handler
  20. , public HDRiSkyboxRequestBus::Handler
  21. , Data::AssetBus::MultiHandler
  22. {
  23. public:
  24. friend class EditorHDRiSkyboxComponent;
  25. AZ_TYPE_INFO(AZ::Render::HDRiSkyboxComponentController, "{D01C123D-4EA1-4A9B-A7D9-47EF26A55CD0}");
  26. static void Reflect(AZ::ReflectContext* context);
  27. static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided);
  28. static void GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible);
  29. static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required);
  30. HDRiSkyboxComponentController() = default;
  31. HDRiSkyboxComponentController(const HDRiSkyboxComponentConfig& config);
  32. void Activate(EntityId entityId);
  33. void Deactivate();
  34. void SetConfiguration(const HDRiSkyboxComponentConfig& config);
  35. const HDRiSkyboxComponentConfig& GetConfiguration() const;
  36. private:
  37. AZ_DISABLE_COPY(HDRiSkyboxComponentController);
  38. //! Data::AssetBus interface
  39. void OnAssetReady(Data::Asset<Data::AssetData> asset) override;
  40. void OnAssetReloaded(Data::Asset<Data::AssetData> asset) override;
  41. void OnAssetError(Data::Asset<Data::AssetData> asset) override;
  42. // TransformNotificationBus::Handler overrides ...
  43. void OnTransformChanged(const AZ::Transform& local, const AZ::Transform& world) override;
  44. // HDRiSkyboxRequestBus::Handler overrides ...
  45. Data::Asset<RPI::StreamingImageAsset> GetCubemapAsset() const override;
  46. void SetCubemapAsset(const Data::Asset<RPI::StreamingImageAsset>& cubemapAsset) override;
  47. void SetExposure(float exposure) override;
  48. float GetExposure() const override;
  49. //! Queues a load of an image Asset
  50. void LoadImage(Data::Asset<RPI::StreamingImageAsset>& imageAsset);
  51. //! Handles all Data::AssetBus calls in a unified way
  52. void UpdateWithAsset(Data::Asset<Data::AssetData> updatedAsset);
  53. //! Validates individual asset updates, returns true for valid ready assets.
  54. bool IsAssetValid(Data::Asset<RPI::StreamingImageAsset>& asset);
  55. //! Get the inverse matrix from entity transfom, without scale and translate
  56. AZ::Matrix4x4 GetInverseTransform(const AZ::Transform& world);
  57. TransformInterface* m_transformInterface = nullptr;
  58. SkyBoxFeatureProcessorInterface* m_featureProcessorInterface = nullptr;
  59. HDRiSkyboxComponentConfig m_configuration;
  60. EntityId m_entityId;
  61. bool m_isActive = false;
  62. };
  63. }
  64. }