Manual_Scene.h 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. //
  2. // Copyright (c) 2008-2020 the Urho3D project.
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to deal
  6. // in the Software without restriction, including without limitation the rights
  7. // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. // copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  20. // THE SOFTWARE.
  21. //
  22. #pragma once
  23. #include "../Graphics/Skeleton.h"
  24. #include "../Scene/Scene.h"
  25. #include "../Graphics/Octree.h"
  26. #include "../Graphics/DebugRenderer.h"
  27. #include "../IO/PackageFile.h"
  28. namespace Urho3D
  29. {
  30. const AttributeInfo& SerializableGetAttributeInfo(unsigned index, Serializable* ptr);
  31. #define REGISTER_MANUAL_PART_Serializable(T, className) \
  32. engine->RegisterObjectMethod(className, "const AttributeInfo& get_attributeInfos(uint) const", asFUNCTION(SerializableGetAttributeInfo), asCALL_CDECL_OBJLAST);
  33. // ========================================================================================
  34. // bool Node::SaveXML(Serializer &dest, const String &indentation="\t") const | File: ../Scene/Node.h
  35. bool NodeSaveXML(File* file, const String& indentation, Node* ptr);
  36. // bool Node::SaveXML(Serializer &dest, const String &indentation="\t") const | File: ../Scene/Node.h
  37. bool NodeSaveXMLVectorBuffer(VectorBuffer& buffer, const String& indentation, Node* ptr);
  38. // bool Node::SaveJSON(Serializer &dest, const String &indentation="\t") const | File: ../Scene/Node.h
  39. bool NodeSaveJSON(File* file, Node* ptr);
  40. // bool Node::SaveJSON(Serializer &dest, const String &indentation="\t") const | File: ../Scene/Node.h
  41. bool NodeSaveJSONVectorBuffer(VectorBuffer& buffer, Node* ptr);
  42. // template<class T> void Node::GetChildrenWithComponent(PODVector< Node * > &dest, bool recursive=false) const | File: ../Scene/Node.h
  43. CScriptArray* NodeGetChildrenWithScript(bool recursive, Node* ptr);
  44. // template<class T> void Node::GetChildrenWithComponent(PODVector< Node * > &dest, bool recursive=false) const | File: ../Scene/Node.h
  45. CScriptArray* NodeGetChildrenWithClassName(const String& className, bool recursive, Node* ptr);
  46. // void Node::GetComponents(PODVector< Component * > &dest, StringHash type, bool recursive=false) const | File: ../Scene/Node.h
  47. CScriptArray* NodeGetComponentsWithType(const String& typeName, bool recursive, Node* ptr);
  48. // unsigned Node::GetNumChildren(bool recursive=false) const | File: ../Scene/Node.h
  49. unsigned NodeGetNumChildrenNonRecursive(Node* ptr);
  50. // unsigned Node::GetNumChildren(bool recursive=false) const | File: ../Scene/Node.h
  51. unsigned NodeGetNumChildrenRecursive(Node* ptr);
  52. // Node* Node::GetChild(unsigned index) const | File: ../Scene/Node.h
  53. Node* NodeGetChild(unsigned index, Node* ptr);
  54. // Node* Node::GetChild(const String &name, bool recursive=false) const | File: ../Scene/Node.h
  55. Node* NodeGetChildByName(const String& name, Node* ptr);
  56. // Node* Node::GetChild(const String &name, bool recursive=false) const | File: ../Scene/Node.h
  57. Node* NodeGetChildByNameRecursive(const String& name, Node* ptr);
  58. // const VariantMap& Node::GetVars() const | File: ../Scene/Node.h
  59. VariantMap& NodeGetVars(Node* ptr);
  60. // const Vector<SharedPtr<Component> >& Node::GetComponents() const | File: ../Scene/Node.h
  61. Component* NodeGetComponent(unsigned index, Node* ptr);
  62. #define REGISTER_MANUAL_PART_Node(T, className) \
  63. RegisterNamedObjectConstructor<T>(engine, className); \
  64. /* bool Node::SaveXML(Serializer &dest, const String &indentation="\t") const | File: ../Scene/Node.h */ \
  65. engine->RegisterObjectMethod(className, "bool SaveXML(File@+, const String&in indentation = \"\t\")", asFUNCTION(NodeSaveXML), asCALL_CDECL_OBJLAST); \
  66. /* bool Node::SaveXML(Serializer &dest, const String &indentation="\t") const | File: ../Scene/Node.h */ \
  67. engine->RegisterObjectMethod(className, "bool SaveXML(VectorBuffer&, const String&in indentation = \"\t\")", asFUNCTION(NodeSaveXMLVectorBuffer), asCALL_CDECL_OBJLAST); \
  68. /* bool Node::SaveJSON(Serializer &dest, const String &indentation="\t") const | File: ../Scene/Node.h */ \
  69. engine->RegisterObjectMethod(className, "bool SaveJSON(File@+)", asFUNCTION(NodeSaveJSON), asCALL_CDECL_OBJLAST); \
  70. /* bool Node::SaveJSON(Serializer &dest, const String &indentation="\t") const | File: ../Scene/Node.h */ \
  71. engine->RegisterObjectMethod(className, "bool SaveJSON(VectorBuffer&)", asFUNCTION(NodeSaveJSONVectorBuffer), asCALL_CDECL_OBJLAST); \
  72. /* template<class T> void Node::GetChildrenWithComponent(PODVector< Node * > &dest, bool recursive=false) const | File: ../Scene/Node.h */ \
  73. engine->RegisterObjectMethod(className, "Array<Node@>@ GetChildrenWithScript(bool recursive = false) const", asFUNCTION(NodeGetChildrenWithScript), asCALL_CDECL_OBJLAST); \
  74. /* template<class T> void Node::GetChildrenWithComponent(PODVector< Node * > &dest, bool recursive=false) const | File: ../Scene/Node.h */ \
  75. engine->RegisterObjectMethod(className, "Array<Node@>@ GetChildrenWithScript(const String&in, bool recursive = false) const", asFUNCTION(NodeGetChildrenWithClassName), asCALL_CDECL_OBJLAST); \
  76. /* void Node::GetComponents(PODVector< Component * > &dest, StringHash type, bool recursive=false) const | File: ../Scene/Node.h */ \
  77. engine->RegisterObjectMethod(className, "Array<Component@>@ GetComponents(const String&in, bool recursive = false) const", asFUNCTION(NodeGetComponentsWithType), asCALL_CDECL_OBJLAST); \
  78. /* unsigned Node::GetNumChildren(bool recursive=false) const | File: ../Scene/Node.h */ \
  79. engine->RegisterObjectMethod(className, "uint get_numChildren() const", asFUNCTION(NodeGetNumChildrenNonRecursive), asCALL_CDECL_OBJLAST); \
  80. /* unsigned Node::GetNumChildren(bool recursive=false) const | File: ../Scene/Node.h */ \
  81. engine->RegisterObjectMethod(className, "uint get_numAllChildren() const", asFUNCTION(NodeGetNumChildrenRecursive), asCALL_CDECL_OBJLAST); \
  82. /* Node* Node::GetChild(unsigned index) const | File: ../Scene/Node.h */ \
  83. engine->RegisterObjectMethod(className, "Node@+ get_children(uint) const", asFUNCTION(NodeGetChild), asCALL_CDECL_OBJLAST); \
  84. /* Node* Node::GetChild(const String &name, bool recursive=false) const | File: ../Scene/Node.h */ \
  85. engine->RegisterObjectMethod(className, "Node@+ get_childrenByName(const String&in) const", asFUNCTION(NodeGetChildByName), asCALL_CDECL_OBJLAST); \
  86. /* Node* Node::GetChild(const String &name, bool recursive=false) const | File: ../Scene/Node.h */ \
  87. engine->RegisterObjectMethod(className, "Node@+ get_allChildrenByName(const String&in) const", asFUNCTION(NodeGetChildByNameRecursive), asCALL_CDECL_OBJLAST); \
  88. /* const Vector<SharedPtr<Component> >& Node::GetComponents() const | File: ../Scene/Node.h */ \
  89. engine->RegisterObjectMethod(className, "Component@+ get_components(uint) const", asFUNCTION(NodeGetComponent), asCALL_CDECL_OBJLAST); \
  90. /* const VariantMap& Node::GetVars() const | File: ../Scene/Node.h */ \
  91. engine->RegisterObjectMethod(className, "VariantMap& get_vars()", asFUNCTION(NodeGetVars), asCALL_CDECL_OBJLAST);
  92. // ========================================================================================
  93. // bool Scene::LoadXML(Deserializer &source) | File: ../Scene/Scene.h
  94. bool SceneLoadXML(File* file, Scene* ptr);
  95. // bool Scene::LoadXML(Deserializer &source) | File: ../Scene/Scene.h
  96. bool SceneLoadXMLVectorBuffer(VectorBuffer& buffer, Scene* ptr);
  97. // bool Scene::LoadJSON(Deserializer &source) | File: ../Scene/Scene.h
  98. bool SceneLoadJSON(File* file, Scene* ptr);
  99. // bool Scene::LoadJSON(Deserializer &source) | File: ../Scene/Scene.h
  100. bool SceneLoadJSONVectorBuffer(VectorBuffer& buffer, Scene* ptr);
  101. // Node* Scene::Instantiate(Deserializer &source, const Vector3 &position, const Quaternion &rotation, CreateMode mode=REPLICATED) | File: ../Scene/Scene.h
  102. Node* SceneInstantiate(File* file, const Vector3& position, const Quaternion& rotation, CreateMode mode, Scene* ptr);
  103. // Node* Scene::Instantiate(Deserializer &source, const Vector3 &position, const Quaternion &rotation, CreateMode mode=REPLICATED) | File: ../Scene/Scene.h
  104. Node* SceneInstantiateVectorBuffer(VectorBuffer& buffer, const Vector3& position, const Quaternion& rotation, CreateMode mode, Scene* ptr);
  105. // Node* Scene::InstantiateXML(Deserializer &source, const Vector3 &position, const Quaternion &rotation, CreateMode mode=REPLICATED) | File: ../Scene/Scene.h
  106. Node* SceneInstantiateXML(File* file, const Vector3& position, const Quaternion& rotation, CreateMode mode, Scene* ptr);
  107. // Node* Scene::InstantiateXML(Deserializer &source, const Vector3 &position, const Quaternion &rotation, CreateMode mode=REPLICATED) | File: ../Scene/Scene.h
  108. Node* SceneInstantiateXMLVectorBuffer(VectorBuffer& buffer, const Vector3& position, const Quaternion& rotation, CreateMode mode, Scene* ptr);
  109. // Node* Scene::InstantiateXML(Deserializer &source, const Vector3 &position, const Quaternion &rotation, CreateMode mode=REPLICATED) | File: ../Scene/Scene.h
  110. Node* SceneInstantiateXMLFile(XMLFile* xml, const Vector3& position, const Quaternion& rotation, CreateMode mode, Scene* ptr);
  111. // Node* Scene::InstantiateJSON(Deserializer &source, const Vector3 &position, const Quaternion &rotation, CreateMode mode=REPLICATED) | File: ../Scene/Scene.h
  112. Node* SceneInstantiateJSON(File* file, const Vector3& position, const Quaternion& rotation, CreateMode mode, Scene* ptr);
  113. // Node* Scene::InstantiateJSON(Deserializer &source, const Vector3 &position, const Quaternion &rotation, CreateMode mode=REPLICATED) | File: ../Scene/Scene.h
  114. Node* SceneInstantiateJSONVectorBuffer(VectorBuffer& buffer, const Vector3& position, const Quaternion& rotation, CreateMode mode, Scene* ptr);
  115. // Node* Scene::InstantiateJSON(Deserializer &source, const Vector3 &position, const Quaternion &rotation, CreateMode mode=REPLICATED) | File: ../Scene/Scene.h
  116. Node* SceneInstantiateJSONFile(JSONFile* json, const Vector3& position, const Quaternion& rotation, CreateMode mode, Scene* ptr);
  117. // bool Scene::GetNodesWithTag(PODVector< Node * > &dest, const String &tag) const | File: ../Scene/Scene.h
  118. CScriptArray* SceneGetNodesWithTag(const String& tag, Scene* ptr);
  119. // template<class T> T * Node::GetComponent(bool recursive=false) const | File: ../Scene/Node.h
  120. DebugRenderer* SceneGetDebugRenderer(Scene* ptr);
  121. // template<class T> T * Node::GetComponent(bool recursive=false) const | File: ../Scene/Node.h
  122. Octree* SceneGetOctree(Scene* ptr);
  123. #define REGISTER_MANUAL_PART_Scene(T, className) \
  124. /* bool Scene::LoadXML(Deserializer &source) | File: ../Scene/Scene.h */ \
  125. engine->RegisterObjectMethod(className, "bool LoadXML(File@+)", asFUNCTION(SceneLoadXML), asCALL_CDECL_OBJLAST); \
  126. /* bool Scene::LoadXML(Deserializer &source) | File: ../Scene/Scene.h */ \
  127. engine->RegisterObjectMethod(className, "bool LoadXML(VectorBuffer&)", asFUNCTION(SceneLoadXMLVectorBuffer), asCALL_CDECL_OBJLAST); \
  128. /* bool Scene::LoadJSON(Deserializer &source) | File: ../Scene/Scene.h */ \
  129. engine->RegisterObjectMethod(className, "bool LoadJSON(File@+)", asFUNCTION(SceneLoadJSON), asCALL_CDECL_OBJLAST); \
  130. /* bool Scene::LoadJSON(Deserializer &source) | File: ../Scene/Scene.h */ \
  131. engine->RegisterObjectMethod(className, "bool LoadJSON(VectorBuffer&)", asFUNCTION(SceneLoadJSONVectorBuffer), asCALL_CDECL_OBJLAST); \
  132. /* Node* Scene::Instantiate(Deserializer &source, const Vector3 &position, const Quaternion &rotation, CreateMode mode=REPLICATED) | File: ../Scene/Scene.h */ \
  133. engine->RegisterObjectMethod(className, "Node@+ Instantiate(File@+, const Vector3&in, const Quaternion&in, CreateMode mode = REPLICATED)", asFUNCTION(SceneInstantiate), asCALL_CDECL_OBJLAST); \
  134. /* Node* Scene::Instantiate(Deserializer &source, const Vector3 &position, const Quaternion &rotation, CreateMode mode=REPLICATED) | File: ../Scene/Scene.h */ \
  135. /* Node* Scene::InstantiateXML(Deserializer &source, const Vector3 &position, const Quaternion &rotation, CreateMode mode=REPLICATED) | File: ../Scene/Scene.h */ \
  136. engine->RegisterObjectMethod(className, "Node@+ Instantiate(VectorBuffer&, const Vector3&in, const Quaternion&in, CreateMode mode = REPLICATED)", asFUNCTION(SceneInstantiateVectorBuffer), asCALL_CDECL_OBJLAST); \
  137. /* Node* Scene::InstantiateXML(Deserializer &source, const Vector3 &position, const Quaternion &rotation, CreateMode mode=REPLICATED) | File: ../Scene/Scene.h */ \
  138. engine->RegisterObjectMethod(className, "Node@+ InstantiateXML(File@+, const Vector3&in, const Quaternion&in, CreateMode mode = REPLICATED)", asFUNCTION(SceneInstantiateXML), asCALL_CDECL_OBJLAST); \
  139. /* Node* Scene::InstantiateXML(Deserializer &source, const Vector3 &position, const Quaternion &rotation, CreateMode mode=REPLICATED) | File: ../Scene/Scene.h */ \
  140. engine->RegisterObjectMethod(className, "Node@+ InstantiateXML(VectorBuffer&, const Vector3&in, const Quaternion&in, CreateMode mode = REPLICATED)", asFUNCTION(SceneInstantiateXMLVectorBuffer), asCALL_CDECL_OBJLAST); \
  141. /* Node* Scene::InstantiateXML(Deserializer &source, const Vector3 &position, const Quaternion &rotation, CreateMode mode=REPLICATED) | File: ../Scene/Scene.h */ \
  142. engine->RegisterObjectMethod(className, "Node@+ InstantiateXML(XMLFile@+, const Vector3&in, const Quaternion&in, CreateMode mode = REPLICATED)", asFUNCTION(SceneInstantiateXMLFile), asCALL_CDECL_OBJLAST); \
  143. /* Node* Scene::InstantiateJSON(Deserializer &source, const Vector3 &position, const Quaternion &rotation, CreateMode mode=REPLICATED) | File: ../Scene/Scene.h */ \
  144. engine->RegisterObjectMethod(className, "Node@+ InstantiateJSON(File@+, const Vector3&in, const Quaternion&in, CreateMode mode = REPLICATED)", asFUNCTION(SceneInstantiateJSON), asCALL_CDECL_OBJLAST); \
  145. /* Node* Scene::InstantiateJSON(Deserializer &source, const Vector3 &position, const Quaternion &rotation, CreateMode mode=REPLICATED) | File: ../Scene/Scene.h */ \
  146. engine->RegisterObjectMethod(className, "Node@+ InstantiateJSON(VectorBuffer&, const Vector3&in, const Quaternion&in, CreateMode mode = REPLICATED)", asFUNCTION(SceneInstantiateJSONVectorBuffer), asCALL_CDECL_OBJLAST); \
  147. /* Node* Scene::InstantiateJSON(Deserializer &source, const Vector3 &position, const Quaternion &rotation, CreateMode mode=REPLICATED) | File: ../Scene/Scene.h */ \
  148. engine->RegisterObjectMethod(className, "Node@+ InstantiateJSON(JSONFile@+, const Vector3&in, const Quaternion&in, CreateMode mode = REPLICATED)", asFUNCTION(SceneInstantiateJSONFile), asCALL_CDECL_OBJLAST); \
  149. /* bool Scene::GetNodesWithTag(PODVector< Node * > &dest, const String &tag) const | File: ../Scene/Scene.h */ \
  150. engine->RegisterObjectMethod(className, "Array<Node@>@ GetNodesWithTag(const String&in) const", asFUNCTION(SceneGetNodesWithTag), asCALL_CDECL_OBJLAST); \
  151. /* Component* Node::GetComponent(StringHash type, bool recursive=false) const | File: ../Scene/Scene.h */ \
  152. /* Workaround Doxygen bug: have no const flag in xml */ \
  153. engine->RegisterObjectMethod(className, "Component@+ GetComponent(StringHash, bool = false) const", asMETHODPR(T, GetComponent, (StringHash, bool) const, Component*), asCALL_THISCALL); \
  154. /* bool Node::SaveXML(XMLElement &dest) const override | File: ../Scene/Scene.h */ \
  155. /* Workaround Doxygen bug: have no const flag in xml */ \
  156. engine->RegisterObjectMethod(className, "bool SaveXML(XMLElement&) const", asMETHODPR(T, SaveXML, (XMLElement &) const, bool), asCALL_THISCALL); \
  157. /* bool Node::SaveJSON(JSONValue &dest) const override | File: ../Scene/Scene.h */\
  158. /* Workaround Doxygen bug: have no const flag in xml */ \
  159. engine->RegisterObjectMethod(className, "bool SaveJSON(JSONValue&) const", asMETHODPR(T, SaveJSON, (JSONValue &) const, bool), asCALL_THISCALL); \
  160. /* template<class T> T * Node::GetComponent(bool recursive=false) const | File: ../Scene/Node.h */ \
  161. engine->RegisterObjectMethod(className, "DebugRenderer@+ get_debugRenderer() const", asFUNCTION(SceneGetDebugRenderer), asCALL_CDECL_OBJLAST); \
  162. engine->RegisterObjectMethod(className, "Octree@+ get_octree() const", asFUNCTION(SceneGetOctree), asCALL_CDECL_OBJLAST);
  163. // ========================================================================================
  164. // WeakPtr<Node> Bone::node_ | File: ../Graphics/Skeleton.h
  165. Node* BoneGetNode(Bone* ptr);
  166. // WeakPtr<Node> Bone::node_ | File: ../Graphics/Skeleton.h
  167. void BoneSetNode(Node* node, Bone* ptr);
  168. #define REGISTER_MANUAL_PART_Bone(T, className) \
  169. /* WeakPtr<Node> Bone::node_ | File: ../Graphics/Skeleton.h */ \
  170. engine->RegisterObjectMethod(className, "void set_node(Node@+)", asFUNCTION(BoneSetNode), asCALL_CDECL_OBJLAST); \
  171. /* WeakPtr<Node> Bone::node_ | File: ../Graphics/Skeleton.h */ \
  172. engine->RegisterObjectMethod(className, "Node@+ get_node() const", asFUNCTION(BoneGetNode), asCALL_CDECL_OBJLAST);
  173. }