Scene.cpp 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  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 <SceneAPI/SceneCore/Containers/Scene.h>
  9. #include <AzCore/RTTI/BehaviorContext.h>
  10. namespace AZ
  11. {
  12. namespace SceneAPI
  13. {
  14. namespace Containers
  15. {
  16. Scene::Scene(const AZStd::string& name)
  17. : m_name(name)
  18. {
  19. }
  20. Scene::Scene(AZStd::string&& name)
  21. : m_name(AZStd::move(name))
  22. {
  23. }
  24. void Scene::SetSource(const AZStd::string& filename, const Uuid& guid)
  25. {
  26. m_sourceFilename = filename;
  27. m_sourceGuid = guid;
  28. }
  29. void Scene::SetSource(AZStd::string&& filename, const Uuid& guid)
  30. {
  31. m_sourceFilename = AZStd::move(filename);
  32. m_sourceGuid = guid;
  33. }
  34. const AZStd::string& Scene::GetSourceFilename() const
  35. {
  36. return m_sourceFilename;
  37. }
  38. AZStd::string_view Scene::GetSourceExtension() const
  39. {
  40. const AZ::IO::PathView sourcePath(m_sourceFilename);
  41. return AZStd::string_view(sourcePath.Extension());
  42. }
  43. const Uuid& Scene::GetSourceGuid() const
  44. {
  45. return m_sourceGuid;
  46. }
  47. void Scene::SetWatchFolder(const AZStd::string& watchFolder)
  48. {
  49. m_watchFolder = watchFolder;
  50. }
  51. const AZStd::string& Scene::GetWatchFolder() const
  52. {
  53. return m_watchFolder;
  54. }
  55. void Scene::SetManifestFilename(const AZStd::string& name)
  56. {
  57. m_manifestFilename = name;
  58. }
  59. void Scene::SetManifestFilename(AZStd::string&& name)
  60. {
  61. m_manifestFilename = AZStd::move(name);
  62. }
  63. const AZStd::string& Scene::GetManifestFilename() const
  64. {
  65. return m_manifestFilename;
  66. }
  67. SceneGraph& Scene::GetGraph()
  68. {
  69. return m_graph;
  70. }
  71. const SceneGraph& Scene::GetGraph() const
  72. {
  73. return m_graph;
  74. }
  75. SceneManifest& Scene::GetManifest()
  76. {
  77. return m_manifest;
  78. }
  79. const SceneManifest& Scene::GetManifest() const
  80. {
  81. return m_manifest;
  82. }
  83. const AZStd::string& Scene::GetName() const
  84. {
  85. return m_name;
  86. }
  87. void Scene::SetOriginalSceneOrientation(SceneOrientation orientation)
  88. {
  89. m_originalOrientation = orientation;
  90. }
  91. void Scene::SetSceneDimension(Vector3 dimension)
  92. {
  93. m_sceneDimension = dimension;
  94. m_hasDimension = true;
  95. }
  96. void Scene::SetSceneVertices(uint32_t vertices)
  97. {
  98. m_vertices = vertices;
  99. }
  100. bool Scene::HasDimension() const
  101. {
  102. return m_hasDimension;
  103. }
  104. Scene::SceneOrientation Scene::GetOriginalSceneOrientation() const
  105. {
  106. return m_originalOrientation;
  107. }
  108. Vector3& Scene::GetSceneDimension()
  109. {
  110. return m_sceneDimension;
  111. }
  112. uint32_t Scene::GetSceneVertices() const
  113. {
  114. return m_vertices;
  115. }
  116. void Scene::Reflect(ReflectContext* context)
  117. {
  118. AZ::BehaviorContext* behaviorContext = azrtti_cast<AZ::BehaviorContext*>(context);
  119. if (behaviorContext)
  120. {
  121. behaviorContext->Class<Scene>()
  122. ->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Automation)
  123. ->Attribute(AZ::Script::Attributes::Module, "scene")
  124. ->Constructor<const AZStd::string&>()
  125. ->Attribute(AZ::Script::Attributes::DefaultConstructorOverrideIndex, 0)
  126. ->Property("name", BehaviorValueGetter(&Scene::m_name), nullptr)
  127. ->Property("manifestFilename", BehaviorValueGetter(&Scene::m_manifestFilename), nullptr)
  128. ->Property("sourceFilename", BehaviorValueGetter(&Scene::m_sourceFilename), nullptr)
  129. ->Property("sourceGuid", BehaviorValueGetter(&Scene::m_sourceGuid), nullptr)
  130. ->Property("graph", BehaviorValueGetter(&Scene::m_graph), nullptr)
  131. ->Property("manifest", BehaviorValueGetter(&Scene::m_manifest), nullptr)
  132. ->Property("watchFolder", BehaviorValueGetter(&Scene::m_watchFolder), nullptr)
  133. ->Constant("SceneOrientation_YUp", BehaviorConstant(SceneOrientation::YUp))
  134. ->Constant("SceneOrientation_ZUp", BehaviorConstant(SceneOrientation::ZUp))
  135. ->Constant("SceneOrientation_XUp", BehaviorConstant(SceneOrientation::XUp))
  136. ->Constant("SceneOrientation_NegXUp", BehaviorConstant(SceneOrientation::NegXUp))
  137. ->Constant("SceneOrientation_NegYUp", BehaviorConstant(SceneOrientation::NegYUp))
  138. ->Constant("SceneOrientation_NegZUp", BehaviorConstant(SceneOrientation::NegZUp))
  139. ->Method("GetOriginalSceneOrientation", [](Scene* self) -> int
  140. {
  141. return aznumeric_cast<int>(self->GetOriginalSceneOrientation());
  142. })
  143. ;
  144. }
  145. }
  146. } // Containers
  147. } // SceneAPI
  148. } // AZ