SceneAPI.cpp 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  1. //
  2. // Copyright (c) 2008-2014 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. #include "Precompiled.h"
  23. #include "APITemplates.h"
  24. #include "Animatable.h"
  25. #include "AttributeAnimation.h"
  26. #include "DebugRenderer.h"
  27. #include "ObjectAnimation.h"
  28. #include "PackageFile.h"
  29. #include "Scene.h"
  30. #include "SmoothedTransform.h"
  31. #include "Sort.h"
  32. #include "SplinePath.h"
  33. namespace Urho3D
  34. {
  35. static void RegisterAttributeAnimation(asIScriptEngine* engine)
  36. {
  37. engine->RegisterEnum("InterpMethod");
  38. engine->RegisterEnumValue("InterpMethod", "IM_LINEAR", IM_LINEAR);
  39. engine->RegisterEnumValue("InterpMethod", "IM_SPLINE", IM_SPLINE);
  40. RegisterResource<AttributeAnimation>(engine, "AttributeAnimation");
  41. engine->RegisterObjectMethod("AttributeAnimation", "void set_interpolationMethod(InterpMethod)", asMETHOD(AttributeAnimation, SetInterpolationMethod), asCALL_THISCALL);
  42. engine->RegisterObjectMethod("AttributeAnimation", "InterpMethod get_interpolationMethod() const", asMETHOD(AttributeAnimation, GetInterpolationMethod), asCALL_THISCALL);
  43. engine->RegisterObjectMethod("AttributeAnimation", "void set_splineTension(float)", asMETHOD(AttributeAnimation, SetSplineTension), asCALL_THISCALL);
  44. engine->RegisterObjectMethod("AttributeAnimation", "float get_splineTension() const", asMETHOD(AttributeAnimation, GetSplineTension), asCALL_THISCALL);
  45. engine->RegisterObjectMethod("AttributeAnimation", "void set_valueType(VariantType)", asMETHOD(AttributeAnimation, SetValueType), asCALL_THISCALL);
  46. engine->RegisterObjectMethod("AttributeAnimation", "VariantType get_valueType() const", asMETHOD(AttributeAnimation, GetValueType), asCALL_THISCALL);
  47. engine->RegisterObjectMethod("AttributeAnimation", "void SetKeyFrame(float, const Variant&in)", asMETHOD(AttributeAnimation, SetKeyFrame), asCALL_THISCALL);
  48. engine->RegisterObjectMethod("AttributeAnimation", "void SetEventFrame(float, const String&in, const Variant&in)", asMETHOD(AttributeAnimation, SetEventFrame), asCALL_THISCALL);
  49. }
  50. static void RegisterObjectAnimation(asIScriptEngine* engine)
  51. {
  52. engine->RegisterEnum("WrapMode");
  53. engine->RegisterEnumValue("WrapMode", "WM_LOOP", WM_LOOP);
  54. engine->RegisterEnumValue("WrapMode", "WM_ONCE", WM_ONCE);
  55. engine->RegisterEnumValue("WrapMode", "WM_CLAMP", WM_CLAMP);
  56. RegisterResource<ObjectAnimation>(engine, "ObjectAnimation");
  57. engine->RegisterObjectMethod("ObjectAnimation", "void AddAttributeAnimation(const String&in, AttributeAnimation@+, WrapMode wrapMode=WM_LOOP, float speed=1.0f)", asMETHOD(ObjectAnimation, AddAttributeAnimation), asCALL_THISCALL);
  58. engine->RegisterObjectMethod("ObjectAnimation", "void RemoveAttributeAnimation(const String&in)", asMETHODPR(ObjectAnimation, RemoveAttributeAnimation, (const String&), void), asCALL_THISCALL);
  59. engine->RegisterObjectMethod("ObjectAnimation", "void RemoveAttributeAnimation(AttributeAnimation@+)", asMETHODPR(ObjectAnimation, RemoveAttributeAnimation, (AttributeAnimation*), void), asCALL_THISCALL);
  60. engine->RegisterObjectMethod("ObjectAnimation", "AttributeAnimation@+ GetAttributeAnimation(const String&in) const", asMETHOD(ObjectAnimation, GetAttributeAnimation), asCALL_THISCALL);
  61. engine->RegisterObjectMethod("ObjectAnimation", "WrapMode GetAttributeAnimationWrapMode(const String&in) const", asMETHOD(ObjectAnimation, GetAttributeAnimationWrapMode), asCALL_THISCALL);
  62. engine->RegisterObjectMethod("ObjectAnimation", "float GetAttributeAnimationSpeed(const String&in) const", asMETHOD(ObjectAnimation, GetAttributeAnimationSpeed), asCALL_THISCALL);
  63. engine->RegisterObjectMethod("ObjectAnimation", "Variant get_attributeAnimations(const String&in) const", asMETHOD(ObjectAnimation, GetAttributeAnimation), asCALL_THISCALL);
  64. engine->RegisterObjectMethod("ObjectAnimation", "Variant get_wrapModes(const String&in) const", asMETHOD(ObjectAnimation, GetAttributeAnimationWrapMode), asCALL_THISCALL);
  65. engine->RegisterObjectMethod("ObjectAnimation", "Variant get_speeds(const String&in) const", asMETHOD(ObjectAnimation, GetAttributeAnimationSpeed), asCALL_THISCALL);
  66. }
  67. static void RegisterSerializable(asIScriptEngine* engine)
  68. {
  69. engine->RegisterGlobalProperty("const uint AM_FILE", (void*)&AM_FILE);
  70. engine->RegisterGlobalProperty("const uint AM_NET", (void*)&AM_NET);
  71. engine->RegisterGlobalProperty("const uint AM_DEFAULT", (void*)&AM_DEFAULT);
  72. engine->RegisterGlobalProperty("const uint AM_LATESTDATA", (void*)&AM_LATESTDATA);
  73. engine->RegisterGlobalProperty("const uint AM_NOEDIT", (void*)&AM_NOEDIT);
  74. engine->RegisterGlobalProperty("const uint AM_NODEID", (void*)&AM_NODEID);
  75. engine->RegisterGlobalProperty("const uint AM_COMPONENTID", (void*)&AM_COMPONENTID);
  76. engine->RegisterGlobalProperty("const uint AM_NODEIDVECTOR", (void*)&AM_NODEIDVECTOR);
  77. RegisterSerializable<Serializable>(engine, "Serializable");
  78. }
  79. static void RegisterAnimatable(asIScriptEngine* engine)
  80. {
  81. RegisterAnimatable<Animatable>(engine, "Animatable");
  82. }
  83. static bool NodeSaveXML(File* file, Node* ptr)
  84. {
  85. if (file)
  86. return ptr->SaveXML(*file);
  87. else
  88. return false;
  89. }
  90. static void RegisterNode(asIScriptEngine* engine)
  91. {
  92. engine->RegisterEnum("CreateMode");
  93. engine->RegisterEnumValue("CreateMode", "REPLICATED", REPLICATED);
  94. engine->RegisterEnumValue("CreateMode", "LOCAL", LOCAL);
  95. engine->RegisterEnum("TransformSpace");
  96. engine->RegisterEnumValue("TransformSpace", "TS_LOCAL", TS_LOCAL);
  97. engine->RegisterEnumValue("TransformSpace", "TS_PARENT", TS_PARENT);
  98. engine->RegisterEnumValue("TransformSpace", "TS_WORLD", TS_WORLD);
  99. // Register Component first. At this point Node is not yet registered, so can not register GetNode for Component
  100. RegisterComponent<Component>(engine, "Component", false, false);
  101. RegisterNode<Node>(engine, "Node");
  102. engine->RegisterObjectMethod("Node", "void SetEnabled(bool, bool)", asMETHODPR(Node, SetEnabled, (bool, bool), void), asCALL_THISCALL);
  103. engine->RegisterObjectMethod("Node", "void set_enabled(bool)", asMETHODPR(Node, SetEnabled, (bool), void), asCALL_THISCALL);
  104. engine->RegisterObjectMethod("Node", "bool get_enabled() const", asMETHOD(Node, IsEnabled), asCALL_THISCALL);
  105. engine->RegisterObjectMethod("Node", "bool SaveXML(File@+)", asFUNCTION(NodeSaveXML), asCALL_CDECL_OBJLAST);
  106. engine->RegisterObjectMethod("Node", "Node@+ Clone(CreateMode mode = REPLICATED)", asMETHOD(Node, Clone), asCALL_THISCALL);
  107. RegisterObjectConstructor<Node>(engine, "Node");
  108. RegisterNamedObjectConstructor<Node>(engine, "Node");
  109. engine->RegisterGlobalFunction("Node@+ get_node()", asFUNCTION(GetScriptContextNode), asCALL_CDECL);
  110. // Now GetNode can be registered
  111. engine->RegisterObjectMethod("Component", "Node@+ get_node() const", asMETHOD(Component, GetNode), asCALL_THISCALL);
  112. // Calling DebugRenderer is part of the Component API, so register it as early as possible
  113. RegisterComponent<DebugRenderer>(engine, "DebugRenderer", true, false);
  114. engine->RegisterObjectMethod("Component", "void DrawDebugGeometry(DebugRenderer@+, bool)", asMETHOD(Component, DrawDebugGeometry), asCALL_THISCALL);
  115. engine->RegisterObjectMethod("DebugRenderer", "void DrawDebugGeometry(DebugRenderer@+, bool)", asMETHOD(DebugRenderer, DrawDebugGeometry), asCALL_THISCALL);
  116. }
  117. static bool SceneLoadXML(File* file, Scene* ptr)
  118. {
  119. if (file)
  120. return ptr->LoadXML(*file);
  121. else
  122. return false;
  123. }
  124. static bool SceneSaveXML(File* file, Scene* ptr)
  125. {
  126. if (file)
  127. return ptr->SaveXML(*file);
  128. else
  129. return false;
  130. }
  131. static Node* SceneInstantiate(File* file, const Vector3& position, const Quaternion& rotation, CreateMode mode, Scene* ptr)
  132. {
  133. if (file)
  134. return ptr->Instantiate(*file, position, rotation, mode);
  135. else
  136. return 0;
  137. }
  138. static Node* SceneInstantiateXML(File* file, const Vector3& position, const Quaternion& rotation, CreateMode mode, Scene* ptr)
  139. {
  140. if (file)
  141. return ptr->InstantiateXML(*file, position, rotation, mode);
  142. else
  143. return 0;
  144. }
  145. static Node* SceneInstantiateXMLFile(XMLFile* xml, const Vector3& position, const Quaternion& rotation, CreateMode mode, Scene* ptr)
  146. {
  147. if (xml)
  148. return ptr->InstantiateXML(xml->GetRoot(), position, rotation, mode);
  149. else
  150. return 0;
  151. }
  152. static CScriptArray* SceneGetRequiredPackageFiles(Scene* ptr)
  153. {
  154. return VectorToHandleArray<PackageFile>(ptr->GetRequiredPackageFiles(), "Array<PackageFile@>");
  155. }
  156. static CScriptArray* GetObjectCategories()
  157. {
  158. Vector<String> categories = GetScriptContext()->GetObjectCategories().Keys();
  159. Sort(categories.Begin(), categories.End());
  160. return VectorToArray<String>(categories, "Array<String>");
  161. }
  162. static CScriptArray* GetObjectsByCategory(const String& category)
  163. {
  164. const HashMap<String, Vector<ShortStringHash> >& categories = GetScriptContext()->GetObjectCategories();
  165. Vector<String> components;
  166. HashMap<String, Vector<ShortStringHash> >::ConstIterator i = categories.Find(category);
  167. if (i != categories.End())
  168. {
  169. const HashMap<ShortStringHash, SharedPtr<ObjectFactory> >& factories = GetScriptContext()->GetObjectFactories();
  170. const Vector<ShortStringHash>& factoryHashes = i->second_;
  171. components.Reserve(factoryHashes.Size());
  172. for (unsigned j = 0; j < factoryHashes.Size(); ++j)
  173. {
  174. HashMap<ShortStringHash, SharedPtr<ObjectFactory> >::ConstIterator k = factories.Find(factoryHashes[j]);
  175. if (k != factories.End())
  176. components.Push(k->second_->GetTypeName());
  177. }
  178. }
  179. Sort(components.Begin(), components.End());
  180. return VectorToArray<String>(components, "Array<String>");
  181. }
  182. static void RegisterSmoothedTransform(asIScriptEngine* engine)
  183. {
  184. RegisterComponent<SmoothedTransform>(engine, "SmoothedTransform");
  185. engine->RegisterObjectMethod("SmoothedTransform", "void Update(float, float)", asMETHOD(SmoothedTransform, Update), asCALL_THISCALL);
  186. engine->RegisterObjectMethod("SmoothedTransform", "void set_targetPosition(const Vector3&in)", asMETHOD(SmoothedTransform, SetTargetPosition), asCALL_THISCALL);
  187. engine->RegisterObjectMethod("SmoothedTransform", "const Vector3& get_targetPosition() const", asMETHOD(SmoothedTransform, GetTargetPosition), asCALL_THISCALL);
  188. engine->RegisterObjectMethod("SmoothedTransform", "void set_targetRotation(const Quaternion&in)", asMETHOD(SmoothedTransform, SetTargetRotation), asCALL_THISCALL);
  189. engine->RegisterObjectMethod("SmoothedTransform", "const Quaternion& get_targetRotation() const", asMETHOD(SmoothedTransform, GetTargetRotation), asCALL_THISCALL);
  190. engine->RegisterObjectMethod("SmoothedTransform", "void set_targetWorldPosition(const Vector3&in)", asMETHOD(SmoothedTransform, SetTargetWorldPosition), asCALL_THISCALL);
  191. engine->RegisterObjectMethod("SmoothedTransform", "Vector3 get_targetWorldPosition() const", asMETHOD(SmoothedTransform, GetTargetWorldPosition), asCALL_THISCALL);
  192. engine->RegisterObjectMethod("SmoothedTransform", "void set_targetWorldRotation(const Quaternion&in)", asMETHOD(SmoothedTransform, SetTargetWorldRotation), asCALL_THISCALL);
  193. engine->RegisterObjectMethod("SmoothedTransform", "Quaternion get_targetWorldRotation() const", asMETHOD(SmoothedTransform, GetTargetWorldRotation), asCALL_THISCALL);
  194. engine->RegisterObjectMethod("SmoothedTransform", "bool get_inProgress() const", asMETHOD(SmoothedTransform, IsInProgress), asCALL_THISCALL);
  195. }
  196. static void RegisterSplinePath(asIScriptEngine* engine)
  197. {
  198. RegisterComponent<SplinePath>(engine, "SplinePath");
  199. engine->RegisterObjectMethod("SplinePath", "void AddControlPoint(Node@+ point, uint index = M_MAX_UNSIGNED)", asMETHOD(SplinePath, AddControlPoint), asCALL_THISCALL);
  200. engine->RegisterObjectMethod("SplinePath", "void RemoveControlPoint(Node@+ point)", asMETHOD(SplinePath, RemoveControlPoint), asCALL_THISCALL);
  201. engine->RegisterObjectMethod("SplinePath", "void ClearControlPoints()", asMETHOD(SplinePath, ClearControlPoints), asCALL_THISCALL);
  202. engine->RegisterObjectMethod("SplinePath", "Vector3 GetPoint(float) const", asMETHOD(SplinePath, GetPoint), asCALL_THISCALL);
  203. engine->RegisterObjectMethod("SplinePath", "void set_interpolationMode(InterpolationMode)", asMETHOD(SplinePath, SetInterpolationMode), asCALL_THISCALL);
  204. engine->RegisterObjectMethod("SplinePath", "void set_speed(float)", asMETHOD(SplinePath, SetSpeed), asCALL_THISCALL);
  205. engine->RegisterObjectMethod("SplinePath", "void set_position(float)", asMETHOD(SplinePath, SetPosition), asCALL_THISCALL);
  206. engine->RegisterObjectMethod("SplinePath", "void set_controlledNode(Node@+)", asMETHOD(SplinePath, GetControlledNode), asCALL_THISCALL);
  207. engine->RegisterObjectMethod("SplinePath", "InterpolationMode get_interpolationMode() const", asMETHOD(SplinePath, GetInterpolationMode), asCALL_THISCALL);
  208. engine->RegisterObjectMethod("SplinePath", "float get_speed() const", asMETHOD(SplinePath, GetSpeed), asCALL_THISCALL);
  209. engine->RegisterObjectMethod("SplinePath", "Vector3 get_position() const", asMETHOD(SplinePath, GetPosition), asCALL_THISCALL);
  210. engine->RegisterObjectMethod("SplinePath", "Node@ get_controlledNode() const", asMETHOD(SplinePath, GetControlledNode), asCALL_THISCALL);
  211. engine->RegisterObjectMethod("SplinePath", "void Move(float)", asMETHOD(SplinePath, Move), asCALL_THISCALL);
  212. engine->RegisterObjectMethod("SplinePath", "void Reset()", asMETHOD(SplinePath, Reset), asCALL_THISCALL);
  213. engine->RegisterObjectMethod("SplinePath", "bool get_isFinished() const", asMETHOD(SplinePath, IsFinished), asCALL_THISCALL);
  214. }
  215. static void RegisterScene(asIScriptEngine* engine)
  216. {
  217. engine->RegisterGlobalProperty("const uint FIRST_REPLICATED_ID", (void*)&FIRST_REPLICATED_ID);
  218. engine->RegisterGlobalProperty("const uint LAST_REPLICATED_ID", (void*)&LAST_REPLICATED_ID);
  219. engine->RegisterGlobalProperty("const uint FIRST_LOCAL_ID", (void*)&FIRST_LOCAL_ID);
  220. engine->RegisterGlobalProperty("const uint LAST_LOCAL_ID", (void*)&LAST_LOCAL_ID);
  221. RegisterNode<Scene>(engine, "Scene");
  222. RegisterObjectConstructor<Scene>(engine, "Scene");
  223. RegisterNamedObjectConstructor<Scene>(engine, "Scene");
  224. engine->RegisterObjectMethod("Scene", "bool LoadXML(File@+)", asFUNCTION(SceneLoadXML), asCALL_CDECL_OBJLAST);
  225. engine->RegisterObjectMethod("Scene", "bool SaveXML(File@+)", asFUNCTION(SceneSaveXML), asCALL_CDECL_OBJLAST);
  226. engine->RegisterObjectMethod("Scene", "bool LoadAsync(File@+)", asMETHOD(Scene, LoadAsync), asCALL_THISCALL);
  227. engine->RegisterObjectMethod("Scene", "bool LoadAsyncXML(File@+)", asMETHOD(Scene, LoadAsyncXML), asCALL_THISCALL);
  228. engine->RegisterObjectMethod("Scene", "void StopAsyncLoading()", asMETHOD(Scene, StopAsyncLoading), asCALL_THISCALL);
  229. engine->RegisterObjectMethod("Scene", "Node@+ Instantiate(File@+, const Vector3&in, const Quaternion&in, CreateMode mode = REPLICATED)", asFUNCTION(SceneInstantiate), asCALL_CDECL_OBJLAST);
  230. engine->RegisterObjectMethod("Scene", "Node@+ InstantiateXML(File@+, const Vector3&in, const Quaternion&in, CreateMode mode = REPLICATED)", asFUNCTION(SceneInstantiateXML), asCALL_CDECL_OBJLAST);
  231. engine->RegisterObjectMethod("Scene", "Node@+ InstantiateXML(XMLFile@+, const Vector3&in, const Quaternion&in, CreateMode mode = REPLICATED)", asFUNCTION(SceneInstantiateXMLFile), asCALL_CDECL_OBJLAST);
  232. engine->RegisterObjectMethod("Scene", "Node@+ InstantiateXML(const XMLElement&in, const Vector3&in, const Quaternion&in, CreateMode mode = REPLICATED)", asMETHODPR(Scene, InstantiateXML, (const XMLElement&, const Vector3&, const Quaternion&, CreateMode), Node*), asCALL_THISCALL);
  233. engine->RegisterObjectMethod("Scene", "void Clear(bool clearReplicated = true, bool clearLocal = true)", asMETHOD(Scene, Clear), asCALL_THISCALL);
  234. engine->RegisterObjectMethod("Scene", "void AddRequiredPackageFile(PackageFile@+)", asMETHOD(Scene, AddRequiredPackageFile), asCALL_THISCALL);
  235. engine->RegisterObjectMethod("Scene", "void ClearRequiredPackageFiles()", asMETHOD(Scene, ClearRequiredPackageFiles), asCALL_THISCALL);
  236. engine->RegisterObjectMethod("Scene", "void RegisterVar(const String&in)", asMETHOD(Scene, RegisterVar), asCALL_THISCALL);
  237. engine->RegisterObjectMethod("Scene", "void UnregisterVar(const String&in)", asMETHOD(Scene, UnregisterVar), asCALL_THISCALL);
  238. engine->RegisterObjectMethod("Scene", "void UnregisterAllVars(const String&in)", asMETHOD(Scene, UnregisterAllVars), asCALL_THISCALL);
  239. engine->RegisterObjectMethod("Scene", "Component@+ GetComponent(uint)", asMETHODPR(Scene, GetComponent, (unsigned) const, Component*), asCALL_THISCALL);
  240. engine->RegisterObjectMethod("Scene", "Node@+ GetNode(uint)", asMETHOD(Scene, GetNode), asCALL_THISCALL);
  241. engine->RegisterObjectMethod("Scene", "const String& GetVarName(ShortStringHash) const", asMETHOD(Scene, GetVarName), asCALL_THISCALL);
  242. engine->RegisterObjectMethod("Scene", "void Update(float)", asMETHOD(Scene, Update), asCALL_THISCALL);
  243. engine->RegisterObjectMethod("Scene", "void set_updateEnabled(bool)", asMETHOD(Scene, SetUpdateEnabled), asCALL_THISCALL);
  244. engine->RegisterObjectMethod("Scene", "bool get_updateEnabled() const", asMETHOD(Scene, IsUpdateEnabled), asCALL_THISCALL);
  245. engine->RegisterObjectMethod("Scene", "void set_timeScale(float)", asMETHOD(Scene, SetTimeScale), asCALL_THISCALL);
  246. engine->RegisterObjectMethod("Scene", "float get_timeScale() const", asMETHOD(Scene, GetTimeScale), asCALL_THISCALL);
  247. engine->RegisterObjectMethod("Scene", "void set_elapsedTime(float)", asMETHOD(Scene, SetElapsedTime), asCALL_THISCALL);
  248. engine->RegisterObjectMethod("Scene", "float get_elapsedTime() const", asMETHOD(Scene, GetElapsedTime), asCALL_THISCALL);
  249. engine->RegisterObjectMethod("Scene", "void set_smoothingConstant(float)", asMETHOD(Scene, SetSmoothingConstant), asCALL_THISCALL);
  250. engine->RegisterObjectMethod("Scene", "float get_smoothingConstant() const", asMETHOD(Scene, GetSmoothingConstant), asCALL_THISCALL);
  251. engine->RegisterObjectMethod("Scene", "void set_snapThreshold(float)", asMETHOD(Scene, SetSnapThreshold), asCALL_THISCALL);
  252. engine->RegisterObjectMethod("Scene", "float get_snapThreshold() const", asMETHOD(Scene, GetSnapThreshold), asCALL_THISCALL);
  253. engine->RegisterObjectMethod("Scene", "bool get_asyncLoading() const", asMETHOD(Scene, IsAsyncLoading), asCALL_THISCALL);
  254. engine->RegisterObjectMethod("Scene", "float get_asyncProgress() const", asMETHOD(Scene, GetAsyncProgress), asCALL_THISCALL);
  255. engine->RegisterObjectMethod("Scene", "uint get_checksum() const", asMETHOD(Scene, GetChecksum), asCALL_THISCALL);
  256. engine->RegisterObjectMethod("Scene", "const String& get_fileName() const", asMETHOD(Scene, GetFileName), asCALL_THISCALL);
  257. engine->RegisterObjectMethod("Scene", "Array<PackageFile@>@ get_requiredPackageFiles() const", asFUNCTION(SceneGetRequiredPackageFiles), asCALL_CDECL_OBJLAST);
  258. engine->RegisterObjectMethod("Node", "Scene@+ get_scene() const", asMETHOD(Node, GetScene), asCALL_THISCALL);
  259. engine->RegisterGlobalFunction("Scene@+ get_scene()", asFUNCTION(GetScriptContextScene), asCALL_CDECL);
  260. engine->RegisterGlobalFunction("Array<String>@ GetObjectCategories()", asFUNCTION(GetObjectCategories), asCALL_CDECL);
  261. engine->RegisterGlobalFunction("Array<String>@ GetObjectsByCategory(const String&in)", asFUNCTION(GetObjectsByCategory), asCALL_CDECL);
  262. }
  263. void RegisterSceneAPI(asIScriptEngine* engine)
  264. {
  265. RegisterAttributeAnimation(engine);
  266. RegisterObjectAnimation(engine);
  267. RegisterSerializable(engine);
  268. RegisterAnimatable(engine);
  269. RegisterNode(engine);
  270. RegisterSmoothedTransform(engine);
  271. RegisterSplinePath(engine);
  272. RegisterScene(engine);
  273. }
  274. }