MaterialAssetBuilderComponent.h 2.8 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 <Atom/RPI.Builders/Model/ModelExporterContexts.h>
  10. #include <AzCore/Serialization/Utils.h>
  11. #include <SceneAPI/SceneCore/Components/ExportingComponent.h>
  12. #include <SceneAPI/SceneCore/SceneBuilderDependencyBus.h>
  13. namespace AZ
  14. {
  15. namespace RPI
  16. {
  17. /**
  18. * Export materials from Scene
  19. */
  20. class MaterialAssetBuilderComponent : public SceneAPI::SceneCore::ExportingComponent
  21. {
  22. public:
  23. AZ_COMPONENT(
  24. MaterialAssetBuilderComponent,
  25. "{777BB521-FCFE-4382-B8FD-E1EAF846F5C9}",
  26. SceneAPI::SceneCore::ExportingComponent);
  27. MaterialAssetBuilderComponent();
  28. ~MaterialAssetBuilderComponent() override = default;
  29. SceneAPI::Events::ProcessingResult BuildMaterials(MaterialAssetBuilderContext& context) const;
  30. // Return the material assetid for material id
  31. static uint32_t GetMaterialAssetSubId(uint64_t materialUid);
  32. // Required for ExportingComponent
  33. static void Reflect(AZ::ReflectContext* context);
  34. private:
  35. SceneAPI::Events::ProcessingResult ConvertMaterials(MaterialAssetBuilderContext& context) const;
  36. SceneAPI::Events::ProcessingResult AssignDefaultMaterials(MaterialAssetBuilderContext& context) const;
  37. Data::Asset<MaterialAsset> GetDefaultMaterialAsset() const;
  38. };
  39. /**
  40. * Report dependencies for the MaterialAssetBuilderComponent
  41. */
  42. class MaterialAssetDependenciesComponent
  43. : public Component
  44. , public SceneAPI::SceneBuilderDependencyBus::Handler
  45. {
  46. public:
  47. AZ_COMPONENT(MaterialAssetDependenciesComponent, "{02163945-D7B4-45D4-9729-4376E1195505}");
  48. static void Reflect(ReflectContext* context);
  49. MaterialAssetDependenciesComponent() = default;
  50. ~MaterialAssetDependenciesComponent() override = default;
  51. static void GetProvidedServices(ComponentDescriptor::DependencyArrayType& provided);
  52. static void GetIncompatibleServices(ComponentDescriptor::DependencyArrayType& incompatible);
  53. // AZ::Component overrides...
  54. void Activate() override;
  55. void Deactivate() override;
  56. // SceneAPI::SceneBuilderDependencyBus::Handler overrides...
  57. void ReportJobDependencies(SceneAPI::JobDependencyList& jobDependencyList, const char* platformIdentifier) override;
  58. void AddFingerprintInfo(AZStd::set<AZStd::string>& fingerprintInfo) override;
  59. };
  60. } // namespace RPI
  61. } // namespace AZ