/**************************************************************************/ /* gltf_state.h */ /**************************************************************************/ /* 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. */ /**************************************************************************/ #ifndef GLTF_STATE_H #define GLTF_STATE_H #include "extensions/gltf_light.h" #include "structures/gltf_accessor.h" #include "structures/gltf_animation.h" #include "structures/gltf_buffer_view.h" #include "structures/gltf_camera.h" #include "structures/gltf_mesh.h" #include "structures/gltf_node.h" #include "structures/gltf_skeleton.h" #include "structures/gltf_skin.h" #include "structures/gltf_texture.h" #include "structures/gltf_texture_sampler.h" class GLTFState : public Resource { GDCLASS(GLTFState, Resource); friend class GLTFDocument; String filename; String base_path; Dictionary json; int major_version = 0; int minor_version = 0; Vector glb_data; bool use_named_skin_binds = false; bool use_khr_texture_transform = false; bool discard_meshes_and_materials = false; bool create_animations = true; int handle_binary_image = HANDLE_BINARY_EXTRACT_TEXTURES; Vector> nodes; Vector> buffers; Vector> buffer_views; Vector> accessors; Vector> meshes; // meshes are loaded directly, no reason not to. Vector animation_players; HashMap, GLTFMaterialIndex> material_cache; Vector> materials; String scene_name; Vector root_nodes; Vector> textures; Vector> texture_samplers; Ref default_texture_sampler; Vector> images; Vector extensions_used; Vector extensions_required; Vector> source_images; Vector> skins; Vector> cameras; Vector> lights; HashSet unique_names; HashSet unique_animation_names; Vector> skeletons; HashMap skeleton_to_node; Vector> animations; HashMap scene_nodes; HashMap scene_mesh_instances; HashMap skeleton3d_to_gltf_skeleton; HashMap> skin_and_skeleton3d_to_gltf_skin; Dictionary additional_data; protected: static void _bind_methods(); 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, HANDLE_BINARY_EMBED_AS_UNCOMPRESSED, // if this value changes from 3, ResourceImporterScene::pre_import must be changed as well. }; 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); int get_major_version(); void set_major_version(int p_major_version); int get_minor_version(); void set_minor_version(int p_minor_version); Vector get_glb_data(); void set_glb_data(Vector p_glb_data); 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); TypedArray get_nodes(); void set_nodes(TypedArray p_nodes); TypedArray get_buffers(); void set_buffers(TypedArray p_buffers); TypedArray get_buffer_views(); void set_buffer_views(TypedArray p_buffer_views); TypedArray get_accessors(); void set_accessors(TypedArray p_accessors); TypedArray get_meshes(); void set_meshes(TypedArray p_meshes); TypedArray get_materials(); void set_materials(TypedArray p_materials); String get_scene_name(); void set_scene_name(String p_scene_name); String get_base_path(); void set_base_path(String p_base_path); PackedInt32Array get_root_nodes(); void set_root_nodes(PackedInt32Array p_root_nodes); TypedArray get_textures(); void set_textures(TypedArray p_textures); TypedArray get_texture_samplers(); void set_texture_samplers(TypedArray p_texture_samplers); TypedArray get_images(); void set_images(TypedArray p_images); TypedArray get_skins(); void set_skins(TypedArray p_skins); TypedArray get_cameras(); void set_cameras(TypedArray p_cameras); TypedArray get_lights(); void set_lights(TypedArray p_lights); TypedArray get_unique_names(); void set_unique_names(TypedArray p_unique_names); TypedArray get_unique_animation_names(); void set_unique_animation_names(TypedArray p_unique_names); TypedArray get_skeletons(); void set_skeletons(TypedArray p_skeletons); 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); TypedArray get_animations(); void set_animations(TypedArray p_animations); Node *get_scene_node(GLTFNodeIndex idx); ImporterMeshInstance3D *get_scene_mesh_instance(GLTFNodeIndex idx); int get_animation_players_count(int idx); AnimationPlayer *get_animation_player(int idx); Variant get_additional_data(const StringName &p_extension_name); void set_additional_data(const StringName &p_extension_name, Variant p_additional_data); }; #endif // GLTF_STATE_H