1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
|
/*************************************************************************/
/* gltf_state.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_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 "gltf_template_convert.h"
#include "gltf_texture.h"
#include "core/templates/rb_map.h"
#include "scene/animation/animation_player.h"
#include "scene/resources/texture.h"
class GLTFState : public Resource {
GDCLASS(GLTFState, Resource);
friend class GLTFDocument;
String filename;
String base_path;
Dictionary json;
int major_version = 0;
int minor_version = 0;
Vector<uint8_t> glb_data;
bool use_named_skin_binds = false;
bool use_khr_texture_transform = false;
bool discard_meshes_and_materials = false;
Vector<Ref<GLTFNode>> nodes;
Vector<Vector<uint8_t>> buffers;
Vector<Ref<GLTFBufferView>> buffer_views;
Vector<Ref<GLTFAccessor>> accessors;
Vector<Ref<GLTFMesh>> meshes; // meshes are loaded directly, no reason not to.
Vector<AnimationPlayer *> animation_players;
HashMap<Ref<BaseMaterial3D>, GLTFMaterialIndex> material_cache;
Vector<Ref<BaseMaterial3D>> materials;
String scene_name;
Vector<int> root_nodes;
Vector<Ref<GLTFTexture>> textures;
Vector<Ref<Texture2D>> images;
Vector<Ref<GLTFSkin>> skins;
Vector<Ref<GLTFCamera>> cameras;
Vector<Ref<GLTFLight>> lights;
HashSet<String> unique_names;
HashSet<String> unique_animation_names;
Vector<Ref<GLTFSkeleton>> skeletons;
HashMap<GLTFSkeletonIndex, GLTFNodeIndex> skeleton_to_node;
Vector<Ref<GLTFAnimation>> animations;
HashMap<GLTFNodeIndex, Node *> scene_nodes;
HashMap<ObjectID, GLTFSkeletonIndex> skeleton3d_to_gltf_skeleton;
HashMap<ObjectID, HashMap<ObjectID, GLTFSkinIndex>> skin_and_skeleton3d_to_gltf_skin;
protected:
static void _bind_methods();
public:
Dictionary get_json();
void set_json(Dictionary p_json);
int get_major_version();
void set_major_version(int p_major_version);
int get_minor_version();
void set_minor_version(int p_minor_version);
Vector<uint8_t> get_glb_data();
void set_glb_data(Vector<uint8_t> p_glb_data);
bool get_use_named_skin_binds();
void set_use_named_skin_binds(bool p_use_named_skin_binds);
bool get_discard_meshes_and_materials();
void set_discard_meshes_and_materials(bool p_discard_meshes_and_materials);
Array get_nodes();
void set_nodes(Array p_nodes);
Array get_buffers();
void set_buffers(Array p_buffers);
Array get_buffer_views();
void set_buffer_views(Array p_buffer_views);
Array get_accessors();
void set_accessors(Array p_accessors);
Array get_meshes();
void set_meshes(Array p_meshes);
Array get_materials();
void set_materials(Array p_materials);
String get_scene_name();
void set_scene_name(String p_scene_name);
String get_base_path();
void set_base_path(String p_base_path);
Array get_root_nodes();
void set_root_nodes(Array p_root_nodes);
Array get_textures();
void set_textures(Array p_textures);
Array get_images();
void set_images(Array p_images);
Array get_skins();
void set_skins(Array p_skins);
Array get_cameras();
void set_cameras(Array p_cameras);
Array get_lights();
void set_lights(Array p_lights);
Array get_unique_names();
void set_unique_names(Array p_unique_names);
Array get_unique_animation_names();
void set_unique_animation_names(Array p_unique_names);
Array get_skeletons();
void set_skeletons(Array p_skeletons);
Dictionary get_skeleton_to_node();
void set_skeleton_to_node(Dictionary p_skeleton_to_node);
Array get_animations();
void set_animations(Array p_animations);
Node *get_scene_node(GLTFNodeIndex idx);
int get_animation_players_count(int idx);
AnimationPlayer *get_animation_player(int idx);
//void set_scene_nodes(RBMap<GLTFNodeIndex, Node *> p_scene_nodes) {
// this->scene_nodes = p_scene_nodes;
//}
//void set_animation_players(Vector<AnimationPlayer *> p_animation_players) {
// this->animation_players = p_animation_players;
//}
//RBMap<Ref<Material>, GLTFMaterialIndex> get_material_cache() {
// return this->material_cache;
//}
//void set_material_cache(RBMap<Ref<Material>, GLTFMaterialIndex> p_material_cache) {
// this->material_cache = p_material_cache;
//}
};
#endif // GLTF_STATE_H
|