DecalExampleComponent.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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 <CommonSampleComponentBase.h>
  10. #include <AzCore/Component/EntityBus.h>
  11. #include <AzCore/Component/TickBus.h>
  12. #include <AzFramework/Input/Events/InputChannelEventListener.h>
  13. #include <Atom/Feature/CoreLights/DirectionalLightFeatureProcessorInterface.h>
  14. #include <Atom/Feature/Decals/DecalFeatureProcessorInterface.h>
  15. #include <Utils/Utils.h>
  16. #include <Utils/ImGuiSidebar.h>
  17. #include "DecalContainer.h"
  18. namespace AtomSampleViewer
  19. {
  20. class DecalContainer;
  21. //! This component creates a simple scene to test Atom's decal system.
  22. class DecalExampleComponent final
  23. : public CommonSampleComponentBase
  24. , public AZ::TickBus::Handler
  25. {
  26. public:
  27. AZ_COMPONENT(DecalExampleComponent, "{91CFCFFC-EDD9-47EB-AE98-4BE9617D6F2F}", CommonSampleComponentBase);
  28. static void Reflect(AZ::ReflectContext* context);
  29. void Activate() override;
  30. void Deactivate() override;
  31. private:
  32. // AZ::TickBus::Handler
  33. void OnTick(float deltaTime, AZ::ScriptTimePoint timePoint) override;
  34. void CreateDecalContainer();
  35. void CreatePlaneObject();
  36. void ScaleObjectToFitDecals();
  37. void EnableArcBallCameraController();
  38. void ConfigureCameraToLookDownAtObject();
  39. void AddImageBasedLight();
  40. void AcquireDirectionalLightFeatureProcessor();
  41. void CreateDirectionalLight();
  42. void UpdateDirectionalLight();
  43. void DrawSidebar();
  44. AZ::Render::MeshFeatureProcessorInterface::MeshHandle m_meshHandle;
  45. Utils::DefaultIBL m_defaultIbl;
  46. AZStd::unique_ptr<DecalContainer> m_decalContainer;
  47. // Used to test the DecalFeatureProcessor::Clone() function
  48. AZStd::unique_ptr<DecalContainer> m_decalContainerClone;
  49. ImGuiSidebar m_imguiSidebar;
  50. bool m_cloneDecalsEnabled = false;
  51. float m_directionalLightRotationAngle = 0.f; // in radians
  52. AZ::Render::DirectionalLightFeatureProcessorInterface* m_directionalLightFeatureProcessor = nullptr;
  53. AZ::Render::DirectionalLightFeatureProcessorInterface::LightHandle m_directionalLightHandle;
  54. // CommonSampleComponentBase overrides...
  55. void OnAllAssetsReadyActivate() override;
  56. };
  57. } // namespace AtomSampleViewer