From 7b8f9a0e8e6adec71cde6e38977686c8c0c59575 Mon Sep 17 00:00:00 2001 From: Aaron Franke Date: Sun, 24 Jul 2022 14:20:50 -0500 Subject: GLTF: Organize structures into a subfolder --- modules/gltf/README.md | 11 ++ modules/gltf/SCsub | 2 + modules/gltf/extensions/gltf_light.cpp | 101 ++++++++++++++ modules/gltf/extensions/gltf_light.h | 73 +++++++++++ modules/gltf/extensions/gltf_spec_gloss.cpp | 90 +++++++++++++ modules/gltf/extensions/gltf_spec_gloss.h | 67 ++++++++++ modules/gltf/gltf_accessor.cpp | 189 --------------------------- modules/gltf/gltf_accessor.h | 104 --------------- modules/gltf/gltf_animation.cpp | 53 -------- modules/gltf/gltf_animation.h | 74 ----------- modules/gltf/gltf_buffer_view.cpp | 92 ------------- modules/gltf/gltf_buffer_view.h | 68 ---------- modules/gltf/gltf_camera.cpp | 47 ------- modules/gltf/gltf_camera.h | 58 -------- modules/gltf/gltf_document.cpp | 2 +- modules/gltf/gltf_document.h | 2 +- modules/gltf/gltf_document_extension.h | 2 +- modules/gltf/gltf_light.cpp | 101 -------------- modules/gltf/gltf_light.h | 73 ----------- modules/gltf/gltf_mesh.cpp | 70 ---------- modules/gltf/gltf_mesh.h | 59 --------- modules/gltf/gltf_node.cpp | 178 ------------------------- modules/gltf/gltf_node.h | 100 -------------- modules/gltf/gltf_skeleton.cpp | 98 -------------- modules/gltf/gltf_skeleton.h | 101 -------------- modules/gltf/gltf_skin.cpp | 158 ---------------------- modules/gltf/gltf_skin.h | 109 --------------- modules/gltf/gltf_spec_gloss.cpp | 90 ------------- modules/gltf/gltf_spec_gloss.h | 67 ---------- modules/gltf/gltf_state.h | 20 +-- modules/gltf/gltf_texture.cpp | 46 ------- modules/gltf/gltf_texture.h | 51 -------- modules/gltf/register_types.cpp | 22 ++-- modules/gltf/structures/gltf_accessor.cpp | 189 +++++++++++++++++++++++++++ modules/gltf/structures/gltf_accessor.h | 104 +++++++++++++++ modules/gltf/structures/gltf_animation.cpp | 53 ++++++++ modules/gltf/structures/gltf_animation.h | 74 +++++++++++ modules/gltf/structures/gltf_buffer_view.cpp | 92 +++++++++++++ modules/gltf/structures/gltf_buffer_view.h | 68 ++++++++++ modules/gltf/structures/gltf_camera.cpp | 47 +++++++ modules/gltf/structures/gltf_camera.h | 58 ++++++++ modules/gltf/structures/gltf_mesh.cpp | 70 ++++++++++ modules/gltf/structures/gltf_mesh.h | 59 +++++++++ modules/gltf/structures/gltf_node.cpp | 178 +++++++++++++++++++++++++ modules/gltf/structures/gltf_node.h | 100 ++++++++++++++ modules/gltf/structures/gltf_skeleton.cpp | 98 ++++++++++++++ modules/gltf/structures/gltf_skeleton.h | 101 ++++++++++++++ modules/gltf/structures/gltf_skin.cpp | 158 ++++++++++++++++++++++ modules/gltf/structures/gltf_skin.h | 109 +++++++++++++++ modules/gltf/structures/gltf_texture.cpp | 46 +++++++ modules/gltf/structures/gltf_texture.h | 51 ++++++++ 51 files changed, 2023 insertions(+), 2010 deletions(-) create mode 100644 modules/gltf/README.md create mode 100644 modules/gltf/extensions/gltf_light.cpp create mode 100644 modules/gltf/extensions/gltf_light.h create mode 100644 modules/gltf/extensions/gltf_spec_gloss.cpp create mode 100644 modules/gltf/extensions/gltf_spec_gloss.h delete mode 100644 modules/gltf/gltf_accessor.cpp delete mode 100644 modules/gltf/gltf_accessor.h delete mode 100644 modules/gltf/gltf_animation.cpp delete mode 100644 modules/gltf/gltf_animation.h delete mode 100644 modules/gltf/gltf_buffer_view.cpp delete mode 100644 modules/gltf/gltf_buffer_view.h delete mode 100644 modules/gltf/gltf_camera.cpp delete mode 100644 modules/gltf/gltf_camera.h delete mode 100644 modules/gltf/gltf_light.cpp delete mode 100644 modules/gltf/gltf_light.h delete mode 100644 modules/gltf/gltf_mesh.cpp delete mode 100644 modules/gltf/gltf_mesh.h delete mode 100644 modules/gltf/gltf_node.cpp delete mode 100644 modules/gltf/gltf_node.h delete mode 100644 modules/gltf/gltf_skeleton.cpp delete mode 100644 modules/gltf/gltf_skeleton.h delete mode 100644 modules/gltf/gltf_skin.cpp delete mode 100644 modules/gltf/gltf_skin.h delete mode 100644 modules/gltf/gltf_spec_gloss.cpp delete mode 100644 modules/gltf/gltf_spec_gloss.h delete mode 100644 modules/gltf/gltf_texture.cpp delete mode 100644 modules/gltf/gltf_texture.h create mode 100644 modules/gltf/structures/gltf_accessor.cpp create mode 100644 modules/gltf/structures/gltf_accessor.h create mode 100644 modules/gltf/structures/gltf_animation.cpp create mode 100644 modules/gltf/structures/gltf_animation.h create mode 100644 modules/gltf/structures/gltf_buffer_view.cpp create mode 100644 modules/gltf/structures/gltf_buffer_view.h create mode 100644 modules/gltf/structures/gltf_camera.cpp create mode 100644 modules/gltf/structures/gltf_camera.h create mode 100644 modules/gltf/structures/gltf_mesh.cpp create mode 100644 modules/gltf/structures/gltf_mesh.h create mode 100644 modules/gltf/structures/gltf_node.cpp create mode 100644 modules/gltf/structures/gltf_node.h create mode 100644 modules/gltf/structures/gltf_skeleton.cpp create mode 100644 modules/gltf/structures/gltf_skeleton.h create mode 100644 modules/gltf/structures/gltf_skin.cpp create mode 100644 modules/gltf/structures/gltf_skin.h create mode 100644 modules/gltf/structures/gltf_texture.cpp create mode 100644 modules/gltf/structures/gltf_texture.h (limited to 'modules/gltf') diff --git a/modules/gltf/README.md b/modules/gltf/README.md new file mode 100644 index 0000000000..5d8966b201 --- /dev/null +++ b/modules/gltf/README.md @@ -0,0 +1,11 @@ +# Godot GLTF import and export module + +In a nutshell, the GLTF module works like this: + +* The [`structures/`](structures/) folder contains GLTF structures, the + small pieces that make up a GLTF file, represented as C++ classes. +* The [`extensions/`](extensions/) folder contains GLTF extensions, which + are optional features that build on top of the base GLTF spec. +* [`GLTFState`](gltf_state.h) holds collections of structures and extensions. +* [`GLTFDocument`](gltf_document.h) operates on GLTFState and its elements. +* The [`editor/`](editor/) folder uses GLTFDocument to import and export 3D models. diff --git a/modules/gltf/SCsub b/modules/gltf/SCsub index 3379404a00..6634d5df7b 100644 --- a/modules/gltf/SCsub +++ b/modules/gltf/SCsub @@ -7,5 +7,7 @@ env_gltf = env_modules.Clone() # Godot's own source files env_gltf.add_source_files(env.modules_sources, "*.cpp") +env_gltf.add_source_files(env.modules_sources, "extensions/*.cpp") +env_gltf.add_source_files(env.modules_sources, "structures/*.cpp") if env["tools"]: env_gltf.add_source_files(env.modules_sources, "editor/*.cpp") diff --git a/modules/gltf/extensions/gltf_light.cpp b/modules/gltf/extensions/gltf_light.cpp new file mode 100644 index 0000000000..af21a4e804 --- /dev/null +++ b/modules/gltf/extensions/gltf_light.cpp @@ -0,0 +1,101 @@ +/*************************************************************************/ +/* gltf_light.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ +/* */ +/* 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 "gltf_light.h" + +void GLTFLight::_bind_methods() { + ClassDB::bind_method(D_METHOD("get_color"), &GLTFLight::get_color); + ClassDB::bind_method(D_METHOD("set_color", "color"), &GLTFLight::set_color); + ClassDB::bind_method(D_METHOD("get_intensity"), &GLTFLight::get_intensity); + ClassDB::bind_method(D_METHOD("set_intensity", "intensity"), &GLTFLight::set_intensity); + ClassDB::bind_method(D_METHOD("get_light_type"), &GLTFLight::get_light_type); + ClassDB::bind_method(D_METHOD("set_light_type", "light_type"), &GLTFLight::set_light_type); + ClassDB::bind_method(D_METHOD("get_range"), &GLTFLight::get_range); + ClassDB::bind_method(D_METHOD("set_range", "range"), &GLTFLight::set_range); + ClassDB::bind_method(D_METHOD("get_inner_cone_angle"), &GLTFLight::get_inner_cone_angle); + ClassDB::bind_method(D_METHOD("set_inner_cone_angle", "inner_cone_angle"), &GLTFLight::set_inner_cone_angle); + ClassDB::bind_method(D_METHOD("get_outer_cone_angle"), &GLTFLight::get_outer_cone_angle); + ClassDB::bind_method(D_METHOD("set_outer_cone_angle", "outer_cone_angle"), &GLTFLight::set_outer_cone_angle); + + ADD_PROPERTY(PropertyInfo(Variant::COLOR, "color"), "set_color", "get_color"); // Color + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "intensity"), "set_intensity", "get_intensity"); // float + ADD_PROPERTY(PropertyInfo(Variant::STRING, "light_type"), "set_light_type", "get_light_type"); // String + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "range"), "set_range", "get_range"); // float + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "inner_cone_angle"), "set_inner_cone_angle", "get_inner_cone_angle"); // float + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "outer_cone_angle"), "set_outer_cone_angle", "get_outer_cone_angle"); // float +} + +Color GLTFLight::get_color() { + return color; +} + +void GLTFLight::set_color(Color p_color) { + color = p_color; +} + +float GLTFLight::get_intensity() { + return intensity; +} + +void GLTFLight::set_intensity(float p_intensity) { + intensity = p_intensity; +} + +String GLTFLight::get_light_type() { + return light_type; +} + +void GLTFLight::set_light_type(String p_light_type) { + light_type = p_light_type; +} + +float GLTFLight::get_range() { + return range; +} + +void GLTFLight::set_range(float p_range) { + range = p_range; +} + +float GLTFLight::get_inner_cone_angle() { + return inner_cone_angle; +} + +void GLTFLight::set_inner_cone_angle(float p_inner_cone_angle) { + inner_cone_angle = p_inner_cone_angle; +} + +float GLTFLight::get_outer_cone_angle() { + return outer_cone_angle; +} + +void GLTFLight::set_outer_cone_angle(float p_outer_cone_angle) { + outer_cone_angle = p_outer_cone_angle; +} diff --git a/modules/gltf/extensions/gltf_light.h b/modules/gltf/extensions/gltf_light.h new file mode 100644 index 0000000000..58fa299dfd --- /dev/null +++ b/modules/gltf/extensions/gltf_light.h @@ -0,0 +1,73 @@ +/*************************************************************************/ +/* gltf_light.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ +/* */ +/* 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_LIGHT_H +#define GLTF_LIGHT_H + +#include "core/config/engine.h" +#include "core/io/resource.h" +#include "scene/3d/light_3d.h" + +class GLTFLight : public Resource { + GDCLASS(GLTFLight, Resource) + friend class GLTFDocument; + +protected: + static void _bind_methods(); + +private: + Color color = Color(1.0f, 1.0f, 1.0f); + float intensity = 1.0f; + String light_type; + float range = INFINITY; + float inner_cone_angle = 0.0f; + float outer_cone_angle = Math_TAU / 8.0f; + +public: + Color get_color(); + void set_color(Color p_color); + + float get_intensity(); + void set_intensity(float p_intensity); + + String get_light_type(); + void set_light_type(String p_light_type); + + float get_range(); + void set_range(float p_range); + + float get_inner_cone_angle(); + void set_inner_cone_angle(float p_inner_cone_angle); + + float get_outer_cone_angle(); + void set_outer_cone_angle(float p_outer_cone_angle); +}; + +#endif // GLTF_LIGHT_H diff --git a/modules/gltf/extensions/gltf_spec_gloss.cpp b/modules/gltf/extensions/gltf_spec_gloss.cpp new file mode 100644 index 0000000000..83af91bfcc --- /dev/null +++ b/modules/gltf/extensions/gltf_spec_gloss.cpp @@ -0,0 +1,90 @@ +/*************************************************************************/ +/* gltf_spec_gloss.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ +/* */ +/* 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 "gltf_spec_gloss.h" + +void GLTFSpecGloss::_bind_methods() { + ClassDB::bind_method(D_METHOD("get_diffuse_img"), &GLTFSpecGloss::get_diffuse_img); + ClassDB::bind_method(D_METHOD("set_diffuse_img", "diffuse_img"), &GLTFSpecGloss::set_diffuse_img); + ClassDB::bind_method(D_METHOD("get_diffuse_factor"), &GLTFSpecGloss::get_diffuse_factor); + ClassDB::bind_method(D_METHOD("set_diffuse_factor", "diffuse_factor"), &GLTFSpecGloss::set_diffuse_factor); + ClassDB::bind_method(D_METHOD("get_gloss_factor"), &GLTFSpecGloss::get_gloss_factor); + ClassDB::bind_method(D_METHOD("set_gloss_factor", "gloss_factor"), &GLTFSpecGloss::set_gloss_factor); + ClassDB::bind_method(D_METHOD("get_specular_factor"), &GLTFSpecGloss::get_specular_factor); + ClassDB::bind_method(D_METHOD("set_specular_factor", "specular_factor"), &GLTFSpecGloss::set_specular_factor); + ClassDB::bind_method(D_METHOD("get_spec_gloss_img"), &GLTFSpecGloss::get_spec_gloss_img); + ClassDB::bind_method(D_METHOD("set_spec_gloss_img", "spec_gloss_img"), &GLTFSpecGloss::set_spec_gloss_img); + + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "diffuse_img"), "set_diffuse_img", "get_diffuse_img"); // Ref + ADD_PROPERTY(PropertyInfo(Variant::COLOR, "diffuse_factor"), "set_diffuse_factor", "get_diffuse_factor"); // Color + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "gloss_factor"), "set_gloss_factor", "get_gloss_factor"); // float + ADD_PROPERTY(PropertyInfo(Variant::COLOR, "specular_factor"), "set_specular_factor", "get_specular_factor"); // Color + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "spec_gloss_img"), "set_spec_gloss_img", "get_spec_gloss_img"); // Ref +} + +Ref GLTFSpecGloss::get_diffuse_img() { + return diffuse_img; +} + +void GLTFSpecGloss::set_diffuse_img(Ref p_diffuse_img) { + diffuse_img = p_diffuse_img; +} + +Color GLTFSpecGloss::get_diffuse_factor() { + return diffuse_factor; +} + +void GLTFSpecGloss::set_diffuse_factor(Color p_diffuse_factor) { + diffuse_factor = p_diffuse_factor; +} + +float GLTFSpecGloss::get_gloss_factor() { + return gloss_factor; +} + +void GLTFSpecGloss::set_gloss_factor(float p_gloss_factor) { + gloss_factor = p_gloss_factor; +} + +Color GLTFSpecGloss::get_specular_factor() { + return specular_factor; +} + +void GLTFSpecGloss::set_specular_factor(Color p_specular_factor) { + specular_factor = p_specular_factor; +} + +Ref GLTFSpecGloss::get_spec_gloss_img() { + return spec_gloss_img; +} + +void GLTFSpecGloss::set_spec_gloss_img(Ref p_spec_gloss_img) { + spec_gloss_img = p_spec_gloss_img; +} diff --git a/modules/gltf/extensions/gltf_spec_gloss.h b/modules/gltf/extensions/gltf_spec_gloss.h new file mode 100644 index 0000000000..f8a431bdce --- /dev/null +++ b/modules/gltf/extensions/gltf_spec_gloss.h @@ -0,0 +1,67 @@ +/*************************************************************************/ +/* gltf_spec_gloss.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ +/* */ +/* 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_SPEC_GLOSS_H +#define GLTF_SPEC_GLOSS_H + +#include "core/io/image.h" +#include "core/io/resource.h" + +class GLTFSpecGloss : public Resource { + GDCLASS(GLTFSpecGloss, Resource); + friend class GLTFDocument; + +private: + Ref diffuse_img = nullptr; + Color diffuse_factor = Color(1.0f, 1.0f, 1.0f); + float gloss_factor = 1.0f; + Color specular_factor = Color(1.0f, 1.0f, 1.0f); + Ref spec_gloss_img = nullptr; + +protected: + static void _bind_methods(); + +public: + Ref get_diffuse_img(); + void set_diffuse_img(Ref p_diffuse_img); + + Color get_diffuse_factor(); + void set_diffuse_factor(Color p_diffuse_factor); + + float get_gloss_factor(); + void set_gloss_factor(float p_gloss_factor); + + Color get_specular_factor(); + void set_specular_factor(Color p_specular_factor); + + Ref get_spec_gloss_img(); + void set_spec_gloss_img(Ref p_spec_gloss_img); +}; +#endif // GLTF_SPEC_GLOSS_H diff --git a/modules/gltf/gltf_accessor.cpp b/modules/gltf/gltf_accessor.cpp deleted file mode 100644 index 1b8911fe72..0000000000 --- a/modules/gltf/gltf_accessor.cpp +++ /dev/null @@ -1,189 +0,0 @@ -/*************************************************************************/ -/* gltf_accessor.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* 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 "gltf_accessor.h" - -void GLTFAccessor::_bind_methods() { - ClassDB::bind_method(D_METHOD("get_buffer_view"), &GLTFAccessor::get_buffer_view); - ClassDB::bind_method(D_METHOD("set_buffer_view", "buffer_view"), &GLTFAccessor::set_buffer_view); - ClassDB::bind_method(D_METHOD("get_byte_offset"), &GLTFAccessor::get_byte_offset); - ClassDB::bind_method(D_METHOD("set_byte_offset", "byte_offset"), &GLTFAccessor::set_byte_offset); - ClassDB::bind_method(D_METHOD("get_component_type"), &GLTFAccessor::get_component_type); - ClassDB::bind_method(D_METHOD("set_component_type", "component_type"), &GLTFAccessor::set_component_type); - ClassDB::bind_method(D_METHOD("get_normalized"), &GLTFAccessor::get_normalized); - ClassDB::bind_method(D_METHOD("set_normalized", "normalized"), &GLTFAccessor::set_normalized); - ClassDB::bind_method(D_METHOD("get_count"), &GLTFAccessor::get_count); - ClassDB::bind_method(D_METHOD("set_count", "count"), &GLTFAccessor::set_count); - ClassDB::bind_method(D_METHOD("get_type"), &GLTFAccessor::get_type); - ClassDB::bind_method(D_METHOD("set_type", "type"), &GLTFAccessor::set_type); - ClassDB::bind_method(D_METHOD("get_min"), &GLTFAccessor::get_min); - ClassDB::bind_method(D_METHOD("set_min", "min"), &GLTFAccessor::set_min); - ClassDB::bind_method(D_METHOD("get_max"), &GLTFAccessor::get_max); - ClassDB::bind_method(D_METHOD("set_max", "max"), &GLTFAccessor::set_max); - ClassDB::bind_method(D_METHOD("get_sparse_count"), &GLTFAccessor::get_sparse_count); - ClassDB::bind_method(D_METHOD("set_sparse_count", "sparse_count"), &GLTFAccessor::set_sparse_count); - ClassDB::bind_method(D_METHOD("get_sparse_indices_buffer_view"), &GLTFAccessor::get_sparse_indices_buffer_view); - ClassDB::bind_method(D_METHOD("set_sparse_indices_buffer_view", "sparse_indices_buffer_view"), &GLTFAccessor::set_sparse_indices_buffer_view); - ClassDB::bind_method(D_METHOD("get_sparse_indices_byte_offset"), &GLTFAccessor::get_sparse_indices_byte_offset); - ClassDB::bind_method(D_METHOD("set_sparse_indices_byte_offset", "sparse_indices_byte_offset"), &GLTFAccessor::set_sparse_indices_byte_offset); - ClassDB::bind_method(D_METHOD("get_sparse_indices_component_type"), &GLTFAccessor::get_sparse_indices_component_type); - ClassDB::bind_method(D_METHOD("set_sparse_indices_component_type", "sparse_indices_component_type"), &GLTFAccessor::set_sparse_indices_component_type); - ClassDB::bind_method(D_METHOD("get_sparse_values_buffer_view"), &GLTFAccessor::get_sparse_values_buffer_view); - ClassDB::bind_method(D_METHOD("set_sparse_values_buffer_view", "sparse_values_buffer_view"), &GLTFAccessor::set_sparse_values_buffer_view); - ClassDB::bind_method(D_METHOD("get_sparse_values_byte_offset"), &GLTFAccessor::get_sparse_values_byte_offset); - ClassDB::bind_method(D_METHOD("set_sparse_values_byte_offset", "sparse_values_byte_offset"), &GLTFAccessor::set_sparse_values_byte_offset); - - ADD_PROPERTY(PropertyInfo(Variant::INT, "buffer_view"), "set_buffer_view", "get_buffer_view"); // GLTFBufferViewIndex - ADD_PROPERTY(PropertyInfo(Variant::INT, "byte_offset"), "set_byte_offset", "get_byte_offset"); // int - ADD_PROPERTY(PropertyInfo(Variant::INT, "component_type"), "set_component_type", "get_component_type"); // int - ADD_PROPERTY(PropertyInfo(Variant::BOOL, "normalized"), "set_normalized", "get_normalized"); // bool - ADD_PROPERTY(PropertyInfo(Variant::INT, "count"), "set_count", "get_count"); // int - ADD_PROPERTY(PropertyInfo(Variant::INT, "type"), "set_type", "get_type"); // GLTFType - ADD_PROPERTY(PropertyInfo(Variant::PACKED_FLOAT64_ARRAY, "min"), "set_min", "get_min"); // Vector - ADD_PROPERTY(PropertyInfo(Variant::PACKED_FLOAT64_ARRAY, "max"), "set_max", "get_max"); // Vector - ADD_PROPERTY(PropertyInfo(Variant::INT, "sparse_count"), "set_sparse_count", "get_sparse_count"); // int - ADD_PROPERTY(PropertyInfo(Variant::INT, "sparse_indices_buffer_view"), "set_sparse_indices_buffer_view", "get_sparse_indices_buffer_view"); // int - ADD_PROPERTY(PropertyInfo(Variant::INT, "sparse_indices_byte_offset"), "set_sparse_indices_byte_offset", "get_sparse_indices_byte_offset"); // int - ADD_PROPERTY(PropertyInfo(Variant::INT, "sparse_indices_component_type"), "set_sparse_indices_component_type", "get_sparse_indices_component_type"); // int - ADD_PROPERTY(PropertyInfo(Variant::INT, "sparse_values_buffer_view"), "set_sparse_values_buffer_view", "get_sparse_values_buffer_view"); // int - ADD_PROPERTY(PropertyInfo(Variant::INT, "sparse_values_byte_offset"), "set_sparse_values_byte_offset", "get_sparse_values_byte_offset"); // int -} - -GLTFBufferViewIndex GLTFAccessor::get_buffer_view() { - return buffer_view; -} - -void GLTFAccessor::set_buffer_view(GLTFBufferViewIndex p_buffer_view) { - buffer_view = p_buffer_view; -} - -int GLTFAccessor::get_byte_offset() { - return byte_offset; -} - -void GLTFAccessor::set_byte_offset(int p_byte_offset) { - byte_offset = p_byte_offset; -} - -int GLTFAccessor::get_component_type() { - return component_type; -} - -void GLTFAccessor::set_component_type(int p_component_type) { - component_type = p_component_type; -} - -bool GLTFAccessor::get_normalized() { - return normalized; -} - -void GLTFAccessor::set_normalized(bool p_normalized) { - normalized = p_normalized; -} - -int GLTFAccessor::get_count() { - return count; -} - -void GLTFAccessor::set_count(int p_count) { - count = p_count; -} - -int GLTFAccessor::get_type() { - return (int)type; -} - -void GLTFAccessor::set_type(int p_type) { - type = (GLTFType)p_type; // TODO: Register enum -} - -Vector GLTFAccessor::get_min() { - return min; -} - -void GLTFAccessor::set_min(Vector p_min) { - min = p_min; -} - -Vector GLTFAccessor::get_max() { - return max; -} - -void GLTFAccessor::set_max(Vector p_max) { - max = p_max; -} - -int GLTFAccessor::get_sparse_count() { - return sparse_count; -} - -void GLTFAccessor::set_sparse_count(int p_sparse_count) { - sparse_count = p_sparse_count; -} - -int GLTFAccessor::get_sparse_indices_buffer_view() { - return sparse_indices_buffer_view; -} - -void GLTFAccessor::set_sparse_indices_buffer_view(int p_sparse_indices_buffer_view) { - sparse_indices_buffer_view = p_sparse_indices_buffer_view; -} - -int GLTFAccessor::get_sparse_indices_byte_offset() { - return sparse_indices_byte_offset; -} - -void GLTFAccessor::set_sparse_indices_byte_offset(int p_sparse_indices_byte_offset) { - sparse_indices_byte_offset = p_sparse_indices_byte_offset; -} - -int GLTFAccessor::get_sparse_indices_component_type() { - return sparse_indices_component_type; -} - -void GLTFAccessor::set_sparse_indices_component_type(int p_sparse_indices_component_type) { - sparse_indices_component_type = p_sparse_indices_component_type; -} - -int GLTFAccessor::get_sparse_values_buffer_view() { - return sparse_values_buffer_view; -} - -void GLTFAccessor::set_sparse_values_buffer_view(int p_sparse_values_buffer_view) { - sparse_values_buffer_view = p_sparse_values_buffer_view; -} - -int GLTFAccessor::get_sparse_values_byte_offset() { - return sparse_values_byte_offset; -} - -void GLTFAccessor::set_sparse_values_byte_offset(int p_sparse_values_byte_offset) { - sparse_values_byte_offset = p_sparse_values_byte_offset; -} diff --git a/modules/gltf/gltf_accessor.h b/modules/gltf/gltf_accessor.h deleted file mode 100644 index d89cc5d1ae..0000000000 --- a/modules/gltf/gltf_accessor.h +++ /dev/null @@ -1,104 +0,0 @@ -/*************************************************************************/ -/* gltf_accessor.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* 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_ACCESSOR_H -#define GLTF_ACCESSOR_H - -#include "core/io/resource.h" - -#include "gltf_defines.h" - -struct GLTFAccessor : public Resource { - GDCLASS(GLTFAccessor, Resource); - friend class GLTFDocument; - -private: - GLTFBufferViewIndex buffer_view = 0; - int byte_offset = 0; - int component_type = 0; - bool normalized = false; - int count = 0; - GLTFType type = GLTFType::TYPE_SCALAR; - Vector min; - Vector max; - int sparse_count = 0; - int sparse_indices_buffer_view = 0; - int sparse_indices_byte_offset = 0; - int sparse_indices_component_type = 0; - int sparse_values_buffer_view = 0; - int sparse_values_byte_offset = 0; - -protected: - static void _bind_methods(); - -public: - GLTFBufferViewIndex get_buffer_view(); - void set_buffer_view(GLTFBufferViewIndex p_buffer_view); - - int get_byte_offset(); - void set_byte_offset(int p_byte_offset); - - int get_component_type(); - void set_component_type(int p_component_type); - - bool get_normalized(); - void set_normalized(bool p_normalized); - - int get_count(); - void set_count(int p_count); - - int get_type(); - void set_type(int p_type); - - Vector get_min(); - void set_min(Vector p_min); - - Vector get_max(); - void set_max(Vector p_max); - - int get_sparse_count(); - void set_sparse_count(int p_sparse_count); - - int get_sparse_indices_buffer_view(); - void set_sparse_indices_buffer_view(int p_sparse_indices_buffer_view); - - int get_sparse_indices_byte_offset(); - void set_sparse_indices_byte_offset(int p_sparse_indices_byte_offset); - - int get_sparse_indices_component_type(); - void set_sparse_indices_component_type(int p_sparse_indices_component_type); - - int get_sparse_values_buffer_view(); - void set_sparse_values_buffer_view(int p_sparse_values_buffer_view); - - int get_sparse_values_byte_offset(); - void set_sparse_values_byte_offset(int p_sparse_values_byte_offset); -}; -#endif // GLTF_ACCESSOR_H diff --git a/modules/gltf/gltf_animation.cpp b/modules/gltf/gltf_animation.cpp deleted file mode 100644 index e598c870ab..0000000000 --- a/modules/gltf/gltf_animation.cpp +++ /dev/null @@ -1,53 +0,0 @@ -/*************************************************************************/ -/* gltf_animation.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* 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 "gltf_animation.h" - -void GLTFAnimation::_bind_methods() { - ClassDB::bind_method(D_METHOD("get_loop"), &GLTFAnimation::get_loop); - ClassDB::bind_method(D_METHOD("set_loop", "loop"), &GLTFAnimation::set_loop); - - ADD_PROPERTY(PropertyInfo(Variant::BOOL, "loop"), "set_loop", "get_loop"); // bool -} - -bool GLTFAnimation::get_loop() const { - return loop; -} - -void GLTFAnimation::set_loop(bool p_val) { - loop = p_val; -} - -HashMap &GLTFAnimation::get_tracks() { - return tracks; -} - -GLTFAnimation::GLTFAnimation() { -} diff --git a/modules/gltf/gltf_animation.h b/modules/gltf/gltf_animation.h deleted file mode 100644 index 8688ddb937..0000000000 --- a/modules/gltf/gltf_animation.h +++ /dev/null @@ -1,74 +0,0 @@ -/*************************************************************************/ -/* gltf_animation.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* 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_ANIMATION_H -#define GLTF_ANIMATION_H - -#include "core/io/resource.h" - -class GLTFAnimation : public Resource { - GDCLASS(GLTFAnimation, Resource); - -protected: - static void _bind_methods(); - -public: - enum Interpolation { - INTERP_LINEAR, - INTERP_STEP, - INTERP_CATMULLROMSPLINE, - INTERP_CUBIC_SPLINE, - }; - - template - struct Channel { - Interpolation interpolation; - Vector times; - Vector values; - }; - - struct Track { - Channel position_track; - Channel rotation_track; - Channel scale_track; - Vector> weight_tracks; - }; - -public: - bool get_loop() const; - void set_loop(bool p_val); - HashMap &get_tracks(); - GLTFAnimation(); - -private: - bool loop = false; - HashMap tracks; -}; -#endif // GLTF_ANIMATION_H diff --git a/modules/gltf/gltf_buffer_view.cpp b/modules/gltf/gltf_buffer_view.cpp deleted file mode 100644 index fc467367c6..0000000000 --- a/modules/gltf/gltf_buffer_view.cpp +++ /dev/null @@ -1,92 +0,0 @@ -/*************************************************************************/ -/* gltf_buffer_view.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* 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 "gltf_buffer_view.h" - -#include "gltf_document_extension.h" - -void GLTFBufferView::_bind_methods() { - ClassDB::bind_method(D_METHOD("get_buffer"), &GLTFBufferView::get_buffer); - ClassDB::bind_method(D_METHOD("set_buffer", "buffer"), &GLTFBufferView::set_buffer); - ClassDB::bind_method(D_METHOD("get_byte_offset"), &GLTFBufferView::get_byte_offset); - ClassDB::bind_method(D_METHOD("set_byte_offset", "byte_offset"), &GLTFBufferView::set_byte_offset); - ClassDB::bind_method(D_METHOD("get_byte_length"), &GLTFBufferView::get_byte_length); - ClassDB::bind_method(D_METHOD("set_byte_length", "byte_length"), &GLTFBufferView::set_byte_length); - ClassDB::bind_method(D_METHOD("get_byte_stride"), &GLTFBufferView::get_byte_stride); - ClassDB::bind_method(D_METHOD("set_byte_stride", "byte_stride"), &GLTFBufferView::set_byte_stride); - ClassDB::bind_method(D_METHOD("get_indices"), &GLTFBufferView::get_indices); - ClassDB::bind_method(D_METHOD("set_indices", "indices"), &GLTFBufferView::set_indices); - - ADD_PROPERTY(PropertyInfo(Variant::INT, "buffer"), "set_buffer", "get_buffer"); // GLTFBufferIndex - ADD_PROPERTY(PropertyInfo(Variant::INT, "byte_offset"), "set_byte_offset", "get_byte_offset"); // int - ADD_PROPERTY(PropertyInfo(Variant::INT, "byte_length"), "set_byte_length", "get_byte_length"); // int - ADD_PROPERTY(PropertyInfo(Variant::INT, "byte_stride"), "set_byte_stride", "get_byte_stride"); // int - ADD_PROPERTY(PropertyInfo(Variant::BOOL, "indices"), "set_indices", "get_indices"); // bool -} - -GLTFBufferIndex GLTFBufferView::get_buffer() { - return buffer; -} - -void GLTFBufferView::set_buffer(GLTFBufferIndex p_buffer) { - buffer = p_buffer; -} - -int GLTFBufferView::get_byte_offset() { - return byte_offset; -} - -void GLTFBufferView::set_byte_offset(int p_byte_offset) { - byte_offset = p_byte_offset; -} - -int GLTFBufferView::get_byte_length() { - return byte_length; -} - -void GLTFBufferView::set_byte_length(int p_byte_length) { - byte_length = p_byte_length; -} - -int GLTFBufferView::get_byte_stride() { - return byte_stride; -} - -void GLTFBufferView::set_byte_stride(int p_byte_stride) { - byte_stride = p_byte_stride; -} - -bool GLTFBufferView::get_indices() { - return indices; -} - -void GLTFBufferView::set_indices(bool p_indices) { - indices = p_indices; -} diff --git a/modules/gltf/gltf_buffer_view.h b/modules/gltf/gltf_buffer_view.h deleted file mode 100644 index e28456fd8e..0000000000 --- a/modules/gltf/gltf_buffer_view.h +++ /dev/null @@ -1,68 +0,0 @@ -/*************************************************************************/ -/* gltf_buffer_view.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* 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_BUFFER_VIEW_H -#define GLTF_BUFFER_VIEW_H - -#include "core/io/resource.h" -#include "gltf_defines.h" - -class GLTFBufferView : public Resource { - GDCLASS(GLTFBufferView, Resource); - friend class GLTFDocument; - -private: - GLTFBufferIndex buffer = -1; - int byte_offset = 0; - int byte_length = 0; - int byte_stride = -1; - bool indices = false; - -protected: - static void _bind_methods(); - -public: - GLTFBufferIndex get_buffer(); - void set_buffer(GLTFBufferIndex p_buffer); - - int get_byte_offset(); - void set_byte_offset(int p_byte_offset); - - int get_byte_length(); - void set_byte_length(int p_byte_length); - - int get_byte_stride(); - void set_byte_stride(int p_byte_stride); - - bool get_indices(); - void set_indices(bool p_indices); - // matrices need to be transformed to this -}; -#endif // GLTF_BUFFER_VIEW_H diff --git a/modules/gltf/gltf_camera.cpp b/modules/gltf/gltf_camera.cpp deleted file mode 100644 index f3ea6a1c4c..0000000000 --- a/modules/gltf/gltf_camera.cpp +++ /dev/null @@ -1,47 +0,0 @@ -/*************************************************************************/ -/* gltf_camera.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* 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 "gltf_camera.h" - -void GLTFCamera::_bind_methods() { - ClassDB::bind_method(D_METHOD("get_perspective"), &GLTFCamera::get_perspective); - ClassDB::bind_method(D_METHOD("set_perspective", "perspective"), &GLTFCamera::set_perspective); - ClassDB::bind_method(D_METHOD("get_fov_size"), &GLTFCamera::get_fov_size); - ClassDB::bind_method(D_METHOD("set_fov_size", "fov_size"), &GLTFCamera::set_fov_size); - ClassDB::bind_method(D_METHOD("get_depth_far"), &GLTFCamera::get_depth_far); - ClassDB::bind_method(D_METHOD("set_depth_far", "zdepth_far"), &GLTFCamera::set_depth_far); - ClassDB::bind_method(D_METHOD("get_depth_near"), &GLTFCamera::get_depth_near); - ClassDB::bind_method(D_METHOD("set_depth_near", "zdepth_near"), &GLTFCamera::set_depth_near); - - ADD_PROPERTY(PropertyInfo(Variant::BOOL, "perspective"), "set_perspective", "get_perspective"); // bool - ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "fov_size"), "set_fov_size", "get_fov_size"); // float - ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "depth_far"), "set_depth_far", "get_depth_far"); // float - ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "depth_near"), "set_depth_near", "get_depth_near"); // float -} diff --git a/modules/gltf/gltf_camera.h b/modules/gltf/gltf_camera.h deleted file mode 100644 index c696d4cc6b..0000000000 --- a/modules/gltf/gltf_camera.h +++ /dev/null @@ -1,58 +0,0 @@ -/*************************************************************************/ -/* gltf_camera.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* 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_CAMERA_H -#define GLTF_CAMERA_H - -#include "core/io/resource.h" - -class GLTFCamera : public Resource { - GDCLASS(GLTFCamera, Resource); - -private: - bool perspective = true; - float fov_size = 75.0; - float depth_far = 4000.0; - float depth_near = 0.05; - -protected: - static void _bind_methods(); - -public: - bool get_perspective() const { return perspective; } - void set_perspective(bool p_val) { perspective = p_val; } - float get_fov_size() const { return fov_size; } - void set_fov_size(float p_val) { fov_size = p_val; } - float get_depth_far() const { return depth_far; } - void set_depth_far(float p_val) { depth_far = p_val; } - float get_depth_near() const { return depth_near; } - void set_depth_near(float p_val) { depth_near = p_val; } -}; -#endif // GLTF_CAMERA_H diff --git a/modules/gltf/gltf_document.cpp b/modules/gltf/gltf_document.cpp index aa2ec4a399..afe6941c81 100644 --- a/modules/gltf/gltf_document.cpp +++ b/modules/gltf/gltf_document.cpp @@ -30,9 +30,9 @@ #include "gltf_document.h" +#include "extensions/gltf_spec_gloss.h" #include "gltf_document_extension.h" #include "gltf_document_extension_convert_importer_mesh.h" -#include "gltf_spec_gloss.h" #include "gltf_state.h" #include "core/crypto/crypto_core.h" diff --git a/modules/gltf/gltf_document.h b/modules/gltf/gltf_document.h index 0c585bf49b..36a2f94a4e 100644 --- a/modules/gltf/gltf_document.h +++ b/modules/gltf/gltf_document.h @@ -31,8 +31,8 @@ #ifndef GLTF_DOCUMENT_H #define GLTF_DOCUMENT_H -#include "gltf_animation.h" #include "gltf_defines.h" +#include "structures/gltf_animation.h" #include "scene/3d/bone_attachment_3d.h" #include "scene/3d/importer_mesh_instance_3d.h" diff --git a/modules/gltf/gltf_document_extension.h b/modules/gltf/gltf_document_extension.h index 8fd4d4e54e..0ef9109584 100644 --- a/modules/gltf/gltf_document_extension.h +++ b/modules/gltf/gltf_document_extension.h @@ -31,8 +31,8 @@ #ifndef GLTF_DOCUMENT_EXTENSION_H #define GLTF_DOCUMENT_EXTENSION_H -#include "gltf_node.h" #include "gltf_state.h" +#include "structures/gltf_node.h" class GLTFDocumentExtension : public Resource { GDCLASS(GLTFDocumentExtension, Resource); diff --git a/modules/gltf/gltf_light.cpp b/modules/gltf/gltf_light.cpp deleted file mode 100644 index af21a4e804..0000000000 --- a/modules/gltf/gltf_light.cpp +++ /dev/null @@ -1,101 +0,0 @@ -/*************************************************************************/ -/* gltf_light.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* 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 "gltf_light.h" - -void GLTFLight::_bind_methods() { - ClassDB::bind_method(D_METHOD("get_color"), &GLTFLight::get_color); - ClassDB::bind_method(D_METHOD("set_color", "color"), &GLTFLight::set_color); - ClassDB::bind_method(D_METHOD("get_intensity"), &GLTFLight::get_intensity); - ClassDB::bind_method(D_METHOD("set_intensity", "intensity"), &GLTFLight::set_intensity); - ClassDB::bind_method(D_METHOD("get_light_type"), &GLTFLight::get_light_type); - ClassDB::bind_method(D_METHOD("set_light_type", "light_type"), &GLTFLight::set_light_type); - ClassDB::bind_method(D_METHOD("get_range"), &GLTFLight::get_range); - ClassDB::bind_method(D_METHOD("set_range", "range"), &GLTFLight::set_range); - ClassDB::bind_method(D_METHOD("get_inner_cone_angle"), &GLTFLight::get_inner_cone_angle); - ClassDB::bind_method(D_METHOD("set_inner_cone_angle", "inner_cone_angle"), &GLTFLight::set_inner_cone_angle); - ClassDB::bind_method(D_METHOD("get_outer_cone_angle"), &GLTFLight::get_outer_cone_angle); - ClassDB::bind_method(D_METHOD("set_outer_cone_angle", "outer_cone_angle"), &GLTFLight::set_outer_cone_angle); - - ADD_PROPERTY(PropertyInfo(Variant::COLOR, "color"), "set_color", "get_color"); // Color - ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "intensity"), "set_intensity", "get_intensity"); // float - ADD_PROPERTY(PropertyInfo(Variant::STRING, "light_type"), "set_light_type", "get_light_type"); // String - ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "range"), "set_range", "get_range"); // float - ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "inner_cone_angle"), "set_inner_cone_angle", "get_inner_cone_angle"); // float - ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "outer_cone_angle"), "set_outer_cone_angle", "get_outer_cone_angle"); // float -} - -Color GLTFLight::get_color() { - return color; -} - -void GLTFLight::set_color(Color p_color) { - color = p_color; -} - -float GLTFLight::get_intensity() { - return intensity; -} - -void GLTFLight::set_intensity(float p_intensity) { - intensity = p_intensity; -} - -String GLTFLight::get_light_type() { - return light_type; -} - -void GLTFLight::set_light_type(String p_light_type) { - light_type = p_light_type; -} - -float GLTFLight::get_range() { - return range; -} - -void GLTFLight::set_range(float p_range) { - range = p_range; -} - -float GLTFLight::get_inner_cone_angle() { - return inner_cone_angle; -} - -void GLTFLight::set_inner_cone_angle(float p_inner_cone_angle) { - inner_cone_angle = p_inner_cone_angle; -} - -float GLTFLight::get_outer_cone_angle() { - return outer_cone_angle; -} - -void GLTFLight::set_outer_cone_angle(float p_outer_cone_angle) { - outer_cone_angle = p_outer_cone_angle; -} diff --git a/modules/gltf/gltf_light.h b/modules/gltf/gltf_light.h deleted file mode 100644 index 58fa299dfd..0000000000 --- a/modules/gltf/gltf_light.h +++ /dev/null @@ -1,73 +0,0 @@ -/*************************************************************************/ -/* gltf_light.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* 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_LIGHT_H -#define GLTF_LIGHT_H - -#include "core/config/engine.h" -#include "core/io/resource.h" -#include "scene/3d/light_3d.h" - -class GLTFLight : public Resource { - GDCLASS(GLTFLight, Resource) - friend class GLTFDocument; - -protected: - static void _bind_methods(); - -private: - Color color = Color(1.0f, 1.0f, 1.0f); - float intensity = 1.0f; - String light_type; - float range = INFINITY; - float inner_cone_angle = 0.0f; - float outer_cone_angle = Math_TAU / 8.0f; - -public: - Color get_color(); - void set_color(Color p_color); - - float get_intensity(); - void set_intensity(float p_intensity); - - String get_light_type(); - void set_light_type(String p_light_type); - - float get_range(); - void set_range(float p_range); - - float get_inner_cone_angle(); - void set_inner_cone_angle(float p_inner_cone_angle); - - float get_outer_cone_angle(); - void set_outer_cone_angle(float p_outer_cone_angle); -}; - -#endif // GLTF_LIGHT_H diff --git a/modules/gltf/gltf_mesh.cpp b/modules/gltf/gltf_mesh.cpp deleted file mode 100644 index 3add8304b1..0000000000 --- a/modules/gltf/gltf_mesh.cpp +++ /dev/null @@ -1,70 +0,0 @@ -/*************************************************************************/ -/* gltf_mesh.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* 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 "gltf_mesh.h" - -#include "scene/resources/importer_mesh.h" - -void GLTFMesh::_bind_methods() { - ClassDB::bind_method(D_METHOD("get_mesh"), &GLTFMesh::get_mesh); - ClassDB::bind_method(D_METHOD("set_mesh", "mesh"), &GLTFMesh::set_mesh); - ClassDB::bind_method(D_METHOD("get_blend_weights"), &GLTFMesh::get_blend_weights); - ClassDB::bind_method(D_METHOD("set_blend_weights", "blend_weights"), &GLTFMesh::set_blend_weights); - ClassDB::bind_method(D_METHOD("get_instance_materials"), &GLTFMesh::get_instance_materials); - ClassDB::bind_method(D_METHOD("set_instance_materials", "instance_materials"), &GLTFMesh::set_instance_materials); - - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "mesh"), "set_mesh", "get_mesh"); - ADD_PROPERTY(PropertyInfo(Variant::PACKED_FLOAT32_ARRAY, "blend_weights"), "set_blend_weights", "get_blend_weights"); // Vector - ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "instance_materials"), "set_instance_materials", "get_instance_materials"); -} - -Ref GLTFMesh::get_mesh() { - return mesh; -} - -void GLTFMesh::set_mesh(Ref p_mesh) { - mesh = p_mesh; -} - -Array GLTFMesh::get_instance_materials() { - return instance_materials; -} - -void GLTFMesh::set_instance_materials(Array p_instance_materials) { - instance_materials = p_instance_materials; -} - -Vector GLTFMesh::get_blend_weights() { - return blend_weights; -} - -void GLTFMesh::set_blend_weights(Vector p_blend_weights) { - blend_weights = p_blend_weights; -} diff --git a/modules/gltf/gltf_mesh.h b/modules/gltf/gltf_mesh.h deleted file mode 100644 index dc26120b48..0000000000 --- a/modules/gltf/gltf_mesh.h +++ /dev/null @@ -1,59 +0,0 @@ -/*************************************************************************/ -/* gltf_mesh.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* 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_MESH_H -#define GLTF_MESH_H - -#include "core/io/resource.h" -#include "scene/3d/importer_mesh_instance_3d.h" -#include "scene/resources/importer_mesh.h" -#include "scene/resources/mesh.h" - -class GLTFMesh : public Resource { - GDCLASS(GLTFMesh, Resource); - -private: - Ref mesh; - Vector blend_weights; - Array instance_materials; - -protected: - static void _bind_methods(); - -public: - Ref get_mesh(); - void set_mesh(Ref p_mesh); - Vector get_blend_weights(); - void set_blend_weights(Vector p_blend_weights); - Array get_instance_materials(); - void set_instance_materials(Array p_instance_materials); -}; - -#endif // GLTF_MESH_H diff --git a/modules/gltf/gltf_node.cpp b/modules/gltf/gltf_node.cpp deleted file mode 100644 index 86280603fa..0000000000 --- a/modules/gltf/gltf_node.cpp +++ /dev/null @@ -1,178 +0,0 @@ -/*************************************************************************/ -/* gltf_node.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* 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 "gltf_node.h" - -void GLTFNode::_bind_methods() { - ClassDB::bind_method(D_METHOD("get_parent"), &GLTFNode::get_parent); - ClassDB::bind_method(D_METHOD("set_parent", "parent"), &GLTFNode::set_parent); - ClassDB::bind_method(D_METHOD("get_height"), &GLTFNode::get_height); - ClassDB::bind_method(D_METHOD("set_height", "height"), &GLTFNode::set_height); - ClassDB::bind_method(D_METHOD("get_xform"), &GLTFNode::get_xform); - ClassDB::bind_method(D_METHOD("set_xform", "xform"), &GLTFNode::set_xform); - ClassDB::bind_method(D_METHOD("get_mesh"), &GLTFNode::get_mesh); - ClassDB::bind_method(D_METHOD("set_mesh", "mesh"), &GLTFNode::set_mesh); - ClassDB::bind_method(D_METHOD("get_camera"), &GLTFNode::get_camera); - ClassDB::bind_method(D_METHOD("set_camera", "camera"), &GLTFNode::set_camera); - ClassDB::bind_method(D_METHOD("get_skin"), &GLTFNode::get_skin); - ClassDB::bind_method(D_METHOD("set_skin", "skin"), &GLTFNode::set_skin); - ClassDB::bind_method(D_METHOD("get_skeleton"), &GLTFNode::get_skeleton); - ClassDB::bind_method(D_METHOD("set_skeleton", "skeleton"), &GLTFNode::set_skeleton); - ClassDB::bind_method(D_METHOD("get_joint"), &GLTFNode::get_joint); - ClassDB::bind_method(D_METHOD("set_joint", "joint"), &GLTFNode::set_joint); - ClassDB::bind_method(D_METHOD("get_position"), &GLTFNode::get_position); - ClassDB::bind_method(D_METHOD("set_position", "position"), &GLTFNode::set_position); - ClassDB::bind_method(D_METHOD("get_rotation"), &GLTFNode::get_rotation); - ClassDB::bind_method(D_METHOD("set_rotation", "rotation"), &GLTFNode::set_rotation); - ClassDB::bind_method(D_METHOD("get_scale"), &GLTFNode::get_scale); - ClassDB::bind_method(D_METHOD("set_scale", "scale"), &GLTFNode::set_scale); - ClassDB::bind_method(D_METHOD("get_children"), &GLTFNode::get_children); - ClassDB::bind_method(D_METHOD("set_children", "children"), &GLTFNode::set_children); - ClassDB::bind_method(D_METHOD("get_light"), &GLTFNode::get_light); - ClassDB::bind_method(D_METHOD("set_light", "light"), &GLTFNode::set_light); - - ADD_PROPERTY(PropertyInfo(Variant::INT, "parent"), "set_parent", "get_parent"); // GLTFNodeIndex - ADD_PROPERTY(PropertyInfo(Variant::INT, "height"), "set_height", "get_height"); // int - ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM3D, "xform"), "set_xform", "get_xform"); // Transform3D - ADD_PROPERTY(PropertyInfo(Variant::INT, "mesh"), "set_mesh", "get_mesh"); // GLTFMeshIndex - ADD_PROPERTY(PropertyInfo(Variant::INT, "camera"), "set_camera", "get_camera"); // GLTFCameraIndex - ADD_PROPERTY(PropertyInfo(Variant::INT, "skin"), "set_skin", "get_skin"); // GLTFSkinIndex - ADD_PROPERTY(PropertyInfo(Variant::INT, "skeleton"), "set_skeleton", "get_skeleton"); // GLTFSkeletonIndex - ADD_PROPERTY(PropertyInfo(Variant::BOOL, "joint"), "set_joint", "get_joint"); // bool - ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "position"), "set_position", "get_position"); // Vector3 - ADD_PROPERTY(PropertyInfo(Variant::QUATERNION, "rotation"), "set_rotation", "get_rotation"); // Quaternion - ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "scale"), "set_scale", "get_scale"); // Vector3 - ADD_PROPERTY(PropertyInfo(Variant::PACKED_INT32_ARRAY, "children"), "set_children", "get_children"); // Vector - ADD_PROPERTY(PropertyInfo(Variant::INT, "light"), "set_light", "get_light"); // GLTFLightIndex -} - -GLTFNodeIndex GLTFNode::get_parent() { - return parent; -} - -void GLTFNode::set_parent(GLTFNodeIndex p_parent) { - parent = p_parent; -} - -int GLTFNode::get_height() { - return height; -} - -void GLTFNode::set_height(int p_height) { - height = p_height; -} - -Transform3D GLTFNode::get_xform() { - return xform; -} - -void GLTFNode::set_xform(Transform3D p_xform) { - xform = p_xform; -} - -GLTFMeshIndex GLTFNode::get_mesh() { - return mesh; -} - -void GLTFNode::set_mesh(GLTFMeshIndex p_mesh) { - mesh = p_mesh; -} - -GLTFCameraIndex GLTFNode::get_camera() { - return camera; -} - -void GLTFNode::set_camera(GLTFCameraIndex p_camera) { - camera = p_camera; -} - -GLTFSkinIndex GLTFNode::get_skin() { - return skin; -} - -void GLTFNode::set_skin(GLTFSkinIndex p_skin) { - skin = p_skin; -} - -GLTFSkeletonIndex GLTFNode::get_skeleton() { - return skeleton; -} - -void GLTFNode::set_skeleton(GLTFSkeletonIndex p_skeleton) { - skeleton = p_skeleton; -} - -bool GLTFNode::get_joint() { - return joint; -} - -void GLTFNode::set_joint(bool p_joint) { - joint = p_joint; -} - -Vector3 GLTFNode::get_position() { - return position; -} - -void GLTFNode::set_position(Vector3 p_position) { - position = p_position; -} - -Quaternion GLTFNode::get_rotation() { - return rotation; -} - -void GLTFNode::set_rotation(Quaternion p_rotation) { - rotation = p_rotation; -} - -Vector3 GLTFNode::get_scale() { - return scale; -} - -void GLTFNode::set_scale(Vector3 p_scale) { - scale = p_scale; -} - -Vector GLTFNode::get_children() { - return children; -} - -void GLTFNode::set_children(Vector p_children) { - children = p_children; -} - -GLTFLightIndex GLTFNode::get_light() { - return light; -} - -void GLTFNode::set_light(GLTFLightIndex p_light) { - light = p_light; -} diff --git a/modules/gltf/gltf_node.h b/modules/gltf/gltf_node.h deleted file mode 100644 index 7b03b55fbc..0000000000 --- a/modules/gltf/gltf_node.h +++ /dev/null @@ -1,100 +0,0 @@ -/*************************************************************************/ -/* gltf_node.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* 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_NODE_H -#define GLTF_NODE_H - -#include "core/io/resource.h" -#include "gltf_defines.h" - -class GLTFNode : public Resource { - GDCLASS(GLTFNode, Resource); - friend class GLTFDocument; - -private: - // matrices need to be transformed to this - GLTFNodeIndex parent = -1; - int height = -1; - Transform3D xform; - GLTFMeshIndex mesh = -1; - GLTFCameraIndex camera = -1; - GLTFSkinIndex skin = -1; - GLTFSkeletonIndex skeleton = -1; - bool joint = false; - Vector3 position; - Quaternion rotation; - Vector3 scale = Vector3(1, 1, 1); - Vector children; - GLTFLightIndex light = -1; - -protected: - static void _bind_methods(); - -public: - GLTFNodeIndex get_parent(); - void set_parent(GLTFNodeIndex p_parent); - - int get_height(); - void set_height(int p_height); - - Transform3D get_xform(); - void set_xform(Transform3D p_xform); - - GLTFMeshIndex get_mesh(); - void set_mesh(GLTFMeshIndex p_mesh); - - GLTFCameraIndex get_camera(); - void set_camera(GLTFCameraIndex p_camera); - - GLTFSkinIndex get_skin(); - void set_skin(GLTFSkinIndex p_skin); - - GLTFSkeletonIndex get_skeleton(); - void set_skeleton(GLTFSkeletonIndex p_skeleton); - - bool get_joint(); - void set_joint(bool p_joint); - - Vector3 get_position(); - void set_position(Vector3 p_position); - - Quaternion get_rotation(); - void set_rotation(Quaternion p_rotation); - - Vector3 get_scale(); - void set_scale(Vector3 p_scale); - - Vector get_children(); - void set_children(Vector p_children); - - GLTFLightIndex get_light(); - void set_light(GLTFLightIndex p_light); -}; -#endif // GLTF_NODE_H diff --git a/modules/gltf/gltf_skeleton.cpp b/modules/gltf/gltf_skeleton.cpp deleted file mode 100644 index 994e9bf6e7..0000000000 --- a/modules/gltf/gltf_skeleton.cpp +++ /dev/null @@ -1,98 +0,0 @@ -/*************************************************************************/ -/* gltf_skeleton.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* 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 "gltf_skeleton.h" - -#include "gltf_template_convert.h" -#include "scene/3d/bone_attachment_3d.h" - -void GLTFSkeleton::_bind_methods() { - ClassDB::bind_method(D_METHOD("get_joints"), &GLTFSkeleton::get_joints); - ClassDB::bind_method(D_METHOD("set_joints", "joints"), &GLTFSkeleton::set_joints); - ClassDB::bind_method(D_METHOD("get_roots"), &GLTFSkeleton::get_roots); - ClassDB::bind_method(D_METHOD("set_roots", "roots"), &GLTFSkeleton::set_roots); - ClassDB::bind_method(D_METHOD("get_godot_skeleton"), &GLTFSkeleton::get_godot_skeleton); - ClassDB::bind_method(D_METHOD("get_unique_names"), &GLTFSkeleton::get_unique_names); - ClassDB::bind_method(D_METHOD("set_unique_names", "unique_names"), &GLTFSkeleton::set_unique_names); - ClassDB::bind_method(D_METHOD("get_godot_bone_node"), &GLTFSkeleton::get_godot_bone_node); - ClassDB::bind_method(D_METHOD("set_godot_bone_node", "godot_bone_node"), &GLTFSkeleton::set_godot_bone_node); - ClassDB::bind_method(D_METHOD("get_bone_attachment_count"), &GLTFSkeleton::get_bone_attachment_count); - ClassDB::bind_method(D_METHOD("get_bone_attachment", "idx"), &GLTFSkeleton::get_bone_attachment); - - ADD_PROPERTY(PropertyInfo(Variant::PACKED_INT32_ARRAY, "joints"), "set_joints", "get_joints"); // Vector - ADD_PROPERTY(PropertyInfo(Variant::PACKED_INT32_ARRAY, "roots"), "set_roots", "get_roots"); // Vector - ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "unique_names", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_INTERNAL | PROPERTY_USAGE_EDITOR), "set_unique_names", "get_unique_names"); // Set - ADD_PROPERTY(PropertyInfo(Variant::DICTIONARY, "godot_bone_node", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_INTERNAL | PROPERTY_USAGE_EDITOR), "set_godot_bone_node", "get_godot_bone_node"); // RBMap GLTFSkeleton::get_joints() { - return joints; -} - -void GLTFSkeleton::set_joints(Vector p_joints) { - joints = p_joints; -} - -Vector GLTFSkeleton::get_roots() { - return roots; -} - -void GLTFSkeleton::set_roots(Vector p_roots) { - roots = p_roots; -} - -Skeleton3D *GLTFSkeleton::get_godot_skeleton() { - return godot_skeleton; -} - -Array GLTFSkeleton::get_unique_names() { - return GLTFTemplateConvert::to_array(unique_names); -} - -void GLTFSkeleton::set_unique_names(Array p_unique_names) { - GLTFTemplateConvert::set_from_array(unique_names, p_unique_names); -} - -Dictionary GLTFSkeleton::get_godot_bone_node() { - return GLTFTemplateConvert::to_dict(godot_bone_node); -} - -void GLTFSkeleton::set_godot_bone_node(Dictionary p_indict) { - GLTFTemplateConvert::set_from_dict(godot_bone_node, p_indict); -} - -BoneAttachment3D *GLTFSkeleton::get_bone_attachment(int idx) { - ERR_FAIL_INDEX_V(idx, bone_attachments.size(), nullptr); - return bone_attachments[idx]; -} - -int32_t GLTFSkeleton::get_bone_attachment_count() { - return bone_attachments.size(); -} diff --git a/modules/gltf/gltf_skeleton.h b/modules/gltf/gltf_skeleton.h deleted file mode 100644 index eaeff0c0cb..0000000000 --- a/modules/gltf/gltf_skeleton.h +++ /dev/null @@ -1,101 +0,0 @@ -/*************************************************************************/ -/* gltf_skeleton.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* 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_SKELETON_H -#define GLTF_SKELETON_H - -#include "core/io/resource.h" -#include "gltf_defines.h" - -class GLTFSkeleton : public Resource { - GDCLASS(GLTFSkeleton, Resource); - friend class GLTFDocument; - -private: - // The *synthesized* skeletons joints - Vector joints; - - // The roots of the skeleton. If there are multiple, each root must have the - // same parent (ie roots are siblings) - Vector roots; - - // The created Skeleton3D for the scene - Skeleton3D *godot_skeleton = nullptr; - - // Set of unique bone names for the skeleton - HashSet unique_names; - - HashMap godot_bone_node; - - Vector bone_attachments; - -protected: - static void _bind_methods(); - -public: - Vector get_joints(); - void set_joints(Vector p_joints); - - Vector get_roots(); - void set_roots(Vector p_roots); - - Skeleton3D *get_godot_skeleton(); - - // Skeleton *get_godot_skeleton() { - // return this->godot_skeleton; - // } - // void set_godot_skeleton(Skeleton p_*godot_skeleton) { - // this->godot_skeleton = p_godot_skeleton; - // } - - Array get_unique_names(); - void set_unique_names(Array p_unique_names); - - //RBMap get_godot_bone_node() { - // return this->godot_bone_node; - //} - //void set_godot_bone_node(RBMap p_godot_bone_node) { - // this->godot_bone_node = p_godot_bone_node; - //} - Dictionary get_godot_bone_node(); - void set_godot_bone_node(Dictionary p_indict); - - //Dictionary get_godot_bone_node() { - // return VariantConversion::to_dict(this->godot_bone_node); - //} - //void set_godot_bone_node(Dictionary p_indict) { - // VariantConversion::set_from_dict(this->godot_bone_node, p_indict); - //} - - BoneAttachment3D *get_bone_attachment(int idx); - - int32_t get_bone_attachment_count(); -}; -#endif // GLTF_SKELETON_H diff --git a/modules/gltf/gltf_skin.cpp b/modules/gltf/gltf_skin.cpp deleted file mode 100644 index 8b0ca7546c..0000000000 --- a/modules/gltf/gltf_skin.cpp +++ /dev/null @@ -1,158 +0,0 @@ -/*************************************************************************/ -/* gltf_skin.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* 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 "gltf_skin.h" - -#include "gltf_template_convert.h" -#include "scene/resources/skin.h" - -void GLTFSkin::_bind_methods() { - ClassDB::bind_method(D_METHOD("get_skin_root"), &GLTFSkin::get_skin_root); - ClassDB::bind_method(D_METHOD("set_skin_root", "skin_root"), &GLTFSkin::set_skin_root); - ClassDB::bind_method(D_METHOD("get_joints_original"), &GLTFSkin::get_joints_original); - ClassDB::bind_method(D_METHOD("set_joints_original", "joints_original"), &GLTFSkin::set_joints_original); - ClassDB::bind_method(D_METHOD("get_inverse_binds"), &GLTFSkin::get_inverse_binds); - ClassDB::bind_method(D_METHOD("set_inverse_binds", "inverse_binds"), &GLTFSkin::set_inverse_binds); - ClassDB::bind_method(D_METHOD("get_joints"), &GLTFSkin::get_joints); - ClassDB::bind_method(D_METHOD("set_joints", "joints"), &GLTFSkin::set_joints); - ClassDB::bind_method(D_METHOD("get_non_joints"), &GLTFSkin::get_non_joints); - ClassDB::bind_method(D_METHOD("set_non_joints", "non_joints"), &GLTFSkin::set_non_joints); - ClassDB::bind_method(D_METHOD("get_roots"), &GLTFSkin::get_roots); - ClassDB::bind_method(D_METHOD("set_roots", "roots"), &GLTFSkin::set_roots); - ClassDB::bind_method(D_METHOD("get_skeleton"), &GLTFSkin::get_skeleton); - ClassDB::bind_method(D_METHOD("set_skeleton", "skeleton"), &GLTFSkin::set_skeleton); - ClassDB::bind_method(D_METHOD("get_joint_i_to_bone_i"), &GLTFSkin::get_joint_i_to_bone_i); - ClassDB::bind_method(D_METHOD("set_joint_i_to_bone_i", "joint_i_to_bone_i"), &GLTFSkin::set_joint_i_to_bone_i); - ClassDB::bind_method(D_METHOD("get_joint_i_to_name"), &GLTFSkin::get_joint_i_to_name); - ClassDB::bind_method(D_METHOD("set_joint_i_to_name", "joint_i_to_name"), &GLTFSkin::set_joint_i_to_name); - ClassDB::bind_method(D_METHOD("get_godot_skin"), &GLTFSkin::get_godot_skin); - ClassDB::bind_method(D_METHOD("set_godot_skin", "godot_skin"), &GLTFSkin::set_godot_skin); - - ADD_PROPERTY(PropertyInfo(Variant::INT, "skin_root"), "set_skin_root", "get_skin_root"); // GLTFNodeIndex - ADD_PROPERTY(PropertyInfo(Variant::PACKED_INT32_ARRAY, "joints_original"), "set_joints_original", "get_joints_original"); // Vector - ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "inverse_binds", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_INTERNAL), "set_inverse_binds", "get_inverse_binds"); // Vector - ADD_PROPERTY(PropertyInfo(Variant::PACKED_INT32_ARRAY, "joints"), "set_joints", "get_joints"); // Vector - ADD_PROPERTY(PropertyInfo(Variant::PACKED_INT32_ARRAY, "non_joints"), "set_non_joints", "get_non_joints"); // Vector - ADD_PROPERTY(PropertyInfo(Variant::PACKED_INT32_ARRAY, "roots"), "set_roots", "get_roots"); // Vector - ADD_PROPERTY(PropertyInfo(Variant::INT, "skeleton"), "set_skeleton", "get_skeleton"); // int - ADD_PROPERTY(PropertyInfo(Variant::DICTIONARY, "joint_i_to_bone_i", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_INTERNAL), "set_joint_i_to_bone_i", "get_joint_i_to_bone_i"); // RBMap -} - -GLTFNodeIndex GLTFSkin::get_skin_root() { - return skin_root; -} - -void GLTFSkin::set_skin_root(GLTFNodeIndex p_skin_root) { - skin_root = p_skin_root; -} - -Vector GLTFSkin::get_joints_original() { - return joints_original; -} - -void GLTFSkin::set_joints_original(Vector p_joints_original) { - joints_original = p_joints_original; -} - -Array GLTFSkin::get_inverse_binds() { - return GLTFTemplateConvert::to_array(inverse_binds); -} - -void GLTFSkin::set_inverse_binds(Array p_inverse_binds) { - GLTFTemplateConvert::set_from_array(inverse_binds, p_inverse_binds); -} - -Vector GLTFSkin::get_joints() { - return joints; -} - -void GLTFSkin::set_joints(Vector p_joints) { - joints = p_joints; -} - -Vector GLTFSkin::get_non_joints() { - return non_joints; -} - -void GLTFSkin::set_non_joints(Vector p_non_joints) { - non_joints = p_non_joints; -} - -Vector GLTFSkin::get_roots() { - return roots; -} - -void GLTFSkin::set_roots(Vector p_roots) { - roots = p_roots; -} - -int GLTFSkin::get_skeleton() { - return skeleton; -} - -void GLTFSkin::set_skeleton(int p_skeleton) { - skeleton = p_skeleton; -} - -Dictionary GLTFSkin::get_joint_i_to_bone_i() { - return GLTFTemplateConvert::to_dict(joint_i_to_bone_i); -} - -void GLTFSkin::set_joint_i_to_bone_i(Dictionary p_joint_i_to_bone_i) { - GLTFTemplateConvert::set_from_dict(joint_i_to_bone_i, p_joint_i_to_bone_i); -} - -Dictionary GLTFSkin::get_joint_i_to_name() { - Dictionary ret; - HashMap::Iterator elem = joint_i_to_name.begin(); - while (elem) { - ret[elem->key] = String(elem->value); - ++elem; - } - return ret; -} - -void GLTFSkin::set_joint_i_to_name(Dictionary p_joint_i_to_name) { - joint_i_to_name = HashMap(); - Array keys = p_joint_i_to_name.keys(); - for (int i = 0; i < keys.size(); i++) { - joint_i_to_name[keys[i]] = p_joint_i_to_name[keys[i]]; - } -} - -Ref GLTFSkin::get_godot_skin() { - return godot_skin; -} - -void GLTFSkin::set_godot_skin(Ref p_godot_skin) { - godot_skin = p_godot_skin; -} diff --git a/modules/gltf/gltf_skin.h b/modules/gltf/gltf_skin.h deleted file mode 100644 index a3f0b2c8af..0000000000 --- a/modules/gltf/gltf_skin.h +++ /dev/null @@ -1,109 +0,0 @@ -/*************************************************************************/ -/* gltf_skin.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* 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_SKIN_H -#define GLTF_SKIN_H - -#include "core/io/resource.h" -#include "gltf_defines.h" - -class GLTFSkin : public Resource { - GDCLASS(GLTFSkin, Resource); - friend class GLTFDocument; - -private: - // The "skeleton" property defined in the gltf spec. -1 = Scene Root - GLTFNodeIndex skin_root = -1; - - Vector joints_original; - Vector inverse_binds; - - // Note: joints + non_joints should form a complete subtree, or subtrees - // with a common parent - - // All nodes that are skins that are caught in-between the original joints - // (inclusive of joints_original) - Vector joints; - - // All Nodes that are caught in-between skin joint nodes, and are not - // defined as joints by any skin - Vector non_joints; - - // The roots of the skin. In the case of multiple roots, their parent *must* - // be the same (the roots must be siblings) - Vector roots; - - // The GLTF Skeleton this Skin points to (after we determine skeletons) - GLTFSkeletonIndex skeleton = -1; - - // A mapping from the joint indices (in the order of joints_original) to the - // Godot Skeleton's bone_indices - HashMap joint_i_to_bone_i; - HashMap joint_i_to_name; - - // The Actual Skin that will be created as a mapping between the IBM's of - // this skin to the generated skeleton for the mesh instances. - Ref godot_skin; - -protected: - static void _bind_methods(); - -public: - GLTFNodeIndex get_skin_root(); - void set_skin_root(GLTFNodeIndex p_skin_root); - - Vector get_joints_original(); - void set_joints_original(Vector p_joints_original); - - Array get_inverse_binds(); - void set_inverse_binds(Array p_inverse_binds); - - Vector get_joints(); - void set_joints(Vector p_joints); - - Vector get_non_joints(); - void set_non_joints(Vector p_non_joints); - - Vector get_roots(); - void set_roots(Vector p_roots); - - int get_skeleton(); - void set_skeleton(int p_skeleton); - - Dictionary get_joint_i_to_bone_i(); - void set_joint_i_to_bone_i(Dictionary p_joint_i_to_bone_i); - - Dictionary get_joint_i_to_name(); - void set_joint_i_to_name(Dictionary p_joint_i_to_name); - - Ref get_godot_skin(); - void set_godot_skin(Ref p_godot_skin); -}; -#endif // GLTF_SKIN_H diff --git a/modules/gltf/gltf_spec_gloss.cpp b/modules/gltf/gltf_spec_gloss.cpp deleted file mode 100644 index 83af91bfcc..0000000000 --- a/modules/gltf/gltf_spec_gloss.cpp +++ /dev/null @@ -1,90 +0,0 @@ -/*************************************************************************/ -/* gltf_spec_gloss.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* 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 "gltf_spec_gloss.h" - -void GLTFSpecGloss::_bind_methods() { - ClassDB::bind_method(D_METHOD("get_diffuse_img"), &GLTFSpecGloss::get_diffuse_img); - ClassDB::bind_method(D_METHOD("set_diffuse_img", "diffuse_img"), &GLTFSpecGloss::set_diffuse_img); - ClassDB::bind_method(D_METHOD("get_diffuse_factor"), &GLTFSpecGloss::get_diffuse_factor); - ClassDB::bind_method(D_METHOD("set_diffuse_factor", "diffuse_factor"), &GLTFSpecGloss::set_diffuse_factor); - ClassDB::bind_method(D_METHOD("get_gloss_factor"), &GLTFSpecGloss::get_gloss_factor); - ClassDB::bind_method(D_METHOD("set_gloss_factor", "gloss_factor"), &GLTFSpecGloss::set_gloss_factor); - ClassDB::bind_method(D_METHOD("get_specular_factor"), &GLTFSpecGloss::get_specular_factor); - ClassDB::bind_method(D_METHOD("set_specular_factor", "specular_factor"), &GLTFSpecGloss::set_specular_factor); - ClassDB::bind_method(D_METHOD("get_spec_gloss_img"), &GLTFSpecGloss::get_spec_gloss_img); - ClassDB::bind_method(D_METHOD("set_spec_gloss_img", "spec_gloss_img"), &GLTFSpecGloss::set_spec_gloss_img); - - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "diffuse_img"), "set_diffuse_img", "get_diffuse_img"); // Ref - ADD_PROPERTY(PropertyInfo(Variant::COLOR, "diffuse_factor"), "set_diffuse_factor", "get_diffuse_factor"); // Color - ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "gloss_factor"), "set_gloss_factor", "get_gloss_factor"); // float - ADD_PROPERTY(PropertyInfo(Variant::COLOR, "specular_factor"), "set_specular_factor", "get_specular_factor"); // Color - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "spec_gloss_img"), "set_spec_gloss_img", "get_spec_gloss_img"); // Ref -} - -Ref GLTFSpecGloss::get_diffuse_img() { - return diffuse_img; -} - -void GLTFSpecGloss::set_diffuse_img(Ref p_diffuse_img) { - diffuse_img = p_diffuse_img; -} - -Color GLTFSpecGloss::get_diffuse_factor() { - return diffuse_factor; -} - -void GLTFSpecGloss::set_diffuse_factor(Color p_diffuse_factor) { - diffuse_factor = p_diffuse_factor; -} - -float GLTFSpecGloss::get_gloss_factor() { - return gloss_factor; -} - -void GLTFSpecGloss::set_gloss_factor(float p_gloss_factor) { - gloss_factor = p_gloss_factor; -} - -Color GLTFSpecGloss::get_specular_factor() { - return specular_factor; -} - -void GLTFSpecGloss::set_specular_factor(Color p_specular_factor) { - specular_factor = p_specular_factor; -} - -Ref GLTFSpecGloss::get_spec_gloss_img() { - return spec_gloss_img; -} - -void GLTFSpecGloss::set_spec_gloss_img(Ref p_spec_gloss_img) { - spec_gloss_img = p_spec_gloss_img; -} diff --git a/modules/gltf/gltf_spec_gloss.h b/modules/gltf/gltf_spec_gloss.h deleted file mode 100644 index f8a431bdce..0000000000 --- a/modules/gltf/gltf_spec_gloss.h +++ /dev/null @@ -1,67 +0,0 @@ -/*************************************************************************/ -/* gltf_spec_gloss.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* 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_SPEC_GLOSS_H -#define GLTF_SPEC_GLOSS_H - -#include "core/io/image.h" -#include "core/io/resource.h" - -class GLTFSpecGloss : public Resource { - GDCLASS(GLTFSpecGloss, Resource); - friend class GLTFDocument; - -private: - Ref diffuse_img = nullptr; - Color diffuse_factor = Color(1.0f, 1.0f, 1.0f); - float gloss_factor = 1.0f; - Color specular_factor = Color(1.0f, 1.0f, 1.0f); - Ref spec_gloss_img = nullptr; - -protected: - static void _bind_methods(); - -public: - Ref get_diffuse_img(); - void set_diffuse_img(Ref p_diffuse_img); - - Color get_diffuse_factor(); - void set_diffuse_factor(Color p_diffuse_factor); - - float get_gloss_factor(); - void set_gloss_factor(float p_gloss_factor); - - Color get_specular_factor(); - void set_specular_factor(Color p_specular_factor); - - Ref get_spec_gloss_img(); - void set_spec_gloss_img(Ref p_spec_gloss_img); -}; -#endif // GLTF_SPEC_GLOSS_H diff --git a/modules/gltf/gltf_state.h b/modules/gltf/gltf_state.h index dd6a65e496..257de5c4e3 100644 --- a/modules/gltf/gltf_state.h +++ b/modules/gltf/gltf_state.h @@ -31,17 +31,17 @@ #ifndef GLTF_STATE_H #define GLTF_STATE_H -#include "gltf_accessor.h" -#include "gltf_animation.h" -#include "gltf_buffer_view.h" -#include "gltf_camera.h" -#include "gltf_light.h" -#include "gltf_mesh.h" -#include "gltf_node.h" -#include "gltf_skeleton.h" -#include "gltf_skin.h" +#include "extensions/gltf_light.h" #include "gltf_template_convert.h" -#include "gltf_texture.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 "core/templates/rb_map.h" #include "scene/animation/animation_player.h" diff --git a/modules/gltf/gltf_texture.cpp b/modules/gltf/gltf_texture.cpp deleted file mode 100644 index 2a21cb3df8..0000000000 --- a/modules/gltf/gltf_texture.cpp +++ /dev/null @@ -1,46 +0,0 @@ -/*************************************************************************/ -/* gltf_texture.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* 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 "gltf_texture.h" - -void GLTFTexture::_bind_methods() { - ClassDB::bind_method(D_METHOD("get_src_image"), &GLTFTexture::get_src_image); - ClassDB::bind_method(D_METHOD("set_src_image", "src_image"), &GLTFTexture::set_src_image); - - ADD_PROPERTY(PropertyInfo(Variant::INT, "src_image"), "set_src_image", "get_src_image"); // int -} - -GLTFImageIndex GLTFTexture::get_src_image() const { - return src_image; -} - -void GLTFTexture::set_src_image(GLTFImageIndex val) { - src_image = val; -} diff --git a/modules/gltf/gltf_texture.h b/modules/gltf/gltf_texture.h deleted file mode 100644 index 2c1c5c2275..0000000000 --- a/modules/gltf/gltf_texture.h +++ /dev/null @@ -1,51 +0,0 @@ -/*************************************************************************/ -/* gltf_texture.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* 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_TEXTURE_H -#define GLTF_TEXTURE_H - -#include "core/io/resource.h" -#include "gltf_defines.h" - -class GLTFTexture : public Resource { - GDCLASS(GLTFTexture, Resource); - -private: - GLTFImageIndex src_image = 0; - -protected: - static void _bind_methods(); - -public: - GLTFImageIndex get_src_image() const; - void set_src_image(GLTFImageIndex val); -}; - -#endif // GLTF_TEXTURE_H diff --git a/modules/gltf/register_types.cpp b/modules/gltf/register_types.cpp index b8bac79584..1e1204aa57 100644 --- a/modules/gltf/register_types.cpp +++ b/modules/gltf/register_types.cpp @@ -32,21 +32,21 @@ #ifndef _3D_DISABLED -#include "gltf_accessor.h" -#include "gltf_animation.h" -#include "gltf_buffer_view.h" -#include "gltf_camera.h" +#include "extensions/gltf_light.h" +#include "extensions/gltf_spec_gloss.h" #include "gltf_document.h" #include "gltf_document_extension.h" #include "gltf_document_extension_convert_importer_mesh.h" -#include "gltf_light.h" -#include "gltf_mesh.h" -#include "gltf_node.h" -#include "gltf_skeleton.h" -#include "gltf_skin.h" -#include "gltf_spec_gloss.h" #include "gltf_state.h" -#include "gltf_texture.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" #ifdef TOOLS_ENABLED #include "core/config/project_settings.h" diff --git a/modules/gltf/structures/gltf_accessor.cpp b/modules/gltf/structures/gltf_accessor.cpp new file mode 100644 index 0000000000..1b8911fe72 --- /dev/null +++ b/modules/gltf/structures/gltf_accessor.cpp @@ -0,0 +1,189 @@ +/*************************************************************************/ +/* gltf_accessor.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ +/* */ +/* 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 "gltf_accessor.h" + +void GLTFAccessor::_bind_methods() { + ClassDB::bind_method(D_METHOD("get_buffer_view"), &GLTFAccessor::get_buffer_view); + ClassDB::bind_method(D_METHOD("set_buffer_view", "buffer_view"), &GLTFAccessor::set_buffer_view); + ClassDB::bind_method(D_METHOD("get_byte_offset"), &GLTFAccessor::get_byte_offset); + ClassDB::bind_method(D_METHOD("set_byte_offset", "byte_offset"), &GLTFAccessor::set_byte_offset); + ClassDB::bind_method(D_METHOD("get_component_type"), &GLTFAccessor::get_component_type); + ClassDB::bind_method(D_METHOD("set_component_type", "component_type"), &GLTFAccessor::set_component_type); + ClassDB::bind_method(D_METHOD("get_normalized"), &GLTFAccessor::get_normalized); + ClassDB::bind_method(D_METHOD("set_normalized", "normalized"), &GLTFAccessor::set_normalized); + ClassDB::bind_method(D_METHOD("get_count"), &GLTFAccessor::get_count); + ClassDB::bind_method(D_METHOD("set_count", "count"), &GLTFAccessor::set_count); + ClassDB::bind_method(D_METHOD("get_type"), &GLTFAccessor::get_type); + ClassDB::bind_method(D_METHOD("set_type", "type"), &GLTFAccessor::set_type); + ClassDB::bind_method(D_METHOD("get_min"), &GLTFAccessor::get_min); + ClassDB::bind_method(D_METHOD("set_min", "min"), &GLTFAccessor::set_min); + ClassDB::bind_method(D_METHOD("get_max"), &GLTFAccessor::get_max); + ClassDB::bind_method(D_METHOD("set_max", "max"), &GLTFAccessor::set_max); + ClassDB::bind_method(D_METHOD("get_sparse_count"), &GLTFAccessor::get_sparse_count); + ClassDB::bind_method(D_METHOD("set_sparse_count", "sparse_count"), &GLTFAccessor::set_sparse_count); + ClassDB::bind_method(D_METHOD("get_sparse_indices_buffer_view"), &GLTFAccessor::get_sparse_indices_buffer_view); + ClassDB::bind_method(D_METHOD("set_sparse_indices_buffer_view", "sparse_indices_buffer_view"), &GLTFAccessor::set_sparse_indices_buffer_view); + ClassDB::bind_method(D_METHOD("get_sparse_indices_byte_offset"), &GLTFAccessor::get_sparse_indices_byte_offset); + ClassDB::bind_method(D_METHOD("set_sparse_indices_byte_offset", "sparse_indices_byte_offset"), &GLTFAccessor::set_sparse_indices_byte_offset); + ClassDB::bind_method(D_METHOD("get_sparse_indices_component_type"), &GLTFAccessor::get_sparse_indices_component_type); + ClassDB::bind_method(D_METHOD("set_sparse_indices_component_type", "sparse_indices_component_type"), &GLTFAccessor::set_sparse_indices_component_type); + ClassDB::bind_method(D_METHOD("get_sparse_values_buffer_view"), &GLTFAccessor::get_sparse_values_buffer_view); + ClassDB::bind_method(D_METHOD("set_sparse_values_buffer_view", "sparse_values_buffer_view"), &GLTFAccessor::set_sparse_values_buffer_view); + ClassDB::bind_method(D_METHOD("get_sparse_values_byte_offset"), &GLTFAccessor::get_sparse_values_byte_offset); + ClassDB::bind_method(D_METHOD("set_sparse_values_byte_offset", "sparse_values_byte_offset"), &GLTFAccessor::set_sparse_values_byte_offset); + + ADD_PROPERTY(PropertyInfo(Variant::INT, "buffer_view"), "set_buffer_view", "get_buffer_view"); // GLTFBufferViewIndex + ADD_PROPERTY(PropertyInfo(Variant::INT, "byte_offset"), "set_byte_offset", "get_byte_offset"); // int + ADD_PROPERTY(PropertyInfo(Variant::INT, "component_type"), "set_component_type", "get_component_type"); // int + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "normalized"), "set_normalized", "get_normalized"); // bool + ADD_PROPERTY(PropertyInfo(Variant::INT, "count"), "set_count", "get_count"); // int + ADD_PROPERTY(PropertyInfo(Variant::INT, "type"), "set_type", "get_type"); // GLTFType + ADD_PROPERTY(PropertyInfo(Variant::PACKED_FLOAT64_ARRAY, "min"), "set_min", "get_min"); // Vector + ADD_PROPERTY(PropertyInfo(Variant::PACKED_FLOAT64_ARRAY, "max"), "set_max", "get_max"); // Vector + ADD_PROPERTY(PropertyInfo(Variant::INT, "sparse_count"), "set_sparse_count", "get_sparse_count"); // int + ADD_PROPERTY(PropertyInfo(Variant::INT, "sparse_indices_buffer_view"), "set_sparse_indices_buffer_view", "get_sparse_indices_buffer_view"); // int + ADD_PROPERTY(PropertyInfo(Variant::INT, "sparse_indices_byte_offset"), "set_sparse_indices_byte_offset", "get_sparse_indices_byte_offset"); // int + ADD_PROPERTY(PropertyInfo(Variant::INT, "sparse_indices_component_type"), "set_sparse_indices_component_type", "get_sparse_indices_component_type"); // int + ADD_PROPERTY(PropertyInfo(Variant::INT, "sparse_values_buffer_view"), "set_sparse_values_buffer_view", "get_sparse_values_buffer_view"); // int + ADD_PROPERTY(PropertyInfo(Variant::INT, "sparse_values_byte_offset"), "set_sparse_values_byte_offset", "get_sparse_values_byte_offset"); // int +} + +GLTFBufferViewIndex GLTFAccessor::get_buffer_view() { + return buffer_view; +} + +void GLTFAccessor::set_buffer_view(GLTFBufferViewIndex p_buffer_view) { + buffer_view = p_buffer_view; +} + +int GLTFAccessor::get_byte_offset() { + return byte_offset; +} + +void GLTFAccessor::set_byte_offset(int p_byte_offset) { + byte_offset = p_byte_offset; +} + +int GLTFAccessor::get_component_type() { + return component_type; +} + +void GLTFAccessor::set_component_type(int p_component_type) { + component_type = p_component_type; +} + +bool GLTFAccessor::get_normalized() { + return normalized; +} + +void GLTFAccessor::set_normalized(bool p_normalized) { + normalized = p_normalized; +} + +int GLTFAccessor::get_count() { + return count; +} + +void GLTFAccessor::set_count(int p_count) { + count = p_count; +} + +int GLTFAccessor::get_type() { + return (int)type; +} + +void GLTFAccessor::set_type(int p_type) { + type = (GLTFType)p_type; // TODO: Register enum +} + +Vector GLTFAccessor::get_min() { + return min; +} + +void GLTFAccessor::set_min(Vector p_min) { + min = p_min; +} + +Vector GLTFAccessor::get_max() { + return max; +} + +void GLTFAccessor::set_max(Vector p_max) { + max = p_max; +} + +int GLTFAccessor::get_sparse_count() { + return sparse_count; +} + +void GLTFAccessor::set_sparse_count(int p_sparse_count) { + sparse_count = p_sparse_count; +} + +int GLTFAccessor::get_sparse_indices_buffer_view() { + return sparse_indices_buffer_view; +} + +void GLTFAccessor::set_sparse_indices_buffer_view(int p_sparse_indices_buffer_view) { + sparse_indices_buffer_view = p_sparse_indices_buffer_view; +} + +int GLTFAccessor::get_sparse_indices_byte_offset() { + return sparse_indices_byte_offset; +} + +void GLTFAccessor::set_sparse_indices_byte_offset(int p_sparse_indices_byte_offset) { + sparse_indices_byte_offset = p_sparse_indices_byte_offset; +} + +int GLTFAccessor::get_sparse_indices_component_type() { + return sparse_indices_component_type; +} + +void GLTFAccessor::set_sparse_indices_component_type(int p_sparse_indices_component_type) { + sparse_indices_component_type = p_sparse_indices_component_type; +} + +int GLTFAccessor::get_sparse_values_buffer_view() { + return sparse_values_buffer_view; +} + +void GLTFAccessor::set_sparse_values_buffer_view(int p_sparse_values_buffer_view) { + sparse_values_buffer_view = p_sparse_values_buffer_view; +} + +int GLTFAccessor::get_sparse_values_byte_offset() { + return sparse_values_byte_offset; +} + +void GLTFAccessor::set_sparse_values_byte_offset(int p_sparse_values_byte_offset) { + sparse_values_byte_offset = p_sparse_values_byte_offset; +} diff --git a/modules/gltf/structures/gltf_accessor.h b/modules/gltf/structures/gltf_accessor.h new file mode 100644 index 0000000000..c9abbda668 --- /dev/null +++ b/modules/gltf/structures/gltf_accessor.h @@ -0,0 +1,104 @@ +/*************************************************************************/ +/* gltf_accessor.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ +/* */ +/* 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_ACCESSOR_H +#define GLTF_ACCESSOR_H + +#include "core/io/resource.h" + +#include "../gltf_defines.h" + +struct GLTFAccessor : public Resource { + GDCLASS(GLTFAccessor, Resource); + friend class GLTFDocument; + +private: + GLTFBufferViewIndex buffer_view = 0; + int byte_offset = 0; + int component_type = 0; + bool normalized = false; + int count = 0; + GLTFType type = GLTFType::TYPE_SCALAR; + Vector min; + Vector max; + int sparse_count = 0; + int sparse_indices_buffer_view = 0; + int sparse_indices_byte_offset = 0; + int sparse_indices_component_type = 0; + int sparse_values_buffer_view = 0; + int sparse_values_byte_offset = 0; + +protected: + static void _bind_methods(); + +public: + GLTFBufferViewIndex get_buffer_view(); + void set_buffer_view(GLTFBufferViewIndex p_buffer_view); + + int get_byte_offset(); + void set_byte_offset(int p_byte_offset); + + int get_component_type(); + void set_component_type(int p_component_type); + + bool get_normalized(); + void set_normalized(bool p_normalized); + + int get_count(); + void set_count(int p_count); + + int get_type(); + void set_type(int p_type); + + Vector get_min(); + void set_min(Vector p_min); + + Vector get_max(); + void set_max(Vector p_max); + + int get_sparse_count(); + void set_sparse_count(int p_sparse_count); + + int get_sparse_indices_buffer_view(); + void set_sparse_indices_buffer_view(int p_sparse_indices_buffer_view); + + int get_sparse_indices_byte_offset(); + void set_sparse_indices_byte_offset(int p_sparse_indices_byte_offset); + + int get_sparse_indices_component_type(); + void set_sparse_indices_component_type(int p_sparse_indices_component_type); + + int get_sparse_values_buffer_view(); + void set_sparse_values_buffer_view(int p_sparse_values_buffer_view); + + int get_sparse_values_byte_offset(); + void set_sparse_values_byte_offset(int p_sparse_values_byte_offset); +}; +#endif // GLTF_ACCESSOR_H diff --git a/modules/gltf/structures/gltf_animation.cpp b/modules/gltf/structures/gltf_animation.cpp new file mode 100644 index 0000000000..e598c870ab --- /dev/null +++ b/modules/gltf/structures/gltf_animation.cpp @@ -0,0 +1,53 @@ +/*************************************************************************/ +/* gltf_animation.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ +/* */ +/* 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 "gltf_animation.h" + +void GLTFAnimation::_bind_methods() { + ClassDB::bind_method(D_METHOD("get_loop"), &GLTFAnimation::get_loop); + ClassDB::bind_method(D_METHOD("set_loop", "loop"), &GLTFAnimation::set_loop); + + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "loop"), "set_loop", "get_loop"); // bool +} + +bool GLTFAnimation::get_loop() const { + return loop; +} + +void GLTFAnimation::set_loop(bool p_val) { + loop = p_val; +} + +HashMap &GLTFAnimation::get_tracks() { + return tracks; +} + +GLTFAnimation::GLTFAnimation() { +} diff --git a/modules/gltf/structures/gltf_animation.h b/modules/gltf/structures/gltf_animation.h new file mode 100644 index 0000000000..8688ddb937 --- /dev/null +++ b/modules/gltf/structures/gltf_animation.h @@ -0,0 +1,74 @@ +/*************************************************************************/ +/* gltf_animation.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ +/* */ +/* 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_ANIMATION_H +#define GLTF_ANIMATION_H + +#include "core/io/resource.h" + +class GLTFAnimation : public Resource { + GDCLASS(GLTFAnimation, Resource); + +protected: + static void _bind_methods(); + +public: + enum Interpolation { + INTERP_LINEAR, + INTERP_STEP, + INTERP_CATMULLROMSPLINE, + INTERP_CUBIC_SPLINE, + }; + + template + struct Channel { + Interpolation interpolation; + Vector times; + Vector values; + }; + + struct Track { + Channel position_track; + Channel rotation_track; + Channel scale_track; + Vector> weight_tracks; + }; + +public: + bool get_loop() const; + void set_loop(bool p_val); + HashMap &get_tracks(); + GLTFAnimation(); + +private: + bool loop = false; + HashMap tracks; +}; +#endif // GLTF_ANIMATION_H diff --git a/modules/gltf/structures/gltf_buffer_view.cpp b/modules/gltf/structures/gltf_buffer_view.cpp new file mode 100644 index 0000000000..ba19ed8628 --- /dev/null +++ b/modules/gltf/structures/gltf_buffer_view.cpp @@ -0,0 +1,92 @@ +/*************************************************************************/ +/* gltf_buffer_view.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ +/* */ +/* 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 "gltf_buffer_view.h" + +#include "../gltf_document_extension.h" + +void GLTFBufferView::_bind_methods() { + ClassDB::bind_method(D_METHOD("get_buffer"), &GLTFBufferView::get_buffer); + ClassDB::bind_method(D_METHOD("set_buffer", "buffer"), &GLTFBufferView::set_buffer); + ClassDB::bind_method(D_METHOD("get_byte_offset"), &GLTFBufferView::get_byte_offset); + ClassDB::bind_method(D_METHOD("set_byte_offset", "byte_offset"), &GLTFBufferView::set_byte_offset); + ClassDB::bind_method(D_METHOD("get_byte_length"), &GLTFBufferView::get_byte_length); + ClassDB::bind_method(D_METHOD("set_byte_length", "byte_length"), &GLTFBufferView::set_byte_length); + ClassDB::bind_method(D_METHOD("get_byte_stride"), &GLTFBufferView::get_byte_stride); + ClassDB::bind_method(D_METHOD("set_byte_stride", "byte_stride"), &GLTFBufferView::set_byte_stride); + ClassDB::bind_method(D_METHOD("get_indices"), &GLTFBufferView::get_indices); + ClassDB::bind_method(D_METHOD("set_indices", "indices"), &GLTFBufferView::set_indices); + + ADD_PROPERTY(PropertyInfo(Variant::INT, "buffer"), "set_buffer", "get_buffer"); // GLTFBufferIndex + ADD_PROPERTY(PropertyInfo(Variant::INT, "byte_offset"), "set_byte_offset", "get_byte_offset"); // int + ADD_PROPERTY(PropertyInfo(Variant::INT, "byte_length"), "set_byte_length", "get_byte_length"); // int + ADD_PROPERTY(PropertyInfo(Variant::INT, "byte_stride"), "set_byte_stride", "get_byte_stride"); // int + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "indices"), "set_indices", "get_indices"); // bool +} + +GLTFBufferIndex GLTFBufferView::get_buffer() { + return buffer; +} + +void GLTFBufferView::set_buffer(GLTFBufferIndex p_buffer) { + buffer = p_buffer; +} + +int GLTFBufferView::get_byte_offset() { + return byte_offset; +} + +void GLTFBufferView::set_byte_offset(int p_byte_offset) { + byte_offset = p_byte_offset; +} + +int GLTFBufferView::get_byte_length() { + return byte_length; +} + +void GLTFBufferView::set_byte_length(int p_byte_length) { + byte_length = p_byte_length; +} + +int GLTFBufferView::get_byte_stride() { + return byte_stride; +} + +void GLTFBufferView::set_byte_stride(int p_byte_stride) { + byte_stride = p_byte_stride; +} + +bool GLTFBufferView::get_indices() { + return indices; +} + +void GLTFBufferView::set_indices(bool p_indices) { + indices = p_indices; +} diff --git a/modules/gltf/structures/gltf_buffer_view.h b/modules/gltf/structures/gltf_buffer_view.h new file mode 100644 index 0000000000..dada1e87b3 --- /dev/null +++ b/modules/gltf/structures/gltf_buffer_view.h @@ -0,0 +1,68 @@ +/*************************************************************************/ +/* gltf_buffer_view.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ +/* */ +/* 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_BUFFER_VIEW_H +#define GLTF_BUFFER_VIEW_H + +#include "../gltf_defines.h" +#include "core/io/resource.h" + +class GLTFBufferView : public Resource { + GDCLASS(GLTFBufferView, Resource); + friend class GLTFDocument; + +private: + GLTFBufferIndex buffer = -1; + int byte_offset = 0; + int byte_length = 0; + int byte_stride = -1; + bool indices = false; + +protected: + static void _bind_methods(); + +public: + GLTFBufferIndex get_buffer(); + void set_buffer(GLTFBufferIndex p_buffer); + + int get_byte_offset(); + void set_byte_offset(int p_byte_offset); + + int get_byte_length(); + void set_byte_length(int p_byte_length); + + int get_byte_stride(); + void set_byte_stride(int p_byte_stride); + + bool get_indices(); + void set_indices(bool p_indices); + // matrices need to be transformed to this +}; +#endif // GLTF_BUFFER_VIEW_H diff --git a/modules/gltf/structures/gltf_camera.cpp b/modules/gltf/structures/gltf_camera.cpp new file mode 100644 index 0000000000..f3ea6a1c4c --- /dev/null +++ b/modules/gltf/structures/gltf_camera.cpp @@ -0,0 +1,47 @@ +/*************************************************************************/ +/* gltf_camera.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ +/* */ +/* 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 "gltf_camera.h" + +void GLTFCamera::_bind_methods() { + ClassDB::bind_method(D_METHOD("get_perspective"), &GLTFCamera::get_perspective); + ClassDB::bind_method(D_METHOD("set_perspective", "perspective"), &GLTFCamera::set_perspective); + ClassDB::bind_method(D_METHOD("get_fov_size"), &GLTFCamera::get_fov_size); + ClassDB::bind_method(D_METHOD("set_fov_size", "fov_size"), &GLTFCamera::set_fov_size); + ClassDB::bind_method(D_METHOD("get_depth_far"), &GLTFCamera::get_depth_far); + ClassDB::bind_method(D_METHOD("set_depth_far", "zdepth_far"), &GLTFCamera::set_depth_far); + ClassDB::bind_method(D_METHOD("get_depth_near"), &GLTFCamera::get_depth_near); + ClassDB::bind_method(D_METHOD("set_depth_near", "zdepth_near"), &GLTFCamera::set_depth_near); + + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "perspective"), "set_perspective", "get_perspective"); // bool + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "fov_size"), "set_fov_size", "get_fov_size"); // float + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "depth_far"), "set_depth_far", "get_depth_far"); // float + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "depth_near"), "set_depth_near", "get_depth_near"); // float +} diff --git a/modules/gltf/structures/gltf_camera.h b/modules/gltf/structures/gltf_camera.h new file mode 100644 index 0000000000..c696d4cc6b --- /dev/null +++ b/modules/gltf/structures/gltf_camera.h @@ -0,0 +1,58 @@ +/*************************************************************************/ +/* gltf_camera.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ +/* */ +/* 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_CAMERA_H +#define GLTF_CAMERA_H + +#include "core/io/resource.h" + +class GLTFCamera : public Resource { + GDCLASS(GLTFCamera, Resource); + +private: + bool perspective = true; + float fov_size = 75.0; + float depth_far = 4000.0; + float depth_near = 0.05; + +protected: + static void _bind_methods(); + +public: + bool get_perspective() const { return perspective; } + void set_perspective(bool p_val) { perspective = p_val; } + float get_fov_size() const { return fov_size; } + void set_fov_size(float p_val) { fov_size = p_val; } + float get_depth_far() const { return depth_far; } + void set_depth_far(float p_val) { depth_far = p_val; } + float get_depth_near() const { return depth_near; } + void set_depth_near(float p_val) { depth_near = p_val; } +}; +#endif // GLTF_CAMERA_H diff --git a/modules/gltf/structures/gltf_mesh.cpp b/modules/gltf/structures/gltf_mesh.cpp new file mode 100644 index 0000000000..3add8304b1 --- /dev/null +++ b/modules/gltf/structures/gltf_mesh.cpp @@ -0,0 +1,70 @@ +/*************************************************************************/ +/* gltf_mesh.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ +/* */ +/* 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 "gltf_mesh.h" + +#include "scene/resources/importer_mesh.h" + +void GLTFMesh::_bind_methods() { + ClassDB::bind_method(D_METHOD("get_mesh"), &GLTFMesh::get_mesh); + ClassDB::bind_method(D_METHOD("set_mesh", "mesh"), &GLTFMesh::set_mesh); + ClassDB::bind_method(D_METHOD("get_blend_weights"), &GLTFMesh::get_blend_weights); + ClassDB::bind_method(D_METHOD("set_blend_weights", "blend_weights"), &GLTFMesh::set_blend_weights); + ClassDB::bind_method(D_METHOD("get_instance_materials"), &GLTFMesh::get_instance_materials); + ClassDB::bind_method(D_METHOD("set_instance_materials", "instance_materials"), &GLTFMesh::set_instance_materials); + + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "mesh"), "set_mesh", "get_mesh"); + ADD_PROPERTY(PropertyInfo(Variant::PACKED_FLOAT32_ARRAY, "blend_weights"), "set_blend_weights", "get_blend_weights"); // Vector + ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "instance_materials"), "set_instance_materials", "get_instance_materials"); +} + +Ref GLTFMesh::get_mesh() { + return mesh; +} + +void GLTFMesh::set_mesh(Ref p_mesh) { + mesh = p_mesh; +} + +Array GLTFMesh::get_instance_materials() { + return instance_materials; +} + +void GLTFMesh::set_instance_materials(Array p_instance_materials) { + instance_materials = p_instance_materials; +} + +Vector GLTFMesh::get_blend_weights() { + return blend_weights; +} + +void GLTFMesh::set_blend_weights(Vector p_blend_weights) { + blend_weights = p_blend_weights; +} diff --git a/modules/gltf/structures/gltf_mesh.h b/modules/gltf/structures/gltf_mesh.h new file mode 100644 index 0000000000..dc26120b48 --- /dev/null +++ b/modules/gltf/structures/gltf_mesh.h @@ -0,0 +1,59 @@ +/*************************************************************************/ +/* gltf_mesh.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ +/* */ +/* 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_MESH_H +#define GLTF_MESH_H + +#include "core/io/resource.h" +#include "scene/3d/importer_mesh_instance_3d.h" +#include "scene/resources/importer_mesh.h" +#include "scene/resources/mesh.h" + +class GLTFMesh : public Resource { + GDCLASS(GLTFMesh, Resource); + +private: + Ref mesh; + Vector blend_weights; + Array instance_materials; + +protected: + static void _bind_methods(); + +public: + Ref get_mesh(); + void set_mesh(Ref p_mesh); + Vector get_blend_weights(); + void set_blend_weights(Vector p_blend_weights); + Array get_instance_materials(); + void set_instance_materials(Array p_instance_materials); +}; + +#endif // GLTF_MESH_H diff --git a/modules/gltf/structures/gltf_node.cpp b/modules/gltf/structures/gltf_node.cpp new file mode 100644 index 0000000000..86280603fa --- /dev/null +++ b/modules/gltf/structures/gltf_node.cpp @@ -0,0 +1,178 @@ +/*************************************************************************/ +/* gltf_node.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ +/* */ +/* 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 "gltf_node.h" + +void GLTFNode::_bind_methods() { + ClassDB::bind_method(D_METHOD("get_parent"), &GLTFNode::get_parent); + ClassDB::bind_method(D_METHOD("set_parent", "parent"), &GLTFNode::set_parent); + ClassDB::bind_method(D_METHOD("get_height"), &GLTFNode::get_height); + ClassDB::bind_method(D_METHOD("set_height", "height"), &GLTFNode::set_height); + ClassDB::bind_method(D_METHOD("get_xform"), &GLTFNode::get_xform); + ClassDB::bind_method(D_METHOD("set_xform", "xform"), &GLTFNode::set_xform); + ClassDB::bind_method(D_METHOD("get_mesh"), &GLTFNode::get_mesh); + ClassDB::bind_method(D_METHOD("set_mesh", "mesh"), &GLTFNode::set_mesh); + ClassDB::bind_method(D_METHOD("get_camera"), &GLTFNode::get_camera); + ClassDB::bind_method(D_METHOD("set_camera", "camera"), &GLTFNode::set_camera); + ClassDB::bind_method(D_METHOD("get_skin"), &GLTFNode::get_skin); + ClassDB::bind_method(D_METHOD("set_skin", "skin"), &GLTFNode::set_skin); + ClassDB::bind_method(D_METHOD("get_skeleton"), &GLTFNode::get_skeleton); + ClassDB::bind_method(D_METHOD("set_skeleton", "skeleton"), &GLTFNode::set_skeleton); + ClassDB::bind_method(D_METHOD("get_joint"), &GLTFNode::get_joint); + ClassDB::bind_method(D_METHOD("set_joint", "joint"), &GLTFNode::set_joint); + ClassDB::bind_method(D_METHOD("get_position"), &GLTFNode::get_position); + ClassDB::bind_method(D_METHOD("set_position", "position"), &GLTFNode::set_position); + ClassDB::bind_method(D_METHOD("get_rotation"), &GLTFNode::get_rotation); + ClassDB::bind_method(D_METHOD("set_rotation", "rotation"), &GLTFNode::set_rotation); + ClassDB::bind_method(D_METHOD("get_scale"), &GLTFNode::get_scale); + ClassDB::bind_method(D_METHOD("set_scale", "scale"), &GLTFNode::set_scale); + ClassDB::bind_method(D_METHOD("get_children"), &GLTFNode::get_children); + ClassDB::bind_method(D_METHOD("set_children", "children"), &GLTFNode::set_children); + ClassDB::bind_method(D_METHOD("get_light"), &GLTFNode::get_light); + ClassDB::bind_method(D_METHOD("set_light", "light"), &GLTFNode::set_light); + + ADD_PROPERTY(PropertyInfo(Variant::INT, "parent"), "set_parent", "get_parent"); // GLTFNodeIndex + ADD_PROPERTY(PropertyInfo(Variant::INT, "height"), "set_height", "get_height"); // int + ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM3D, "xform"), "set_xform", "get_xform"); // Transform3D + ADD_PROPERTY(PropertyInfo(Variant::INT, "mesh"), "set_mesh", "get_mesh"); // GLTFMeshIndex + ADD_PROPERTY(PropertyInfo(Variant::INT, "camera"), "set_camera", "get_camera"); // GLTFCameraIndex + ADD_PROPERTY(PropertyInfo(Variant::INT, "skin"), "set_skin", "get_skin"); // GLTFSkinIndex + ADD_PROPERTY(PropertyInfo(Variant::INT, "skeleton"), "set_skeleton", "get_skeleton"); // GLTFSkeletonIndex + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "joint"), "set_joint", "get_joint"); // bool + ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "position"), "set_position", "get_position"); // Vector3 + ADD_PROPERTY(PropertyInfo(Variant::QUATERNION, "rotation"), "set_rotation", "get_rotation"); // Quaternion + ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "scale"), "set_scale", "get_scale"); // Vector3 + ADD_PROPERTY(PropertyInfo(Variant::PACKED_INT32_ARRAY, "children"), "set_children", "get_children"); // Vector + ADD_PROPERTY(PropertyInfo(Variant::INT, "light"), "set_light", "get_light"); // GLTFLightIndex +} + +GLTFNodeIndex GLTFNode::get_parent() { + return parent; +} + +void GLTFNode::set_parent(GLTFNodeIndex p_parent) { + parent = p_parent; +} + +int GLTFNode::get_height() { + return height; +} + +void GLTFNode::set_height(int p_height) { + height = p_height; +} + +Transform3D GLTFNode::get_xform() { + return xform; +} + +void GLTFNode::set_xform(Transform3D p_xform) { + xform = p_xform; +} + +GLTFMeshIndex GLTFNode::get_mesh() { + return mesh; +} + +void GLTFNode::set_mesh(GLTFMeshIndex p_mesh) { + mesh = p_mesh; +} + +GLTFCameraIndex GLTFNode::get_camera() { + return camera; +} + +void GLTFNode::set_camera(GLTFCameraIndex p_camera) { + camera = p_camera; +} + +GLTFSkinIndex GLTFNode::get_skin() { + return skin; +} + +void GLTFNode::set_skin(GLTFSkinIndex p_skin) { + skin = p_skin; +} + +GLTFSkeletonIndex GLTFNode::get_skeleton() { + return skeleton; +} + +void GLTFNode::set_skeleton(GLTFSkeletonIndex p_skeleton) { + skeleton = p_skeleton; +} + +bool GLTFNode::get_joint() { + return joint; +} + +void GLTFNode::set_joint(bool p_joint) { + joint = p_joint; +} + +Vector3 GLTFNode::get_position() { + return position; +} + +void GLTFNode::set_position(Vector3 p_position) { + position = p_position; +} + +Quaternion GLTFNode::get_rotation() { + return rotation; +} + +void GLTFNode::set_rotation(Quaternion p_rotation) { + rotation = p_rotation; +} + +Vector3 GLTFNode::get_scale() { + return scale; +} + +void GLTFNode::set_scale(Vector3 p_scale) { + scale = p_scale; +} + +Vector GLTFNode::get_children() { + return children; +} + +void GLTFNode::set_children(Vector p_children) { + children = p_children; +} + +GLTFLightIndex GLTFNode::get_light() { + return light; +} + +void GLTFNode::set_light(GLTFLightIndex p_light) { + light = p_light; +} diff --git a/modules/gltf/structures/gltf_node.h b/modules/gltf/structures/gltf_node.h new file mode 100644 index 0000000000..67a268dd1a --- /dev/null +++ b/modules/gltf/structures/gltf_node.h @@ -0,0 +1,100 @@ +/*************************************************************************/ +/* gltf_node.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ +/* */ +/* 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_NODE_H +#define GLTF_NODE_H + +#include "../gltf_defines.h" +#include "core/io/resource.h" + +class GLTFNode : public Resource { + GDCLASS(GLTFNode, Resource); + friend class GLTFDocument; + +private: + // matrices need to be transformed to this + GLTFNodeIndex parent = -1; + int height = -1; + Transform3D xform; + GLTFMeshIndex mesh = -1; + GLTFCameraIndex camera = -1; + GLTFSkinIndex skin = -1; + GLTFSkeletonIndex skeleton = -1; + bool joint = false; + Vector3 position; + Quaternion rotation; + Vector3 scale = Vector3(1, 1, 1); + Vector children; + GLTFLightIndex light = -1; + +protected: + static void _bind_methods(); + +public: + GLTFNodeIndex get_parent(); + void set_parent(GLTFNodeIndex p_parent); + + int get_height(); + void set_height(int p_height); + + Transform3D get_xform(); + void set_xform(Transform3D p_xform); + + GLTFMeshIndex get_mesh(); + void set_mesh(GLTFMeshIndex p_mesh); + + GLTFCameraIndex get_camera(); + void set_camera(GLTFCameraIndex p_camera); + + GLTFSkinIndex get_skin(); + void set_skin(GLTFSkinIndex p_skin); + + GLTFSkeletonIndex get_skeleton(); + void set_skeleton(GLTFSkeletonIndex p_skeleton); + + bool get_joint(); + void set_joint(bool p_joint); + + Vector3 get_position(); + void set_position(Vector3 p_position); + + Quaternion get_rotation(); + void set_rotation(Quaternion p_rotation); + + Vector3 get_scale(); + void set_scale(Vector3 p_scale); + + Vector get_children(); + void set_children(Vector p_children); + + GLTFLightIndex get_light(); + void set_light(GLTFLightIndex p_light); +}; +#endif // GLTF_NODE_H diff --git a/modules/gltf/structures/gltf_skeleton.cpp b/modules/gltf/structures/gltf_skeleton.cpp new file mode 100644 index 0000000000..90a6b0f50f --- /dev/null +++ b/modules/gltf/structures/gltf_skeleton.cpp @@ -0,0 +1,98 @@ +/*************************************************************************/ +/* gltf_skeleton.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ +/* */ +/* 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 "gltf_skeleton.h" + +#include "../gltf_template_convert.h" +#include "scene/3d/bone_attachment_3d.h" + +void GLTFSkeleton::_bind_methods() { + ClassDB::bind_method(D_METHOD("get_joints"), &GLTFSkeleton::get_joints); + ClassDB::bind_method(D_METHOD("set_joints", "joints"), &GLTFSkeleton::set_joints); + ClassDB::bind_method(D_METHOD("get_roots"), &GLTFSkeleton::get_roots); + ClassDB::bind_method(D_METHOD("set_roots", "roots"), &GLTFSkeleton::set_roots); + ClassDB::bind_method(D_METHOD("get_godot_skeleton"), &GLTFSkeleton::get_godot_skeleton); + ClassDB::bind_method(D_METHOD("get_unique_names"), &GLTFSkeleton::get_unique_names); + ClassDB::bind_method(D_METHOD("set_unique_names", "unique_names"), &GLTFSkeleton::set_unique_names); + ClassDB::bind_method(D_METHOD("get_godot_bone_node"), &GLTFSkeleton::get_godot_bone_node); + ClassDB::bind_method(D_METHOD("set_godot_bone_node", "godot_bone_node"), &GLTFSkeleton::set_godot_bone_node); + ClassDB::bind_method(D_METHOD("get_bone_attachment_count"), &GLTFSkeleton::get_bone_attachment_count); + ClassDB::bind_method(D_METHOD("get_bone_attachment", "idx"), &GLTFSkeleton::get_bone_attachment); + + ADD_PROPERTY(PropertyInfo(Variant::PACKED_INT32_ARRAY, "joints"), "set_joints", "get_joints"); // Vector + ADD_PROPERTY(PropertyInfo(Variant::PACKED_INT32_ARRAY, "roots"), "set_roots", "get_roots"); // Vector + ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "unique_names", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_INTERNAL | PROPERTY_USAGE_EDITOR), "set_unique_names", "get_unique_names"); // Set + ADD_PROPERTY(PropertyInfo(Variant::DICTIONARY, "godot_bone_node", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_INTERNAL | PROPERTY_USAGE_EDITOR), "set_godot_bone_node", "get_godot_bone_node"); // RBMap GLTFSkeleton::get_joints() { + return joints; +} + +void GLTFSkeleton::set_joints(Vector p_joints) { + joints = p_joints; +} + +Vector GLTFSkeleton::get_roots() { + return roots; +} + +void GLTFSkeleton::set_roots(Vector p_roots) { + roots = p_roots; +} + +Skeleton3D *GLTFSkeleton::get_godot_skeleton() { + return godot_skeleton; +} + +Array GLTFSkeleton::get_unique_names() { + return GLTFTemplateConvert::to_array(unique_names); +} + +void GLTFSkeleton::set_unique_names(Array p_unique_names) { + GLTFTemplateConvert::set_from_array(unique_names, p_unique_names); +} + +Dictionary GLTFSkeleton::get_godot_bone_node() { + return GLTFTemplateConvert::to_dict(godot_bone_node); +} + +void GLTFSkeleton::set_godot_bone_node(Dictionary p_indict) { + GLTFTemplateConvert::set_from_dict(godot_bone_node, p_indict); +} + +BoneAttachment3D *GLTFSkeleton::get_bone_attachment(int idx) { + ERR_FAIL_INDEX_V(idx, bone_attachments.size(), nullptr); + return bone_attachments[idx]; +} + +int32_t GLTFSkeleton::get_bone_attachment_count() { + return bone_attachments.size(); +} diff --git a/modules/gltf/structures/gltf_skeleton.h b/modules/gltf/structures/gltf_skeleton.h new file mode 100644 index 0000000000..05bfa37a06 --- /dev/null +++ b/modules/gltf/structures/gltf_skeleton.h @@ -0,0 +1,101 @@ +/*************************************************************************/ +/* gltf_skeleton.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ +/* */ +/* 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_SKELETON_H +#define GLTF_SKELETON_H + +#include "../gltf_defines.h" +#include "core/io/resource.h" + +class GLTFSkeleton : public Resource { + GDCLASS(GLTFSkeleton, Resource); + friend class GLTFDocument; + +private: + // The *synthesized* skeletons joints + Vector joints; + + // The roots of the skeleton. If there are multiple, each root must have the + // same parent (ie roots are siblings) + Vector roots; + + // The created Skeleton3D for the scene + Skeleton3D *godot_skeleton = nullptr; + + // Set of unique bone names for the skeleton + HashSet unique_names; + + HashMap godot_bone_node; + + Vector bone_attachments; + +protected: + static void _bind_methods(); + +public: + Vector get_joints(); + void set_joints(Vector p_joints); + + Vector get_roots(); + void set_roots(Vector p_roots); + + Skeleton3D *get_godot_skeleton(); + + // Skeleton *get_godot_skeleton() { + // return this->godot_skeleton; + // } + // void set_godot_skeleton(Skeleton p_*godot_skeleton) { + // this->godot_skeleton = p_godot_skeleton; + // } + + Array get_unique_names(); + void set_unique_names(Array p_unique_names); + + //RBMap get_godot_bone_node() { + // return this->godot_bone_node; + //} + //void set_godot_bone_node(RBMap p_godot_bone_node) { + // this->godot_bone_node = p_godot_bone_node; + //} + Dictionary get_godot_bone_node(); + void set_godot_bone_node(Dictionary p_indict); + + //Dictionary get_godot_bone_node() { + // return VariantConversion::to_dict(this->godot_bone_node); + //} + //void set_godot_bone_node(Dictionary p_indict) { + // VariantConversion::set_from_dict(this->godot_bone_node, p_indict); + //} + + BoneAttachment3D *get_bone_attachment(int idx); + + int32_t get_bone_attachment_count(); +}; +#endif // GLTF_SKELETON_H diff --git a/modules/gltf/structures/gltf_skin.cpp b/modules/gltf/structures/gltf_skin.cpp new file mode 100644 index 0000000000..2e46ee3be2 --- /dev/null +++ b/modules/gltf/structures/gltf_skin.cpp @@ -0,0 +1,158 @@ +/*************************************************************************/ +/* gltf_skin.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ +/* */ +/* 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 "gltf_skin.h" + +#include "../gltf_template_convert.h" +#include "scene/resources/skin.h" + +void GLTFSkin::_bind_methods() { + ClassDB::bind_method(D_METHOD("get_skin_root"), &GLTFSkin::get_skin_root); + ClassDB::bind_method(D_METHOD("set_skin_root", "skin_root"), &GLTFSkin::set_skin_root); + ClassDB::bind_method(D_METHOD("get_joints_original"), &GLTFSkin::get_joints_original); + ClassDB::bind_method(D_METHOD("set_joints_original", "joints_original"), &GLTFSkin::set_joints_original); + ClassDB::bind_method(D_METHOD("get_inverse_binds"), &GLTFSkin::get_inverse_binds); + ClassDB::bind_method(D_METHOD("set_inverse_binds", "inverse_binds"), &GLTFSkin::set_inverse_binds); + ClassDB::bind_method(D_METHOD("get_joints"), &GLTFSkin::get_joints); + ClassDB::bind_method(D_METHOD("set_joints", "joints"), &GLTFSkin::set_joints); + ClassDB::bind_method(D_METHOD("get_non_joints"), &GLTFSkin::get_non_joints); + ClassDB::bind_method(D_METHOD("set_non_joints", "non_joints"), &GLTFSkin::set_non_joints); + ClassDB::bind_method(D_METHOD("get_roots"), &GLTFSkin::get_roots); + ClassDB::bind_method(D_METHOD("set_roots", "roots"), &GLTFSkin::set_roots); + ClassDB::bind_method(D_METHOD("get_skeleton"), &GLTFSkin::get_skeleton); + ClassDB::bind_method(D_METHOD("set_skeleton", "skeleton"), &GLTFSkin::set_skeleton); + ClassDB::bind_method(D_METHOD("get_joint_i_to_bone_i"), &GLTFSkin::get_joint_i_to_bone_i); + ClassDB::bind_method(D_METHOD("set_joint_i_to_bone_i", "joint_i_to_bone_i"), &GLTFSkin::set_joint_i_to_bone_i); + ClassDB::bind_method(D_METHOD("get_joint_i_to_name"), &GLTFSkin::get_joint_i_to_name); + ClassDB::bind_method(D_METHOD("set_joint_i_to_name", "joint_i_to_name"), &GLTFSkin::set_joint_i_to_name); + ClassDB::bind_method(D_METHOD("get_godot_skin"), &GLTFSkin::get_godot_skin); + ClassDB::bind_method(D_METHOD("set_godot_skin", "godot_skin"), &GLTFSkin::set_godot_skin); + + ADD_PROPERTY(PropertyInfo(Variant::INT, "skin_root"), "set_skin_root", "get_skin_root"); // GLTFNodeIndex + ADD_PROPERTY(PropertyInfo(Variant::PACKED_INT32_ARRAY, "joints_original"), "set_joints_original", "get_joints_original"); // Vector + ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "inverse_binds", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_INTERNAL), "set_inverse_binds", "get_inverse_binds"); // Vector + ADD_PROPERTY(PropertyInfo(Variant::PACKED_INT32_ARRAY, "joints"), "set_joints", "get_joints"); // Vector + ADD_PROPERTY(PropertyInfo(Variant::PACKED_INT32_ARRAY, "non_joints"), "set_non_joints", "get_non_joints"); // Vector + ADD_PROPERTY(PropertyInfo(Variant::PACKED_INT32_ARRAY, "roots"), "set_roots", "get_roots"); // Vector + ADD_PROPERTY(PropertyInfo(Variant::INT, "skeleton"), "set_skeleton", "get_skeleton"); // int + ADD_PROPERTY(PropertyInfo(Variant::DICTIONARY, "joint_i_to_bone_i", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_INTERNAL), "set_joint_i_to_bone_i", "get_joint_i_to_bone_i"); // RBMap +} + +GLTFNodeIndex GLTFSkin::get_skin_root() { + return skin_root; +} + +void GLTFSkin::set_skin_root(GLTFNodeIndex p_skin_root) { + skin_root = p_skin_root; +} + +Vector GLTFSkin::get_joints_original() { + return joints_original; +} + +void GLTFSkin::set_joints_original(Vector p_joints_original) { + joints_original = p_joints_original; +} + +Array GLTFSkin::get_inverse_binds() { + return GLTFTemplateConvert::to_array(inverse_binds); +} + +void GLTFSkin::set_inverse_binds(Array p_inverse_binds) { + GLTFTemplateConvert::set_from_array(inverse_binds, p_inverse_binds); +} + +Vector GLTFSkin::get_joints() { + return joints; +} + +void GLTFSkin::set_joints(Vector p_joints) { + joints = p_joints; +} + +Vector GLTFSkin::get_non_joints() { + return non_joints; +} + +void GLTFSkin::set_non_joints(Vector p_non_joints) { + non_joints = p_non_joints; +} + +Vector GLTFSkin::get_roots() { + return roots; +} + +void GLTFSkin::set_roots(Vector p_roots) { + roots = p_roots; +} + +int GLTFSkin::get_skeleton() { + return skeleton; +} + +void GLTFSkin::set_skeleton(int p_skeleton) { + skeleton = p_skeleton; +} + +Dictionary GLTFSkin::get_joint_i_to_bone_i() { + return GLTFTemplateConvert::to_dict(joint_i_to_bone_i); +} + +void GLTFSkin::set_joint_i_to_bone_i(Dictionary p_joint_i_to_bone_i) { + GLTFTemplateConvert::set_from_dict(joint_i_to_bone_i, p_joint_i_to_bone_i); +} + +Dictionary GLTFSkin::get_joint_i_to_name() { + Dictionary ret; + HashMap::Iterator elem = joint_i_to_name.begin(); + while (elem) { + ret[elem->key] = String(elem->value); + ++elem; + } + return ret; +} + +void GLTFSkin::set_joint_i_to_name(Dictionary p_joint_i_to_name) { + joint_i_to_name = HashMap(); + Array keys = p_joint_i_to_name.keys(); + for (int i = 0; i < keys.size(); i++) { + joint_i_to_name[keys[i]] = p_joint_i_to_name[keys[i]]; + } +} + +Ref GLTFSkin::get_godot_skin() { + return godot_skin; +} + +void GLTFSkin::set_godot_skin(Ref p_godot_skin) { + godot_skin = p_godot_skin; +} diff --git a/modules/gltf/structures/gltf_skin.h b/modules/gltf/structures/gltf_skin.h new file mode 100644 index 0000000000..1127c20a3b --- /dev/null +++ b/modules/gltf/structures/gltf_skin.h @@ -0,0 +1,109 @@ +/*************************************************************************/ +/* gltf_skin.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ +/* */ +/* 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_SKIN_H +#define GLTF_SKIN_H + +#include "../gltf_defines.h" +#include "core/io/resource.h" + +class GLTFSkin : public Resource { + GDCLASS(GLTFSkin, Resource); + friend class GLTFDocument; + +private: + // The "skeleton" property defined in the gltf spec. -1 = Scene Root + GLTFNodeIndex skin_root = -1; + + Vector joints_original; + Vector inverse_binds; + + // Note: joints + non_joints should form a complete subtree, or subtrees + // with a common parent + + // All nodes that are skins that are caught in-between the original joints + // (inclusive of joints_original) + Vector joints; + + // All Nodes that are caught in-between skin joint nodes, and are not + // defined as joints by any skin + Vector non_joints; + + // The roots of the skin. In the case of multiple roots, their parent *must* + // be the same (the roots must be siblings) + Vector roots; + + // The GLTF Skeleton this Skin points to (after we determine skeletons) + GLTFSkeletonIndex skeleton = -1; + + // A mapping from the joint indices (in the order of joints_original) to the + // Godot Skeleton's bone_indices + HashMap joint_i_to_bone_i; + HashMap joint_i_to_name; + + // The Actual Skin that will be created as a mapping between the IBM's of + // this skin to the generated skeleton for the mesh instances. + Ref godot_skin; + +protected: + static void _bind_methods(); + +public: + GLTFNodeIndex get_skin_root(); + void set_skin_root(GLTFNodeIndex p_skin_root); + + Vector get_joints_original(); + void set_joints_original(Vector p_joints_original); + + Array get_inverse_binds(); + void set_inverse_binds(Array p_inverse_binds); + + Vector get_joints(); + void set_joints(Vector p_joints); + + Vector get_non_joints(); + void set_non_joints(Vector p_non_joints); + + Vector get_roots(); + void set_roots(Vector p_roots); + + int get_skeleton(); + void set_skeleton(int p_skeleton); + + Dictionary get_joint_i_to_bone_i(); + void set_joint_i_to_bone_i(Dictionary p_joint_i_to_bone_i); + + Dictionary get_joint_i_to_name(); + void set_joint_i_to_name(Dictionary p_joint_i_to_name); + + Ref get_godot_skin(); + void set_godot_skin(Ref p_godot_skin); +}; +#endif // GLTF_SKIN_H diff --git a/modules/gltf/structures/gltf_texture.cpp b/modules/gltf/structures/gltf_texture.cpp new file mode 100644 index 0000000000..2a21cb3df8 --- /dev/null +++ b/modules/gltf/structures/gltf_texture.cpp @@ -0,0 +1,46 @@ +/*************************************************************************/ +/* gltf_texture.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ +/* */ +/* 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 "gltf_texture.h" + +void GLTFTexture::_bind_methods() { + ClassDB::bind_method(D_METHOD("get_src_image"), &GLTFTexture::get_src_image); + ClassDB::bind_method(D_METHOD("set_src_image", "src_image"), &GLTFTexture::set_src_image); + + ADD_PROPERTY(PropertyInfo(Variant::INT, "src_image"), "set_src_image", "get_src_image"); // int +} + +GLTFImageIndex GLTFTexture::get_src_image() const { + return src_image; +} + +void GLTFTexture::set_src_image(GLTFImageIndex val) { + src_image = val; +} diff --git a/modules/gltf/structures/gltf_texture.h b/modules/gltf/structures/gltf_texture.h new file mode 100644 index 0000000000..b1d12dddfa --- /dev/null +++ b/modules/gltf/structures/gltf_texture.h @@ -0,0 +1,51 @@ +/*************************************************************************/ +/* gltf_texture.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ +/* */ +/* 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_TEXTURE_H +#define GLTF_TEXTURE_H + +#include "../gltf_defines.h" +#include "core/io/resource.h" + +class GLTFTexture : public Resource { + GDCLASS(GLTFTexture, Resource); + +private: + GLTFImageIndex src_image = 0; + +protected: + static void _bind_methods(); + +public: + GLTFImageIndex get_src_image() const; + void set_src_image(GLTFImageIndex val); +}; + +#endif // GLTF_TEXTURE_H -- cgit v1.2.3