|
@@ -43,10 +43,18 @@ class EditorSceneImporterGLTF : public EditorSceneImporter {
|
|
|
|
|
|
GDCLASS(EditorSceneImporterGLTF, EditorSceneImporter);
|
|
|
|
|
|
+ typedef int GLTFAccessorIndex;
|
|
|
+ typedef int GLTFAnimationIndex;
|
|
|
+ typedef int GLTFBufferIndex;
|
|
|
+ typedef int GLTFBufferViewIndex;
|
|
|
+ typedef int GLTFCameraIndex;
|
|
|
+ typedef int GLTFImageIndex;
|
|
|
+ typedef int GLTFMaterialIndex;
|
|
|
+ typedef int GLTFMeshIndex;
|
|
|
typedef int GLTFNodeIndex;
|
|
|
- typedef int GLTFSkinIndex;
|
|
|
typedef int GLTFSkeletonIndex;
|
|
|
- typedef int GLTFMeshIndex;
|
|
|
+ typedef int GLTFSkinIndex;
|
|
|
+ typedef int GLTFTextureIndex;
|
|
|
|
|
|
enum {
|
|
|
ARRAY_BUFFER = 34962,
|
|
@@ -68,8 +76,8 @@ class EditorSceneImporterGLTF : public EditorSceneImporter {
|
|
|
|
|
|
};
|
|
|
|
|
|
- String _get_component_type_name(uint32_t p_component);
|
|
|
- int _get_component_type_size(int component_type);
|
|
|
+ String _get_component_type_name(const uint32_t p_component);
|
|
|
+ int _get_component_type_size(const int component_type);
|
|
|
|
|
|
enum GLTFType {
|
|
|
TYPE_SCALAR,
|
|
@@ -81,7 +89,7 @@ class EditorSceneImporterGLTF : public EditorSceneImporter {
|
|
|
TYPE_MAT4,
|
|
|
};
|
|
|
|
|
|
- String _get_type_name(GLTFType p_component);
|
|
|
+ String _get_type_name(const GLTFType p_component);
|
|
|
|
|
|
struct GLTFNode {
|
|
|
|
|
@@ -92,14 +100,13 @@ class EditorSceneImporterGLTF : public EditorSceneImporter {
|
|
|
Transform xform;
|
|
|
String name;
|
|
|
|
|
|
- int mesh;
|
|
|
- int camera;
|
|
|
- int skin;
|
|
|
+ GLTFMeshIndex mesh;
|
|
|
+ GLTFCameraIndex camera;
|
|
|
+ GLTFSkinIndex skin;
|
|
|
|
|
|
GLTFSkeletonIndex skeleton;
|
|
|
bool joint;
|
|
|
|
|
|
-
|
|
|
Vector3 translation;
|
|
|
Quat rotation;
|
|
|
Vector3 scale;
|
|
@@ -123,7 +130,7 @@ class EditorSceneImporterGLTF : public EditorSceneImporter {
|
|
|
|
|
|
struct GLTFBufferView {
|
|
|
|
|
|
- int buffer;
|
|
|
+ GLTFBufferIndex buffer;
|
|
|
int byte_offset;
|
|
|
int byte_length;
|
|
|
int byte_stride;
|
|
@@ -131,7 +138,7 @@ class EditorSceneImporterGLTF : public EditorSceneImporter {
|
|
|
//matrices need to be transformed to this
|
|
|
|
|
|
GLTFBufferView() :
|
|
|
- buffer(0),
|
|
|
+ buffer(-1),
|
|
|
byte_offset(0),
|
|
|
byte_length(0),
|
|
|
byte_stride(0),
|
|
@@ -141,7 +148,7 @@ class EditorSceneImporterGLTF : public EditorSceneImporter {
|
|
|
|
|
|
struct GLTFAccessor {
|
|
|
|
|
|
- int buffer_view;
|
|
|
+ GLTFBufferViewIndex buffer_view;
|
|
|
int byte_offset;
|
|
|
int component_type;
|
|
|
bool normalized;
|
|
@@ -170,7 +177,7 @@ class EditorSceneImporterGLTF : public EditorSceneImporter {
|
|
|
}
|
|
|
};
|
|
|
struct GLTFTexture {
|
|
|
- int src_image;
|
|
|
+ GLTFImageIndex src_image;
|
|
|
};
|
|
|
|
|
|
struct GLTFSkeleton {
|
|
@@ -321,7 +328,7 @@ class EditorSceneImporterGLTF : public EditorSceneImporter {
|
|
|
|
|
|
String _gen_unique_name(GLTFState &state, const String &p_name);
|
|
|
|
|
|
- Ref<Texture> _get_texture(GLTFState &state, int p_texture);
|
|
|
+ Ref<Texture> _get_texture(GLTFState &state, const GLTFTextureIndex p_texture);
|
|
|
|
|
|
Error _parse_json(const String &p_path, GLTFState &state);
|
|
|
Error _parse_glb(const String &p_path, GLTFState &state);
|
|
@@ -335,17 +342,18 @@ class EditorSceneImporterGLTF : public EditorSceneImporter {
|
|
|
Error _parse_buffer_views(GLTFState &state);
|
|
|
GLTFType _get_type_from_str(const String &p_string);
|
|
|
Error _parse_accessors(GLTFState &state);
|
|
|
- Error _decode_buffer_view(GLTFState &state, int p_buffer_view, double *dst, int skip_every, int skip_bytes, int element_size, int count, GLTFType type, int component_count, int component_type, int component_size, bool normalized, int byte_offset, bool for_vertex);
|
|
|
- Vector<double> _decode_accessor(GLTFState &state, int p_accessor, bool p_for_vertex);
|
|
|
- PoolVector<float> _decode_accessor_as_floats(GLTFState &state, int p_accessor, bool p_for_vertex);
|
|
|
- PoolVector<int> _decode_accessor_as_ints(GLTFState &state, int p_accessor, bool p_for_vertex);
|
|
|
- PoolVector<Vector2> _decode_accessor_as_vec2(GLTFState &state, int p_accessor, bool p_for_vertex);
|
|
|
- PoolVector<Vector3> _decode_accessor_as_vec3(GLTFState &state, int p_accessor, bool p_for_vertex);
|
|
|
- PoolVector<Color> _decode_accessor_as_color(GLTFState &state, int p_accessor, bool p_for_vertex);
|
|
|
- Vector<Quat> _decode_accessor_as_quat(GLTFState &state, int p_accessor, bool p_for_vertex);
|
|
|
- Vector<Transform2D> _decode_accessor_as_xform2d(GLTFState &state, int p_accessor, bool p_for_vertex);
|
|
|
- Vector<Basis> _decode_accessor_as_basis(GLTFState &state, int p_accessor, bool p_for_vertex);
|
|
|
- Vector<Transform> _decode_accessor_as_xform(GLTFState &state, int p_accessor, bool p_for_vertex);
|
|
|
+ Error _decode_buffer_view(GLTFState &state, double *dst, const GLTFBufferViewIndex p_buffer_view, const int skip_every, const int skip_bytes, const int element_size, const int count, const GLTFType type, const int component_count, const int component_type, const int component_size, const bool normalized, const int byte_offset, const bool for_vertex);
|
|
|
+
|
|
|
+ Vector<double> _decode_accessor(GLTFState &state, const GLTFAccessorIndex p_accessor, const bool p_for_vertex);
|
|
|
+ PoolVector<float> _decode_accessor_as_floats(GLTFState &state, const GLTFAccessorIndex p_accessor, const bool p_for_vertex);
|
|
|
+ PoolVector<int> _decode_accessor_as_ints(GLTFState &state, const GLTFAccessorIndex p_accessor, const bool p_for_vertex);
|
|
|
+ PoolVector<Vector2> _decode_accessor_as_vec2(GLTFState &state, const GLTFAccessorIndex p_accessor, const bool p_for_vertex);
|
|
|
+ PoolVector<Vector3> _decode_accessor_as_vec3(GLTFState &state, const GLTFAccessorIndex p_accessor, const bool p_for_vertex);
|
|
|
+ PoolVector<Color> _decode_accessor_as_color(GLTFState &state, const GLTFAccessorIndex p_accessor, const bool p_for_vertex);
|
|
|
+ Vector<Quat> _decode_accessor_as_quat(GLTFState &state, const GLTFAccessorIndex p_accessor, const bool p_for_vertex);
|
|
|
+ Vector<Transform2D> _decode_accessor_as_xform2d(GLTFState &state, const GLTFAccessorIndex p_accessor, const bool p_for_vertex);
|
|
|
+ Vector<Basis> _decode_accessor_as_basis(GLTFState &state, const GLTFAccessorIndex p_accessor, const bool p_for_vertex);
|
|
|
+ Vector<Transform> _decode_accessor_as_xform(GLTFState &state, const GLTFAccessorIndex p_accessor, const bool p_for_vertex);
|
|
|
|
|
|
Error _parse_meshes(GLTFState &state);
|
|
|
Error _parse_images(GLTFState &state, const String &p_base_path);
|
|
@@ -355,7 +363,7 @@ class EditorSceneImporterGLTF : public EditorSceneImporter {
|
|
|
|
|
|
GLTFNodeIndex _find_highest_node(GLTFState &state, const Vector<GLTFNodeIndex> &subtree);
|
|
|
|
|
|
- bool _capture_nodes_in_skin(GLTFState &state, GLTFSkin &skin, GLTFNodeIndex node_index);
|
|
|
+ bool _capture_nodes_in_skin(GLTFState &state, GLTFSkin &skin, const GLTFNodeIndex node_index);
|
|
|
void _capture_nodes_for_multirooted_skin(GLTFState &state, GLTFSkin &skin);
|
|
|
Error _expand_skin(GLTFState &state, GLTFSkin &skin);
|
|
|
Error _verify_skin(GLTFState &state, GLTFSkin &skin);
|
|
@@ -364,7 +372,7 @@ class EditorSceneImporterGLTF : public EditorSceneImporter {
|
|
|
Error _determine_skeletons(GLTFState &state);
|
|
|
Error _reparent_non_joint_skeleton_subtrees(GLTFState &state, GLTFSkeleton &skeleton, const Vector<GLTFNodeIndex> &non_joints);
|
|
|
Error _reparent_to_fake_joint(GLTFState &state, GLTFSkeleton &skeleton, const GLTFNodeIndex node_index);
|
|
|
- Error _determine_skeleton_roots(GLTFState &state, GLTFSkeletonIndex &skel_i);
|
|
|
+ Error _determine_skeleton_roots(GLTFState &state, const GLTFSkeletonIndex skel_i);
|
|
|
|
|
|
Error _create_skeletons(GLTFState &state);
|
|
|
Error _map_skin_joints_indices_to_skeleton_bone_indices(GLTFState &state);
|
|
@@ -384,16 +392,16 @@ class EditorSceneImporterGLTF : public EditorSceneImporter {
|
|
|
Spatial *_generate_spatial(GLTFState &state, Node *scene_parent, const GLTFNodeIndex node_index);
|
|
|
|
|
|
void _generate_scene_node(GLTFState &state, Node *scene_parent, Spatial *scene_root, const GLTFNodeIndex node_index);
|
|
|
- Spatial *_generate_scene(GLTFState &state, int p_bake_fps);
|
|
|
+ Spatial *_generate_scene(GLTFState &state, const int p_bake_fps);
|
|
|
|
|
|
void _process_mesh_instances(GLTFState &state, Spatial *scene_root);
|
|
|
|
|
|
void _assign_scene_names(GLTFState &state);
|
|
|
|
|
|
template <class T>
|
|
|
- T _interpolate_track(const Vector<float> &p_times, const Vector<T> &p_values, float p_time, GLTFAnimation::Interpolation p_interp);
|
|
|
+ T _interpolate_track(const Vector<float> &p_times, const Vector<T> &p_values, const float p_time, const GLTFAnimation::Interpolation p_interp);
|
|
|
|
|
|
- void _import_animation(GLTFState &state, AnimationPlayer *ap, int index, int bake_fps);
|
|
|
+ void _import_animation(GLTFState &state, AnimationPlayer *ap, const GLTFAnimationIndex index, const int bake_fps);
|
|
|
|
|
|
public:
|
|
|
virtual uint32_t get_import_flags() const;
|