SharedThumbnailRenderer.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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 <Atom/RPI.Reflect/Asset/AssetUtils.h>
  10. #include <Atom/RPI.Reflect/Material/MaterialAsset.h>
  11. #include <Atom/RPI.Reflect/Model/ModelAsset.h>
  12. #include <Atom/RPI.Reflect/System/AnyAsset.h>
  13. #include <AzCore/Component/TickBus.h>
  14. #include <AzToolsFramework/Thumbnails/Thumbnail.h>
  15. #include <AzToolsFramework/Thumbnails/ThumbnailerBus.h>
  16. #include <Thumbnails/Thumbnail.h>
  17. namespace AZ
  18. {
  19. namespace LyIntegration
  20. {
  21. //! Provides custom thumbnail rendering of supported asset types
  22. class SharedThumbnailRenderer final
  23. : public AzToolsFramework::Thumbnailer::ThumbnailerRendererRequestBus::MultiHandler
  24. , public SystemTickBus::Handler
  25. {
  26. public:
  27. AZ_CLASS_ALLOCATOR(SharedThumbnailRenderer, AZ::SystemAllocator);
  28. SharedThumbnailRenderer();
  29. ~SharedThumbnailRenderer();
  30. private:
  31. struct ThumbnailConfig
  32. {
  33. bool IsValid() const;
  34. Data::Asset<RPI::ModelAsset> m_modelAsset;
  35. Data::Asset<RPI::MaterialAsset> m_materialAsset;
  36. Data::Asset<RPI::AnyAsset> m_lightingAsset;
  37. };
  38. ThumbnailConfig GetThumbnailConfig(AzToolsFramework::Thumbnailer::SharedThumbnailKey thumbnailKey);
  39. //! ThumbnailerRendererRequestBus::Handler interface overrides...
  40. void RenderThumbnail(AzToolsFramework::Thumbnailer::SharedThumbnailKey thumbnailKey, int thumbnailSize) override;
  41. bool Installed() const override;
  42. //! SystemTickBus::Handler interface overrides...
  43. void OnSystemTick() override;
  44. // Default assets to be kept loaded and used for rendering if not overridden
  45. Data::Asset<RPI::AnyAsset> m_defaultLightingPresetAsset;
  46. Data::Asset<RPI::ModelAsset> m_defaultModelAsset;
  47. Data::Asset<RPI::MaterialAsset> m_defaultMaterialAsset;
  48. Data::Asset<RPI::MaterialAsset> m_reflectionMaterialAsset;
  49. };
  50. } // namespace LyIntegration
  51. } // namespace AZ