ImportContexts.h 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  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/RTTI/RTTI.h>
  10. #include <AzCore/std/string/string.h>
  11. #include <SceneAPI/SceneCore/Events/CallProcessorBus.h>
  12. #include <SceneAPI/SceneCore/Containers/SceneGraph.h>
  13. #include <SceneAPI/SceneCore/Containers/Scene.h>
  14. namespace AZ
  15. {
  16. namespace SceneAPI
  17. {
  18. namespace Containers
  19. {
  20. class Scene;
  21. }
  22. namespace DataTypes
  23. {
  24. class IGraphObject;
  25. }
  26. namespace Events
  27. {
  28. class ImportEventContext;
  29. }
  30. namespace SceneBuilder
  31. {
  32. class RenamedNodesMap;
  33. // ImportContext
  34. // Base structure containing common data needed for all import contexts
  35. struct ImportContext
  36. : public Events::ICallContext
  37. {
  38. AZ_RTTI(ImportContext, "{68E546D5-9B79-4293-AD37-4A4BA688892F}", Events::ICallContext);
  39. ImportContext(Containers::Scene& scene, Containers::SceneGraph::NodeIndex currentGraphPosition,
  40. RenamedNodesMap& nodeNameMap);
  41. ImportContext(Containers::Scene& scene, RenamedNodesMap& nodeNameMap);
  42. Containers::Scene& m_scene;
  43. Containers::SceneGraph::NodeIndex m_currentGraphPosition;
  44. RenamedNodesMap& m_nodeNameMap; // Map of the nodes that have received a new name.
  45. };
  46. // NodeEncounteredContext
  47. // Context pushed to indicate that a new Node has been found and any
  48. // importers that have means to process the contained data should do so
  49. // Member Variables:
  50. // m_createdData - out container that importers must add their created data
  51. // to.
  52. struct NodeEncounteredContext
  53. : public ImportContext
  54. {
  55. AZ_RTTI(NodeEncounteredContext, "{40C31D76-7101-4ACD-8849-0D6D0AF62855}", ImportContext);
  56. NodeEncounteredContext(Containers::Scene& scene,
  57. Containers::SceneGraph::NodeIndex currentGraphPosition,
  58. RenamedNodesMap& nodeNameMap);
  59. NodeEncounteredContext(Events::ImportEventContext& parent,
  60. Containers::SceneGraph::NodeIndex currentGraphPosition,
  61. RenamedNodesMap& nodeNameMap);
  62. AZStd::vector<AZStd::shared_ptr<DataTypes::IGraphObject>> m_createdData;
  63. };
  64. // SceneDataPopulatedContextBase
  65. // Context pushed to indicate that a piece of scene data has been fully
  66. // processed and any importers that wish to place it within the scene graph
  67. // may now do so.
  68. // Member Variables:
  69. // m_graphData - the piece of data that should be inserted in the graph
  70. // m_dataName - the name that should be used as the basis for the scene node
  71. // name
  72. struct SceneDataPopulatedContextBase
  73. : public ImportContext
  74. {
  75. AZ_RTTI(SceneDataPopulatedContextBase, "{5F4CE8D2-EEAC-49F7-8065-0B6372162D6F}", ImportContext);
  76. SceneDataPopulatedContextBase(NodeEncounteredContext& parent,
  77. AZStd::shared_ptr<DataTypes::IGraphObject> nodeData,
  78. const AZStd::string& dataName);
  79. SceneDataPopulatedContextBase(Containers::Scene& scene,
  80. Containers::SceneGraph::NodeIndex currentGraphPosition,
  81. RenamedNodesMap& nodeNameMap,
  82. AZStd::shared_ptr<DataTypes::IGraphObject> nodeData, const AZStd::string& dataName);
  83. AZStd::shared_ptr<DataTypes::IGraphObject> m_graphData;
  84. const AZStd::string m_dataName;
  85. };
  86. // SceneNodeAppendedContextBase
  87. // Context pushed to indicate that data has been added to the scene graph.
  88. // Generally created due to the insertion of a node during SceneDataPopulatedContextBase
  89. // processing.
  90. struct SceneNodeAppendedContextBase
  91. : public ImportContext
  92. {
  93. AZ_RTTI(SceneNodeAppendedContextBase, "{0A69FB6C-2B1B-46E7-AEC3-C4B8ABBFDD69}", ImportContext);
  94. SceneNodeAppendedContextBase(SceneDataPopulatedContextBase& parent, Containers::SceneGraph::NodeIndex newIndex);
  95. SceneNodeAppendedContextBase(Containers::Scene& scene,
  96. Containers::SceneGraph::NodeIndex currentGraphPosition, RenamedNodesMap& nodeNameMap);
  97. };
  98. // SceneAttributeDataPopulatedContextBase
  99. // Context pushed to indicate that attribute data has been found and processed
  100. struct SceneAttributeDataPopulatedContextBase
  101. : public ImportContext
  102. {
  103. AZ_RTTI(SceneAttributeDataPopulatedContextBase, "{DA133E14-0770-435B-9A4E-38679367F56C}", ImportContext);
  104. SceneAttributeDataPopulatedContextBase(SceneNodeAppendedContextBase& parent,
  105. AZStd::shared_ptr<DataTypes::IGraphObject> nodeData,
  106. const Containers::SceneGraph::NodeIndex attributeNodeIndex, const AZStd::string& dataName);
  107. AZStd::shared_ptr<DataTypes::IGraphObject> m_graphData;
  108. const AZStd::string m_dataName;
  109. };
  110. // SceneAttributeNodeAppendedContextBase
  111. // Context pushed to indicate that an attribute node has been added to the scene graph
  112. struct SceneAttributeNodeAppendedContextBase
  113. : public ImportContext
  114. {
  115. AZ_RTTI(SceneAttributeNodeAppendedContextBase, "{8A382A1E-CFE7-47D2-BA5B-CFDF1FB9F03D}", ImportContext);
  116. SceneAttributeNodeAppendedContextBase(SceneAttributeDataPopulatedContextBase& parent,
  117. Containers::SceneGraph::NodeIndex newIndex);
  118. };
  119. // SceneNodeAddedAttributesContextBase
  120. // Context pushed to indicate that all attribute processors have completed their
  121. // work for a specific data node.
  122. struct SceneNodeAddedAttributesContextBase
  123. : public ImportContext
  124. {
  125. AZ_RTTI(SceneNodeAddedAttributesContextBase, "{65B97E48-16A0-4BBD-B364-CFDA9E3600B6}", ImportContext);
  126. SceneNodeAddedAttributesContextBase(SceneNodeAppendedContextBase& parent);
  127. };
  128. // SceneNodeFinalizeContextBase
  129. // Context pushed last after all other contexts for a scene node to allow any
  130. // post-processing needed for an importer.
  131. struct SceneNodeFinalizeContextBase
  132. : public ImportContext
  133. {
  134. AZ_RTTI(SceneNodeFinalizeContextBase, "{F2C7D1BC-8065-423E-9212-241EB426A2BB}", ImportContext);
  135. SceneNodeFinalizeContextBase(SceneNodeAddedAttributesContextBase& parent);
  136. };
  137. // FinalizeSceneContextBase
  138. // Context pushed after the scene has been fully created. This can be used to finalize pending work
  139. // such as resolving named links.
  140. struct FinalizeSceneContextBase
  141. : public ImportContext
  142. {
  143. AZ_RTTI(FinalizeSceneContextBase, "{91C54F51-9B4D-4C61-956C-9D530725D737}", ImportContext);
  144. FinalizeSceneContextBase(Containers::Scene& scene, RenamedNodesMap& nodeNameMap);
  145. };
  146. } // namespace SceneBuilder
  147. } // namespace SceneAPI
  148. } // namespace AZ