SharedPreviewContent.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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.Public/Base.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 <AtomLyIntegration/CommonFeatures/Material/MaterialAssignment.h>
  14. #include <AtomToolsFramework/PreviewRenderer/PreviewContent.h>
  15. namespace AZ
  16. {
  17. namespace LyIntegration
  18. {
  19. //! Creates a simple scene used for most previews and thumbnails
  20. class SharedPreviewContent final : public AtomToolsFramework::PreviewContent
  21. {
  22. public:
  23. AZ_CLASS_ALLOCATOR(SharedPreviewContent, AZ::SystemAllocator);
  24. SharedPreviewContent(
  25. RPI::ScenePtr scene,
  26. RPI::ViewPtr view,
  27. AZ::Uuid entityContextId,
  28. const Data::Asset<RPI::ModelAsset>& modelAsset,
  29. const Data::Asset<RPI::MaterialAsset>& materialAsset,
  30. const Data::Asset<RPI::AnyAsset>& lightingPresetAsset,
  31. const Render::MaterialPropertyOverrideMap& materialPropertyOverrides);
  32. ~SharedPreviewContent() override;
  33. void Load() override;
  34. bool IsReady() const override;
  35. bool IsError() const override;
  36. void ReportErrors() override;
  37. void Update() override;
  38. private:
  39. void UpdateModel();
  40. void UpdateLighting();
  41. void UpdateCamera();
  42. static constexpr float AspectRatio = 1.0f;
  43. static constexpr float NearDist = 0.001f;
  44. static constexpr float FarDist = 100.0f;
  45. static constexpr float FieldOfView = Constants::HalfPi;
  46. static constexpr float CameraRotationAngle = Constants::QuarterPi / 3.0f;
  47. RPI::ScenePtr m_scene;
  48. RPI::ViewPtr m_view;
  49. AZ::Uuid m_entityContextId;
  50. Entity* m_modelEntity = {};
  51. Data::Asset<RPI::ModelAsset> m_modelAsset;
  52. Data::Asset<RPI::MaterialAsset> m_materialAsset;
  53. Data::Asset<RPI::AnyAsset> m_lightingPresetAsset;
  54. Render::MaterialPropertyOverrideMap m_materialPropertyOverrides;
  55. };
  56. } // namespace LyIntegration
  57. } // namespace AZ