HDRiSkyboxComponentController.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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 SetCubemapAssetPath(const AZStd::string& path) override;
  48. void SetCubemapAssetId(AZ::Data::AssetId) override;
  49. AZ::Data::AssetId GetCubemapAssetId() const override;
  50. AZStd::string GetCubemapAssetPath() const override;
  51. void SetExposure(float exposure) override;
  52. float GetExposure() const override;
  53. //! Queues a load of an image Asset
  54. void LoadImage(Data::Asset<RPI::StreamingImageAsset>& imageAsset);
  55. //! Handles all Data::AssetBus calls in a unified way
  56. void UpdateWithAsset(Data::Asset<Data::AssetData> updatedAsset);
  57. //! Validates individual asset updates, returns true for valid ready assets.
  58. bool IsAssetValid(Data::Asset<RPI::StreamingImageAsset>& asset);
  59. //! Get the inverse matrix from entity transfom, without scale and translate
  60. AZ::Matrix4x4 GetInverseTransform(const AZ::Transform& world);
  61. TransformInterface* m_transformInterface = nullptr;
  62. SkyBoxFeatureProcessorInterface* m_featureProcessorInterface = nullptr;
  63. HDRiSkyboxComponentConfig m_configuration;
  64. EntityId m_entityId;
  65. bool m_isActive = false;
  66. };
  67. }
  68. }