gltf_state.cpp 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380
  1. /**************************************************************************/
  2. /* gltf_state.cpp */
  3. /**************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /**************************************************************************/
  8. /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
  9. /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
  10. /* */
  11. /* Permission is hereby granted, free of charge, to any person obtaining */
  12. /* a copy of this software and associated documentation files (the */
  13. /* "Software"), to deal in the Software without restriction, including */
  14. /* without limitation the rights to use, copy, modify, merge, publish, */
  15. /* distribute, sublicense, and/or sell copies of the Software, and to */
  16. /* permit persons to whom the Software is furnished to do so, subject to */
  17. /* the following conditions: */
  18. /* */
  19. /* The above copyright notice and this permission notice shall be */
  20. /* included in all copies or substantial portions of the Software. */
  21. /* */
  22. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  23. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  24. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
  25. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  26. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  27. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  28. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  29. /**************************************************************************/
  30. #include "gltf_state.h"
  31. #include "gltf_template_convert.h"
  32. void GLTFState::_bind_methods() {
  33. ClassDB::bind_method(D_METHOD("add_used_extension", "extension_name", "required"), &GLTFState::add_used_extension);
  34. ClassDB::bind_method(D_METHOD("get_json"), &GLTFState::get_json);
  35. ClassDB::bind_method(D_METHOD("set_json", "json"), &GLTFState::set_json);
  36. ClassDB::bind_method(D_METHOD("get_major_version"), &GLTFState::get_major_version);
  37. ClassDB::bind_method(D_METHOD("set_major_version", "major_version"), &GLTFState::set_major_version);
  38. ClassDB::bind_method(D_METHOD("get_minor_version"), &GLTFState::get_minor_version);
  39. ClassDB::bind_method(D_METHOD("set_minor_version", "minor_version"), &GLTFState::set_minor_version);
  40. ClassDB::bind_method(D_METHOD("get_glb_data"), &GLTFState::get_glb_data);
  41. ClassDB::bind_method(D_METHOD("set_glb_data", "glb_data"), &GLTFState::set_glb_data);
  42. ClassDB::bind_method(D_METHOD("get_use_named_skin_binds"), &GLTFState::get_use_named_skin_binds);
  43. ClassDB::bind_method(D_METHOD("set_use_named_skin_binds", "use_named_skin_binds"), &GLTFState::set_use_named_skin_binds);
  44. ClassDB::bind_method(D_METHOD("get_nodes"), &GLTFState::get_nodes);
  45. ClassDB::bind_method(D_METHOD("set_nodes", "nodes"), &GLTFState::set_nodes);
  46. ClassDB::bind_method(D_METHOD("get_buffers"), &GLTFState::get_buffers);
  47. ClassDB::bind_method(D_METHOD("set_buffers", "buffers"), &GLTFState::set_buffers);
  48. ClassDB::bind_method(D_METHOD("get_buffer_views"), &GLTFState::get_buffer_views);
  49. ClassDB::bind_method(D_METHOD("set_buffer_views", "buffer_views"), &GLTFState::set_buffer_views);
  50. ClassDB::bind_method(D_METHOD("get_accessors"), &GLTFState::get_accessors);
  51. ClassDB::bind_method(D_METHOD("set_accessors", "accessors"), &GLTFState::set_accessors);
  52. ClassDB::bind_method(D_METHOD("get_meshes"), &GLTFState::get_meshes);
  53. ClassDB::bind_method(D_METHOD("set_meshes", "meshes"), &GLTFState::set_meshes);
  54. ClassDB::bind_method(D_METHOD("get_animation_players_count", "idx"), &GLTFState::get_animation_players_count);
  55. ClassDB::bind_method(D_METHOD("get_animation_player", "idx"), &GLTFState::get_animation_player);
  56. ClassDB::bind_method(D_METHOD("get_materials"), &GLTFState::get_materials);
  57. ClassDB::bind_method(D_METHOD("set_materials", "materials"), &GLTFState::set_materials);
  58. ClassDB::bind_method(D_METHOD("get_scene_name"), &GLTFState::get_scene_name);
  59. ClassDB::bind_method(D_METHOD("set_scene_name", "scene_name"), &GLTFState::set_scene_name);
  60. ClassDB::bind_method(D_METHOD("get_base_path"), &GLTFState::get_base_path);
  61. ClassDB::bind_method(D_METHOD("set_base_path", "base_path"), &GLTFState::set_base_path);
  62. ClassDB::bind_method(D_METHOD("get_root_nodes"), &GLTFState::get_root_nodes);
  63. ClassDB::bind_method(D_METHOD("set_root_nodes", "root_nodes"), &GLTFState::set_root_nodes);
  64. ClassDB::bind_method(D_METHOD("get_textures"), &GLTFState::get_textures);
  65. ClassDB::bind_method(D_METHOD("set_textures", "textures"), &GLTFState::set_textures);
  66. ClassDB::bind_method(D_METHOD("get_texture_samplers"), &GLTFState::get_texture_samplers);
  67. ClassDB::bind_method(D_METHOD("set_texture_samplers", "texture_samplers"), &GLTFState::set_texture_samplers);
  68. ClassDB::bind_method(D_METHOD("get_images"), &GLTFState::get_images);
  69. ClassDB::bind_method(D_METHOD("set_images", "images"), &GLTFState::set_images);
  70. ClassDB::bind_method(D_METHOD("get_skins"), &GLTFState::get_skins);
  71. ClassDB::bind_method(D_METHOD("set_skins", "skins"), &GLTFState::set_skins);
  72. ClassDB::bind_method(D_METHOD("get_cameras"), &GLTFState::get_cameras);
  73. ClassDB::bind_method(D_METHOD("set_cameras", "cameras"), &GLTFState::set_cameras);
  74. ClassDB::bind_method(D_METHOD("get_lights"), &GLTFState::get_lights);
  75. ClassDB::bind_method(D_METHOD("set_lights", "lights"), &GLTFState::set_lights);
  76. ClassDB::bind_method(D_METHOD("get_unique_names"), &GLTFState::get_unique_names);
  77. ClassDB::bind_method(D_METHOD("set_unique_names", "unique_names"), &GLTFState::set_unique_names);
  78. ClassDB::bind_method(D_METHOD("get_unique_animation_names"), &GLTFState::get_unique_animation_names);
  79. ClassDB::bind_method(D_METHOD("set_unique_animation_names", "unique_animation_names"), &GLTFState::set_unique_animation_names);
  80. ClassDB::bind_method(D_METHOD("get_skeletons"), &GLTFState::get_skeletons);
  81. ClassDB::bind_method(D_METHOD("set_skeletons", "skeletons"), &GLTFState::set_skeletons);
  82. ClassDB::bind_method(D_METHOD("get_create_animations"), &GLTFState::get_create_animations);
  83. ClassDB::bind_method(D_METHOD("set_create_animations", "create_animations"), &GLTFState::set_create_animations);
  84. ClassDB::bind_method(D_METHOD("get_animations"), &GLTFState::get_animations);
  85. ClassDB::bind_method(D_METHOD("set_animations", "animations"), &GLTFState::set_animations);
  86. ClassDB::bind_method(D_METHOD("get_scene_node", "idx"), &GLTFState::get_scene_node);
  87. ClassDB::bind_method(D_METHOD("get_node_index", "scene_node"), &GLTFState::get_node_index);
  88. ClassDB::bind_method(D_METHOD("get_additional_data", "extension_name"), &GLTFState::get_additional_data);
  89. ClassDB::bind_method(D_METHOD("set_additional_data", "extension_name", "additional_data"), &GLTFState::set_additional_data);
  90. ClassDB::bind_method(D_METHOD("get_handle_binary_image"), &GLTFState::get_handle_binary_image);
  91. ClassDB::bind_method(D_METHOD("set_handle_binary_image", "method"), &GLTFState::set_handle_binary_image);
  92. ADD_PROPERTY(PropertyInfo(Variant::DICTIONARY, "json"), "set_json", "get_json"); // Dictionary
  93. ADD_PROPERTY(PropertyInfo(Variant::INT, "major_version"), "set_major_version", "get_major_version"); // int
  94. ADD_PROPERTY(PropertyInfo(Variant::INT, "minor_version"), "set_minor_version", "get_minor_version"); // int
  95. ADD_PROPERTY(PropertyInfo(Variant::PACKED_BYTE_ARRAY, "glb_data"), "set_glb_data", "get_glb_data"); // Vector<uint8_t>
  96. ADD_PROPERTY(PropertyInfo(Variant::BOOL, "use_named_skin_binds"), "set_use_named_skin_binds", "get_use_named_skin_binds"); // bool
  97. ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "nodes", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_INTERNAL | PROPERTY_USAGE_EDITOR), "set_nodes", "get_nodes"); // Vector<Ref<GLTFNode>>
  98. ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "buffers"), "set_buffers", "get_buffers"); // Vector<Vector<uint8_t>
  99. ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "buffer_views", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_INTERNAL | PROPERTY_USAGE_EDITOR), "set_buffer_views", "get_buffer_views"); // Vector<Ref<GLTFBufferView>>
  100. ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "accessors", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_INTERNAL | PROPERTY_USAGE_EDITOR), "set_accessors", "get_accessors"); // Vector<Ref<GLTFAccessor>>
  101. ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "meshes", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_INTERNAL | PROPERTY_USAGE_EDITOR), "set_meshes", "get_meshes"); // Vector<Ref<GLTFMesh>>
  102. ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "materials", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_INTERNAL | PROPERTY_USAGE_EDITOR), "set_materials", "get_materials"); // Vector<Ref<Material>
  103. ADD_PROPERTY(PropertyInfo(Variant::STRING, "scene_name"), "set_scene_name", "get_scene_name"); // String
  104. ADD_PROPERTY(PropertyInfo(Variant::STRING, "base_path"), "set_base_path", "get_base_path"); // String
  105. ADD_PROPERTY(PropertyInfo(Variant::PACKED_INT32_ARRAY, "root_nodes"), "set_root_nodes", "get_root_nodes"); // Vector<int>
  106. ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "textures", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_INTERNAL | PROPERTY_USAGE_EDITOR), "set_textures", "get_textures"); // Vector<Ref<GLTFTexture>>
  107. ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "texture_samplers", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_INTERNAL | PROPERTY_USAGE_EDITOR), "set_texture_samplers", "get_texture_samplers"); //Vector<Ref<GLTFTextureSampler>>
  108. ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "images", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_INTERNAL | PROPERTY_USAGE_EDITOR), "set_images", "get_images"); // Vector<Ref<Texture>
  109. ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "skins", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_INTERNAL | PROPERTY_USAGE_EDITOR), "set_skins", "get_skins"); // Vector<Ref<GLTFSkin>>
  110. ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "cameras", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_INTERNAL | PROPERTY_USAGE_EDITOR), "set_cameras", "get_cameras"); // Vector<Ref<GLTFCamera>>
  111. ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "lights", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_INTERNAL | PROPERTY_USAGE_EDITOR), "set_lights", "get_lights"); // Vector<Ref<GLTFLight>>
  112. ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "unique_names", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_INTERNAL | PROPERTY_USAGE_EDITOR), "set_unique_names", "get_unique_names"); // Set<String>
  113. ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "unique_animation_names", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_INTERNAL | PROPERTY_USAGE_EDITOR), "set_unique_animation_names", "get_unique_animation_names"); // Set<String>
  114. ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "skeletons", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_INTERNAL | PROPERTY_USAGE_EDITOR), "set_skeletons", "get_skeletons"); // Vector<Ref<GLTFSkeleton>>
  115. ADD_PROPERTY(PropertyInfo(Variant::BOOL, "create_animations"), "set_create_animations", "get_create_animations"); // bool
  116. ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "animations", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_INTERNAL | PROPERTY_USAGE_EDITOR), "set_animations", "get_animations"); // Vector<Ref<GLTFAnimation>>
  117. ADD_PROPERTY(PropertyInfo(Variant::INT, "handle_binary_image", PROPERTY_HINT_ENUM, "Discard All Textures,Extract Textures,Embed As Basis Universal,Embed as Uncompressed", PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_INTERNAL | PROPERTY_USAGE_EDITOR), "set_handle_binary_image", "get_handle_binary_image"); // enum
  118. BIND_CONSTANT(HANDLE_BINARY_DISCARD_TEXTURES);
  119. BIND_CONSTANT(HANDLE_BINARY_EXTRACT_TEXTURES);
  120. BIND_CONSTANT(HANDLE_BINARY_EMBED_AS_BASISU);
  121. BIND_CONSTANT(HANDLE_BINARY_EMBED_AS_UNCOMPRESSED);
  122. }
  123. void GLTFState::add_used_extension(const String &p_extension_name, bool p_required) {
  124. if (!extensions_used.has(p_extension_name)) {
  125. extensions_used.push_back(p_extension_name);
  126. }
  127. if (p_required) {
  128. if (!extensions_required.has(p_extension_name)) {
  129. extensions_required.push_back(p_extension_name);
  130. }
  131. }
  132. }
  133. Dictionary GLTFState::get_json() {
  134. return json;
  135. }
  136. void GLTFState::set_json(Dictionary p_json) {
  137. json = p_json;
  138. }
  139. int GLTFState::get_major_version() {
  140. return major_version;
  141. }
  142. void GLTFState::set_major_version(int p_major_version) {
  143. major_version = p_major_version;
  144. }
  145. int GLTFState::get_minor_version() {
  146. return minor_version;
  147. }
  148. void GLTFState::set_minor_version(int p_minor_version) {
  149. minor_version = p_minor_version;
  150. }
  151. Vector<uint8_t> GLTFState::get_glb_data() {
  152. return glb_data;
  153. }
  154. void GLTFState::set_glb_data(Vector<uint8_t> p_glb_data) {
  155. glb_data = p_glb_data;
  156. }
  157. bool GLTFState::get_use_named_skin_binds() {
  158. return use_named_skin_binds;
  159. }
  160. void GLTFState::set_use_named_skin_binds(bool p_use_named_skin_binds) {
  161. use_named_skin_binds = p_use_named_skin_binds;
  162. }
  163. TypedArray<GLTFNode> GLTFState::get_nodes() {
  164. return GLTFTemplateConvert::to_array(nodes);
  165. }
  166. void GLTFState::set_nodes(TypedArray<GLTFNode> p_nodes) {
  167. GLTFTemplateConvert::set_from_array(nodes, p_nodes);
  168. }
  169. TypedArray<PackedByteArray> GLTFState::get_buffers() {
  170. return GLTFTemplateConvert::to_array(buffers);
  171. }
  172. void GLTFState::set_buffers(TypedArray<PackedByteArray> p_buffers) {
  173. GLTFTemplateConvert::set_from_array(buffers, p_buffers);
  174. }
  175. TypedArray<GLTFBufferView> GLTFState::get_buffer_views() {
  176. return GLTFTemplateConvert::to_array(buffer_views);
  177. }
  178. void GLTFState::set_buffer_views(TypedArray<GLTFBufferView> p_buffer_views) {
  179. GLTFTemplateConvert::set_from_array(buffer_views, p_buffer_views);
  180. }
  181. TypedArray<GLTFAccessor> GLTFState::get_accessors() {
  182. return GLTFTemplateConvert::to_array(accessors);
  183. }
  184. void GLTFState::set_accessors(TypedArray<GLTFAccessor> p_accessors) {
  185. GLTFTemplateConvert::set_from_array(accessors, p_accessors);
  186. }
  187. TypedArray<GLTFMesh> GLTFState::get_meshes() {
  188. return GLTFTemplateConvert::to_array(meshes);
  189. }
  190. void GLTFState::set_meshes(TypedArray<GLTFMesh> p_meshes) {
  191. GLTFTemplateConvert::set_from_array(meshes, p_meshes);
  192. }
  193. TypedArray<Material> GLTFState::get_materials() {
  194. return GLTFTemplateConvert::to_array(materials);
  195. }
  196. void GLTFState::set_materials(TypedArray<Material> p_materials) {
  197. GLTFTemplateConvert::set_from_array(materials, p_materials);
  198. }
  199. String GLTFState::get_scene_name() {
  200. return scene_name;
  201. }
  202. void GLTFState::set_scene_name(String p_scene_name) {
  203. scene_name = p_scene_name;
  204. }
  205. PackedInt32Array GLTFState::get_root_nodes() {
  206. return root_nodes;
  207. }
  208. void GLTFState::set_root_nodes(PackedInt32Array p_root_nodes) {
  209. root_nodes = p_root_nodes;
  210. }
  211. TypedArray<GLTFTexture> GLTFState::get_textures() {
  212. return GLTFTemplateConvert::to_array(textures);
  213. }
  214. void GLTFState::set_textures(TypedArray<GLTFTexture> p_textures) {
  215. GLTFTemplateConvert::set_from_array(textures, p_textures);
  216. }
  217. TypedArray<GLTFTextureSampler> GLTFState::get_texture_samplers() {
  218. return GLTFTemplateConvert::to_array(texture_samplers);
  219. }
  220. void GLTFState::set_texture_samplers(TypedArray<GLTFTextureSampler> p_texture_samplers) {
  221. GLTFTemplateConvert::set_from_array(texture_samplers, p_texture_samplers);
  222. }
  223. TypedArray<Texture2D> GLTFState::get_images() {
  224. return GLTFTemplateConvert::to_array(images);
  225. }
  226. void GLTFState::set_images(TypedArray<Texture2D> p_images) {
  227. GLTFTemplateConvert::set_from_array(images, p_images);
  228. }
  229. TypedArray<GLTFSkin> GLTFState::get_skins() {
  230. return GLTFTemplateConvert::to_array(skins);
  231. }
  232. void GLTFState::set_skins(TypedArray<GLTFSkin> p_skins) {
  233. GLTFTemplateConvert::set_from_array(skins, p_skins);
  234. }
  235. TypedArray<GLTFCamera> GLTFState::get_cameras() {
  236. return GLTFTemplateConvert::to_array(cameras);
  237. }
  238. void GLTFState::set_cameras(TypedArray<GLTFCamera> p_cameras) {
  239. GLTFTemplateConvert::set_from_array(cameras, p_cameras);
  240. }
  241. TypedArray<GLTFLight> GLTFState::get_lights() {
  242. return GLTFTemplateConvert::to_array(lights);
  243. }
  244. void GLTFState::set_lights(TypedArray<GLTFLight> p_lights) {
  245. GLTFTemplateConvert::set_from_array(lights, p_lights);
  246. }
  247. TypedArray<String> GLTFState::get_unique_names() {
  248. return GLTFTemplateConvert::to_array(unique_names);
  249. }
  250. void GLTFState::set_unique_names(TypedArray<String> p_unique_names) {
  251. GLTFTemplateConvert::set_from_array(unique_names, p_unique_names);
  252. }
  253. TypedArray<String> GLTFState::get_unique_animation_names() {
  254. return GLTFTemplateConvert::to_array(unique_animation_names);
  255. }
  256. void GLTFState::set_unique_animation_names(TypedArray<String> p_unique_animation_names) {
  257. GLTFTemplateConvert::set_from_array(unique_animation_names, p_unique_animation_names);
  258. }
  259. TypedArray<GLTFSkeleton> GLTFState::get_skeletons() {
  260. return GLTFTemplateConvert::to_array(skeletons);
  261. }
  262. void GLTFState::set_skeletons(TypedArray<GLTFSkeleton> p_skeletons) {
  263. GLTFTemplateConvert::set_from_array(skeletons, p_skeletons);
  264. }
  265. bool GLTFState::get_create_animations() {
  266. return create_animations;
  267. }
  268. void GLTFState::set_create_animations(bool p_create_animations) {
  269. create_animations = p_create_animations;
  270. }
  271. TypedArray<GLTFAnimation> GLTFState::get_animations() {
  272. return GLTFTemplateConvert::to_array(animations);
  273. }
  274. void GLTFState::set_animations(TypedArray<GLTFAnimation> p_animations) {
  275. GLTFTemplateConvert::set_from_array(animations, p_animations);
  276. }
  277. Node *GLTFState::get_scene_node(GLTFNodeIndex idx) {
  278. if (!scene_nodes.has(idx)) {
  279. return nullptr;
  280. }
  281. return scene_nodes[idx];
  282. }
  283. GLTFNodeIndex GLTFState::get_node_index(Node *p_node) {
  284. for (KeyValue<GLTFNodeIndex, Node *> x : scene_nodes) {
  285. if (x.value == p_node) {
  286. return x.key;
  287. }
  288. }
  289. return -1;
  290. }
  291. int GLTFState::get_animation_players_count(int idx) {
  292. return animation_players.size();
  293. }
  294. AnimationPlayer *GLTFState::get_animation_player(int idx) {
  295. ERR_FAIL_INDEX_V(idx, animation_players.size(), nullptr);
  296. return animation_players[idx];
  297. }
  298. void GLTFState::set_discard_meshes_and_materials(bool p_discard_meshes_and_materials) {
  299. discard_meshes_and_materials = p_discard_meshes_and_materials;
  300. }
  301. bool GLTFState::get_discard_meshes_and_materials() {
  302. return discard_meshes_and_materials;
  303. }
  304. String GLTFState::get_base_path() {
  305. return base_path;
  306. }
  307. void GLTFState::set_base_path(String p_base_path) {
  308. base_path = p_base_path;
  309. }
  310. Variant GLTFState::get_additional_data(const StringName &p_extension_name) {
  311. return additional_data[p_extension_name];
  312. }
  313. void GLTFState::set_additional_data(const StringName &p_extension_name, Variant p_additional_data) {
  314. additional_data[p_extension_name] = p_additional_data;
  315. }