ModelExporterComponent.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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/Serialization/Utils.h>
  10. #include <SceneAPI/SceneCore/Components/ExportingComponent.h>
  11. namespace AZ
  12. {
  13. namespace SceneAPI
  14. {
  15. namespace Events
  16. {
  17. class ExportEventContext;
  18. }
  19. }
  20. namespace RPI
  21. {
  22. /**
  23. * This is the central component that drive the process of exporting a scene to Model
  24. * and Material assets. It delegates asset-build duties to other components like
  25. * ModelAssetBuilderComponent and MaterialAssetBuilderComponent via export events.
  26. */
  27. class ModelExporterComponent : public SceneAPI::SceneCore::ExportingComponent
  28. {
  29. public:
  30. AZ_COMPONENT(
  31. ModelExporterComponent,
  32. "{AE42AB62-A4D6-4147-88A0-692549EE5427}",
  33. SceneAPI::SceneCore::ExportingComponent);
  34. static void Reflect(ReflectContext* context);
  35. ModelExporterComponent();
  36. ~ModelExporterComponent() override = default;
  37. SceneAPI::Events::ProcessingResult ExportModel(SceneAPI::Events::ExportEventContext& context) const;
  38. private:
  39. struct AssetExportContext
  40. {
  41. AssetExportContext() = default;
  42. AssetExportContext(
  43. AZStd::string_view relativeFileName,
  44. AZStd::string_view extension,
  45. Uuid sourceUuid,
  46. DataStream::StreamType dataStreamType);
  47. AZStd::string_view m_relativeFileName;
  48. AZStd::string_view m_extension;
  49. const Uuid m_sourceUuid = Uuid::CreateNull();
  50. const DataStream::StreamType m_dataStreamType = DataStream::ST_BINARY;
  51. };
  52. template<class T>
  53. bool ExportAsset(
  54. const Data::Asset<T>& asset,
  55. const AssetExportContext& assetContext,
  56. SceneAPI::Events::ExportEventContext& eventContext,
  57. const char* assetTypeDebugName) const;
  58. };
  59. } // namespace RPI
  60. } // namespace AZ