diff options
Diffstat (limited to 'modules/gltf')
-rw-r--r-- | modules/gltf/doc_classes/GLTFLight.xml | 3 | ||||
-rw-r--r-- | modules/gltf/doc_classes/GLTFSpecGloss.xml | 8 | ||||
-rw-r--r-- | modules/gltf/doc_classes/GLTFState.xml | 2 | ||||
-rw-r--r-- | modules/gltf/editor/editor_scene_importer_gltf.cpp | 3 | ||||
-rw-r--r-- | modules/gltf/extensions/gltf_light.h | 2 | ||||
-rw-r--r-- | modules/gltf/extensions/gltf_spec_gloss.h | 5 | ||||
-rw-r--r-- | modules/gltf/gltf_document.cpp | 2 | ||||
-rw-r--r-- | modules/gltf/gltf_state.cpp | 11 | ||||
-rw-r--r-- | modules/gltf/gltf_state.h | 4 |
9 files changed, 39 insertions, 1 deletions
diff --git a/modules/gltf/doc_classes/GLTFLight.xml b/modules/gltf/doc_classes/GLTFLight.xml index 354cd48a06..db2dfb487a 100644 --- a/modules/gltf/doc_classes/GLTFLight.xml +++ b/modules/gltf/doc_classes/GLTFLight.xml @@ -1,10 +1,13 @@ <?xml version="1.0" encoding="UTF-8" ?> <class name="GLTFLight" inherits="Resource" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd"> <brief_description> + Represents a GLTF light. </brief_description> <description> + Represents a light as defined by the [code]KHR_lights_punctual[/code] GLTF extension. </description> <tutorials> + <link title="KHR_lights_punctual GLTF extension spec">https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_lights_punctual</link> </tutorials> <members> <member name="color" type="Color" setter="set_color" getter="get_color" default="Color(1, 1, 1, 1)"> diff --git a/modules/gltf/doc_classes/GLTFSpecGloss.xml b/modules/gltf/doc_classes/GLTFSpecGloss.xml index 8433cf8dd7..8882e48257 100644 --- a/modules/gltf/doc_classes/GLTFSpecGloss.xml +++ b/modules/gltf/doc_classes/GLTFSpecGloss.xml @@ -1,21 +1,29 @@ <?xml version="1.0" encoding="UTF-8" ?> <class name="GLTFSpecGloss" inherits="Resource" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd"> <brief_description> + Archived GLTF extension for specular/glossy materials. </brief_description> <description> + KHR_materials_pbrSpecularGlossiness is an archived GLTF extension. This means that it is deprecated and not recommended for new files. However, it is still supported for loading old files. </description> <tutorials> + <link title="KHR_materials_pbrSpecularGlossiness GLTF extension spec">https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Archived/KHR_materials_pbrSpecularGlossiness</link> </tutorials> <members> <member name="diffuse_factor" type="Color" setter="set_diffuse_factor" getter="get_diffuse_factor" default="Color(1, 1, 1, 1)"> + The reflected diffuse factor of the material. </member> <member name="diffuse_img" type="Image" setter="set_diffuse_img" getter="get_diffuse_img"> + The diffuse texture. </member> <member name="gloss_factor" type="float" setter="set_gloss_factor" getter="get_gloss_factor" default="1.0"> + The glossiness or smoothness of the material. </member> <member name="spec_gloss_img" type="Image" setter="set_spec_gloss_img" getter="get_spec_gloss_img"> + The specular-glossiness texture. </member> <member name="specular_factor" type="Color" setter="set_specular_factor" getter="get_specular_factor" default="Color(1, 1, 1, 1)"> + The specular RGB color of the material. The alpha channel is unused. </member> </members> </class> diff --git a/modules/gltf/doc_classes/GLTFState.xml b/modules/gltf/doc_classes/GLTFState.xml index a168e6108f..adf51ab59e 100644 --- a/modules/gltf/doc_classes/GLTFState.xml +++ b/modules/gltf/doc_classes/GLTFState.xml @@ -196,6 +196,8 @@ </member> <member name="buffers" type="Array" setter="set_buffers" getter="get_buffers" default="[]"> </member> + <member name="create_animations" type="bool" setter="set_create_animations" getter="get_create_animations" default="true"> + </member> <member name="glb_data" type="PackedByteArray" setter="set_glb_data" getter="get_glb_data" default="PackedByteArray()"> </member> <member name="json" type="Dictionary" setter="set_json" getter="get_json" default="{}"> diff --git a/modules/gltf/editor/editor_scene_importer_gltf.cpp b/modules/gltf/editor/editor_scene_importer_gltf.cpp index 3fadec5167..161808aade 100644 --- a/modules/gltf/editor/editor_scene_importer_gltf.cpp +++ b/modules/gltf/editor/editor_scene_importer_gltf.cpp @@ -60,6 +60,9 @@ Node *EditorSceneFormatImporterGLTF::import_scene(const String &p_path, uint32_t } return nullptr; } + if (p_options.has("animation/import")) { + state->set_create_animations(bool(p_options["animation/import"])); + } return doc->generate_scene(state, p_bake_fps); } diff --git a/modules/gltf/extensions/gltf_light.h b/modules/gltf/extensions/gltf_light.h index 58fa299dfd..f0765a1bbc 100644 --- a/modules/gltf/extensions/gltf_light.h +++ b/modules/gltf/extensions/gltf_light.h @@ -35,6 +35,8 @@ #include "core/io/resource.h" #include "scene/3d/light_3d.h" +// https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_lights_punctual + class GLTFLight : public Resource { GDCLASS(GLTFLight, Resource) friend class GLTFDocument; diff --git a/modules/gltf/extensions/gltf_spec_gloss.h b/modules/gltf/extensions/gltf_spec_gloss.h index a45fa4296c..2b4d3ee609 100644 --- a/modules/gltf/extensions/gltf_spec_gloss.h +++ b/modules/gltf/extensions/gltf_spec_gloss.h @@ -34,6 +34,11 @@ #include "core/io/image.h" #include "core/io/resource.h" +// KHR_materials_pbrSpecularGlossiness is an archived GLTF extension. +// This means that it is deprecated and not recommended for new files. +// However, it is still supported for loading old files. +// https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Archived/KHR_materials_pbrSpecularGlossiness + class GLTFSpecGloss : public Resource { GDCLASS(GLTFSpecGloss, Resource); friend class GLTFDocument; diff --git a/modules/gltf/gltf_document.cpp b/modules/gltf/gltf_document.cpp index 7e90f198f6..d102970932 100644 --- a/modules/gltf/gltf_document.cpp +++ b/modules/gltf/gltf_document.cpp @@ -6899,7 +6899,7 @@ Node *GLTFDocument::generate_scene(Ref<GLTFState> state, int32_t p_bake_fps) { Node *root = gltf_root_node->get_parent(); ERR_FAIL_NULL_V(root, nullptr); _process_mesh_instances(state, root); - if (state->animations.size()) { + if (state->get_create_animations() && state->animations.size()) { AnimationPlayer *ap = memnew(AnimationPlayer); root->add_child(ap, true); ap->set_owner(root); diff --git a/modules/gltf/gltf_state.cpp b/modules/gltf/gltf_state.cpp index a5f7bcf9d6..8212e4c22f 100644 --- a/modules/gltf/gltf_state.cpp +++ b/modules/gltf/gltf_state.cpp @@ -79,6 +79,8 @@ void GLTFState::_bind_methods() { ClassDB::bind_method(D_METHOD("set_skeletons", "skeletons"), &GLTFState::set_skeletons); ClassDB::bind_method(D_METHOD("get_skeleton_to_node"), &GLTFState::get_skeleton_to_node); ClassDB::bind_method(D_METHOD("set_skeleton_to_node", "skeleton_to_node"), &GLTFState::set_skeleton_to_node); + ClassDB::bind_method(D_METHOD("get_create_animations"), &GLTFState::get_create_animations); + ClassDB::bind_method(D_METHOD("set_create_animations", "create_animations"), &GLTFState::set_create_animations); ClassDB::bind_method(D_METHOD("get_animations"), &GLTFState::get_animations); ClassDB::bind_method(D_METHOD("set_animations", "animations"), &GLTFState::set_animations); ClassDB::bind_method(D_METHOD("get_scene_node", "idx"), &GLTFState::get_scene_node); @@ -106,6 +108,7 @@ void GLTFState::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "unique_animation_names", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_INTERNAL | PROPERTY_USAGE_EDITOR), "set_unique_animation_names", "get_unique_animation_names"); // Set<String> ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "skeletons", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_INTERNAL | PROPERTY_USAGE_EDITOR), "set_skeletons", "get_skeletons"); // Vector<Ref<GLTFSkeleton>> 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>> } @@ -285,6 +288,14 @@ void GLTFState::set_skeleton_to_node(Dictionary p_skeleton_to_node) { GLTFTemplateConvert::set_from_dict(skeleton_to_node, p_skeleton_to_node); } +bool GLTFState::get_create_animations() { + return create_animations; +} + +void GLTFState::set_create_animations(bool p_create_animations) { + create_animations = p_create_animations; +} + Array GLTFState::get_animations() { return GLTFTemplateConvert::to_array(animations); } diff --git a/modules/gltf/gltf_state.h b/modules/gltf/gltf_state.h index d2a4948f06..c08132f874 100644 --- a/modules/gltf/gltf_state.h +++ b/modules/gltf/gltf_state.h @@ -61,6 +61,7 @@ class GLTFState : public Resource { bool use_named_skin_binds = false; bool use_khr_texture_transform = false; bool discard_meshes_and_materials = false; + bool create_animations = true; Vector<Ref<GLTFNode>> nodes; Vector<Vector<uint8_t>> buffers; @@ -168,6 +169,9 @@ public: Dictionary get_skeleton_to_node(); void set_skeleton_to_node(Dictionary p_skeleton_to_node); + bool get_create_animations(); + void set_create_animations(bool p_create_animations); + Array get_animations(); void set_animations(Array p_animations); |