StarsComponentController.h 2.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 <AzCore/Asset/AssetCommon.h>
  12. #include <StarsComponentConfig.h>
  13. namespace AZ::RPI
  14. {
  15. class Scene;
  16. }
  17. namespace AZ::Render
  18. {
  19. class StarsFeatureProcessor;
  20. class StarsComponentController final
  21. : private TransformNotificationBus::Handler
  22. , private Data::AssetBus::MultiHandler
  23. {
  24. public:
  25. friend class EditorStarsComponent;
  26. AZ_TYPE_INFO(AZ::Render::StarsComponentController, "{774F8FA2-3465-46FA-B635-DBF573230643}");
  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 GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent);
  31. StarsComponentController() = default;
  32. StarsComponentController(const StarsComponentConfig& config);
  33. void Activate(EntityId entityId);
  34. void Deactivate();
  35. void SetConfiguration(const StarsComponentConfig& config);
  36. const StarsComponentConfig& GetConfiguration() const;
  37. private:
  38. AZ_DISABLE_COPY(StarsComponentController);
  39. //! TransformNotificationBus
  40. void OnTransformChanged(const AZ::Transform& local, const AZ::Transform& world) override;
  41. //! Data::AssetBus interface
  42. void OnAssetReady(Data::Asset<Data::AssetData> asset) override;
  43. void OnAssetReloaded(Data::Asset<Data::AssetData> asset) override;
  44. void OnConfigChanged();
  45. void OnStarsAssetChanged();
  46. void UpdateStarsFromAsset(Data::Asset<Data::AssetData> asset);
  47. void EnableFeatureProcessor(EntityId entityId);
  48. void DisableFeatureProcessor();
  49. StarsComponentConfig m_configuration;
  50. AZ::Render::StarsFeatureProcessor* m_starsFeatureProcessor = nullptr;
  51. struct Star
  52. {
  53. float ascension;
  54. float declination;
  55. uint8_t red;
  56. uint8_t green;
  57. uint8_t blue;
  58. uint8_t magnitude;
  59. };
  60. RPI::Scene* m_scene;
  61. };
  62. } // AZ::Render