gltf_document.h 20 KB

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