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 | |
31 | #include "gltf_state.h" |
32 | |
33 | #include "gltf_template_convert.h" |
34 | |
35 | void GLTFState::_bind_methods() { |
36 | ClassDB::bind_method(D_METHOD("add_used_extension" , "extension_name" , "required" ), &GLTFState::add_used_extension); |
37 | ClassDB::bind_method(D_METHOD("get_json" ), &GLTFState::get_json); |
38 | ClassDB::bind_method(D_METHOD("set_json" , "json" ), &GLTFState::set_json); |
39 | ClassDB::bind_method(D_METHOD("get_major_version" ), &GLTFState::get_major_version); |
40 | ClassDB::bind_method(D_METHOD("set_major_version" , "major_version" ), &GLTFState::set_major_version); |
41 | ClassDB::bind_method(D_METHOD("get_minor_version" ), &GLTFState::get_minor_version); |
42 | ClassDB::bind_method(D_METHOD("set_minor_version" , "minor_version" ), &GLTFState::set_minor_version); |
43 | ClassDB::bind_method(D_METHOD("get_copyright" ), &GLTFState::get_copyright); |
44 | ClassDB::bind_method(D_METHOD("set_copyright" , "copyright" ), &GLTFState::set_copyright); |
45 | ClassDB::bind_method(D_METHOD("get_glb_data" ), &GLTFState::get_glb_data); |
46 | ClassDB::bind_method(D_METHOD("set_glb_data" , "glb_data" ), &GLTFState::set_glb_data); |
47 | ClassDB::bind_method(D_METHOD("get_use_named_skin_binds" ), &GLTFState::get_use_named_skin_binds); |
48 | ClassDB::bind_method(D_METHOD("set_use_named_skin_binds" , "use_named_skin_binds" ), &GLTFState::set_use_named_skin_binds); |
49 | ClassDB::bind_method(D_METHOD("get_nodes" ), &GLTFState::get_nodes); |
50 | ClassDB::bind_method(D_METHOD("set_nodes" , "nodes" ), &GLTFState::set_nodes); |
51 | ClassDB::bind_method(D_METHOD("get_buffers" ), &GLTFState::get_buffers); |
52 | ClassDB::bind_method(D_METHOD("set_buffers" , "buffers" ), &GLTFState::set_buffers); |
53 | ClassDB::bind_method(D_METHOD("get_buffer_views" ), &GLTFState::get_buffer_views); |
54 | ClassDB::bind_method(D_METHOD("set_buffer_views" , "buffer_views" ), &GLTFState::set_buffer_views); |
55 | ClassDB::bind_method(D_METHOD("get_accessors" ), &GLTFState::get_accessors); |
56 | ClassDB::bind_method(D_METHOD("set_accessors" , "accessors" ), &GLTFState::set_accessors); |
57 | ClassDB::bind_method(D_METHOD("get_meshes" ), &GLTFState::get_meshes); |
58 | ClassDB::bind_method(D_METHOD("set_meshes" , "meshes" ), &GLTFState::set_meshes); |
59 | ClassDB::bind_method(D_METHOD("get_animation_players_count" , "idx" ), &GLTFState::get_animation_players_count); |
60 | ClassDB::bind_method(D_METHOD("get_animation_player" , "idx" ), &GLTFState::get_animation_player); |
61 | ClassDB::bind_method(D_METHOD("get_materials" ), &GLTFState::get_materials); |
62 | ClassDB::bind_method(D_METHOD("set_materials" , "materials" ), &GLTFState::set_materials); |
63 | ClassDB::bind_method(D_METHOD("get_scene_name" ), &GLTFState::get_scene_name); |
64 | ClassDB::bind_method(D_METHOD("set_scene_name" , "scene_name" ), &GLTFState::set_scene_name); |
65 | ClassDB::bind_method(D_METHOD("get_base_path" ), &GLTFState::get_base_path); |
66 | ClassDB::bind_method(D_METHOD("set_base_path" , "base_path" ), &GLTFState::set_base_path); |
67 | ClassDB::bind_method(D_METHOD("get_filename" ), &GLTFState::get_filename); |
68 | ClassDB::bind_method(D_METHOD("set_filename" , "filename" ), &GLTFState::set_filename); |
69 | ClassDB::bind_method(D_METHOD("get_root_nodes" ), &GLTFState::get_root_nodes); |
70 | ClassDB::bind_method(D_METHOD("set_root_nodes" , "root_nodes" ), &GLTFState::set_root_nodes); |
71 | ClassDB::bind_method(D_METHOD("get_textures" ), &GLTFState::get_textures); |
72 | ClassDB::bind_method(D_METHOD("set_textures" , "textures" ), &GLTFState::set_textures); |
73 | ClassDB::bind_method(D_METHOD("get_texture_samplers" ), &GLTFState::get_texture_samplers); |
74 | ClassDB::bind_method(D_METHOD("set_texture_samplers" , "texture_samplers" ), &GLTFState::set_texture_samplers); |
75 | ClassDB::bind_method(D_METHOD("get_images" ), &GLTFState::get_images); |
76 | ClassDB::bind_method(D_METHOD("set_images" , "images" ), &GLTFState::set_images); |
77 | ClassDB::bind_method(D_METHOD("get_skins" ), &GLTFState::get_skins); |
78 | ClassDB::bind_method(D_METHOD("set_skins" , "skins" ), &GLTFState::set_skins); |
79 | ClassDB::bind_method(D_METHOD("get_cameras" ), &GLTFState::get_cameras); |
80 | ClassDB::bind_method(D_METHOD("set_cameras" , "cameras" ), &GLTFState::set_cameras); |
81 | ClassDB::bind_method(D_METHOD("get_lights" ), &GLTFState::get_lights); |
82 | ClassDB::bind_method(D_METHOD("set_lights" , "lights" ), &GLTFState::set_lights); |
83 | ClassDB::bind_method(D_METHOD("get_unique_names" ), &GLTFState::get_unique_names); |
84 | ClassDB::bind_method(D_METHOD("set_unique_names" , "unique_names" ), &GLTFState::set_unique_names); |
85 | ClassDB::bind_method(D_METHOD("get_unique_animation_names" ), &GLTFState::get_unique_animation_names); |
86 | ClassDB::bind_method(D_METHOD("set_unique_animation_names" , "unique_animation_names" ), &GLTFState::set_unique_animation_names); |
87 | ClassDB::bind_method(D_METHOD("get_skeletons" ), &GLTFState::get_skeletons); |
88 | ClassDB::bind_method(D_METHOD("set_skeletons" , "skeletons" ), &GLTFState::set_skeletons); |
89 | ClassDB::bind_method(D_METHOD("get_create_animations" ), &GLTFState::get_create_animations); |
90 | ClassDB::bind_method(D_METHOD("set_create_animations" , "create_animations" ), &GLTFState::set_create_animations); |
91 | ClassDB::bind_method(D_METHOD("get_animations" ), &GLTFState::get_animations); |
92 | ClassDB::bind_method(D_METHOD("set_animations" , "animations" ), &GLTFState::set_animations); |
93 | ClassDB::bind_method(D_METHOD("get_scene_node" , "idx" ), &GLTFState::get_scene_node); |
94 | ClassDB::bind_method(D_METHOD("get_node_index" , "scene_node" ), &GLTFState::get_node_index); |
95 | ClassDB::bind_method(D_METHOD("get_additional_data" , "extension_name" ), &GLTFState::get_additional_data); |
96 | ClassDB::bind_method(D_METHOD("set_additional_data" , "extension_name" , "additional_data" ), &GLTFState::set_additional_data); |
97 | ClassDB::bind_method(D_METHOD("get_handle_binary_image" ), &GLTFState::get_handle_binary_image); |
98 | ClassDB::bind_method(D_METHOD("set_handle_binary_image" , "method" ), &GLTFState::set_handle_binary_image); |
99 | |
100 | ADD_PROPERTY(PropertyInfo(Variant::DICTIONARY, "json" ), "set_json" , "get_json" ); // Dictionary |
101 | ADD_PROPERTY(PropertyInfo(Variant::INT, "major_version" ), "set_major_version" , "get_major_version" ); // int |
102 | ADD_PROPERTY(PropertyInfo(Variant::INT, "minor_version" ), "set_minor_version" , "get_minor_version" ); // int |
103 | ADD_PROPERTY(PropertyInfo(Variant::STRING, "copyright" ), "set_copyright" , "get_copyright" ); // String |
104 | ADD_PROPERTY(PropertyInfo(Variant::PACKED_BYTE_ARRAY, "glb_data" ), "set_glb_data" , "get_glb_data" ); // Vector<uint8_t> |
105 | ADD_PROPERTY(PropertyInfo(Variant::BOOL, "use_named_skin_binds" ), "set_use_named_skin_binds" , "get_use_named_skin_binds" ); // bool |
106 | 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>> |
107 | ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "buffers" ), "set_buffers" , "get_buffers" ); // Vector<Vector<uint8_t> |
108 | 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>> |
109 | 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>> |
110 | 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>> |
111 | 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> |
112 | ADD_PROPERTY(PropertyInfo(Variant::STRING, "scene_name" ), "set_scene_name" , "get_scene_name" ); // String |
113 | ADD_PROPERTY(PropertyInfo(Variant::STRING, "base_path" ), "set_base_path" , "get_base_path" ); // String |
114 | ADD_PROPERTY(PropertyInfo(Variant::STRING, "filename" ), "set_filename" , "get_filename" ); // String |
115 | ADD_PROPERTY(PropertyInfo(Variant::PACKED_INT32_ARRAY, "root_nodes" ), "set_root_nodes" , "get_root_nodes" ); // Vector<int> |
116 | 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>> |
117 | 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>> |
118 | 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> |
119 | 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>> |
120 | 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>> |
121 | 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>> |
122 | 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> |
123 | 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> |
124 | 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>> |
125 | ADD_PROPERTY(PropertyInfo(Variant::BOOL, "create_animations" ), "set_create_animations" , "get_create_animations" ); // bool |
126 | 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>> |
127 | 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 |
128 | |
129 | BIND_CONSTANT(HANDLE_BINARY_DISCARD_TEXTURES); |
130 | BIND_CONSTANT(HANDLE_BINARY_EXTRACT_TEXTURES); |
131 | BIND_CONSTANT(HANDLE_BINARY_EMBED_AS_BASISU); |
132 | BIND_CONSTANT(HANDLE_BINARY_EMBED_AS_UNCOMPRESSED); |
133 | } |
134 | |
135 | void GLTFState::add_used_extension(const String &p_extension_name, bool p_required) { |
136 | if (!extensions_used.has(p_extension_name)) { |
137 | extensions_used.push_back(p_extension_name); |
138 | } |
139 | if (p_required) { |
140 | if (!extensions_required.has(p_extension_name)) { |
141 | extensions_required.push_back(p_extension_name); |
142 | } |
143 | } |
144 | } |
145 | |
146 | Dictionary GLTFState::get_json() { |
147 | return json; |
148 | } |
149 | |
150 | void GLTFState::set_json(Dictionary p_json) { |
151 | json = p_json; |
152 | } |
153 | |
154 | int GLTFState::get_major_version() { |
155 | return major_version; |
156 | } |
157 | |
158 | void GLTFState::set_major_version(int p_major_version) { |
159 | major_version = p_major_version; |
160 | } |
161 | |
162 | int GLTFState::get_minor_version() { |
163 | return minor_version; |
164 | } |
165 | |
166 | void GLTFState::set_minor_version(int p_minor_version) { |
167 | minor_version = p_minor_version; |
168 | } |
169 | |
170 | String GLTFState::get_copyright() const { |
171 | return copyright; |
172 | } |
173 | |
174 | void GLTFState::set_copyright(const String &p_copyright) { |
175 | copyright = p_copyright; |
176 | } |
177 | |
178 | Vector<uint8_t> GLTFState::get_glb_data() { |
179 | return glb_data; |
180 | } |
181 | |
182 | void GLTFState::set_glb_data(Vector<uint8_t> p_glb_data) { |
183 | glb_data = p_glb_data; |
184 | } |
185 | |
186 | bool GLTFState::get_use_named_skin_binds() { |
187 | return use_named_skin_binds; |
188 | } |
189 | |
190 | void GLTFState::set_use_named_skin_binds(bool p_use_named_skin_binds) { |
191 | use_named_skin_binds = p_use_named_skin_binds; |
192 | } |
193 | |
194 | TypedArray<GLTFNode> GLTFState::get_nodes() { |
195 | return GLTFTemplateConvert::to_array(nodes); |
196 | } |
197 | |
198 | void GLTFState::set_nodes(TypedArray<GLTFNode> p_nodes) { |
199 | GLTFTemplateConvert::set_from_array(nodes, p_nodes); |
200 | } |
201 | |
202 | TypedArray<PackedByteArray> GLTFState::get_buffers() { |
203 | return GLTFTemplateConvert::to_array(buffers); |
204 | } |
205 | |
206 | void GLTFState::set_buffers(TypedArray<PackedByteArray> p_buffers) { |
207 | GLTFTemplateConvert::set_from_array(buffers, p_buffers); |
208 | } |
209 | |
210 | TypedArray<GLTFBufferView> GLTFState::get_buffer_views() { |
211 | return GLTFTemplateConvert::to_array(buffer_views); |
212 | } |
213 | |
214 | void GLTFState::set_buffer_views(TypedArray<GLTFBufferView> p_buffer_views) { |
215 | GLTFTemplateConvert::set_from_array(buffer_views, p_buffer_views); |
216 | } |
217 | |
218 | TypedArray<GLTFAccessor> GLTFState::get_accessors() { |
219 | return GLTFTemplateConvert::to_array(accessors); |
220 | } |
221 | |
222 | void GLTFState::set_accessors(TypedArray<GLTFAccessor> p_accessors) { |
223 | GLTFTemplateConvert::set_from_array(accessors, p_accessors); |
224 | } |
225 | |
226 | TypedArray<GLTFMesh> GLTFState::get_meshes() { |
227 | return GLTFTemplateConvert::to_array(meshes); |
228 | } |
229 | |
230 | void GLTFState::set_meshes(TypedArray<GLTFMesh> p_meshes) { |
231 | GLTFTemplateConvert::set_from_array(meshes, p_meshes); |
232 | } |
233 | |
234 | TypedArray<Material> GLTFState::get_materials() { |
235 | return GLTFTemplateConvert::to_array(materials); |
236 | } |
237 | |
238 | void GLTFState::set_materials(TypedArray<Material> p_materials) { |
239 | GLTFTemplateConvert::set_from_array(materials, p_materials); |
240 | } |
241 | |
242 | String GLTFState::get_scene_name() { |
243 | return scene_name; |
244 | } |
245 | |
246 | void GLTFState::set_scene_name(String p_scene_name) { |
247 | scene_name = p_scene_name; |
248 | } |
249 | |
250 | PackedInt32Array GLTFState::get_root_nodes() { |
251 | return root_nodes; |
252 | } |
253 | |
254 | void GLTFState::set_root_nodes(PackedInt32Array p_root_nodes) { |
255 | root_nodes = p_root_nodes; |
256 | } |
257 | |
258 | TypedArray<GLTFTexture> GLTFState::get_textures() { |
259 | return GLTFTemplateConvert::to_array(textures); |
260 | } |
261 | |
262 | void GLTFState::set_textures(TypedArray<GLTFTexture> p_textures) { |
263 | GLTFTemplateConvert::set_from_array(textures, p_textures); |
264 | } |
265 | |
266 | TypedArray<GLTFTextureSampler> GLTFState::get_texture_samplers() { |
267 | return GLTFTemplateConvert::to_array(texture_samplers); |
268 | } |
269 | |
270 | void GLTFState::set_texture_samplers(TypedArray<GLTFTextureSampler> p_texture_samplers) { |
271 | GLTFTemplateConvert::set_from_array(texture_samplers, p_texture_samplers); |
272 | } |
273 | |
274 | TypedArray<Texture2D> GLTFState::get_images() { |
275 | return GLTFTemplateConvert::to_array(images); |
276 | } |
277 | |
278 | void GLTFState::set_images(TypedArray<Texture2D> p_images) { |
279 | GLTFTemplateConvert::set_from_array(images, p_images); |
280 | } |
281 | |
282 | TypedArray<GLTFSkin> GLTFState::get_skins() { |
283 | return GLTFTemplateConvert::to_array(skins); |
284 | } |
285 | |
286 | void GLTFState::set_skins(TypedArray<GLTFSkin> p_skins) { |
287 | GLTFTemplateConvert::set_from_array(skins, p_skins); |
288 | } |
289 | |
290 | TypedArray<GLTFCamera> GLTFState::get_cameras() { |
291 | return GLTFTemplateConvert::to_array(cameras); |
292 | } |
293 | |
294 | void GLTFState::set_cameras(TypedArray<GLTFCamera> p_cameras) { |
295 | GLTFTemplateConvert::set_from_array(cameras, p_cameras); |
296 | } |
297 | |
298 | TypedArray<GLTFLight> GLTFState::get_lights() { |
299 | return GLTFTemplateConvert::to_array(lights); |
300 | } |
301 | |
302 | void GLTFState::set_lights(TypedArray<GLTFLight> p_lights) { |
303 | GLTFTemplateConvert::set_from_array(lights, p_lights); |
304 | } |
305 | |
306 | TypedArray<String> GLTFState::get_unique_names() { |
307 | return GLTFTemplateConvert::to_array(unique_names); |
308 | } |
309 | |
310 | void GLTFState::set_unique_names(TypedArray<String> p_unique_names) { |
311 | GLTFTemplateConvert::set_from_array(unique_names, p_unique_names); |
312 | } |
313 | |
314 | TypedArray<String> GLTFState::get_unique_animation_names() { |
315 | return GLTFTemplateConvert::to_array(unique_animation_names); |
316 | } |
317 | |
318 | void GLTFState::set_unique_animation_names(TypedArray<String> p_unique_animation_names) { |
319 | GLTFTemplateConvert::set_from_array(unique_animation_names, p_unique_animation_names); |
320 | } |
321 | |
322 | TypedArray<GLTFSkeleton> GLTFState::get_skeletons() { |
323 | return GLTFTemplateConvert::to_array(skeletons); |
324 | } |
325 | |
326 | void GLTFState::set_skeletons(TypedArray<GLTFSkeleton> p_skeletons) { |
327 | GLTFTemplateConvert::set_from_array(skeletons, p_skeletons); |
328 | } |
329 | |
330 | bool GLTFState::get_create_animations() { |
331 | return create_animations; |
332 | } |
333 | |
334 | void GLTFState::set_create_animations(bool p_create_animations) { |
335 | create_animations = p_create_animations; |
336 | } |
337 | |
338 | TypedArray<GLTFAnimation> GLTFState::get_animations() { |
339 | return GLTFTemplateConvert::to_array(animations); |
340 | } |
341 | |
342 | void GLTFState::set_animations(TypedArray<GLTFAnimation> p_animations) { |
343 | GLTFTemplateConvert::set_from_array(animations, p_animations); |
344 | } |
345 | |
346 | Node *GLTFState::get_scene_node(GLTFNodeIndex idx) { |
347 | if (!scene_nodes.has(idx)) { |
348 | return nullptr; |
349 | } |
350 | return scene_nodes[idx]; |
351 | } |
352 | |
353 | GLTFNodeIndex GLTFState::get_node_index(Node *p_node) { |
354 | for (KeyValue<GLTFNodeIndex, Node *> x : scene_nodes) { |
355 | if (x.value == p_node) { |
356 | return x.key; |
357 | } |
358 | } |
359 | return -1; |
360 | } |
361 | |
362 | int GLTFState::get_animation_players_count(int idx) { |
363 | return animation_players.size(); |
364 | } |
365 | |
366 | AnimationPlayer *GLTFState::get_animation_player(int idx) { |
367 | ERR_FAIL_INDEX_V(idx, animation_players.size(), nullptr); |
368 | return animation_players[idx]; |
369 | } |
370 | |
371 | void GLTFState::set_discard_meshes_and_materials(bool p_discard_meshes_and_materials) { |
372 | discard_meshes_and_materials = p_discard_meshes_and_materials; |
373 | } |
374 | |
375 | bool GLTFState::get_discard_meshes_and_materials() { |
376 | return discard_meshes_and_materials; |
377 | } |
378 | |
379 | String GLTFState::get_base_path() { |
380 | return base_path; |
381 | } |
382 | |
383 | void GLTFState::set_base_path(String p_base_path) { |
384 | base_path = p_base_path; |
385 | } |
386 | |
387 | String GLTFState::get_filename() const { |
388 | return filename; |
389 | } |
390 | |
391 | void GLTFState::set_filename(const String &p_filename) { |
392 | filename = p_filename; |
393 | } |
394 | |
395 | Variant GLTFState::get_additional_data(const StringName &p_extension_name) { |
396 | return additional_data[p_extension_name]; |
397 | } |
398 | |
399 | void GLTFState::set_additional_data(const StringName &p_extension_name, Variant p_additional_data) { |
400 | additional_data[p_extension_name] = p_additional_data; |
401 | } |
402 | |