UVsPreExportComponent.cpp 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. #include <Generation/Components/UVsGenerator/UVsPreExportComponent.h>
  9. #include <AzCore/RTTI/RTTI.h>
  10. #include <Generation/Components/UVsGenerator/UVsGenerateComponent.h> // for the context
  11. #include <SceneAPI/SceneCore/Components/GenerationComponent.h>
  12. #include <AzCore/Serialization/SerializeContext.h>
  13. #include <SceneAPI/SceneCore/Events/GenerateEventContext.h>
  14. #include <SceneAPI/SceneCore/Events/ProcessingResult.h>
  15. #include <SceneAPI/SceneCore/Events/CallProcessorBus.h>
  16. namespace AZ::SceneGenerationComponents
  17. {
  18. //! This is the component responsible for actually hooking into the scene API's processing flow
  19. //! during the generation step.
  20. class UVsPreExportComponent : public AZ::SceneAPI::SceneCore::GenerationComponent
  21. {
  22. public:
  23. AZ_COMPONENT(UVsPreExportComponent, s_UVsPreExportComponentTypeId, AZ::SceneAPI::SceneCore::GenerationComponent);
  24. UVsPreExportComponent();
  25. static void Reflect(AZ::ReflectContext* context);
  26. AZ::SceneAPI::Events::ProcessingResult Register(AZ::SceneAPI::Events::GenerateAdditionEventContext& context);
  27. };
  28. AZ::ComponentDescriptor* CreateUVsPreExportComponentDescriptor()
  29. {
  30. return UVsPreExportComponent::CreateDescriptor();
  31. }
  32. namespace SceneEvents = AZ::SceneAPI::Events;
  33. UVsPreExportComponent::UVsPreExportComponent()
  34. {
  35. BindToCall(&UVsPreExportComponent::Register);
  36. }
  37. void UVsPreExportComponent::Reflect(AZ::ReflectContext* context)
  38. {
  39. AZ::SerializeContext* serializeContext = azrtti_cast<AZ::SerializeContext*>(context);
  40. if (serializeContext)
  41. {
  42. serializeContext->Class<UVsPreExportComponent, AZ::SceneAPI::SceneCore::GenerationComponent>()->Version(1);
  43. }
  44. }
  45. AZ::SceneAPI::Events::ProcessingResult UVsPreExportComponent::Register(AZ::SceneAPI::Events::GenerateAdditionEventContext& context)
  46. {
  47. SceneEvents::ProcessingResultCombiner result;
  48. UVsGenerateContext uvsGenerateContext(context.GetScene());
  49. result += SceneEvents::Process<UVsGenerateContext>(uvsGenerateContext);
  50. return result.GetResult();
  51. }
  52. } // namespace AZ::SceneGenerationComponents