gltf_document.h 19 KB

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