godot/modules/fbx/fbx_document.cpp

/**************************************************************************/
/*  fbx_document.cpp                                                      */
/**************************************************************************/
/*                         This file is part of:                          */
/*                             GODOT ENGINE                               */
/*                        https://godotengine.org                         */
/**************************************************************************/
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur.                  */
/*                                                                        */
/* Permission is hereby granted, free of charge, to any person obtaining  */
/* a copy of this software and associated documentation files (the        */
/* "Software"), to deal in the Software without restriction, including    */
/* without limitation the rights to use, copy, modify, merge, publish,    */
/* distribute, sublicense, and/or sell copies of the Software, and to     */
/* permit persons to whom the Software is furnished to do so, subject to  */
/* the following conditions:                                              */
/*                                                                        */
/* The above copyright notice and this permission notice shall be         */
/* included in all copies or substantial portions of the Software.        */
/*                                                                        */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,        */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF     */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY   */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,   */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE      */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.                 */
/**************************************************************************/

#include "fbx_document.h"

#include "core/config/project_settings.h"
#include "core/crypto/crypto_core.h"
#include "core/io/config_file.h"
#include "core/io/file_access.h"
#include "core/io/file_access_memory.h"
#include "core/io/image.h"
#include "core/math/color.h"
#include "scene/3d/bone_attachment_3d.h"
#include "scene/3d/camera_3d.h"
#include "scene/3d/importer_mesh_instance_3d.h"
#include "scene/3d/light_3d.h"
#include "scene/resources/image_texture.h"
#include "scene/resources/material.h"
#include "scene/resources/portable_compressed_texture.h"
#include "scene/resources/surface_tool.h"

#include "modules/gltf/extensions/gltf_light.h"
#include "modules/gltf/gltf_defines.h"
#include "modules/gltf/skin_tool.h"
#include "modules/gltf/structures/gltf_animation.h"
#include "modules/gltf/structures/gltf_camera.h"

#ifdef TOOLS_ENABLED
#include "editor/editor_file_system.h"
#endif

// FIXME: Hardcoded to avoid editor dependency.
#define FBX_IMPORT_USE_NAMED_SKIN_BINDS
#define FBX_IMPORT_DISCARD_MESHES_AND_MATERIALS
#define FBX_IMPORT_FORCE_DISABLE_MESH_COMPRESSION

#include <ufbx.h>

static size_t _file_access_read_fn(void *user, void *data, size_t size) {}

static bool _file_access_skip_fn(void *user, size_t size) {}

static Vector2 _as_vec2(const ufbx_vec2 &p_vector) {}

static Color _as_color(const ufbx_vec4 &p_vector) {}

static Quaternion _as_quaternion(const ufbx_quat &p_quat) {}

static Transform3D _as_transform(const ufbx_transform &p_xform) {}

static real_t _relative_error(const Vector3 &p_a, const Vector3 &p_b) {}

static Color _material_color(const ufbx_material_map &p_map) {}

static Color _material_color(const ufbx_material_map &p_map, const ufbx_material_map &p_factor) {}

static const ufbx_texture *_get_file_texture(const ufbx_texture *p_texture) {}

static Ref<Image> _get_decompressed_image(Ref<Texture2D> texture) {}

static Vector<Vector2> _decode_vertex_attrib_vec2(const ufbx_vertex_vec2 &p_attrib, const Vector<uint32_t> &p_indices) {}

static Vector<Vector3> _decode_vertex_attrib_vec3(const ufbx_vertex_vec3 &p_attrib, const Vector<uint32_t> &p_indices) {}

static Vector<float> _decode_vertex_attrib_vec3_as_tangent(const ufbx_vertex_vec3 &p_attrib, const Vector<uint32_t> &p_indices) {}

static Vector<Color> _decode_vertex_attrib_color(const ufbx_vertex_vec4 &p_attrib, const Vector<uint32_t> &p_indices) {}

static Vector3 _encode_vertex_index(uint32_t p_index) {}

static uint32_t _decode_vertex_index(const Vector3 &p_vertex) {}

static ufbx_skin_deformer *_find_skin_deformer(ufbx_skin_cluster *p_cluster) {}

static String _find_element_name(ufbx_element *p_element) {}

struct ThreadPoolFBX {};

static void _thread_pool_task(void *user, uint32_t index) {}

static bool _thread_pool_init_fn(void *user, ufbx_thread_pool_context ctx, const ufbx_thread_pool_info *info) {}

static bool _thread_pool_run_fn(void *user, ufbx_thread_pool_context ctx, uint32_t group, uint32_t start_index, uint32_t count) {}

static bool _thread_pool_wait_fn(void *user, ufbx_thread_pool_context ctx, uint32_t group, uint32_t max_index) {}

String FBXDocument::_gen_unique_name(HashSet<String> &unique_names, const String &p_name) {}

String FBXDocument::_sanitize_animation_name(const String &p_name) {}

String FBXDocument::_gen_unique_animation_name(Ref<FBXState> p_state, const String &p_name) {}

Error FBXDocument::_parse_scenes(Ref<FBXState> p_state) {}

Error FBXDocument::_parse_nodes(Ref<FBXState> p_state) {}

Error FBXDocument::_parse_meshes(Ref<FBXState> p_state) {}

Ref<Image> FBXDocument::_parse_image_bytes_into_image(Ref<FBXState> p_state, const Vector<uint8_t> &p_bytes, const String &p_filename, int p_index) {}

GLTFImageIndex FBXDocument::_parse_image_save_image(Ref<FBXState> p_state, const Vector<uint8_t> &p_bytes, const String &p_file_extension, int p_index, Ref<Image> p_image) {}

Error FBXDocument::_parse_images(Ref<FBXState> p_state, const String &p_base_path) {}

Ref<Texture2D> FBXDocument::_get_texture(Ref<FBXState> p_state, const GLTFTextureIndex p_texture, int p_texture_types) {}

Error FBXDocument::_parse_materials(Ref<FBXState> p_state) {}
Error FBXDocument::_parse_cameras(Ref<FBXState> p_state) {}

Error FBXDocument::_parse_animations(Ref<FBXState> p_state) {}

void FBXDocument::_assign_node_names(Ref<FBXState> p_state) {}

BoneAttachment3D *FBXDocument::_generate_bone_attachment(Ref<FBXState> p_state, Skeleton3D *p_skeleton, const GLTFNodeIndex p_node_index, const GLTFNodeIndex p_bone_index) {}

ImporterMeshInstance3D *FBXDocument::_generate_mesh_instance(Ref<FBXState> p_state, const GLTFNodeIndex p_node_index) {}

Camera3D *FBXDocument::_generate_camera(Ref<FBXState> p_state, const GLTFNodeIndex p_node_index) {}

Light3D *FBXDocument::_generate_light(Ref<FBXState> p_state, const GLTFNodeIndex p_node_index) {}

Node3D *FBXDocument::_generate_spatial(Ref<FBXState> p_state, const GLTFNodeIndex p_node_index) {}

void FBXDocument::_generate_scene_node(Ref<FBXState> p_state, const GLTFNodeIndex p_node_index, Node *p_scene_parent, Node *p_scene_root) {}

void FBXDocument::_generate_skeleton_bone_node(Ref<FBXState> p_state, const GLTFNodeIndex p_node_index, Node *p_scene_parent, Node *p_scene_root) {}

void FBXDocument::_import_animation(Ref<FBXState> p_state, AnimationPlayer *p_animation_player, const GLTFAnimationIndex p_index, const bool p_trimming, const bool p_remove_immutable_tracks) {}

void FBXDocument::_process_mesh_instances(Ref<FBXState> p_state, Node *p_scene_root) {}

Error FBXDocument::_parse(Ref<FBXState> p_state, String p_path, Ref<FileAccess> p_file) {}

Node *FBXDocument::generate_scene(Ref<GLTFState> p_state, float p_bake_fps, bool p_trimming, bool p_remove_immutable_tracks) {}

Error FBXDocument::append_from_buffer(PackedByteArray p_bytes, String p_base_path, Ref<GLTFState> p_state, uint32_t p_flags) {}

Error FBXDocument::_parse_fbx_state(Ref<FBXState> p_state, const String &p_search_path) {}

Error FBXDocument::append_from_file(String p_path, Ref<GLTFState> p_state, uint32_t p_flags, String p_base_path) {}

void FBXDocument::_process_uv_set(PackedVector2Array &uv_array) {}

void FBXDocument::_zero_unused_elements(Vector<float> &cur_custom, int start, int end, int num_channels) {}

Error FBXDocument::_parse_lights(Ref<FBXState> p_state) {}

String FBXDocument::_get_texture_path(const String &p_base_dir, const String &p_source_file_path) const {}

Error FBXDocument::_parse_skins(Ref<FBXState> p_state) {}

PackedByteArray FBXDocument::generate_buffer(Ref<GLTFState> p_state) {}

Error FBXDocument::write_to_filesystem(Ref<GLTFState> p_state, const String &p_path) {}

Error FBXDocument::append_from_scene(Node *p_node, Ref<GLTFState> p_state, uint32_t p_flags) {}

Vector3 FBXDocument::_as_vec3(const ufbx_vec3 &p_vector) {}

String FBXDocument::_as_string(const ufbx_string &p_string) {}

Transform3D FBXDocument::_as_xform(const ufbx_matrix &p_mat) {}