summaryrefslogtreecommitdiff
path: root/modules/gltf
diff options
context:
space:
mode:
Diffstat (limited to 'modules/gltf')
-rw-r--r--modules/gltf/doc_classes/GLTFDocument.xml1
-rw-r--r--modules/gltf/doc_classes/GLTFState.xml19
-rw-r--r--modules/gltf/editor/editor_scene_importer_blend.cpp8
-rw-r--r--modules/gltf/editor/editor_scene_importer_fbx.cpp2
-rw-r--r--modules/gltf/editor/editor_scene_importer_gltf.cpp26
-rw-r--r--modules/gltf/editor/editor_scene_importer_gltf.h2
-rw-r--r--modules/gltf/gltf_document.cpp263
-rw-r--r--modules/gltf/gltf_document.h12
-rw-r--r--modules/gltf/gltf_state.cpp7
-rw-r--r--modules/gltf/gltf_state.h26
10 files changed, 288 insertions, 78 deletions
diff --git a/modules/gltf/doc_classes/GLTFDocument.xml b/modules/gltf/doc_classes/GLTFDocument.xml
index d7e8141eb1..d6657cad5d 100644
--- a/modules/gltf/doc_classes/GLTFDocument.xml
+++ b/modules/gltf/doc_classes/GLTFDocument.xml
@@ -51,6 +51,7 @@
<param index="0" name="state" type="GLTFState" />
<param index="1" name="bake_fps" type="float" default="30" />
<param index="2" name="trimming" type="bool" default="false" />
+ <param index="3" name="remove_immutable_tracks" type="bool" default="true" />
<description>
Takes a [GLTFState] object through the [param state] parameter and returns a Godot Engine scene node.
</description>
diff --git a/modules/gltf/doc_classes/GLTFState.xml b/modules/gltf/doc_classes/GLTFState.xml
index 9a554a0d49..b8943795a0 100644
--- a/modules/gltf/doc_classes/GLTFState.xml
+++ b/modules/gltf/doc_classes/GLTFState.xml
@@ -55,6 +55,11 @@
<description>
</description>
</method>
+ <method name="get_handle_binary_image">
+ <return type="int" />
+ <description>
+ </description>
+ </method>
<method name="get_images">
<return type="Texture2D[]" />
<description>
@@ -155,6 +160,12 @@
<description>
</description>
</method>
+ <method name="set_handle_binary_image">
+ <return type="void" />
+ <param index="0" name="method" type="int" />
+ <description>
+ </description>
+ </method>
<method name="set_images">
<return type="void" />
<param index="0" name="images" type="Texture2D[]" />
@@ -251,4 +262,12 @@
<member name="use_named_skin_binds" type="bool" setter="set_use_named_skin_binds" getter="get_use_named_skin_binds" default="false">
</member>
</members>
+ <constants>
+ <constant name="HANDLE_BINARY_DISCARD_TEXTURES" value="0">
+ </constant>
+ <constant name="HANDLE_BINARY_EXTRACT_TEXTURES" value="1">
+ </constant>
+ <constant name="HANDLE_BINARY_EMBED_AS_BASISU" value="2">
+ </constant>
+ </constants>
</class>
diff --git a/modules/gltf/editor/editor_scene_importer_blend.cpp b/modules/gltf/editor/editor_scene_importer_blend.cpp
index 2b8c057ee5..5415c5818f 100644
--- a/modules/gltf/editor/editor_scene_importer_blend.cpp
+++ b/modules/gltf/editor/editor_scene_importer_blend.cpp
@@ -32,6 +32,7 @@
#ifdef TOOLS_ENABLED
+#include "../gltf_defines.h"
#include "../gltf_document.h"
#include "core/config/project_settings.h"
@@ -43,7 +44,6 @@
#include "scene/gui/line_edit.h"
#ifdef WINDOWS_ENABLED
-// Code by Pedro Estebanez (https://github.com/godotengine/godot/pull/59766)
#include <shlwapi.h>
#endif
@@ -221,6 +221,7 @@ Node *EditorSceneFormatImporterBlend::import_scene(const String &p_path, uint32_
gltf.instantiate();
Ref<GLTFState> state;
state.instantiate();
+
String base_dir;
if (p_options.has(SNAME("blender/materials/unpack_enabled")) && p_options[SNAME("blender/materials/unpack_enabled")]) {
base_dir = sink.get_base_dir();
@@ -232,7 +233,7 @@ Node *EditorSceneFormatImporterBlend::import_scene(const String &p_path, uint32_
}
return nullptr;
}
- return gltf->generate_scene(state, (float)p_options["animation/fps"], (bool)p_options["animation/trimming"]);
+ return gltf->generate_scene(state, (float)p_options["animation/fps"], (bool)p_options["animation/trimming"], (bool)p_options["animation/remove_immutable_tracks"]);
}
Variant EditorSceneFormatImporterBlend::get_option_visibility(const String &p_path, bool p_for_animation, const String &p_option,
@@ -274,9 +275,6 @@ void EditorSceneFormatImporterBlend::get_import_options(const String &p_path, Li
ADD_OPTION_BOOL("blender/animation/limit_playback", true);
ADD_OPTION_BOOL("blender/animation/always_sample", true);
ADD_OPTION_BOOL("blender/animation/group_tracks", true);
-
-#undef ADD_OPTION_BOOL
-#undef ADD_OPTION_ENUM
}
///////////////////////////
diff --git a/modules/gltf/editor/editor_scene_importer_fbx.cpp b/modules/gltf/editor/editor_scene_importer_fbx.cpp
index 6c6ab7cd03..d829630032 100644
--- a/modules/gltf/editor/editor_scene_importer_fbx.cpp
+++ b/modules/gltf/editor/editor_scene_importer_fbx.cpp
@@ -100,7 +100,7 @@ Node *EditorSceneFormatImporterFBX::import_scene(const String &p_path, uint32_t
}
return nullptr;
}
- return gltf->generate_scene(state, (float)p_options["animation/fps"], (bool)p_options["animation/trimming"]);
+ return gltf->generate_scene(state, (float)p_options["animation/fps"], (bool)p_options["animation/trimming"], (bool)p_options["animation/remove_immutable_tracks"]);
}
Variant EditorSceneFormatImporterFBX::get_option_visibility(const String &p_path, bool p_for_animation,
diff --git a/modules/gltf/editor/editor_scene_importer_gltf.cpp b/modules/gltf/editor/editor_scene_importer_gltf.cpp
index 39956a6ff6..67bbf8dd15 100644
--- a/modules/gltf/editor/editor_scene_importer_gltf.cpp
+++ b/modules/gltf/editor/editor_scene_importer_gltf.cpp
@@ -32,6 +32,7 @@
#include "editor_scene_importer_gltf.h"
+#include "../gltf_defines.h"
#include "../gltf_document.h"
uint32_t EditorSceneFormatImporterGLTF::get_import_flags() const {
@@ -50,6 +51,10 @@ Node *EditorSceneFormatImporterGLTF::import_scene(const String &p_path, uint32_t
doc.instantiate();
Ref<GLTFState> state;
state.instantiate();
+ if (p_options.has("meshes/handle_gltf_embedded_images")) {
+ int32_t enum_option = p_options["meshes/handle_gltf_embedded_images"];
+ state->set_handle_binary_image(enum_option);
+ }
Error err = doc->append_from_file(p_path, state, p_flags);
if (err != OK) {
if (r_err) {
@@ -61,11 +66,28 @@ Node *EditorSceneFormatImporterGLTF::import_scene(const String &p_path, uint32_t
state->set_create_animations(bool(p_options["animation/import"]));
}
+#ifndef DISABLE_DEPRECATED
if (p_options.has("animation/trimming")) {
- return doc->generate_scene(state, (float)p_options["animation/fps"], (bool)p_options["animation/trimming"]);
+ if (p_options.has("animation/remove_immutable_tracks")) {
+ return doc->generate_scene(state, (float)p_options["animation/fps"], (bool)p_options["animation/trimming"], (bool)p_options["animation/remove_immutable_tracks"]);
+ } else {
+ return doc->generate_scene(state, (float)p_options["animation/fps"], (bool)p_options["animation/trimming"], true);
+ }
} else {
- return doc->generate_scene(state, (float)p_options["animation/fps"], false);
+ if (p_options.has("animation/remove_immutable_tracks")) {
+ return doc->generate_scene(state, (float)p_options["animation/fps"], false, (bool)p_options["animation/remove_immutable_tracks"]);
+ } else {
+ return doc->generate_scene(state, (float)p_options["animation/fps"], false, true);
+ }
}
+#else
+ return doc->generate_scene(state, (float)p_options["animation/fps"], (bool)p_options["animation/trimming"], (bool)p_options["animation/remove_immutable_tracks"]);
+#endif
+}
+
+void EditorSceneFormatImporterGLTF::get_import_options(const String &p_path,
+ List<ResourceImporter::ImportOption> *r_options) {
+ r_options->push_back(ResourceImporterScene::ImportOption(PropertyInfo(Variant::INT, "meshes/handle_gltf_embedded_images", PROPERTY_HINT_ENUM, "Discard All Textures,Extract Textures,Embed As Basis Universal", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), GLTFState::HANDLE_BINARY_EXTRACT_TEXTURES));
}
#endif // TOOLS_ENABLED
diff --git a/modules/gltf/editor/editor_scene_importer_gltf.h b/modules/gltf/editor/editor_scene_importer_gltf.h
index c2a4bf046d..ed57ec8cdb 100644
--- a/modules/gltf/editor/editor_scene_importer_gltf.h
+++ b/modules/gltf/editor/editor_scene_importer_gltf.h
@@ -47,6 +47,8 @@ public:
virtual Node *import_scene(const String &p_path, uint32_t p_flags,
const HashMap<StringName, Variant> &p_options,
List<String> *r_missing_deps, Error *r_err = nullptr) override;
+ virtual void get_import_options(const String &p_path,
+ List<ResourceImporter::ImportOption> *r_options) override;
};
#endif // TOOLS_ENABLED
diff --git a/modules/gltf/gltf_document.cpp b/modules/gltf/gltf_document.cpp
index b243ba933d..5950ad33b5 100644
--- a/modules/gltf/gltf_document.cpp
+++ b/modules/gltf/gltf_document.cpp
@@ -33,6 +33,7 @@
#include "extensions/gltf_spec_gloss.h"
#include "core/crypto/crypto_core.h"
+#include "core/io/config_file.h"
#include "core/io/dir_access.h"
#include "core/io/file_access.h"
#include "core/io/file_access_memory.h"
@@ -543,6 +544,7 @@ String GLTFDocument::_gen_unique_bone_name(Ref<GLTFState> p_state, const GLTFSke
}
Error GLTFDocument::_parse_scenes(Ref<GLTFState> p_state) {
+ p_state->unique_names.insert("Skeleton3D"); // Reserve skeleton name.
ERR_FAIL_COND_V(!p_state->json.has("scenes"), ERR_FILE_CORRUPT);
const Array &scenes = p_state->json["scenes"];
int loaded_scene = 0;
@@ -3063,6 +3065,7 @@ Error GLTFDocument::_parse_images(Ref<GLTFState> p_state, const String &p_base_p
// Ref: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#images
const Array &images = p_state->json["images"];
+ HashSet<String> used_names;
for (int i = 0; i < images.size(); i++) {
const Dictionary &d = images[i];
@@ -3089,6 +3092,19 @@ Error GLTFDocument::_parse_images(Ref<GLTFState> p_state, const String &p_base_p
const uint8_t *data_ptr = nullptr;
int data_size = 0;
+ String image_name;
+ if (d.has("name")) {
+ image_name = d["name"];
+ image_name = image_name.get_file().get_basename().validate_filename();
+ }
+ if (image_name.is_empty()) {
+ image_name = itos(i);
+ }
+ while (used_names.has(image_name)) {
+ image_name += "_" + itos(i);
+ }
+ used_names.insert(image_name);
+
if (d.has("uri")) {
// Handles the first two bullet points from the spec (embedded data, or external file).
String uri = d["uri"];
@@ -3127,6 +3143,7 @@ Error GLTFDocument::_parse_images(Ref<GLTFState> p_state, const String &p_base_p
String extension = uri.get_extension().to_lower();
if (texture.is_valid()) {
p_state->images.push_back(texture);
+ p_state->source_images.push_back(texture->get_image());
continue;
} else if (mimetype == "image/png" || mimetype == "image/jpeg" || extension == "png" || extension == "jpg" || extension == "jpeg") {
// Fallback to loading as byte array.
@@ -3196,9 +3213,69 @@ Error GLTFDocument::_parse_images(Ref<GLTFState> p_state, const String &p_base_p
if (img.is_null()) {
ERR_PRINT(vformat("glTF: Couldn't load image index '%d' with its given mimetype: %s.", i, mimetype));
p_state->images.push_back(Ref<Texture2D>());
+ p_state->source_images.push_back(Ref<Image>());
continue;
}
- p_state->images.push_back(ImageTexture::create_from_image(img));
+ img->set_name(image_name);
+ if (GLTFState::GLTFHandleBinary(p_state->handle_binary_image) == GLTFState::GLTFHandleBinary::HANDLE_BINARY_DISCARD_TEXTURES) {
+ p_state->images.push_back(Ref<Texture2D>());
+ p_state->source_images.push_back(Ref<Image>());
+ continue;
+ } else if (GLTFState::GLTFHandleBinary(p_state->handle_binary_image) == GLTFState::GLTFHandleBinary::HANDLE_BINARY_EXTRACT_TEXTURES) {
+ if (p_state->base_path.is_empty()) {
+ p_state->images.push_back(Ref<Texture2D>());
+ p_state->source_images.push_back(Ref<Image>());
+ } else if (img->get_name().is_empty()) {
+ WARN_PRINT(vformat("glTF: Image index '%d' couldn't be named. Skipping it.", i));
+ p_state->images.push_back(Ref<Texture2D>());
+ p_state->source_images.push_back(Ref<Image>());
+ } else {
+ String file_path = p_state->get_base_path() + "/" + p_state->filename.get_basename() + "_" + img->get_name() + ".png";
+ Ref<ConfigFile> config;
+ config.instantiate();
+ if (FileAccess::exists(file_path + ".import")) {
+ config->load(file_path + ".import");
+ }
+ config->set_value("remap", "importer", "texture");
+ config->set_value("remap", "type", "Texture2D");
+ if (!config->has_section_key("params", "compress/mode")) {
+ config->set_value("remap", "compress/mode", 2); //user may want another compression, so leave it bes
+ }
+ if (!config->has_section_key("params", "mipmaps/generate")) {
+ config->set_value("params", "mipmaps/generate", true);
+ }
+ Error err = OK;
+ err = config->save(file_path + ".import");
+ ERR_FAIL_COND_V(err != OK, err);
+ img->save_png(file_path);
+ ERR_FAIL_COND_V(err != OK, err);
+ ResourceLoader::import(file_path);
+ Ref<Texture2D> saved_image = ResourceLoader::load(file_path, "Texture2D");
+ if (saved_image.is_valid()) {
+ p_state->images.push_back(saved_image);
+ p_state->source_images.push_back(img);
+ } else {
+ WARN_PRINT(vformat("glTF: Image index '%d' couldn't be loaded with the name: %s. Skipping it.", i, img->get_name()));
+ // Placeholder to keep count.
+ p_state->images.push_back(Ref<Texture2D>());
+ p_state->source_images.push_back(Ref<Image>());
+ }
+ }
+ continue;
+ } else if (GLTFState::GLTFHandleBinary(p_state->handle_binary_image) == GLTFState::GLTFHandleBinary::HANDLE_BINARY_EMBED_AS_BASISU) {
+ Ref<PortableCompressedTexture2D> tex;
+ tex.instantiate();
+ tex->set_name(img->get_name());
+ tex->set_keep_compressed_buffer(true);
+ p_state->source_images.push_back(img);
+ tex->create_from_image(img, PortableCompressedTexture2D::COMPRESSION_MODE_BASIS_UNIVERSAL);
+ p_state->images.push_back(tex);
+ p_state->source_images.push_back(img);
+ continue;
+ }
+
+ p_state->images.push_back(Ref<Texture2D>());
+ p_state->source_images.push_back(Ref<Image>());
}
print_verbose("glTF: Total images: " + itos(p_state->images.size()));
@@ -3268,12 +3345,24 @@ GLTFTextureIndex GLTFDocument::_set_texture(Ref<GLTFState> p_state, Ref<Texture2
return gltf_texture_i;
}
-Ref<Texture2D> GLTFDocument::_get_texture(Ref<GLTFState> p_state, const GLTFTextureIndex p_texture) {
+Ref<Texture2D> GLTFDocument::_get_texture(Ref<GLTFState> p_state, const GLTFTextureIndex p_texture, int p_texture_types) {
ERR_FAIL_INDEX_V(p_texture, p_state->textures.size(), Ref<Texture2D>());
const GLTFImageIndex image = p_state->textures[p_texture]->get_src_image();
-
ERR_FAIL_INDEX_V(image, p_state->images.size(), Ref<Texture2D>());
-
+ if (GLTFState::GLTFHandleBinary(p_state->handle_binary_image) == GLTFState::GLTFHandleBinary::HANDLE_BINARY_EMBED_AS_BASISU) {
+ Ref<PortableCompressedTexture2D> portable_texture;
+ portable_texture.instantiate();
+ portable_texture->set_keep_compressed_buffer(true);
+ Ref<Image> new_img = p_state->source_images[p_texture]->duplicate();
+ ERR_FAIL_COND_V(new_img.is_null(), Ref<Texture2D>());
+ new_img->generate_mipmaps();
+ if (p_texture_types) {
+ portable_texture->create_from_image(new_img, PortableCompressedTexture2D::COMPRESSION_MODE_BASIS_UNIVERSAL, true);
+ } else {
+ portable_texture->create_from_image(new_img, PortableCompressedTexture2D::COMPRESSION_MODE_BASIS_UNIVERSAL, false);
+ }
+ p_state->images.write[image] = portable_texture;
+ }
return p_state->images[image];
}
@@ -3684,7 +3773,7 @@ Error GLTFDocument::_parse_materials(Ref<GLTFState> p_state) {
material->set_texture_filter(diffuse_sampler->get_filter_mode());
material->set_flag(BaseMaterial3D::FLAG_USE_TEXTURE_REPEAT, diffuse_sampler->get_wrap_mode());
}
- Ref<Texture2D> diffuse_texture = _get_texture(p_state, diffuse_texture_dict["index"]);
+ Ref<Texture2D> diffuse_texture = _get_texture(p_state, diffuse_texture_dict["index"], TEXTURE_TYPE_GENERIC);
if (diffuse_texture.is_valid()) {
spec_gloss->diffuse_img = diffuse_texture->get_image();
material->set_texture(BaseMaterial3D::TEXTURE_ALBEDO, diffuse_texture);
@@ -3712,7 +3801,7 @@ Error GLTFDocument::_parse_materials(Ref<GLTFState> p_state) {
if (sgm.has("specularGlossinessTexture")) {
const Dictionary &spec_gloss_texture = sgm["specularGlossinessTexture"];
if (spec_gloss_texture.has("index")) {
- const Ref<Texture2D> orig_texture = _get_texture(p_state, spec_gloss_texture["index"]);
+ const Ref<Texture2D> orig_texture = _get_texture(p_state, spec_gloss_texture["index"], TEXTURE_TYPE_GENERIC);
if (orig_texture.is_valid()) {
spec_gloss->spec_gloss_img = orig_texture->get_image();
}
@@ -3735,7 +3824,7 @@ Error GLTFDocument::_parse_materials(Ref<GLTFState> p_state) {
Ref<GLTFTextureSampler> bct_sampler = _get_sampler_for_texture(p_state, bct["index"]);
material->set_texture_filter(bct_sampler->get_filter_mode());
material->set_flag(BaseMaterial3D::FLAG_USE_TEXTURE_REPEAT, bct_sampler->get_wrap_mode());
- material->set_texture(BaseMaterial3D::TEXTURE_ALBEDO, _get_texture(p_state, bct["index"]));
+ material->set_texture(BaseMaterial3D::TEXTURE_ALBEDO, _get_texture(p_state, bct["index"], TEXTURE_TYPE_GENERIC));
}
if (!mr.has("baseColorFactor")) {
material->set_albedo(Color(1, 1, 1));
@@ -3758,7 +3847,7 @@ Error GLTFDocument::_parse_materials(Ref<GLTFState> p_state) {
if (mr.has("metallicRoughnessTexture")) {
const Dictionary &bct = mr["metallicRoughnessTexture"];
if (bct.has("index")) {
- const Ref<Texture2D> t = _get_texture(p_state, bct["index"]);
+ const Ref<Texture2D> t = _get_texture(p_state, bct["index"], TEXTURE_TYPE_GENERIC);
material->set_texture(BaseMaterial3D::TEXTURE_METALLIC, t);
material->set_metallic_texture_channel(BaseMaterial3D::TEXTURE_CHANNEL_BLUE);
material->set_texture(BaseMaterial3D::TEXTURE_ROUGHNESS, t);
@@ -3776,7 +3865,7 @@ Error GLTFDocument::_parse_materials(Ref<GLTFState> p_state) {
if (d.has("normalTexture")) {
const Dictionary &bct = d["normalTexture"];
if (bct.has("index")) {
- material->set_texture(BaseMaterial3D::TEXTURE_NORMAL, _get_texture(p_state, bct["index"]));
+ material->set_texture(BaseMaterial3D::TEXTURE_NORMAL, _get_texture(p_state, bct["index"], TEXTURE_TYPE_NORMAL));
material->set_feature(BaseMaterial3D::FEATURE_NORMAL_MAPPING, true);
}
if (bct.has("scale")) {
@@ -3786,7 +3875,7 @@ Error GLTFDocument::_parse_materials(Ref<GLTFState> p_state) {
if (d.has("occlusionTexture")) {
const Dictionary &bct = d["occlusionTexture"];
if (bct.has("index")) {
- material->set_texture(BaseMaterial3D::TEXTURE_AMBIENT_OCCLUSION, _get_texture(p_state, bct["index"]));
+ material->set_texture(BaseMaterial3D::TEXTURE_AMBIENT_OCCLUSION, _get_texture(p_state, bct["index"], TEXTURE_TYPE_GENERIC));
material->set_ao_texture_channel(BaseMaterial3D::TEXTURE_CHANNEL_RED);
material->set_feature(BaseMaterial3D::FEATURE_AMBIENT_OCCLUSION, true);
}
@@ -3804,7 +3893,7 @@ Error GLTFDocument::_parse_materials(Ref<GLTFState> p_state) {
if (d.has("emissiveTexture")) {
const Dictionary &bct = d["emissiveTexture"];
if (bct.has("index")) {
- material->set_texture(BaseMaterial3D::TEXTURE_EMISSION, _get_texture(p_state, bct["index"]));
+ material->set_texture(BaseMaterial3D::TEXTURE_EMISSION, _get_texture(p_state, bct["index"], TEXTURE_TYPE_GENERIC));
material->set_feature(BaseMaterial3D::FEATURE_EMISSION, true);
material->set_emission(Color(0, 0, 0));
}
@@ -4233,6 +4322,21 @@ Error GLTFDocument::_parse_skins(Ref<GLTFState> p_state) {
return OK;
}
+void GLTFDocument::_recurse_children(Ref<GLTFState> p_state, const GLTFNodeIndex p_node_index,
+ RBSet<GLTFNodeIndex> &p_all_skin_nodes, HashSet<GLTFNodeIndex> &p_child_visited_set) {
+ if (p_child_visited_set.has(p_node_index)) {
+ return;
+ }
+ p_child_visited_set.insert(p_node_index);
+ for (int i = 0; i < p_state->nodes[p_node_index]->children.size(); ++i) {
+ _recurse_children(p_state, p_state->nodes[p_node_index]->children[i], p_all_skin_nodes, p_child_visited_set);
+ }
+
+ if (p_state->nodes[p_node_index]->skin < 0 || p_state->nodes[p_node_index]->mesh < 0 || !p_state->nodes[p_node_index]->children.is_empty()) {
+ p_all_skin_nodes.insert(p_node_index);
+ }
+}
+
Error GLTFDocument::_determine_skeletons(Ref<GLTFState> p_state) {
// Using a disjoint set, we are going to potentially combine all skins that are actually branches
// of a main skeleton, or treat skins defining the same set of nodes as ONE skeleton.
@@ -4243,16 +4347,21 @@ Error GLTFDocument::_determine_skeletons(Ref<GLTFState> p_state) {
for (GLTFSkinIndex skin_i = 0; skin_i < p_state->skins.size(); ++skin_i) {
const Ref<GLTFSkin> skin = p_state->skins[skin_i];
- Vector<GLTFNodeIndex> all_skin_nodes;
- all_skin_nodes.append_array(skin->joints);
- all_skin_nodes.append_array(skin->non_joints);
-
- for (int i = 0; i < all_skin_nodes.size(); ++i) {
- const GLTFNodeIndex node_index = all_skin_nodes[i];
+ HashSet<GLTFNodeIndex> child_visited_set;
+ RBSet<GLTFNodeIndex> all_skin_nodes;
+ for (int i = 0; i < skin->joints.size(); ++i) {
+ all_skin_nodes.insert(skin->joints[i]);
+ _recurse_children(p_state, skin->joints[i], all_skin_nodes, child_visited_set);
+ }
+ for (int i = 0; i < skin->non_joints.size(); ++i) {
+ all_skin_nodes.insert(skin->non_joints[i]);
+ _recurse_children(p_state, skin->non_joints[i], all_skin_nodes, child_visited_set);
+ }
+ for (GLTFNodeIndex node_index : all_skin_nodes) {
const GLTFNodeIndex parent = p_state->nodes[node_index]->parent;
skeleton_sets.insert(node_index);
- if (all_skin_nodes.find(parent) >= 0) {
+ if (all_skin_nodes.has(parent)) {
skeleton_sets.create_union(parent, node_index);
}
}
@@ -4471,7 +4580,7 @@ Error GLTFDocument::_create_skeletons(Ref<GLTFState> p_state) {
p_state->skeleton3d_to_gltf_skeleton[skeleton->get_instance_id()] = skel_i;
// Make a unique name, no gltf node represents this skeleton
- skeleton->set_name(_gen_unique_name(p_state, "Skeleton3D"));
+ skeleton->set_name("Skeleton3D");
List<GLTFNodeIndex> bones;
@@ -5163,6 +5272,7 @@ ImporterMeshInstance3D *GLTFDocument::_generate_mesh_instance(Ref<GLTFState> p_s
ImporterMeshInstance3D *mi = memnew(ImporterMeshInstance3D);
print_verbose("glTF: Creating mesh for: " + gltf_node->get_name());
+ p_state->scene_mesh_instances.insert(p_node_index, mi);
Ref<GLTFMesh> mesh = p_state->meshes.write[gltf_node->mesh];
if (mesh.is_null()) {
return mi;
@@ -5603,7 +5713,7 @@ void GLTFDocument::_generate_scene_node(Ref<GLTFState> p_state, Node *scene_pare
bone_attachment->set_owner(scene_root);
// There is no gltf_node that represent this, so just directly create a unique name
- bone_attachment->set_name(_gen_unique_name(p_state, "BoneAttachment3D"));
+ bone_attachment->set_name(gltf_node->get_name());
// We change the scene_parent to our bone attachment now. We do not set current_node because we want to make the node
// and attach it to the bone_attachment
@@ -5619,7 +5729,13 @@ void GLTFDocument::_generate_scene_node(Ref<GLTFState> p_state, Node *scene_pare
}
// If none of our GLTFDocumentExtension classes generated us a node, we generate one.
if (!current_node) {
- if (gltf_node->mesh >= 0) {
+ if (gltf_node->skin >= 0 && gltf_node->mesh >= 0 && !gltf_node->children.is_empty()) {
+ current_node = _generate_spatial(p_state, node_index);
+ Node3D *mesh_inst = _generate_mesh_instance(p_state, node_index);
+ mesh_inst->set_name(gltf_node->get_name());
+
+ current_node->add_child(mesh_inst, true);
+ } else if (gltf_node->mesh >= 0) {
current_node = _generate_mesh_instance(p_state, node_index);
} else if (gltf_node->camera >= 0) {
current_node = _generate_camera(p_state, node_index);
@@ -5640,7 +5756,6 @@ void GLTFDocument::_generate_scene_node(Ref<GLTFState> p_state, Node *scene_pare
current_node->set_name(gltf_node->get_name());
p_state->scene_nodes.insert(node_index, current_node);
-
for (int i = 0; i < gltf_node->children.size(); ++i) {
_generate_scene_node(p_state, current_node, scene_root, gltf_node->children[i]);
}
@@ -5659,22 +5774,17 @@ void GLTFDocument::_generate_skeleton_bone_node(Ref<GLTFState> p_state, Node *p_
Skeleton3D *active_skeleton = Object::cast_to<Skeleton3D>(p_scene_parent);
if (active_skeleton != skeleton) {
if (active_skeleton) {
- // Bone Attachment - Direct Parented Skeleton Case
+ // Should no longer be possible.
+ ERR_PRINT(vformat("glTF: Generating scene detected direct parented Skeletons at node %d", p_node_index));
BoneAttachment3D *bone_attachment = _generate_bone_attachment(p_state, active_skeleton, p_node_index, gltf_node->parent);
-
p_scene_parent->add_child(bone_attachment, true);
bone_attachment->set_owner(p_scene_root);
-
// There is no gltf_node that represent this, so just directly create a unique name
bone_attachment->set_name(_gen_unique_name(p_state, "BoneAttachment3D"));
-
// We change the scene_parent to our bone attachment now. We do not set current_node because we want to make the node
// and attach it to the bone_attachment
p_scene_parent = bone_attachment;
- WARN_PRINT(vformat("glTF: Generating scene detected direct parented Skeletons at node %d", p_node_index));
}
-
- // Add it to the scene if it has not already been added
if (skeleton->get_parent() == nullptr) {
p_scene_parent->add_child(skeleton, true);
skeleton->set_owner(p_scene_root);
@@ -5682,9 +5792,10 @@ void GLTFDocument::_generate_skeleton_bone_node(Ref<GLTFState> p_state, Node *p_
}
active_skeleton = skeleton;
- current_node = skeleton;
+ current_node = active_skeleton;
if (requires_extra_node) {
+ current_node = nullptr;
// skinned meshes must not be placed in a bone attachment.
if (!is_skinned_mesh) {
// Bone Attachment - Same Node Case
@@ -5694,7 +5805,7 @@ void GLTFDocument::_generate_skeleton_bone_node(Ref<GLTFState> p_state, Node *p_
bone_attachment->set_owner(p_scene_root);
// There is no gltf_node that represent this, so just directly create a unique name
- bone_attachment->set_name(_gen_unique_name(p_state, "BoneAttachment3D"));
+ bone_attachment->set_name(gltf_node->get_name());
// We change the scene_parent to our bone attachment now. We do not set current_node because we want to make the node
// and attach it to the bone_attachment
@@ -5859,7 +5970,7 @@ T GLTFDocument::_interpolate_track(const Vector<real_t> &p_times, const Vector<T
ERR_FAIL_V(p_values[0]);
}
-void GLTFDocument::_import_animation(Ref<GLTFState> p_state, AnimationPlayer *p_animation_player, const GLTFAnimationIndex p_index, const float p_bake_fps, const bool p_trimming) {
+void GLTFDocument::_import_animation(Ref<GLTFState> p_state, AnimationPlayer *p_animation_player, const GLTFAnimationIndex p_index, const float p_bake_fps, const bool p_trimming, const bool p_remove_immutable_tracks) {
Ref<GLTFAnimation> anim = p_state->animations[p_index];
String anim_name = anim->get_name();
@@ -5885,6 +5996,8 @@ void GLTFDocument::_import_animation(Ref<GLTFState> p_state, AnimationPlayer *p_
NodePath node_path;
//for skeletons, transform tracks always affect bones
NodePath transform_node_path;
+ //for meshes, especially skinned meshes, there are cases where it will be added as a child
+ NodePath mesh_instance_node_path;
GLTFNodeIndex node_index = track_i.key;
@@ -5895,6 +6008,12 @@ void GLTFDocument::_import_animation(Ref<GLTFState> p_state, AnimationPlayer *p_
HashMap<GLTFNodeIndex, Node *>::Iterator node_element = p_state->scene_nodes.find(node_index);
ERR_CONTINUE_MSG(!node_element, vformat("Unable to find node %d for animation", node_index));
node_path = root->get_path_to(node_element->value);
+ HashMap<GLTFNodeIndex, ImporterMeshInstance3D *>::Iterator mesh_instance_element = p_state->scene_mesh_instances.find(node_index);
+ if (mesh_instance_element) {
+ mesh_instance_node_path = root->get_path_to(mesh_instance_element->value);
+ } else {
+ mesh_instance_node_path = node_path;
+ }
if (gltf_node->skeleton >= 0) {
const Skeleton3D *sk = p_state->skeletons[gltf_node->skeleton]->godot_skeleton;
@@ -5954,35 +6073,38 @@ void GLTFDocument::_import_animation(Ref<GLTFState> p_state, AnimationPlayer *p_
int scale_idx = -1;
if (track.position_track.values.size()) {
- Vector3 base_pos = p_state->nodes[track_i.key]->position;
- bool not_default = false; //discard the track if all it contains is default values
- for (int i = 0; i < track.position_track.times.size(); i++) {
- Vector3 value = track.position_track.values[track.position_track.interpolation == GLTFAnimation::INTERP_CUBIC_SPLINE ? (1 + i * 3) : i];
- if (!value.is_equal_approx(base_pos)) {
- not_default = true;
- break;
+ bool is_default = true; //discard the track if all it contains is default values
+ if (p_remove_immutable_tracks) {
+ Vector3 base_pos = p_state->nodes[track_i.key]->position;
+ for (int i = 0; i < track.position_track.times.size(); i++) {
+ Vector3 value = track.position_track.values[track.position_track.interpolation == GLTFAnimation::INTERP_CUBIC_SPLINE ? (1 + i * 3) : i];
+ if (!value.is_equal_approx(base_pos)) {
+ is_default = false;
+ break;
+ }
}
}
- if (not_default) {
+ if (!p_remove_immutable_tracks || !is_default) {
position_idx = base_idx;
animation->add_track(Animation::TYPE_POSITION_3D);
animation->track_set_path(position_idx, transform_node_path);
animation->track_set_imported(position_idx, true); //helps merging later
-
base_idx++;
}
}
if (track.rotation_track.values.size()) {
- Quaternion base_rot = p_state->nodes[track_i.key]->rotation.normalized();
- bool not_default = false; //discard the track if all it contains is default values
- for (int i = 0; i < track.rotation_track.times.size(); i++) {
- Quaternion value = track.rotation_track.values[track.rotation_track.interpolation == GLTFAnimation::INTERP_CUBIC_SPLINE ? (1 + i * 3) : i].normalized();
- if (!value.is_equal_approx(base_rot)) {
- not_default = true;
- break;
+ bool is_default = true; //discard the track if all it contains is default values
+ if (p_remove_immutable_tracks) {
+ Quaternion base_rot = p_state->nodes[track_i.key]->rotation.normalized();
+ for (int i = 0; i < track.rotation_track.times.size(); i++) {
+ Quaternion value = track.rotation_track.values[track.rotation_track.interpolation == GLTFAnimation::INTERP_CUBIC_SPLINE ? (1 + i * 3) : i].normalized();
+ if (!value.is_equal_approx(base_rot)) {
+ is_default = false;
+ break;
+ }
}
}
- if (not_default) {
+ if (!p_remove_immutable_tracks || !is_default) {
rotation_idx = base_idx;
animation->add_track(Animation::TYPE_ROTATION_3D);
animation->track_set_path(rotation_idx, transform_node_path);
@@ -5991,16 +6113,18 @@ void GLTFDocument::_import_animation(Ref<GLTFState> p_state, AnimationPlayer *p_
}
}
if (track.scale_track.values.size()) {
- Vector3 base_scale = p_state->nodes[track_i.key]->scale;
- bool not_default = false; //discard the track if all it contains is default values
- for (int i = 0; i < track.scale_track.times.size(); i++) {
- Vector3 value = track.scale_track.values[track.scale_track.interpolation == GLTFAnimation::INTERP_CUBIC_SPLINE ? (1 + i * 3) : i];
- if (!value.is_equal_approx(base_scale)) {
- not_default = true;
- break;
+ bool is_default = true; //discard the track if all it contains is default values
+ if (p_remove_immutable_tracks) {
+ Vector3 base_scale = p_state->nodes[track_i.key]->scale;
+ for (int i = 0; i < track.scale_track.times.size(); i++) {
+ Vector3 value = track.scale_track.values[track.scale_track.interpolation == GLTFAnimation::INTERP_CUBIC_SPLINE ? (1 + i * 3) : i];
+ if (!value.is_equal_approx(base_scale)) {
+ is_default = false;
+ break;
+ }
}
}
- if (not_default) {
+ if (!p_remove_immutable_tracks || !is_default) {
scale_idx = base_idx;
animation->add_track(Animation::TYPE_SCALE_3D);
animation->track_set_path(scale_idx, transform_node_path);
@@ -6067,7 +6191,7 @@ void GLTFDocument::_import_animation(Ref<GLTFState> p_state, AnimationPlayer *p_
ERR_CONTINUE(mesh->get_mesh().is_null());
ERR_CONTINUE(mesh->get_mesh()->get_mesh().is_null());
- const String blend_path = String(node_path) + ":" + String(mesh->get_mesh()->get_blend_shape_name(i));
+ const String blend_path = String(mesh_instance_node_path) + ":" + String(mesh->get_mesh()->get_blend_shape_name(i));
const int track_idx = animation->get_track_count();
animation->add_track(Animation::TYPE_BLEND_SHAPE);
@@ -6258,11 +6382,16 @@ void GLTFDocument::_process_mesh_instances(Ref<GLTFState> p_state, Node *p_scene
if (node->skin >= 0 && node->mesh >= 0) {
const GLTFSkinIndex skin_i = node->skin;
- HashMap<GLTFNodeIndex, Node *>::Iterator mi_element = p_state->scene_nodes.find(node_i);
- ERR_CONTINUE_MSG(!mi_element, vformat("Unable to find node %d", node_i));
-
- ImporterMeshInstance3D *mi = Object::cast_to<ImporterMeshInstance3D>(mi_element->value);
- ERR_CONTINUE_MSG(mi == nullptr, vformat("Unable to cast node %d of type %s to ImporterMeshInstance3D", node_i, mi_element->value->get_class_name()));
+ ImporterMeshInstance3D *mi = nullptr;
+ HashMap<GLTFNodeIndex, ImporterMeshInstance3D *>::Iterator mi_element = p_state->scene_mesh_instances.find(node_i);
+ if (mi_element) {
+ mi = mi_element->value;
+ } else {
+ HashMap<GLTFNodeIndex, Node *>::Iterator si_element = p_state->scene_nodes.find(node_i);
+ ERR_CONTINUE_MSG(!si_element, vformat("Unable to find node %d", node_i));
+ mi = Object::cast_to<ImporterMeshInstance3D>(si_element->value);
+ ERR_CONTINUE_MSG(mi == nullptr, vformat("Unable to cast node %d of type %s to ImporterMeshInstance3D", node_i, si_element->value->get_class_name()));
+ }
const GLTFSkeletonIndex skel_i = p_state->skins.write[node->skin]->skeleton;
Ref<GLTFSkeleton> gltf_skeleton = p_state->skeletons.write[skel_i];
@@ -6780,8 +6909,8 @@ void GLTFDocument::_bind_methods() {
&GLTFDocument::append_from_buffer, DEFVAL(0));
ClassDB::bind_method(D_METHOD("append_from_scene", "node", "state", "flags"),
&GLTFDocument::append_from_scene, DEFVAL(0));
- ClassDB::bind_method(D_METHOD("generate_scene", "state", "bake_fps", "trimming"),
- &GLTFDocument::generate_scene, DEFVAL(30), DEFVAL(false));
+ ClassDB::bind_method(D_METHOD("generate_scene", "state", "bake_fps", "trimming", "remove_immutable_tracks"),
+ &GLTFDocument::generate_scene, DEFVAL(30), DEFVAL(false), DEFVAL(true));
ClassDB::bind_method(D_METHOD("generate_buffer", "state"),
&GLTFDocument::generate_buffer);
ClassDB::bind_method(D_METHOD("write_to_filesystem", "state", "path"),
@@ -6890,7 +7019,7 @@ Error GLTFDocument::write_to_filesystem(Ref<GLTFState> p_state, const String &p_
return OK;
}
-Node *GLTFDocument::generate_scene(Ref<GLTFState> p_state, float p_bake_fps, bool p_trimming) {
+Node *GLTFDocument::generate_scene(Ref<GLTFState> p_state, float p_bake_fps, bool p_trimming, bool p_remove_immutable_tracks) {
ERR_FAIL_NULL_V(p_state, nullptr);
ERR_FAIL_INDEX_V(0, p_state->root_nodes.size(), nullptr);
Error err = OK;
@@ -6904,7 +7033,7 @@ Node *GLTFDocument::generate_scene(Ref<GLTFState> p_state, float p_bake_fps, boo
root->add_child(ap, true);
ap->set_owner(root);
for (int i = 0; i < p_state->animations.size(); i++) {
- _import_animation(p_state, ap, i, p_bake_fps, p_trimming);
+ _import_animation(p_state, ap, i, p_bake_fps, p_trimming, p_remove_immutable_tracks);
}
}
for (KeyValue<GLTFNodeIndex, Node *> E : p_state->scene_nodes) {
diff --git a/modules/gltf/gltf_document.h b/modules/gltf/gltf_document.h
index 164c63c53c..b8b989bf89 100644
--- a/modules/gltf/gltf_document.h
+++ b/modules/gltf/gltf_document.h
@@ -64,6 +64,10 @@ public:
COMPONENT_TYPE_INT = 5125,
COMPONENT_TYPE_FLOAT = 5126,
};
+ enum {
+ TEXTURE_TYPE_GENERIC = 0,
+ TEXTURE_TYPE_NORMAL = 1,
+ };
protected:
static void _bind_methods();
@@ -92,7 +96,7 @@ private:
GLTFTextureIndex _set_texture(Ref<GLTFState> p_state, Ref<Texture2D> p_texture,
StandardMaterial3D::TextureFilter p_filter_mode, bool p_repeats);
Ref<Texture2D> _get_texture(Ref<GLTFState> p_state,
- const GLTFTextureIndex p_texture);
+ const GLTFTextureIndex p_texture, int p_texture_type);
GLTFTextureSamplerIndex _set_sampler_for_mode(Ref<GLTFState> p_state,
StandardMaterial3D::TextureFilter p_filter_mode, bool p_repeats);
Ref<GLTFTextureSampler> _get_sampler_for_texture(Ref<GLTFState> p_state,
@@ -160,6 +164,8 @@ private:
float &r_metallic);
GLTFNodeIndex _find_highest_node(Ref<GLTFState> p_state,
const Vector<GLTFNodeIndex> &p_subset);
+ void _recurse_children(Ref<GLTFState> p_state, const GLTFNodeIndex p_node_index,
+ RBSet<GLTFNodeIndex> &p_all_skin_nodes, HashSet<GLTFNodeIndex> &p_child_visited_set);
bool _capture_nodes_in_skin(Ref<GLTFState> p_state, Ref<GLTFSkin> p_skin,
const GLTFNodeIndex p_node_index);
void _capture_nodes_for_multirooted_skin(Ref<GLTFState> p_state, Ref<GLTFSkin> p_skin);
@@ -290,7 +296,7 @@ public:
Error append_from_scene(Node *p_node, Ref<GLTFState> r_state, uint32_t p_flags = 0);
public:
- Node *generate_scene(Ref<GLTFState> p_state, float p_bake_fps = 30.0f, bool p_trimming = false);
+ Node *generate_scene(Ref<GLTFState> p_state, float p_bake_fps = 30.0f, bool p_trimming = false, bool p_remove_immutable_tracks = true);
PackedByteArray generate_buffer(Ref<GLTFState> p_state);
Error write_to_filesystem(Ref<GLTFState> p_state, const String &p_path);
@@ -303,7 +309,7 @@ public:
const GLTFNodeIndex p_node_index);
void _generate_skeleton_bone_node(Ref<GLTFState> p_state, Node *p_scene_parent, Node3D *p_scene_root, const GLTFNodeIndex p_node_index);
void _import_animation(Ref<GLTFState> p_state, AnimationPlayer *p_animation_player,
- const GLTFAnimationIndex p_index, const float p_bake_fps, const bool p_trimming);
+ const GLTFAnimationIndex p_index, const float p_bake_fps, const bool p_trimming, const bool p_remove_immutable_tracks);
void _convert_mesh_instances(Ref<GLTFState> p_state);
GLTFCameraIndex _convert_camera(Ref<GLTFState> p_state, Camera3D *p_camera);
void _convert_light_to_gltf(Light3D *p_light, Ref<GLTFState> p_state, Ref<GLTFNode> p_gltf_node);
diff --git a/modules/gltf/gltf_state.cpp b/modules/gltf/gltf_state.cpp
index 252453dfc2..b67484fc8e 100644
--- a/modules/gltf/gltf_state.cpp
+++ b/modules/gltf/gltf_state.cpp
@@ -91,6 +91,8 @@ void GLTFState::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_scene_node", "idx"), &GLTFState::get_scene_node);
ClassDB::bind_method(D_METHOD("get_additional_data", "extension_name"), &GLTFState::get_additional_data);
ClassDB::bind_method(D_METHOD("set_additional_data", "extension_name", "additional_data"), &GLTFState::set_additional_data);
+ ClassDB::bind_method(D_METHOD("get_handle_binary_image"), &GLTFState::get_handle_binary_image);
+ ClassDB::bind_method(D_METHOD("set_handle_binary_image", "method"), &GLTFState::set_handle_binary_image);
ADD_PROPERTY(PropertyInfo(Variant::DICTIONARY, "json"), "set_json", "get_json"); // Dictionary
ADD_PROPERTY(PropertyInfo(Variant::INT, "major_version"), "set_major_version", "get_major_version"); // int
@@ -118,6 +120,11 @@ void GLTFState::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::DICTIONARY, "skeleton_to_node", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_INTERNAL | PROPERTY_USAGE_EDITOR), "set_skeleton_to_node", "get_skeleton_to_node"); // RBMap<GLTFSkeletonIndex,
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "create_animations"), "set_create_animations", "get_create_animations"); // bool
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "animations", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_INTERNAL | PROPERTY_USAGE_EDITOR), "set_animations", "get_animations"); // Vector<Ref<GLTFAnimation>>
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "handle_binary_image", PROPERTY_HINT_ENUM, "Discard All Textures,Extract Textures,Embed As Basis Universal", PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_INTERNAL | PROPERTY_USAGE_EDITOR), "set_handle_binary_image", "get_handle_binary_image"); // enum
+
+ BIND_CONSTANT(HANDLE_BINARY_DISCARD_TEXTURES);
+ BIND_CONSTANT(HANDLE_BINARY_EXTRACT_TEXTURES);
+ BIND_CONSTANT(HANDLE_BINARY_EMBED_AS_BASISU);
}
void GLTFState::add_used_extension(const String &p_extension_name, bool p_required) {
diff --git a/modules/gltf/gltf_state.h b/modules/gltf/gltf_state.h
index 488ad038aa..52d7949d03 100644
--- a/modules/gltf/gltf_state.h
+++ b/modules/gltf/gltf_state.h
@@ -59,6 +59,8 @@ class GLTFState : public Resource {
bool discard_meshes_and_materials = false;
bool create_animations = true;
+ int handle_binary_image = HANDLE_BINARY_EXTRACT_TEXTURES;
+
Vector<Ref<GLTFNode>> nodes;
Vector<Vector<uint8_t>> buffers;
Vector<Ref<GLTFBufferView>> buffer_views;
@@ -78,6 +80,7 @@ class GLTFState : public Resource {
Vector<Ref<Texture2D>> images;
Vector<String> extensions_used;
Vector<String> extensions_required;
+ Vector<Ref<Image>> source_images;
Vector<Ref<GLTFSkin>> skins;
Vector<Ref<GLTFCamera>> cameras;
@@ -89,6 +92,7 @@ class GLTFState : public Resource {
HashMap<GLTFSkeletonIndex, GLTFNodeIndex> skeleton_to_node;
Vector<Ref<GLTFAnimation>> animations;
HashMap<GLTFNodeIndex, Node *> scene_nodes;
+ HashMap<GLTFNodeIndex, ImporterMeshInstance3D *> scene_mesh_instances;
HashMap<ObjectID, GLTFSkeletonIndex> skeleton3d_to_gltf_skeleton;
HashMap<ObjectID, HashMap<ObjectID, GLTFSkinIndex>> skin_and_skeleton3d_to_gltf_skin;
@@ -100,6 +104,18 @@ protected:
public:
void add_used_extension(const String &p_extension, bool p_required = false);
+ enum GLTFHandleBinary {
+ HANDLE_BINARY_DISCARD_TEXTURES = 0,
+ HANDLE_BINARY_EXTRACT_TEXTURES,
+ HANDLE_BINARY_EMBED_AS_BASISU,
+ };
+ int32_t get_handle_binary_image() {
+ return handle_binary_image;
+ }
+ void set_handle_binary_image(int32_t p_handle_binary_image) {
+ handle_binary_image = p_handle_binary_image;
+ }
+
Dictionary get_json();
void set_json(Dictionary p_json);
@@ -115,6 +131,15 @@ public:
bool get_use_named_skin_binds();
void set_use_named_skin_binds(bool p_use_named_skin_binds);
+ bool get_discard_textures();
+ void set_discard_textures(bool p_discard_textures);
+
+ bool get_embed_as_basisu();
+ void set_embed_as_basisu(bool p_embed_as_basisu);
+
+ bool get_extract_textures();
+ void set_extract_textures(bool p_extract_textures);
+
bool get_discard_meshes_and_materials();
void set_discard_meshes_and_materials(bool p_discard_meshes_and_materials);
@@ -182,6 +207,7 @@ public:
void set_animations(TypedArray<GLTFAnimation> p_animations);
Node *get_scene_node(GLTFNodeIndex idx);
+ ImporterMeshInstance3D *get_scene_mesh_instance(GLTFNodeIndex idx);
int get_animation_players_count(int idx);