Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
godotengine
GitHub Repository: godotengine/godot
Path: blob/master/modules/gltf/gltf_document.h
10277 views
1
/**************************************************************************/
2
/* gltf_document.h */
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
#pragma once
32
33
#include "extensions/gltf_document_extension.h"
34
#include "extensions/gltf_spec_gloss.h"
35
#include "gltf_defines.h"
36
#include "gltf_state.h"
37
38
#include "scene/3d/mesh_instance_3d.h"
39
#include "scene/3d/multimesh_instance_3d.h"
40
41
class CSGShape3D;
42
class GridMap;
43
44
class GLTFDocument : public Resource {
45
GDCLASS(GLTFDocument, Resource);
46
47
public:
48
const int32_t JOINT_GROUP_SIZE = 4;
49
50
enum {
51
ARRAY_BUFFER = 34962,
52
ELEMENT_ARRAY_BUFFER = 34963,
53
};
54
enum {
55
TEXTURE_TYPE_GENERIC = 0,
56
TEXTURE_TYPE_NORMAL = 1,
57
};
58
enum RootNodeMode {
59
ROOT_NODE_MODE_SINGLE_ROOT,
60
ROOT_NODE_MODE_KEEP_ROOT,
61
ROOT_NODE_MODE_MULTI_ROOT,
62
};
63
enum VisibilityMode {
64
VISIBILITY_MODE_INCLUDE_REQUIRED,
65
VISIBILITY_MODE_INCLUDE_OPTIONAL,
66
VISIBILITY_MODE_EXCLUDE,
67
};
68
69
private:
70
int _naming_version = 2;
71
String _image_format = "PNG";
72
float _lossy_quality = 0.75f;
73
String _fallback_image_format = "None";
74
float _fallback_image_quality = 0.25f;
75
Ref<GLTFDocumentExtension> _image_save_extension;
76
RootNodeMode _root_node_mode = RootNodeMode::ROOT_NODE_MODE_SINGLE_ROOT;
77
VisibilityMode _visibility_mode = VisibilityMode::VISIBILITY_MODE_INCLUDE_REQUIRED;
78
79
protected:
80
static void _bind_methods();
81
String _gen_unique_name(Ref<GLTFState> p_state, const String &p_name);
82
static Vector<Ref<GLTFDocumentExtension>> all_document_extensions;
83
Vector<Ref<GLTFDocumentExtension>> document_extensions;
84
85
public:
86
static void register_gltf_document_extension(Ref<GLTFDocumentExtension> p_extension, bool p_first_priority = false);
87
static void unregister_gltf_document_extension(Ref<GLTFDocumentExtension> p_extension);
88
static void unregister_all_gltf_document_extensions();
89
static Vector<Ref<GLTFDocumentExtension>> get_all_gltf_document_extensions();
90
static Vector<String> get_supported_gltf_extensions();
91
static HashSet<String> get_supported_gltf_extensions_hashset();
92
93
static NodePath _find_material_node_path(Ref<GLTFState> p_state, Ref<Material> p_material);
94
static Ref<GLTFObjectModelProperty> import_object_model_property(Ref<GLTFState> p_state, const String &p_json_pointer);
95
static Ref<GLTFObjectModelProperty> export_object_model_property(Ref<GLTFState> p_state, const NodePath &p_node_path, const Node *p_godot_node, GLTFNodeIndex p_gltf_node_index);
96
97
void set_naming_version(int p_version);
98
int get_naming_version() const;
99
void set_image_format(const String &p_image_format);
100
String get_image_format() const;
101
void set_lossy_quality(float p_lossy_quality);
102
float get_lossy_quality() const;
103
void set_fallback_image_format(const String &p_fallback_image_format);
104
String get_fallback_image_format() const;
105
void set_fallback_image_quality(float p_fallback_image_quality);
106
float get_fallback_image_quality() const;
107
void set_root_node_mode(RootNodeMode p_root_node_mode);
108
RootNodeMode get_root_node_mode() const;
109
void set_visibility_mode(VisibilityMode p_visibility_mode);
110
VisibilityMode get_visibility_mode() const;
111
static String _gen_unique_name_static(HashSet<String> &r_unique_names, const String &p_name);
112
113
private:
114
void _build_parent_hierarchy(Ref<GLTFState> p_state);
115
double _filter_number(double p_float);
116
void _round_min_max_components(Vector<double> &r_type_min, Vector<double> &r_type_max);
117
String _get_component_type_name(const GLTFAccessor::GLTFComponentType p_component_type);
118
int _get_component_type_size(const GLTFAccessor::GLTFComponentType p_component_type);
119
Error _parse_scenes(Ref<GLTFState> p_state);
120
Error _parse_nodes(Ref<GLTFState> p_state);
121
String _get_accessor_type_name(const GLTFAccessor::GLTFAccessorType p_accessor_type);
122
String _sanitize_animation_name(const String &p_name);
123
String _gen_unique_animation_name(Ref<GLTFState> p_state, const String &p_name);
124
String _sanitize_bone_name(const String &p_name);
125
String _gen_unique_bone_name(Ref<GLTFState> p_state,
126
const GLTFSkeletonIndex p_skel_i,
127
const String &p_name);
128
GLTFTextureIndex _set_texture(Ref<GLTFState> p_state, Ref<Texture2D> p_texture,
129
StandardMaterial3D::TextureFilter p_filter_mode, bool p_repeats);
130
Ref<Texture2D> _get_texture(Ref<GLTFState> p_state,
131
const GLTFTextureIndex p_texture, int p_texture_type);
132
GLTFTextureSamplerIndex _set_sampler_for_mode(Ref<GLTFState> p_state,
133
StandardMaterial3D::TextureFilter p_filter_mode, bool p_repeats);
134
Ref<GLTFTextureSampler> _get_sampler_for_texture(Ref<GLTFState> p_state,
135
const GLTFTextureIndex p_texture);
136
Error _parse_json(const String &p_path, Ref<GLTFState> p_state);
137
Error _parse_glb(Ref<FileAccess> p_file, Ref<GLTFState> p_state);
138
void _compute_node_heights(Ref<GLTFState> p_state);
139
Error _parse_buffers(Ref<GLTFState> p_state, const String &p_base_path);
140
Error _parse_buffer_views(Ref<GLTFState> p_state);
141
GLTFAccessor::GLTFAccessorType _get_accessor_type_from_str(const String &p_string);
142
Error _parse_accessors(Ref<GLTFState> p_state);
143
Error _decode_buffer_view(Ref<GLTFState> p_state, double *p_dst,
144
const GLTFBufferViewIndex p_buffer_view,
145
const int64_t p_skip_every, const int64_t p_skip_bytes,
146
const int64_t p_element_size, const int64_t p_count,
147
const GLTFAccessor::GLTFAccessorType p_accessor_type, const int64_t p_component_count,
148
const GLTFAccessor::GLTFComponentType p_component_type, const int64_t p_component_size,
149
const bool p_normalized, const int64_t p_byte_offset,
150
const bool p_for_vertex);
151
Vector<double> _decode_accessor(Ref<GLTFState> p_state,
152
const GLTFAccessorIndex p_accessor,
153
const bool p_for_vertex);
154
Vector<float> _decode_accessor_as_floats(Ref<GLTFState> p_state,
155
const GLTFAccessorIndex p_accessor,
156
const bool p_for_vertex,
157
const Vector<int> &p_packed_vertex_ids = Vector<int>());
158
Vector<int> _decode_accessor_as_ints(Ref<GLTFState> p_state,
159
const GLTFAccessorIndex p_accessor,
160
const bool p_for_vertex,
161
const Vector<int> &p_packed_vertex_ids = Vector<int>());
162
Vector<Vector2> _decode_accessor_as_vec2(Ref<GLTFState> p_state,
163
const GLTFAccessorIndex p_accessor,
164
const bool p_for_vertex,
165
const Vector<int> &p_packed_vertex_ids = Vector<int>());
166
Vector<Vector3> _decode_accessor_as_vec3(Ref<GLTFState> p_state,
167
const GLTFAccessorIndex p_accessor,
168
const bool p_for_vertex,
169
const Vector<int> &p_packed_vertex_ids = Vector<int>());
170
Vector<Color> _decode_accessor_as_color(Ref<GLTFState> p_state,
171
const GLTFAccessorIndex p_accessor,
172
const bool p_for_vertex,
173
const Vector<int> &p_packed_vertex_ids = Vector<int>());
174
Vector<Quaternion> _decode_accessor_as_quaternion(Ref<GLTFState> p_state,
175
const GLTFAccessorIndex p_accessor,
176
const bool p_for_vertex);
177
Vector<Transform2D> _decode_accessor_as_xform2d(Ref<GLTFState> p_state,
178
const GLTFAccessorIndex p_accessor,
179
const bool p_for_vertex);
180
Vector<Basis> _decode_accessor_as_basis(Ref<GLTFState> p_state,
181
const GLTFAccessorIndex p_accessor,
182
const bool p_for_vertex);
183
Vector<Transform3D> _decode_accessor_as_xform(Ref<GLTFState> p_state,
184
const GLTFAccessorIndex p_accessor,
185
const bool p_for_vertex);
186
Vector<Variant> _decode_accessor_as_variant(Ref<GLTFState> p_state,
187
const GLTFAccessorIndex p_accessor,
188
Variant::Type p_variant_type,
189
GLTFAccessor::GLTFAccessorType p_accessor_type);
190
GLTFAccessorIndex _encode_accessor_as_variant(Ref<GLTFState> p_state,
191
Vector<Variant> p_attribs,
192
Variant::Type p_variant_type,
193
GLTFAccessor::GLTFAccessorType p_accessor_type,
194
GLTFAccessor::GLTFComponentType p_component_type = GLTFAccessor::COMPONENT_TYPE_SINGLE_FLOAT);
195
Error _parse_meshes(Ref<GLTFState> p_state);
196
Error _serialize_textures(Ref<GLTFState> p_state);
197
Error _serialize_texture_samplers(Ref<GLTFState> p_state);
198
Error _serialize_images(Ref<GLTFState> p_state);
199
Dictionary _serialize_image(Ref<GLTFState> p_state, Ref<Image> p_image, const String &p_image_format, float p_lossy_quality, Ref<GLTFDocumentExtension> p_image_save_extension);
200
Error _serialize_lights(Ref<GLTFState> p_state);
201
Ref<Image> _parse_image_bytes_into_image(Ref<GLTFState> p_state, const Vector<uint8_t> &p_bytes, const String &p_mime_type, int p_index, String &r_file_extension);
202
void _parse_image_save_image(Ref<GLTFState> p_state, const Vector<uint8_t> &p_bytes, const String &p_resource_uri, const String &p_file_extension, int p_index, Ref<Image> p_image);
203
Error _parse_images(Ref<GLTFState> p_state, const String &p_base_path);
204
Error _parse_textures(Ref<GLTFState> p_state);
205
Error _parse_texture_samplers(Ref<GLTFState> p_state);
206
Error _parse_materials(Ref<GLTFState> p_state);
207
void _set_texture_transform_uv1(const Dictionary &d, Ref<BaseMaterial3D> p_material);
208
void spec_gloss_to_rough_metal(Ref<GLTFSpecGloss> r_spec_gloss,
209
Ref<BaseMaterial3D> p_material);
210
static void spec_gloss_to_metal_base_color(const Color &p_specular_factor,
211
const Color &p_diffuse,
212
Color &r_base_color,
213
float &r_metallic);
214
Error _parse_skins(Ref<GLTFState> p_state);
215
Error _serialize_skins(Ref<GLTFState> p_state);
216
Error _create_skins(Ref<GLTFState> p_state);
217
bool _skins_are_same(const Ref<Skin> p_skin_a, const Ref<Skin> p_skin_b);
218
void _remove_duplicate_skins(Ref<GLTFState> p_state);
219
Error _serialize_cameras(Ref<GLTFState> p_state);
220
Error _parse_cameras(Ref<GLTFState> p_state);
221
Error _parse_lights(Ref<GLTFState> p_state);
222
Error _parse_animations(Ref<GLTFState> p_state);
223
void _parse_animation_pointer(Ref<GLTFState> p_state, const String &p_animation_json_pointer, const Ref<GLTFAnimation> p_gltf_animation, const GLTFAnimation::Interpolation p_interp, const Vector<double> &p_times, const int p_output_value_accessor_index);
224
Error _serialize_animations(Ref<GLTFState> p_state);
225
bool _does_skinned_mesh_require_placeholder_node(Ref<GLTFState> p_state, Ref<GLTFNode> p_gltf_node);
226
BoneAttachment3D *_generate_bone_attachment(Skeleton3D *p_godot_skeleton, const Ref<GLTFNode> &p_bone_node);
227
BoneAttachment3D *_generate_bone_attachment_compat_4pt4(Ref<GLTFState> p_state, Skeleton3D *p_skeleton, const GLTFNodeIndex p_node_index, const GLTFNodeIndex p_bone_index);
228
ImporterMeshInstance3D *_generate_mesh_instance(Ref<GLTFState> p_state, const GLTFNodeIndex p_node_index);
229
Camera3D *_generate_camera(Ref<GLTFState> p_state, const GLTFNodeIndex p_node_index);
230
Light3D *_generate_light(Ref<GLTFState> p_state, const GLTFNodeIndex p_node_index);
231
Node3D *_generate_spatial(Ref<GLTFState> p_state, const GLTFNodeIndex p_node_index);
232
void _assign_node_names(Ref<GLTFState> p_state);
233
template <typename T>
234
T _interpolate_track(const Vector<double> &p_times, const Vector<T> &p_values,
235
const float p_time,
236
const GLTFAnimation::Interpolation p_interp);
237
GLTFAccessorIndex _encode_accessor_as_quaternions(Ref<GLTFState> p_state,
238
const Vector<Quaternion> p_attribs,
239
const bool p_for_vertex);
240
GLTFAccessorIndex _encode_accessor_as_weights(Ref<GLTFState> p_state,
241
const Vector<Color> p_attribs,
242
const bool p_for_vertex);
243
GLTFAccessorIndex _encode_accessor_as_joints(Ref<GLTFState> p_state,
244
const Vector<Color> p_attribs,
245
const bool p_for_vertex);
246
GLTFAccessorIndex _encode_accessor_as_floats(Ref<GLTFState> p_state,
247
const Vector<double> p_attribs,
248
const bool p_for_vertex);
249
GLTFAccessorIndex _encode_accessor_as_vec2(Ref<GLTFState> p_state,
250
const Vector<Vector2> p_attribs,
251
const bool p_for_vertex);
252
253
void _calc_accessor_vec2_min_max(int p_i, const int64_t p_element_count, Vector<double> &p_type_max, Vector2 p_attribs, Vector<double> &p_type_min) {
254
if (p_i == 0) {
255
for (int64_t type_i = 0; type_i < p_element_count; type_i++) {
256
p_type_max.write[type_i] = p_attribs[(p_i * p_element_count) + type_i];
257
p_type_min.write[type_i] = p_attribs[(p_i * p_element_count) + type_i];
258
}
259
}
260
for (int64_t type_i = 0; type_i < p_element_count; type_i++) {
261
p_type_max.write[type_i] = MAX(p_attribs[(p_i * p_element_count) + type_i], p_type_max[type_i]);
262
p_type_min.write[type_i] = MIN(p_attribs[(p_i * p_element_count) + type_i], p_type_min[type_i]);
263
p_type_max.write[type_i] = _filter_number(p_type_max.write[type_i]);
264
p_type_min.write[type_i] = _filter_number(p_type_min.write[type_i]);
265
}
266
}
267
268
GLTFAccessorIndex _encode_accessor_as_vec3(Ref<GLTFState> p_state,
269
const Vector<Vector3> p_attribs,
270
const bool p_for_vertex);
271
GLTFAccessorIndex _encode_sparse_accessor_as_vec3(Ref<GLTFState> p_state, const Vector<Vector3> p_attribs, const Vector<Vector3> p_reference_attribs, const float p_reference_multiplier, const bool p_for_vertex, const GLTFAccessorIndex p_reference_accessor);
272
GLTFAccessorIndex _encode_accessor_as_color(Ref<GLTFState> p_state,
273
const Vector<Color> p_attribs,
274
const bool p_for_vertex);
275
276
void _calc_accessor_min_max(int p_i, const int64_t p_element_count, Vector<double> &p_type_max, Vector<double> p_attribs, Vector<double> &p_type_min);
277
278
GLTFAccessorIndex _encode_accessor_as_ints(Ref<GLTFState> p_state,
279
const Vector<int32_t> p_attribs,
280
const bool p_for_vertex,
281
const bool p_for_indices);
282
GLTFAccessorIndex _encode_accessor_as_xform(Ref<GLTFState> p_state,
283
const Vector<Transform3D> p_attribs,
284
const bool p_for_vertex);
285
Error _encode_accessor_into_buffer_view(Ref<GLTFState> p_state, const double *p_src,
286
const int64_t p_count, const GLTFAccessor::GLTFAccessorType p_accessor_type,
287
const GLTFAccessor::GLTFComponentType p_component_type, const bool p_normalized,
288
const int64_t p_byte_offset, const bool p_for_vertex,
289
GLTFBufferViewIndex &r_buffer_view, const bool p_for_indices = false);
290
291
Error _encode_accessors(Ref<GLTFState> p_state);
292
Error _encode_buffer_views(Ref<GLTFState> p_state);
293
Error _serialize_materials(Ref<GLTFState> p_state);
294
Error _serialize_meshes(Ref<GLTFState> p_state);
295
Error _serialize_nodes(Ref<GLTFState> p_state);
296
Error _serialize_scenes(Ref<GLTFState> p_state);
297
String interpolation_to_string(const GLTFAnimation::Interpolation p_interp);
298
Error _encode_buffer_bins(Ref<GLTFState> p_state, const String &p_path);
299
Error _encode_buffer_glb(Ref<GLTFState> p_state, const String &p_path);
300
PackedByteArray _serialize_glb_buffer(Ref<GLTFState> p_state, Error *r_err);
301
Dictionary _serialize_texture_transform_uv1(Ref<BaseMaterial3D> p_material);
302
Dictionary _serialize_texture_transform_uv2(Ref<BaseMaterial3D> p_material);
303
Error _serialize_asset_header(Ref<GLTFState> p_state);
304
Error _serialize_file(Ref<GLTFState> p_state, const String p_path);
305
Error _serialize_gltf_extensions(Ref<GLTFState> p_state) const;
306
307
public:
308
// https://www.itu.int/rec/R-REC-BT.601
309
// https://www.itu.int/dms_pubrec/itu-r/rec/bt/R-REC-BT.601-7-201103-I!!PDF-E.pdf
310
static constexpr float R_BRIGHTNESS_COEFF = 0.299f;
311
static constexpr float G_BRIGHTNESS_COEFF = 0.587f;
312
static constexpr float B_BRIGHTNESS_COEFF = 0.114f;
313
314
private:
315
// https://github.com/microsoft/glTF-SDK/blob/master/GLTFSDK/Source/PBRUtils.cpp#L9
316
// https://bghgary.github.io/glTF/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
317
static float solve_metallic(float p_dielectric_specular, float p_diffuse,
318
float p_specular,
319
float p_one_minus_specular_strength);
320
static float get_perceived_brightness(const Color p_color);
321
static float get_max_component(const Color &p_color);
322
323
public:
324
virtual Error append_from_file(String p_path, Ref<GLTFState> p_state, uint32_t p_flags = 0, String p_base_path = String());
325
virtual Error append_from_buffer(PackedByteArray p_bytes, String p_base_path, Ref<GLTFState> p_state, uint32_t p_flags = 0);
326
virtual Error append_from_scene(Node *p_node, Ref<GLTFState> p_state, uint32_t p_flags = 0);
327
328
virtual Node *generate_scene(Ref<GLTFState> p_state, float p_bake_fps = 30.0f, bool p_trimming = false, bool p_remove_immutable_tracks = true);
329
virtual PackedByteArray generate_buffer(Ref<GLTFState> p_state);
330
virtual Error write_to_filesystem(Ref<GLTFState> p_state, const String &p_path);
331
332
public:
333
Error _parse_gltf_state(Ref<GLTFState> p_state, const String &p_search_path);
334
Error _parse_asset_header(Ref<GLTFState> p_state);
335
Error _parse_gltf_extensions(Ref<GLTFState> p_state);
336
void _process_mesh_instances(Ref<GLTFState> p_state, Node *p_scene_root);
337
Node *_generate_scene_node_tree(Ref<GLTFState> p_state);
338
void _generate_scene_node(Ref<GLTFState> p_state, const GLTFNodeIndex p_node_index, Node *p_scene_parent, Node *p_scene_root);
339
void _generate_skeleton_bone_node(Ref<GLTFState> p_state, const GLTFNodeIndex p_node_index, Node3D *p_current_node, Node *p_scene_parent, Node *p_scene_root);
340
void _attach_node_to_skeleton(Ref<GLTFState> p_state, const GLTFNodeIndex p_node_index, Node3D *p_current_node, Skeleton3D *p_godot_skeleton, Node *p_scene_root, GLTFNodeIndex p_bone_node_index = -1);
341
void _generate_scene_node_compat_4pt4(Ref<GLTFState> p_state, const GLTFNodeIndex p_node_index, Node *p_scene_parent, Node *p_scene_root);
342
void _generate_skeleton_bone_node_compat_4pt4(Ref<GLTFState> p_state, const GLTFNodeIndex p_node_index, Node *p_scene_parent, Node *p_scene_root);
343
void _import_animation(Ref<GLTFState> p_state, AnimationPlayer *p_animation_player,
344
const GLTFAnimationIndex p_index, const bool p_trimming, const bool p_remove_immutable_tracks);
345
void _convert_mesh_instances(Ref<GLTFState> p_state);
346
GLTFCameraIndex _convert_camera(Ref<GLTFState> p_state, Camera3D *p_camera);
347
void _convert_light_to_gltf(Light3D *p_light, Ref<GLTFState> p_state, Ref<GLTFNode> p_gltf_node);
348
GLTFLightIndex _convert_light(Ref<GLTFState> p_state, Light3D *p_light);
349
void _convert_spatial(Ref<GLTFState> p_state, Node3D *p_spatial, Ref<GLTFNode> p_node);
350
void _convert_scene_node(Ref<GLTFState> p_state, Node *p_current,
351
const GLTFNodeIndex p_gltf_current,
352
const GLTFNodeIndex p_gltf_root);
353
354
void _convert_csg_shape_to_gltf(CSGShape3D *p_current, GLTFNodeIndex p_gltf_parent, Ref<GLTFNode> p_gltf_node, Ref<GLTFState> p_state);
355
356
void _check_visibility(Node *p_node, bool &r_retflag);
357
void _convert_camera_to_gltf(Camera3D *p_camera, Ref<GLTFState> p_state,
358
Ref<GLTFNode> p_gltf_node);
359
void _convert_grid_map_to_gltf(
360
GridMap *p_grid_map,
361
GLTFNodeIndex p_parent_node_index,
362
GLTFNodeIndex p_root_node_index,
363
Ref<GLTFNode> p_gltf_node, Ref<GLTFState> p_state);
364
void _convert_multi_mesh_instance_to_gltf(
365
MultiMeshInstance3D *p_multi_mesh_instance,
366
GLTFNodeIndex p_parent_node_index,
367
GLTFNodeIndex p_root_node_index,
368
Ref<GLTFNode> p_gltf_node, Ref<GLTFState> p_state);
369
void _convert_skeleton_to_gltf(
370
Skeleton3D *p_scene_parent, Ref<GLTFState> p_state,
371
GLTFNodeIndex p_parent_node_index,
372
GLTFNodeIndex p_root_node_index,
373
Ref<GLTFNode> p_gltf_node);
374
void _convert_bone_attachment_to_gltf(BoneAttachment3D *p_bone_attachment,
375
Ref<GLTFState> p_state,
376
GLTFNodeIndex p_parent_node_index,
377
GLTFNodeIndex p_root_node_index,
378
Ref<GLTFNode> p_gltf_node);
379
void _convert_mesh_instance_to_gltf(MeshInstance3D *p_mesh_instance,
380
Ref<GLTFState> p_state,
381
Ref<GLTFNode> p_gltf_node);
382
GLTFMeshIndex _convert_mesh_to_gltf(Ref<GLTFState> p_state,
383
MeshInstance3D *p_mesh_instance);
384
385
GLTFNodeIndex _node_and_or_bone_to_gltf_node_index(Ref<GLTFState> p_state, const Vector<StringName> &p_node_subpath, const Node *p_godot_node);
386
bool _convert_animation_node_track(Ref<GLTFState> p_state,
387
GLTFAnimation::NodeTrack &p_gltf_node_track,
388
const Ref<Animation> &p_godot_animation,
389
int32_t p_godot_anim_track_index,
390
Vector<double> &p_times);
391
void _convert_animation(Ref<GLTFState> p_state, AnimationPlayer *p_animation_player, const String &p_animation_track_name);
392
393
Error _serialize(Ref<GLTFState> p_state);
394
Error _parse(Ref<GLTFState> p_state, String p_path, Ref<FileAccess> p_file);
395
};
396
397
VARIANT_ENUM_CAST(GLTFDocument::RootNodeMode);
398
VARIANT_ENUM_CAST(GLTFDocument::VisibilityMode);
399
400