gltf_document.h 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453
  1. /*************************************************************************/
  2. /* gltf_document.h */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
  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 "gltf_animation.h"
  33. #include "core/variant/dictionary.h"
  34. #include "core/variant/variant.h"
  35. #include "gltf_document_extension_convert_importer_mesh.h"
  36. #include "scene/3d/bone_attachment_3d.h"
  37. #include "scene/3d/importer_mesh_instance_3d.h"
  38. #include "scene/3d/light_3d.h"
  39. #include "scene/3d/mesh_instance_3d.h"
  40. #include "scene/3d/node_3d.h"
  41. #include "scene/3d/skeleton_3d.h"
  42. #include "scene/animation/animation_player.h"
  43. #include "scene/resources/material.h"
  44. #include "scene/resources/texture.h"
  45. #include "modules/modules_enabled.gen.h"
  46. #include <cstdint>
  47. class GLTFState;
  48. class GLTFSkin;
  49. class GLTFNode;
  50. class GLTFSpecGloss;
  51. class GLTFSkeleton;
  52. class CSGShape3D;
  53. class GridMap;
  54. class MultiMeshInstance3D;
  55. class GLTFDocumentExtension;
  56. using GLTFAccessorIndex = int;
  57. using GLTFAnimationIndex = int;
  58. using GLTFBufferIndex = int;
  59. using GLTFBufferViewIndex = int;
  60. using GLTFCameraIndex = int;
  61. using GLTFImageIndex = int;
  62. using GLTFMaterialIndex = int;
  63. using GLTFMeshIndex = int;
  64. using GLTFLightIndex = int;
  65. using GLTFNodeIndex = int;
  66. using GLTFSkeletonIndex = int;
  67. using GLTFSkinIndex = int;
  68. using GLTFTextureIndex = int;
  69. class GLTFDocument : public Resource {
  70. GDCLASS(GLTFDocument, Resource);
  71. friend class GLTFState;
  72. friend class GLTFSkin;
  73. friend class GLTFSkeleton;
  74. TypedArray<GLTFDocumentExtension> document_extensions;
  75. private:
  76. const float BAKE_FPS = 30.0f;
  77. public:
  78. GLTFDocument();
  79. const int32_t JOINT_GROUP_SIZE = 4;
  80. enum GLTFType {
  81. TYPE_SCALAR,
  82. TYPE_VEC2,
  83. TYPE_VEC3,
  84. TYPE_VEC4,
  85. TYPE_MAT2,
  86. TYPE_MAT3,
  87. TYPE_MAT4,
  88. };
  89. enum {
  90. ARRAY_BUFFER = 34962,
  91. ELEMENT_ARRAY_BUFFER = 34963,
  92. TYPE_BYTE = 5120,
  93. TYPE_UNSIGNED_BYTE = 5121,
  94. TYPE_SHORT = 5122,
  95. TYPE_UNSIGNED_SHORT = 5123,
  96. TYPE_UNSIGNED_INT = 5125,
  97. TYPE_FLOAT = 5126,
  98. COMPONENT_TYPE_BYTE = 5120,
  99. COMPONENT_TYPE_UNSIGNED_BYTE = 5121,
  100. COMPONENT_TYPE_SHORT = 5122,
  101. COMPONENT_TYPE_UNSIGNED_SHORT = 5123,
  102. COMPONENT_TYPE_INT = 5125,
  103. COMPONENT_TYPE_FLOAT = 5126,
  104. };
  105. protected:
  106. static void _bind_methods();
  107. public:
  108. Node *import_scene(const String &p_path, uint32_t p_flags, int32_t p_bake_fps, Ref<GLTFState> r_state);
  109. Node *import_scene_gltf(const String &p_path, uint32_t p_flags, int32_t p_bake_fps, Ref<GLTFState> r_state, List<String> *r_missing_deps, Error *r_err = nullptr);
  110. Error save_scene(Node *p_node, const String &p_path,
  111. const String &p_src_path, uint32_t p_flags,
  112. float p_bake_fps, Ref<GLTFState> r_state);
  113. void set_extensions(TypedArray<GLTFDocumentExtension> p_extensions);
  114. TypedArray<GLTFDocumentExtension> get_extensions() const;
  115. private:
  116. template <class T>
  117. static Array to_array(const Vector<T> &p_inp) {
  118. Array ret;
  119. for (int i = 0; i < p_inp.size(); i++) {
  120. ret.push_back(p_inp[i]);
  121. }
  122. return ret;
  123. }
  124. template <class T>
  125. static Array to_array(const Set<T> &p_inp) {
  126. Array ret;
  127. typename Set<T>::Element *elem = p_inp.front();
  128. while (elem) {
  129. ret.push_back(elem->get());
  130. elem = elem->next();
  131. }
  132. return ret;
  133. }
  134. template <class T>
  135. static void set_from_array(Vector<T> &r_out, const Array &p_inp) {
  136. r_out.clear();
  137. for (int i = 0; i < p_inp.size(); i++) {
  138. r_out.push_back(p_inp[i]);
  139. }
  140. }
  141. template <class T>
  142. static void set_from_array(Set<T> &r_out, const Array &p_inp) {
  143. r_out.clear();
  144. for (int i = 0; i < p_inp.size(); i++) {
  145. r_out.insert(p_inp[i]);
  146. }
  147. }
  148. template <class K, class V>
  149. static Dictionary to_dict(const Map<K, V> &p_inp) {
  150. Dictionary ret;
  151. for (typename Map<K, V>::Element *E = p_inp.front(); E; E = E->next()) {
  152. ret[E->key()] = E->value();
  153. }
  154. return ret;
  155. }
  156. template <class K, class V>
  157. static void set_from_dict(Map<K, V> &r_out, const Dictionary &p_inp) {
  158. r_out.clear();
  159. Array keys = p_inp.keys();
  160. for (int i = 0; i < keys.size(); i++) {
  161. r_out[keys[i]] = p_inp[keys[i]];
  162. }
  163. }
  164. void _build_parent_hierachy(Ref<GLTFState> state);
  165. double _filter_number(double p_float);
  166. String _get_component_type_name(const uint32_t p_component);
  167. int _get_component_type_size(const int component_type);
  168. Error _parse_scenes(Ref<GLTFState> state);
  169. Error _parse_nodes(Ref<GLTFState> state);
  170. String _get_type_name(const GLTFType p_component);
  171. String _get_accessor_type_name(const GLTFDocument::GLTFType p_type);
  172. String _gen_unique_name(Ref<GLTFState> state, const String &p_name);
  173. String _sanitize_animation_name(const String &name);
  174. String _gen_unique_animation_name(Ref<GLTFState> state, const String &p_name);
  175. String _sanitize_bone_name(const String &name);
  176. String _gen_unique_bone_name(Ref<GLTFState> state,
  177. const GLTFSkeletonIndex skel_i,
  178. const String &p_name);
  179. GLTFTextureIndex _set_texture(Ref<GLTFState> state, Ref<Texture2D> p_texture);
  180. Ref<Texture2D> _get_texture(Ref<GLTFState> state,
  181. const GLTFTextureIndex p_texture);
  182. Error _parse_json(const String &p_path, Ref<GLTFState> state);
  183. Error _parse_glb(const String &p_path, Ref<GLTFState> state);
  184. void _compute_node_heights(Ref<GLTFState> state);
  185. Error _parse_buffers(Ref<GLTFState> state, const String &p_base_path);
  186. Error _parse_buffer_views(Ref<GLTFState> state);
  187. GLTFType _get_type_from_str(const String &p_string);
  188. Error _parse_accessors(Ref<GLTFState> state);
  189. Error _decode_buffer_view(Ref<GLTFState> state, double *dst,
  190. const GLTFBufferViewIndex p_buffer_view,
  191. const int skip_every, const int skip_bytes,
  192. const int element_size, const int count,
  193. const GLTFType type, const int component_count,
  194. const int component_type, const int component_size,
  195. const bool normalized, const int byte_offset,
  196. const bool for_vertex);
  197. Vector<double> _decode_accessor(Ref<GLTFState> state,
  198. const GLTFAccessorIndex p_accessor,
  199. const bool p_for_vertex);
  200. Vector<float> _decode_accessor_as_floats(Ref<GLTFState> state,
  201. const GLTFAccessorIndex p_accessor,
  202. const bool p_for_vertex);
  203. Vector<int> _decode_accessor_as_ints(Ref<GLTFState> state,
  204. const GLTFAccessorIndex p_accessor,
  205. const bool p_for_vertex);
  206. Vector<Vector2> _decode_accessor_as_vec2(Ref<GLTFState> state,
  207. const GLTFAccessorIndex p_accessor,
  208. const bool p_for_vertex);
  209. Vector<Vector3> _decode_accessor_as_vec3(Ref<GLTFState> state,
  210. const GLTFAccessorIndex p_accessor,
  211. const bool p_for_vertex);
  212. Vector<Color> _decode_accessor_as_color(Ref<GLTFState> state,
  213. const GLTFAccessorIndex p_accessor,
  214. const bool p_for_vertex);
  215. Vector<Quaternion> _decode_accessor_as_quaternion(Ref<GLTFState> state,
  216. const GLTFAccessorIndex p_accessor,
  217. const bool p_for_vertex);
  218. Vector<Transform2D> _decode_accessor_as_xform2d(Ref<GLTFState> state,
  219. const GLTFAccessorIndex p_accessor,
  220. const bool p_for_vertex);
  221. Vector<Basis> _decode_accessor_as_basis(Ref<GLTFState> state,
  222. const GLTFAccessorIndex p_accessor,
  223. const bool p_for_vertex);
  224. Vector<Transform3D> _decode_accessor_as_xform(Ref<GLTFState> state,
  225. const GLTFAccessorIndex p_accessor,
  226. const bool p_for_vertex);
  227. Error _parse_meshes(Ref<GLTFState> state);
  228. Error _serialize_textures(Ref<GLTFState> state);
  229. Error _serialize_images(Ref<GLTFState> state, const String &p_path);
  230. Error _serialize_lights(Ref<GLTFState> state);
  231. Error _parse_images(Ref<GLTFState> state, const String &p_base_path);
  232. Error _parse_textures(Ref<GLTFState> state);
  233. Error _parse_materials(Ref<GLTFState> state);
  234. void _set_texture_transform_uv1(const Dictionary &d, Ref<BaseMaterial3D> material);
  235. void spec_gloss_to_rough_metal(Ref<GLTFSpecGloss> r_spec_gloss,
  236. Ref<BaseMaterial3D> p_material);
  237. static void spec_gloss_to_metal_base_color(const Color &p_specular_factor,
  238. const Color &p_diffuse,
  239. Color &r_base_color,
  240. float &r_metallic);
  241. GLTFNodeIndex _find_highest_node(Ref<GLTFState> state,
  242. const Vector<GLTFNodeIndex> &subset);
  243. bool _capture_nodes_in_skin(Ref<GLTFState> state, Ref<GLTFSkin> skin,
  244. const GLTFNodeIndex node_index);
  245. void _capture_nodes_for_multirooted_skin(Ref<GLTFState> state, Ref<GLTFSkin> skin);
  246. Error _expand_skin(Ref<GLTFState> state, Ref<GLTFSkin> skin);
  247. Error _verify_skin(Ref<GLTFState> state, Ref<GLTFSkin> skin);
  248. Error _parse_skins(Ref<GLTFState> state);
  249. Error _determine_skeletons(Ref<GLTFState> state);
  250. Error _reparent_non_joint_skeleton_subtrees(
  251. Ref<GLTFState> state, Ref<GLTFSkeleton> skeleton,
  252. const Vector<GLTFNodeIndex> &non_joints);
  253. Error _determine_skeleton_roots(Ref<GLTFState> state,
  254. const GLTFSkeletonIndex skel_i);
  255. Error _create_skeletons(Ref<GLTFState> state);
  256. Error _map_skin_joints_indices_to_skeleton_bone_indices(Ref<GLTFState> state);
  257. Error _serialize_skins(Ref<GLTFState> state);
  258. Error _create_skins(Ref<GLTFState> state);
  259. bool _skins_are_same(const Ref<Skin> skin_a, const Ref<Skin> skin_b);
  260. void _remove_duplicate_skins(Ref<GLTFState> state);
  261. Error _serialize_cameras(Ref<GLTFState> state);
  262. Error _parse_cameras(Ref<GLTFState> state);
  263. Error _parse_lights(Ref<GLTFState> state);
  264. Error _parse_animations(Ref<GLTFState> state);
  265. Error _serialize_animations(Ref<GLTFState> state);
  266. BoneAttachment3D *_generate_bone_attachment(Ref<GLTFState> state,
  267. Skeleton3D *skeleton,
  268. const GLTFNodeIndex node_index,
  269. const GLTFNodeIndex bone_index);
  270. ImporterMeshInstance3D *_generate_mesh_instance(Ref<GLTFState> state, Node *parent_node, const GLTFNodeIndex node_index);
  271. Camera3D *_generate_camera(Ref<GLTFState> state, Node *parent_node, const GLTFNodeIndex node_index);
  272. Node3D *_generate_light(Ref<GLTFState> state, Node *parent_node, const GLTFNodeIndex node_index);
  273. Node3D *_generate_spatial(Ref<GLTFState> state, Node *parent_node, const GLTFNodeIndex node_index);
  274. void _assign_scene_names(Ref<GLTFState> state);
  275. template <class T>
  276. T _interpolate_track(const Vector<float> &p_times, const Vector<T> &p_values,
  277. const float p_time,
  278. const GLTFAnimation::Interpolation p_interp);
  279. GLTFAccessorIndex _encode_accessor_as_quaternions(Ref<GLTFState> state,
  280. const Vector<Quaternion> p_attribs,
  281. const bool p_for_vertex);
  282. GLTFAccessorIndex _encode_accessor_as_weights(Ref<GLTFState> state,
  283. const Vector<Color> p_attribs,
  284. const bool p_for_vertex);
  285. GLTFAccessorIndex _encode_accessor_as_joints(Ref<GLTFState> state,
  286. const Vector<Color> p_attribs,
  287. const bool p_for_vertex);
  288. GLTFAccessorIndex _encode_accessor_as_floats(Ref<GLTFState> state,
  289. const Vector<real_t> p_attribs,
  290. const bool p_for_vertex);
  291. GLTFAccessorIndex _encode_accessor_as_vec2(Ref<GLTFState> state,
  292. const Vector<Vector2> p_attribs,
  293. const bool p_for_vertex);
  294. void _calc_accessor_vec2_min_max(int i, const int element_count, Vector<double> &type_max, Vector2 attribs, Vector<double> &type_min) {
  295. if (i == 0) {
  296. for (int32_t type_i = 0; type_i < element_count; type_i++) {
  297. type_max.write[type_i] = attribs[(i * element_count) + type_i];
  298. type_min.write[type_i] = attribs[(i * element_count) + type_i];
  299. }
  300. }
  301. for (int32_t type_i = 0; type_i < element_count; type_i++) {
  302. type_max.write[type_i] = MAX(attribs[(i * element_count) + type_i], type_max[type_i]);
  303. type_min.write[type_i] = MIN(attribs[(i * element_count) + type_i], type_min[type_i]);
  304. type_max.write[type_i] = _filter_number(type_max.write[type_i]);
  305. type_min.write[type_i] = _filter_number(type_min.write[type_i]);
  306. }
  307. }
  308. GLTFAccessorIndex _encode_accessor_as_vec3(Ref<GLTFState> state,
  309. const Vector<Vector3> p_attribs,
  310. const bool p_for_vertex);
  311. GLTFAccessorIndex _encode_accessor_as_color(Ref<GLTFState> state,
  312. const Vector<Color> p_attribs,
  313. const bool p_for_vertex);
  314. 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);
  315. GLTFAccessorIndex _encode_accessor_as_ints(Ref<GLTFState> state,
  316. const Vector<int32_t> p_attribs,
  317. const bool p_for_vertex);
  318. GLTFAccessorIndex _encode_accessor_as_xform(Ref<GLTFState> state,
  319. const Vector<Transform3D> p_attribs,
  320. const bool p_for_vertex);
  321. Error _encode_buffer_view(Ref<GLTFState> state, const double *src,
  322. const int count, const GLTFType type,
  323. const int component_type, const bool normalized,
  324. const int byte_offset, const bool for_vertex,
  325. GLTFBufferViewIndex &r_accessor);
  326. Error _encode_accessors(Ref<GLTFState> state);
  327. Error _encode_buffer_views(Ref<GLTFState> state);
  328. Error _serialize_materials(Ref<GLTFState> state);
  329. Error _serialize_meshes(Ref<GLTFState> state);
  330. Error _serialize_nodes(Ref<GLTFState> state);
  331. Error _serialize_scenes(Ref<GLTFState> state);
  332. String interpolation_to_string(const GLTFAnimation::Interpolation p_interp);
  333. GLTFAnimation::Track _convert_animation_track(Ref<GLTFState> state,
  334. GLTFAnimation::Track p_track,
  335. Ref<Animation> p_animation,
  336. int32_t p_track_i,
  337. GLTFNodeIndex p_node_i);
  338. Error _encode_buffer_bins(Ref<GLTFState> state, const String &p_path);
  339. Error _encode_buffer_glb(Ref<GLTFState> state, const String &p_path);
  340. Dictionary _serialize_texture_transform_uv1(Ref<BaseMaterial3D> p_material);
  341. Dictionary _serialize_texture_transform_uv2(Ref<BaseMaterial3D> p_material);
  342. Error _serialize_version(Ref<GLTFState> state);
  343. Error _serialize_file(Ref<GLTFState> state, const String p_path);
  344. Error _serialize_extensions(Ref<GLTFState> state) const;
  345. public:
  346. // https://www.itu.int/rec/R-REC-BT.601
  347. // https://www.itu.int/dms_pubrec/itu-r/rec/bt/R-REC-BT.601-7-201103-I!!PDF-E.pdf
  348. static constexpr float R_BRIGHTNESS_COEFF = 0.299f;
  349. static constexpr float G_BRIGHTNESS_COEFF = 0.587f;
  350. static constexpr float B_BRIGHTNESS_COEFF = 0.114f;
  351. private:
  352. // https://github.com/microsoft/glTF-SDK/blob/master/GLTFSDK/Source/PBRUtils.cpp#L9
  353. // https://bghgary.github.io/glTF/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  354. static float solve_metallic(float p_dielectric_specular, float diffuse,
  355. float specular,
  356. float p_one_minus_specular_strength);
  357. static float get_perceived_brightness(const Color p_color);
  358. static float get_max_component(const Color &p_color);
  359. public:
  360. void _process_mesh_instances(Ref<GLTFState> state, Node *scene_root);
  361. void _generate_scene_node(Ref<GLTFState> state, Node *scene_parent,
  362. Node3D *scene_root,
  363. const GLTFNodeIndex node_index);
  364. void _generate_skeleton_bone_node(Ref<GLTFState> state, Node *scene_parent, Node3D *scene_root, const GLTFNodeIndex node_index);
  365. void _import_animation(Ref<GLTFState> state, AnimationPlayer *ap,
  366. const GLTFAnimationIndex index, const int bake_fps);
  367. void _convert_mesh_instances(Ref<GLTFState> state);
  368. GLTFCameraIndex _convert_camera(Ref<GLTFState> state, Camera3D *p_camera);
  369. void _convert_light_to_gltf(Light3D *light, Ref<GLTFState> state, Ref<GLTFNode> gltf_node);
  370. GLTFLightIndex _convert_light(Ref<GLTFState> state, Light3D *p_light);
  371. void _convert_spatial(Ref<GLTFState> state, Node3D *p_spatial, Ref<GLTFNode> p_node);
  372. void _convert_scene_node(Ref<GLTFState> state, Node *p_current,
  373. const GLTFNodeIndex p_gltf_current,
  374. const GLTFNodeIndex p_gltf_root);
  375. #ifdef MODULE_CSG_ENABLED
  376. void _convert_csg_shape_to_gltf(CSGShape3D *p_current, GLTFNodeIndex p_gltf_parent, Ref<GLTFNode> gltf_node, Ref<GLTFState> state);
  377. #endif // MODULE_CSG_ENABLED
  378. void _create_gltf_node(Ref<GLTFState> state,
  379. Node *p_scene_parent,
  380. GLTFNodeIndex current_node_i,
  381. GLTFNodeIndex p_parent_node_index,
  382. GLTFNodeIndex p_root_gltf_node,
  383. Ref<GLTFNode> gltf_node);
  384. void _convert_animation_player_to_gltf(
  385. AnimationPlayer *animation_player, Ref<GLTFState> state,
  386. GLTFNodeIndex p_gltf_current,
  387. GLTFNodeIndex p_gltf_root_index,
  388. Ref<GLTFNode> p_gltf_node, Node *p_scene_parent);
  389. void _check_visibility(Node *p_node, bool &retflag);
  390. void _convert_camera_to_gltf(Camera3D *camera, Ref<GLTFState> state,
  391. Ref<GLTFNode> gltf_node);
  392. #ifdef MODULE_GRIDMAP_ENABLED
  393. void _convert_grid_map_to_gltf(
  394. GridMap *p_grid_map,
  395. GLTFNodeIndex p_parent_node_index,
  396. GLTFNodeIndex p_root_node_index,
  397. Ref<GLTFNode> gltf_node, Ref<GLTFState> state);
  398. #endif // MODULE_GRIDMAP_ENABLED
  399. void _convert_multi_mesh_instance_to_gltf(
  400. MultiMeshInstance3D *p_multi_mesh_instance,
  401. GLTFNodeIndex p_parent_node_index,
  402. GLTFNodeIndex p_root_node_index,
  403. Ref<GLTFNode> gltf_node, Ref<GLTFState> state);
  404. void _convert_skeleton_to_gltf(
  405. Skeleton3D *p_scene_parent, Ref<GLTFState> state,
  406. GLTFNodeIndex p_parent_node_index,
  407. GLTFNodeIndex p_root_node_index,
  408. Ref<GLTFNode> gltf_node);
  409. void _convert_bone_attachment_to_gltf(BoneAttachment3D *p_bone_attachment,
  410. Ref<GLTFState> state,
  411. GLTFNodeIndex p_parent_node_index,
  412. GLTFNodeIndex p_root_node_index,
  413. Ref<GLTFNode> gltf_node);
  414. void _convert_mesh_instance_to_gltf(MeshInstance3D *p_mesh_instance,
  415. Ref<GLTFState> state,
  416. Ref<GLTFNode> gltf_node);
  417. GLTFMeshIndex _convert_mesh_to_gltf(Ref<GLTFState> state,
  418. MeshInstance3D *p_mesh_instance);
  419. void _convert_animation(Ref<GLTFState> state, AnimationPlayer *ap,
  420. String p_animation_track_name);
  421. Error serialize(Ref<GLTFState> state, Node *p_root, const String &p_path);
  422. Error parse(Ref<GLTFState> state, String p_paths, bool p_read_binary = false);
  423. };
  424. #endif // GLTF_DOCUMENT_H