Merge pull request #49120 from lyuma/gltf-module-3.x
This commit is contained in:
commit
9b35708a21
52 changed files with 10942 additions and 3796 deletions
|
@ -90,7 +90,6 @@
|
|||
#include "editor/fileserver/editor_file_server.h"
|
||||
#include "editor/filesystem_dock.h"
|
||||
#include "editor/import/editor_import_collada.h"
|
||||
#include "editor/import/editor_scene_importer_gltf.h"
|
||||
#include "editor/import/resource_importer_bitmask.h"
|
||||
#include "editor/import/resource_importer_csv_translation.h"
|
||||
#include "editor/import/resource_importer_image.h"
|
||||
|
@ -5809,10 +5808,6 @@ EditorNode::EditorNode() {
|
|||
import_obj2.instance();
|
||||
import_scene->add_importer(import_obj2);
|
||||
|
||||
Ref<EditorSceneImporterGLTF> import_gltf;
|
||||
import_gltf.instance();
|
||||
import_scene->add_importer(import_gltf);
|
||||
|
||||
Ref<EditorSceneImporterESCN> import_escn;
|
||||
import_escn.instance();
|
||||
import_scene->add_importer(import_escn);
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,447 +0,0 @@
|
|||
/*************************************************************************/
|
||||
/* editor_scene_importer_gltf.h */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2021 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 EDITOR_SCENE_IMPORTER_GLTF_H
|
||||
#define EDITOR_SCENE_IMPORTER_GLTF_H
|
||||
|
||||
#include "editor/import/resource_importer_scene.h"
|
||||
#include "scene/3d/light.h"
|
||||
#include "scene/3d/skeleton.h"
|
||||
#include "scene/3d/spatial.h"
|
||||
|
||||
class AnimationPlayer;
|
||||
class BoneAttachment;
|
||||
class MeshInstance;
|
||||
|
||||
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 GLTFLightIndex;
|
||||
typedef int GLTFNodeIndex;
|
||||
typedef int GLTFSkeletonIndex;
|
||||
typedef int GLTFSkinIndex;
|
||||
typedef int GLTFTextureIndex;
|
||||
|
||||
enum {
|
||||
ARRAY_BUFFER = 34962,
|
||||
ELEMENT_ARRAY_BUFFER = 34963,
|
||||
|
||||
TYPE_BYTE = 5120,
|
||||
TYPE_UNSIGNED_BYTE = 5121,
|
||||
TYPE_SHORT = 5122,
|
||||
TYPE_UNSIGNED_SHORT = 5123,
|
||||
TYPE_UNSIGNED_INT = 5125,
|
||||
TYPE_FLOAT = 5126,
|
||||
|
||||
COMPONENT_TYPE_BYTE = 5120,
|
||||
COMPONENT_TYPE_UNSIGNED_BYTE = 5121,
|
||||
COMPONENT_TYPE_SHORT = 5122,
|
||||
COMPONENT_TYPE_UNSIGNED_SHORT = 5123,
|
||||
COMPONENT_TYPE_INT = 5125,
|
||||
COMPONENT_TYPE_FLOAT = 5126,
|
||||
|
||||
};
|
||||
|
||||
String _get_component_type_name(const uint32_t p_component);
|
||||
int _get_component_type_size(const int component_type);
|
||||
|
||||
enum GLTFType {
|
||||
TYPE_SCALAR,
|
||||
TYPE_VEC2,
|
||||
TYPE_VEC3,
|
||||
TYPE_VEC4,
|
||||
TYPE_MAT2,
|
||||
TYPE_MAT3,
|
||||
TYPE_MAT4,
|
||||
};
|
||||
|
||||
String _get_type_name(const GLTFType p_component);
|
||||
|
||||
struct GLTFNode {
|
||||
//matrices need to be transformed to this
|
||||
GLTFNodeIndex parent;
|
||||
int height;
|
||||
|
||||
Transform xform;
|
||||
String name;
|
||||
|
||||
GLTFMeshIndex mesh;
|
||||
GLTFCameraIndex camera;
|
||||
GLTFSkinIndex skin;
|
||||
|
||||
GLTFSkeletonIndex skeleton;
|
||||
bool joint;
|
||||
|
||||
Vector3 translation;
|
||||
Quat rotation;
|
||||
Vector3 scale;
|
||||
|
||||
Vector<int> children;
|
||||
|
||||
GLTFLightIndex light;
|
||||
|
||||
GLTFNode() :
|
||||
parent(-1),
|
||||
height(-1),
|
||||
mesh(-1),
|
||||
camera(-1),
|
||||
skin(-1),
|
||||
skeleton(-1),
|
||||
joint(false),
|
||||
translation(0, 0, 0),
|
||||
scale(Vector3(1, 1, 1)),
|
||||
light(-1) {}
|
||||
};
|
||||
|
||||
struct GLTFBufferView {
|
||||
GLTFBufferIndex buffer;
|
||||
int byte_offset;
|
||||
int byte_length;
|
||||
int byte_stride;
|
||||
bool indices;
|
||||
//matrices need to be transformed to this
|
||||
|
||||
GLTFBufferView() :
|
||||
buffer(-1),
|
||||
byte_offset(0),
|
||||
byte_length(0),
|
||||
byte_stride(0),
|
||||
indices(false) {
|
||||
}
|
||||
};
|
||||
|
||||
struct GLTFAccessor {
|
||||
GLTFBufferViewIndex buffer_view;
|
||||
int byte_offset;
|
||||
int component_type;
|
||||
bool normalized;
|
||||
int count;
|
||||
GLTFType type;
|
||||
float min;
|
||||
float max;
|
||||
int sparse_count;
|
||||
int sparse_indices_buffer_view;
|
||||
int sparse_indices_byte_offset;
|
||||
int sparse_indices_component_type;
|
||||
int sparse_values_buffer_view;
|
||||
int sparse_values_byte_offset;
|
||||
|
||||
GLTFAccessor() {
|
||||
buffer_view = 0;
|
||||
byte_offset = 0;
|
||||
component_type = 0;
|
||||
normalized = false;
|
||||
count = 0;
|
||||
min = 0;
|
||||
max = 0;
|
||||
sparse_count = 0;
|
||||
sparse_indices_buffer_view = 0;
|
||||
sparse_indices_byte_offset = 0;
|
||||
sparse_indices_component_type = 0;
|
||||
sparse_values_buffer_view = 0;
|
||||
sparse_values_byte_offset = 0;
|
||||
}
|
||||
};
|
||||
struct GLTFTexture {
|
||||
GLTFImageIndex src_image;
|
||||
};
|
||||
|
||||
struct GLTFSkeleton {
|
||||
// The *synthesized* skeletons joints
|
||||
Vector<GLTFNodeIndex> joints;
|
||||
|
||||
// The roots of the skeleton. If there are multiple, each root must have the same parent
|
||||
// (ie roots are siblings)
|
||||
Vector<GLTFNodeIndex> roots;
|
||||
|
||||
// The created Skeleton for the scene
|
||||
Skeleton *godot_skeleton;
|
||||
|
||||
// Set of unique bone names for the skeleton
|
||||
Set<String> unique_names;
|
||||
|
||||
GLTFSkeleton() :
|
||||
godot_skeleton(nullptr) {
|
||||
}
|
||||
};
|
||||
|
||||
struct GLTFSkin {
|
||||
String name;
|
||||
|
||||
// The "skeleton" property defined in the gltf spec. -1 = Scene Root
|
||||
GLTFNodeIndex skin_root;
|
||||
|
||||
Vector<GLTFNodeIndex> joints_original;
|
||||
Vector<Transform> 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<GLTFNodeIndex> joints;
|
||||
|
||||
// All Nodes that are caught in-between skin joint nodes, and are not defined
|
||||
// as joints by any skin
|
||||
Vector<GLTFNodeIndex> 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<GLTFNodeIndex> roots;
|
||||
|
||||
// The GLTF Skeleton this Skin points to (after we determine skeletons)
|
||||
GLTFSkeletonIndex skeleton;
|
||||
|
||||
// A mapping from the joint indices (in the order of joints_original) to the
|
||||
// Godot Skeleton's bone_indices
|
||||
Map<int, int> joint_i_to_bone_i;
|
||||
Map<int, StringName> 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<Skin> godot_skin;
|
||||
|
||||
GLTFSkin() :
|
||||
skin_root(-1),
|
||||
skeleton(-1) {}
|
||||
};
|
||||
|
||||
struct GLTFMesh {
|
||||
Ref<ArrayMesh> mesh;
|
||||
Vector<float> blend_weights;
|
||||
};
|
||||
|
||||
struct GLTFCamera {
|
||||
bool perspective;
|
||||
float fov_size;
|
||||
float zfar;
|
||||
float znear;
|
||||
|
||||
GLTFCamera() {
|
||||
perspective = true;
|
||||
fov_size = 65;
|
||||
zfar = 500;
|
||||
znear = 0.1;
|
||||
}
|
||||
};
|
||||
|
||||
struct GLTFLight {
|
||||
Color color;
|
||||
float intensity;
|
||||
String type;
|
||||
float range;
|
||||
float inner_cone_angle;
|
||||
float outer_cone_angle;
|
||||
GLTFLight() {
|
||||
color = Color(1.0f, 1.0f, 1.0f);
|
||||
intensity = 1.0f;
|
||||
type = "";
|
||||
range = Math_INF;
|
||||
inner_cone_angle = 0.0f;
|
||||
outer_cone_angle = Math_PI / 4.0;
|
||||
}
|
||||
};
|
||||
|
||||
struct GLTFAnimation {
|
||||
bool loop = false;
|
||||
|
||||
enum Interpolation {
|
||||
INTERP_LINEAR,
|
||||
INTERP_STEP,
|
||||
INTERP_CATMULLROMSPLINE,
|
||||
INTERP_CUBIC_SPLINE
|
||||
};
|
||||
|
||||
template <class T>
|
||||
struct Channel {
|
||||
Interpolation interpolation;
|
||||
Vector<float> times;
|
||||
Vector<T> values;
|
||||
};
|
||||
|
||||
struct Track {
|
||||
Channel<Vector3> translation_track;
|
||||
Channel<Quat> rotation_track;
|
||||
Channel<Vector3> scale_track;
|
||||
Vector<Channel<float>> weight_tracks;
|
||||
};
|
||||
|
||||
String name;
|
||||
|
||||
Map<int, Track> tracks;
|
||||
};
|
||||
|
||||
struct GLTFState {
|
||||
Dictionary json;
|
||||
int major_version;
|
||||
int minor_version;
|
||||
Vector<uint8_t> glb_data;
|
||||
|
||||
bool use_named_skin_binds;
|
||||
bool use_legacy_names;
|
||||
|
||||
Vector<GLTFNode *> nodes;
|
||||
Vector<Vector<uint8_t>> buffers;
|
||||
Vector<GLTFBufferView> buffer_views;
|
||||
Vector<GLTFAccessor> accessors;
|
||||
|
||||
Vector<GLTFMesh> meshes; //meshes are loaded directly, no reason not to.
|
||||
Vector<Ref<Material>> materials;
|
||||
|
||||
String scene_name;
|
||||
Vector<int> root_nodes;
|
||||
|
||||
Vector<GLTFTexture> textures;
|
||||
Vector<Ref<Texture>> images;
|
||||
|
||||
Vector<GLTFSkin> skins;
|
||||
Vector<GLTFCamera> cameras;
|
||||
Vector<GLTFLight> lights;
|
||||
|
||||
Set<String> unique_names;
|
||||
Set<String> unique_animation_names;
|
||||
|
||||
Vector<GLTFSkeleton> skeletons;
|
||||
Vector<GLTFAnimation> animations;
|
||||
|
||||
Map<GLTFNodeIndex, Node *> scene_nodes;
|
||||
|
||||
// EditorSceneImporter::ImportFlags
|
||||
uint32_t import_flags;
|
||||
|
||||
~GLTFState() {
|
||||
for (int i = 0; i < nodes.size(); i++) {
|
||||
memdelete(nodes[i]);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
String _sanitize_scene_name(GLTFState &state, const String &p_name);
|
||||
String _legacy_validate_node_name(const String &p_name);
|
||||
String _gen_unique_name(GLTFState &state, const String &p_name);
|
||||
|
||||
String _sanitize_animation_name(const String &p_name);
|
||||
String _gen_unique_animation_name(GLTFState &state, const String &p_name);
|
||||
|
||||
String _sanitize_bone_name(GLTFState &state, const String &p_name);
|
||||
String _gen_unique_bone_name(GLTFState &state, const GLTFSkeletonIndex skel_i, const String &p_name);
|
||||
|
||||
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);
|
||||
|
||||
Error _parse_scenes(GLTFState &state);
|
||||
Error _parse_nodes(GLTFState &state);
|
||||
|
||||
void _compute_node_heights(GLTFState &state);
|
||||
|
||||
Error _parse_buffers(GLTFState &state, const String &p_base_path);
|
||||
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, 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);
|
||||
Error _parse_textures(GLTFState &state);
|
||||
|
||||
Error _parse_materials(GLTFState &state);
|
||||
|
||||
GLTFNodeIndex _find_highest_node(GLTFState &state, const Vector<GLTFNodeIndex> &subset);
|
||||
|
||||
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);
|
||||
Error _parse_skins(GLTFState &state);
|
||||
|
||||
Error _determine_skeletons(GLTFState &state);
|
||||
Error _reparent_non_joint_skeleton_subtrees(GLTFState &state, GLTFSkeleton &skeleton, const Vector<GLTFNodeIndex> &non_joints);
|
||||
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);
|
||||
|
||||
Error _create_skins(GLTFState &state);
|
||||
bool _skins_are_same(const Ref<Skin> &skin_a, const Ref<Skin> &skin_b);
|
||||
void _remove_duplicate_skins(GLTFState &state);
|
||||
|
||||
Error _parse_cameras(GLTFState &state);
|
||||
Error _parse_lights(GLTFState &state);
|
||||
Error _parse_animations(GLTFState &state);
|
||||
|
||||
BoneAttachment *_generate_bone_attachment(GLTFState &state, Skeleton *skeleton, const GLTFNodeIndex node_index, const GLTFNodeIndex bone_index);
|
||||
MeshInstance *_generate_mesh_instance(GLTFState &state, Node *scene_parent, const GLTFNodeIndex node_index);
|
||||
Camera *_generate_camera(GLTFState &state, Node *scene_parent, const GLTFNodeIndex node_index);
|
||||
Spatial *_generate_light(GLTFState &state, Node *scene_parent, const GLTFNodeIndex node_index);
|
||||
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);
|
||||
void _generate_skeleton_bone_node(GLTFState &state, Node *scene_parent, Spatial *scene_root, const GLTFNodeIndex node_index);
|
||||
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, const float p_time, const GLTFAnimation::Interpolation p_interp);
|
||||
|
||||
void _import_animation(GLTFState &state, AnimationPlayer *ap, const GLTFAnimationIndex index, const int bake_fps);
|
||||
|
||||
public:
|
||||
virtual uint32_t get_import_flags() const;
|
||||
virtual void get_extensions(List<String> *r_extensions) const;
|
||||
virtual Node *import_scene(const String &p_path, uint32_t p_flags, int p_bake_fps, List<String> *r_missing_deps = nullptr, Error *r_err = nullptr);
|
||||
virtual Ref<Animation> import_animation(const String &p_path, uint32_t p_flags, int p_bake_fps);
|
||||
|
||||
EditorSceneImporterGLTF();
|
||||
};
|
||||
|
||||
#endif // EDITOR_SCENE_IMPORTER_GLTF_H
|
10
modules/gltf/SCsub
Normal file
10
modules/gltf/SCsub
Normal file
|
@ -0,0 +1,10 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
Import("env")
|
||||
Import("env_modules")
|
||||
|
||||
env_gltf = env_modules.Clone()
|
||||
env_gltf.Prepend(CPPPATH=["."])
|
||||
|
||||
# Godot's own source files
|
||||
env_gltf.add_source_files(env.modules_sources, "*.cpp")
|
30
modules/gltf/config.py
Normal file
30
modules/gltf/config.py
Normal file
|
@ -0,0 +1,30 @@
|
|||
def can_build(env, platform):
|
||||
return env["tools"] and not env["disable_3d"]
|
||||
|
||||
|
||||
def configure(env):
|
||||
pass
|
||||
|
||||
|
||||
def get_doc_classes():
|
||||
return [
|
||||
"EditorSceneImporterGLTF",
|
||||
"GLTFAccessor",
|
||||
"GLTFAnimation",
|
||||
"GLTFBufferView",
|
||||
"GLTFCamera",
|
||||
"GLTFDocument",
|
||||
"GLTFLight",
|
||||
"GLTFMesh",
|
||||
"GLTFNode",
|
||||
"GLTFSkeleton",
|
||||
"GLTFSkin",
|
||||
"GLTFSpecGloss",
|
||||
"GLTFState",
|
||||
"GLTFTexture",
|
||||
"PackedSceneGLTF",
|
||||
]
|
||||
|
||||
|
||||
def get_doc_path():
|
||||
return "doc_classes"
|
13
modules/gltf/doc_classes/EditorSceneImporterGLTF.xml
Normal file
13
modules/gltf/doc_classes/EditorSceneImporterGLTF.xml
Normal file
|
@ -0,0 +1,13 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="EditorSceneImporterGLTF" inherits="EditorSceneImporter" version="3.4">
|
||||
<brief_description>
|
||||
</brief_description>
|
||||
<description>
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
<methods>
|
||||
</methods>
|
||||
<constants>
|
||||
</constants>
|
||||
</class>
|
43
modules/gltf/doc_classes/GLTFAccessor.xml
Normal file
43
modules/gltf/doc_classes/GLTFAccessor.xml
Normal file
|
@ -0,0 +1,43 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="GLTFAccessor" inherits="Resource" version="3.4">
|
||||
<brief_description>
|
||||
</brief_description>
|
||||
<description>
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
<methods>
|
||||
</methods>
|
||||
<members>
|
||||
<member name="buffer_view" type="int" setter="set_buffer_view" getter="get_buffer_view" default="0">
|
||||
</member>
|
||||
<member name="byte_offset" type="int" setter="set_byte_offset" getter="get_byte_offset" default="0">
|
||||
</member>
|
||||
<member name="component_type" type="int" setter="set_component_type" getter="get_component_type" default="0">
|
||||
</member>
|
||||
<member name="count" type="int" setter="set_count" getter="get_count" default="0">
|
||||
</member>
|
||||
<member name="max" type="PoolRealArray" setter="set_max" getter="get_max" default="PoolRealArray( )">
|
||||
</member>
|
||||
<member name="min" type="PoolRealArray" setter="set_min" getter="get_min" default="PoolRealArray( )">
|
||||
</member>
|
||||
<member name="normalized" type="bool" setter="set_normalized" getter="get_normalized" default="false">
|
||||
</member>
|
||||
<member name="sparse_count" type="int" setter="set_sparse_count" getter="get_sparse_count" default="0">
|
||||
</member>
|
||||
<member name="sparse_indices_buffer_view" type="int" setter="set_sparse_indices_buffer_view" getter="get_sparse_indices_buffer_view" default="0">
|
||||
</member>
|
||||
<member name="sparse_indices_byte_offset" type="int" setter="set_sparse_indices_byte_offset" getter="get_sparse_indices_byte_offset" default="0">
|
||||
</member>
|
||||
<member name="sparse_indices_component_type" type="int" setter="set_sparse_indices_component_type" getter="get_sparse_indices_component_type" default="0">
|
||||
</member>
|
||||
<member name="sparse_values_buffer_view" type="int" setter="set_sparse_values_buffer_view" getter="get_sparse_values_buffer_view" default="0">
|
||||
</member>
|
||||
<member name="sparse_values_byte_offset" type="int" setter="set_sparse_values_byte_offset" getter="get_sparse_values_byte_offset" default="0">
|
||||
</member>
|
||||
<member name="type" type="int" setter="set_type" getter="get_type" default="0">
|
||||
</member>
|
||||
</members>
|
||||
<constants>
|
||||
</constants>
|
||||
</class>
|
17
modules/gltf/doc_classes/GLTFAnimation.xml
Normal file
17
modules/gltf/doc_classes/GLTFAnimation.xml
Normal file
|
@ -0,0 +1,17 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="GLTFAnimation" inherits="Resource" version="3.4">
|
||||
<brief_description>
|
||||
</brief_description>
|
||||
<description>
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
<methods>
|
||||
</methods>
|
||||
<members>
|
||||
<member name="loop" type="bool" setter="set_loop" getter="get_loop" default="false">
|
||||
</member>
|
||||
</members>
|
||||
<constants>
|
||||
</constants>
|
||||
</class>
|
25
modules/gltf/doc_classes/GLTFBufferView.xml
Normal file
25
modules/gltf/doc_classes/GLTFBufferView.xml
Normal file
|
@ -0,0 +1,25 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="GLTFBufferView" inherits="Resource" version="3.4">
|
||||
<brief_description>
|
||||
</brief_description>
|
||||
<description>
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
<methods>
|
||||
</methods>
|
||||
<members>
|
||||
<member name="buffer" type="int" setter="set_buffer" getter="get_buffer" default="-1">
|
||||
</member>
|
||||
<member name="byte_length" type="int" setter="set_byte_length" getter="get_byte_length" default="0">
|
||||
</member>
|
||||
<member name="byte_offset" type="int" setter="set_byte_offset" getter="get_byte_offset" default="0">
|
||||
</member>
|
||||
<member name="byte_stride" type="int" setter="set_byte_stride" getter="get_byte_stride" default="-1">
|
||||
</member>
|
||||
<member name="indices" type="bool" setter="set_indices" getter="get_indices" default="false">
|
||||
</member>
|
||||
</members>
|
||||
<constants>
|
||||
</constants>
|
||||
</class>
|
23
modules/gltf/doc_classes/GLTFCamera.xml
Normal file
23
modules/gltf/doc_classes/GLTFCamera.xml
Normal file
|
@ -0,0 +1,23 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="GLTFCamera" inherits="Resource" version="3.4">
|
||||
<brief_description>
|
||||
</brief_description>
|
||||
<description>
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
<methods>
|
||||
</methods>
|
||||
<members>
|
||||
<member name="fov_size" type="float" setter="set_fov_size" getter="get_fov_size" default="75.0">
|
||||
</member>
|
||||
<member name="perspective" type="bool" setter="set_perspective" getter="get_perspective" default="true">
|
||||
</member>
|
||||
<member name="zfar" type="float" setter="set_zfar" getter="get_zfar" default="4000.0">
|
||||
</member>
|
||||
<member name="znear" type="float" setter="set_znear" getter="get_znear" default="0.05">
|
||||
</member>
|
||||
</members>
|
||||
<constants>
|
||||
</constants>
|
||||
</class>
|
13
modules/gltf/doc_classes/GLTFDocument.xml
Normal file
13
modules/gltf/doc_classes/GLTFDocument.xml
Normal file
|
@ -0,0 +1,13 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="GLTFDocument" inherits="Resource" version="3.4">
|
||||
<brief_description>
|
||||
</brief_description>
|
||||
<description>
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
<methods>
|
||||
</methods>
|
||||
<constants>
|
||||
</constants>
|
||||
</class>
|
27
modules/gltf/doc_classes/GLTFLight.xml
Normal file
27
modules/gltf/doc_classes/GLTFLight.xml
Normal file
|
@ -0,0 +1,27 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="GLTFLight" inherits="Resource" version="3.4">
|
||||
<brief_description>
|
||||
</brief_description>
|
||||
<description>
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
<methods>
|
||||
</methods>
|
||||
<members>
|
||||
<member name="color" type="Color" setter="set_color" getter="get_color" default="Color( 0, 0, 0, 1 )">
|
||||
</member>
|
||||
<member name="inner_cone_angle" type="float" setter="set_inner_cone_angle" getter="get_inner_cone_angle" default="0.0">
|
||||
</member>
|
||||
<member name="intensity" type="float" setter="set_intensity" getter="get_intensity" default="0.0">
|
||||
</member>
|
||||
<member name="outer_cone_angle" type="float" setter="set_outer_cone_angle" getter="get_outer_cone_angle" default="0.0">
|
||||
</member>
|
||||
<member name="range" type="float" setter="set_range" getter="get_range" default="0.0">
|
||||
</member>
|
||||
<member name="type" type="String" setter="set_type" getter="get_type" default="""">
|
||||
</member>
|
||||
</members>
|
||||
<constants>
|
||||
</constants>
|
||||
</class>
|
19
modules/gltf/doc_classes/GLTFMesh.xml
Normal file
19
modules/gltf/doc_classes/GLTFMesh.xml
Normal file
|
@ -0,0 +1,19 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="GLTFMesh" inherits="Resource" version="3.4">
|
||||
<brief_description>
|
||||
</brief_description>
|
||||
<description>
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
<methods>
|
||||
</methods>
|
||||
<members>
|
||||
<member name="blend_weights" type="PoolRealArray" setter="set_blend_weights" getter="get_blend_weights" default="PoolRealArray( )">
|
||||
</member>
|
||||
<member name="mesh" type="ArrayMesh" setter="set_mesh" getter="get_mesh">
|
||||
</member>
|
||||
</members>
|
||||
<constants>
|
||||
</constants>
|
||||
</class>
|
41
modules/gltf/doc_classes/GLTFNode.xml
Normal file
41
modules/gltf/doc_classes/GLTFNode.xml
Normal file
|
@ -0,0 +1,41 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="GLTFNode" inherits="Resource" version="3.4">
|
||||
<brief_description>
|
||||
</brief_description>
|
||||
<description>
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
<methods>
|
||||
</methods>
|
||||
<members>
|
||||
<member name="camera" type="int" setter="set_camera" getter="get_camera" default="-1">
|
||||
</member>
|
||||
<member name="children" type="PoolIntArray" setter="set_children" getter="get_children" default="PoolIntArray( )">
|
||||
</member>
|
||||
<member name="height" type="int" setter="set_height" getter="get_height" default="-1">
|
||||
</member>
|
||||
<member name="joint" type="bool" setter="set_joint" getter="get_joint" default="false">
|
||||
</member>
|
||||
<member name="light" type="int" setter="set_light" getter="get_light" default="-1">
|
||||
</member>
|
||||
<member name="mesh" type="int" setter="set_mesh" getter="get_mesh" default="-1">
|
||||
</member>
|
||||
<member name="parent" type="int" setter="set_parent" getter="get_parent" default="-1">
|
||||
</member>
|
||||
<member name="rotation" type="Quat" setter="set_rotation" getter="get_rotation" default="Quat( 0, 0, 0, 1 )">
|
||||
</member>
|
||||
<member name="scale" type="Vector3" setter="set_scale" getter="get_scale" default="Vector3( 1, 1, 1 )">
|
||||
</member>
|
||||
<member name="skeleton" type="int" setter="set_skeleton" getter="get_skeleton" default="-1">
|
||||
</member>
|
||||
<member name="skin" type="int" setter="set_skin" getter="get_skin" default="-1">
|
||||
</member>
|
||||
<member name="translation" type="Vector3" setter="set_translation" getter="get_translation" default="Vector3( 0, 0, 0 )">
|
||||
</member>
|
||||
<member name="xform" type="Transform" setter="set_xform" getter="get_xform" default="Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 )">
|
||||
</member>
|
||||
</members>
|
||||
<constants>
|
||||
</constants>
|
||||
</class>
|
67
modules/gltf/doc_classes/GLTFSkeleton.xml
Normal file
67
modules/gltf/doc_classes/GLTFSkeleton.xml
Normal file
|
@ -0,0 +1,67 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="GLTFSkeleton" inherits="Resource" version="3.4">
|
||||
<brief_description>
|
||||
</brief_description>
|
||||
<description>
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
<methods>
|
||||
<method name="get_bone_attachment">
|
||||
<return type="BoneAttachment">
|
||||
</return>
|
||||
<argument index="0" name="idx" type="int">
|
||||
</argument>
|
||||
<description>
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_bone_attachment_count">
|
||||
<return type="int">
|
||||
</return>
|
||||
<description>
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_godot_bone_node">
|
||||
<return type="Dictionary">
|
||||
</return>
|
||||
<description>
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_godot_skeleton">
|
||||
<return type="Skeleton">
|
||||
</return>
|
||||
<description>
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_unique_names">
|
||||
<return type="Array">
|
||||
</return>
|
||||
<description>
|
||||
</description>
|
||||
</method>
|
||||
<method name="set_godot_bone_node">
|
||||
<return type="void">
|
||||
</return>
|
||||
<argument index="0" name="godot_bone_node" type="Dictionary">
|
||||
</argument>
|
||||
<description>
|
||||
</description>
|
||||
</method>
|
||||
<method name="set_unique_names">
|
||||
<return type="void">
|
||||
</return>
|
||||
<argument index="0" name="unique_names" type="Array">
|
||||
</argument>
|
||||
<description>
|
||||
</description>
|
||||
</method>
|
||||
</methods>
|
||||
<members>
|
||||
<member name="joints" type="PoolIntArray" setter="set_joints" getter="get_joints" default="PoolIntArray( )">
|
||||
</member>
|
||||
<member name="roots" type="PoolIntArray" setter="set_roots" getter="get_roots" default="PoolIntArray( )">
|
||||
</member>
|
||||
</members>
|
||||
<constants>
|
||||
</constants>
|
||||
</class>
|
71
modules/gltf/doc_classes/GLTFSkin.xml
Normal file
71
modules/gltf/doc_classes/GLTFSkin.xml
Normal file
|
@ -0,0 +1,71 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="GLTFSkin" inherits="Resource" version="3.4">
|
||||
<brief_description>
|
||||
</brief_description>
|
||||
<description>
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
<methods>
|
||||
<method name="get_inverse_binds">
|
||||
<return type="Array">
|
||||
</return>
|
||||
<description>
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_joint_i_to_bone_i">
|
||||
<return type="Dictionary">
|
||||
</return>
|
||||
<description>
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_joint_i_to_name">
|
||||
<return type="Dictionary">
|
||||
</return>
|
||||
<description>
|
||||
</description>
|
||||
</method>
|
||||
<method name="set_inverse_binds">
|
||||
<return type="void">
|
||||
</return>
|
||||
<argument index="0" name="inverse_binds" type="Array">
|
||||
</argument>
|
||||
<description>
|
||||
</description>
|
||||
</method>
|
||||
<method name="set_joint_i_to_bone_i">
|
||||
<return type="void">
|
||||
</return>
|
||||
<argument index="0" name="joint_i_to_bone_i" type="Dictionary">
|
||||
</argument>
|
||||
<description>
|
||||
</description>
|
||||
</method>
|
||||
<method name="set_joint_i_to_name">
|
||||
<return type="void">
|
||||
</return>
|
||||
<argument index="0" name="joint_i_to_name" type="Dictionary">
|
||||
</argument>
|
||||
<description>
|
||||
</description>
|
||||
</method>
|
||||
</methods>
|
||||
<members>
|
||||
<member name="godot_skin" type="Skin" setter="set_godot_skin" getter="get_godot_skin">
|
||||
</member>
|
||||
<member name="joints" type="PoolIntArray" setter="set_joints" getter="get_joints" default="PoolIntArray( )">
|
||||
</member>
|
||||
<member name="joints_original" type="PoolIntArray" setter="set_joints_original" getter="get_joints_original" default="PoolIntArray( )">
|
||||
</member>
|
||||
<member name="non_joints" type="PoolIntArray" setter="set_non_joints" getter="get_non_joints" default="PoolIntArray( )">
|
||||
</member>
|
||||
<member name="roots" type="PoolIntArray" setter="set_roots" getter="get_roots" default="PoolIntArray( )">
|
||||
</member>
|
||||
<member name="skeleton" type="int" setter="set_skeleton" getter="get_skeleton" default="-1">
|
||||
</member>
|
||||
<member name="skin_root" type="int" setter="set_skin_root" getter="get_skin_root" default="-1">
|
||||
</member>
|
||||
</members>
|
||||
<constants>
|
||||
</constants>
|
||||
</class>
|
25
modules/gltf/doc_classes/GLTFSpecGloss.xml
Normal file
25
modules/gltf/doc_classes/GLTFSpecGloss.xml
Normal file
|
@ -0,0 +1,25 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="GLTFSpecGloss" inherits="Resource" version="3.4">
|
||||
<brief_description>
|
||||
</brief_description>
|
||||
<description>
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
<methods>
|
||||
</methods>
|
||||
<members>
|
||||
<member name="diffuse_factor" type="Color" setter="set_diffuse_factor" getter="get_diffuse_factor" default="Color( 1, 1, 1, 1 )">
|
||||
</member>
|
||||
<member name="diffuse_img" type="Image" setter="set_diffuse_img" getter="get_diffuse_img">
|
||||
</member>
|
||||
<member name="gloss_factor" type="float" setter="set_gloss_factor" getter="get_gloss_factor" default="1.0">
|
||||
</member>
|
||||
<member name="spec_gloss_img" type="Image" setter="set_spec_gloss_img" getter="get_spec_gloss_img">
|
||||
</member>
|
||||
<member name="specular_factor" type="Color" setter="set_specular_factor" getter="get_specular_factor" default="Color( 1, 1, 1, 1 )">
|
||||
</member>
|
||||
</members>
|
||||
<constants>
|
||||
</constants>
|
||||
</class>
|
265
modules/gltf/doc_classes/GLTFState.xml
Normal file
265
modules/gltf/doc_classes/GLTFState.xml
Normal file
|
@ -0,0 +1,265 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="GLTFState" inherits="Resource" version="3.4">
|
||||
<brief_description>
|
||||
</brief_description>
|
||||
<description>
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
<methods>
|
||||
<method name="get_accessors">
|
||||
<return type="Array">
|
||||
</return>
|
||||
<description>
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_animation_player">
|
||||
<return type="AnimationPlayer">
|
||||
</return>
|
||||
<argument index="0" name="idx" type="int">
|
||||
</argument>
|
||||
<description>
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_animation_players_count">
|
||||
<return type="int">
|
||||
</return>
|
||||
<argument index="0" name="idx" type="int">
|
||||
</argument>
|
||||
<description>
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_animations">
|
||||
<return type="Array">
|
||||
</return>
|
||||
<description>
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_buffer_views">
|
||||
<return type="Array">
|
||||
</return>
|
||||
<description>
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_cameras">
|
||||
<return type="Array">
|
||||
</return>
|
||||
<description>
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_images">
|
||||
<return type="Array">
|
||||
</return>
|
||||
<description>
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_lights">
|
||||
<return type="Array">
|
||||
</return>
|
||||
<description>
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_materials">
|
||||
<return type="Array">
|
||||
</return>
|
||||
<description>
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_meshes">
|
||||
<return type="Array">
|
||||
</return>
|
||||
<description>
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_nodes">
|
||||
<return type="Array">
|
||||
</return>
|
||||
<description>
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_scene_node">
|
||||
<return type="Node">
|
||||
</return>
|
||||
<argument index="0" name="idx" type="int">
|
||||
</argument>
|
||||
<description>
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_skeleton_to_node">
|
||||
<return type="Dictionary">
|
||||
</return>
|
||||
<description>
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_skeletons">
|
||||
<return type="Array">
|
||||
</return>
|
||||
<description>
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_skins">
|
||||
<return type="Array">
|
||||
</return>
|
||||
<description>
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_textures">
|
||||
<return type="Array">
|
||||
</return>
|
||||
<description>
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_unique_animation_names">
|
||||
<return type="Array">
|
||||
</return>
|
||||
<description>
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_unique_names">
|
||||
<return type="Array">
|
||||
</return>
|
||||
<description>
|
||||
</description>
|
||||
</method>
|
||||
<method name="set_accessors">
|
||||
<return type="void">
|
||||
</return>
|
||||
<argument index="0" name="accessors" type="Array">
|
||||
</argument>
|
||||
<description>
|
||||
</description>
|
||||
</method>
|
||||
<method name="set_animations">
|
||||
<return type="void">
|
||||
</return>
|
||||
<argument index="0" name="animations" type="Array">
|
||||
</argument>
|
||||
<description>
|
||||
</description>
|
||||
</method>
|
||||
<method name="set_buffer_views">
|
||||
<return type="void">
|
||||
</return>
|
||||
<argument index="0" name="buffer_views" type="Array">
|
||||
</argument>
|
||||
<description>
|
||||
</description>
|
||||
</method>
|
||||
<method name="set_cameras">
|
||||
<return type="void">
|
||||
</return>
|
||||
<argument index="0" name="cameras" type="Array">
|
||||
</argument>
|
||||
<description>
|
||||
</description>
|
||||
</method>
|
||||
<method name="set_images">
|
||||
<return type="void">
|
||||
</return>
|
||||
<argument index="0" name="images" type="Array">
|
||||
</argument>
|
||||
<description>
|
||||
</description>
|
||||
</method>
|
||||
<method name="set_lights">
|
||||
<return type="void">
|
||||
</return>
|
||||
<argument index="0" name="lights" type="Array">
|
||||
</argument>
|
||||
<description>
|
||||
</description>
|
||||
</method>
|
||||
<method name="set_materials">
|
||||
<return type="void">
|
||||
</return>
|
||||
<argument index="0" name="materials" type="Array">
|
||||
</argument>
|
||||
<description>
|
||||
</description>
|
||||
</method>
|
||||
<method name="set_meshes">
|
||||
<return type="void">
|
||||
</return>
|
||||
<argument index="0" name="meshes" type="Array">
|
||||
</argument>
|
||||
<description>
|
||||
</description>
|
||||
</method>
|
||||
<method name="set_nodes">
|
||||
<return type="void">
|
||||
</return>
|
||||
<argument index="0" name="nodes" type="Array">
|
||||
</argument>
|
||||
<description>
|
||||
</description>
|
||||
</method>
|
||||
<method name="set_skeleton_to_node">
|
||||
<return type="void">
|
||||
</return>
|
||||
<argument index="0" name="skeleton_to_node" type="Dictionary">
|
||||
</argument>
|
||||
<description>
|
||||
</description>
|
||||
</method>
|
||||
<method name="set_skeletons">
|
||||
<return type="void">
|
||||
</return>
|
||||
<argument index="0" name="skeletons" type="Array">
|
||||
</argument>
|
||||
<description>
|
||||
</description>
|
||||
</method>
|
||||
<method name="set_skins">
|
||||
<return type="void">
|
||||
</return>
|
||||
<argument index="0" name="skins" type="Array">
|
||||
</argument>
|
||||
<description>
|
||||
</description>
|
||||
</method>
|
||||
<method name="set_textures">
|
||||
<return type="void">
|
||||
</return>
|
||||
<argument index="0" name="textures" type="Array">
|
||||
</argument>
|
||||
<description>
|
||||
</description>
|
||||
</method>
|
||||
<method name="set_unique_animation_names">
|
||||
<return type="void">
|
||||
</return>
|
||||
<argument index="0" name="unique_animation_names" type="Array">
|
||||
</argument>
|
||||
<description>
|
||||
</description>
|
||||
</method>
|
||||
<method name="set_unique_names">
|
||||
<return type="void">
|
||||
</return>
|
||||
<argument index="0" name="unique_names" type="Array">
|
||||
</argument>
|
||||
<description>
|
||||
</description>
|
||||
</method>
|
||||
</methods>
|
||||
<members>
|
||||
<member name="buffers" type="Array" setter="set_buffers" getter="get_buffers" default="[ ]">
|
||||
</member>
|
||||
<member name="glb_data" type="PoolByteArray" setter="set_glb_data" getter="get_glb_data" default="PoolByteArray( )">
|
||||
</member>
|
||||
<member name="json" type="Dictionary" setter="set_json" getter="get_json" default="{}">
|
||||
</member>
|
||||
<member name="major_version" type="int" setter="set_major_version" getter="get_major_version" default="0">
|
||||
</member>
|
||||
<member name="minor_version" type="int" setter="set_minor_version" getter="get_minor_version" default="0">
|
||||
</member>
|
||||
<member name="root_nodes" type="Array" setter="set_root_nodes" getter="get_root_nodes" default="[ ]">
|
||||
</member>
|
||||
<member name="scene_name" type="String" setter="set_scene_name" getter="get_scene_name" default="""">
|
||||
</member>
|
||||
<member name="use_named_skin_binds" type="bool" setter="set_use_named_skin_binds" getter="get_use_named_skin_binds" default="false">
|
||||
</member>
|
||||
</members>
|
||||
<constants>
|
||||
</constants>
|
||||
</class>
|
17
modules/gltf/doc_classes/GLTFTexture.xml
Normal file
17
modules/gltf/doc_classes/GLTFTexture.xml
Normal file
|
@ -0,0 +1,17 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="GLTFTexture" inherits="Resource" version="3.4">
|
||||
<brief_description>
|
||||
</brief_description>
|
||||
<description>
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
<methods>
|
||||
</methods>
|
||||
<members>
|
||||
<member name="src_image" type="int" setter="set_src_image" getter="get_src_image" default="0">
|
||||
</member>
|
||||
</members>
|
||||
<constants>
|
||||
</constants>
|
||||
</class>
|
58
modules/gltf/doc_classes/PackedSceneGLTF.xml
Normal file
58
modules/gltf/doc_classes/PackedSceneGLTF.xml
Normal file
|
@ -0,0 +1,58 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="PackedSceneGLTF" inherits="PackedScene" version="3.4">
|
||||
<brief_description>
|
||||
</brief_description>
|
||||
<description>
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
<methods>
|
||||
<method name="export_gltf">
|
||||
<return type="int" enum="Error">
|
||||
</return>
|
||||
<argument index="0" name="node" type="Node">
|
||||
</argument>
|
||||
<argument index="1" name="path" type="String">
|
||||
</argument>
|
||||
<argument index="2" name="flags" type="int" default="0">
|
||||
</argument>
|
||||
<argument index="3" name="bake_fps" type="float" default="1000.0">
|
||||
</argument>
|
||||
<description>
|
||||
</description>
|
||||
</method>
|
||||
<method name="import_gltf_scene">
|
||||
<return type="Node">
|
||||
</return>
|
||||
<argument index="0" name="path" type="String">
|
||||
</argument>
|
||||
<argument index="1" name="flags" type="int" default="0">
|
||||
</argument>
|
||||
<argument index="2" name="bake_fps" type="float" default="1000.0">
|
||||
</argument>
|
||||
<argument index="3" name="state" type="GLTFState" default="null">
|
||||
</argument>
|
||||
<description>
|
||||
</description>
|
||||
</method>
|
||||
<method name="pack_gltf">
|
||||
<return type="void">
|
||||
</return>
|
||||
<argument index="0" name="path" type="String">
|
||||
</argument>
|
||||
<argument index="1" name="flags" type="int" default="0">
|
||||
</argument>
|
||||
<argument index="2" name="bake_fps" type="float" default="1000.0">
|
||||
</argument>
|
||||
<argument index="3" name="state" type="GLTFState" default="null">
|
||||
</argument>
|
||||
<description>
|
||||
</description>
|
||||
</method>
|
||||
</methods>
|
||||
<members>
|
||||
<member name="_bundled" type="Dictionary" setter="_set_bundled_scene" getter="_get_bundled_scene" override="true" default="{"conn_count": 0,"conns": PoolIntArray( ),"editable_instances": [ ],"names": PoolStringArray( ),"node_count": 0,"node_paths": [ ],"nodes": PoolIntArray( ),"variants": [ ],"version": 2}" />
|
||||
</members>
|
||||
<constants>
|
||||
</constants>
|
||||
</class>
|
95
modules/gltf/editor_scene_exporter_gltf_plugin.cpp
Normal file
95
modules/gltf/editor_scene_exporter_gltf_plugin.cpp
Normal file
|
@ -0,0 +1,95 @@
|
|||
/*************************************************************************/
|
||||
/* editor_scene_exporter_gltf_plugin.cpp */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2021 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 "editor_scene_exporter_gltf_plugin.h"
|
||||
#include "core/object.h"
|
||||
#include "core/project_settings.h"
|
||||
#include "core/vector.h"
|
||||
#include "editor/editor_file_system.h"
|
||||
#include "scene/3d/mesh_instance.h"
|
||||
#include "scene/gui/check_box.h"
|
||||
#include "scene/main/node.h"
|
||||
|
||||
#include "editor/editor_node.h"
|
||||
|
||||
String SceneExporterGLTFPlugin::get_name() const {
|
||||
return "ConvertGLTF2";
|
||||
}
|
||||
|
||||
bool SceneExporterGLTFPlugin::has_main_screen() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
SceneExporterGLTFPlugin::SceneExporterGLTFPlugin(EditorNode *p_node) {
|
||||
editor = p_node;
|
||||
convert_gltf2.instance();
|
||||
file_export_lib = memnew(EditorFileDialog);
|
||||
editor->get_gui_base()->add_child(file_export_lib);
|
||||
file_export_lib->connect("file_selected", this, "_gltf2_dialog_action");
|
||||
file_export_lib->set_title(TTR("Export Library"));
|
||||
file_export_lib->set_mode(EditorFileDialog::MODE_SAVE_FILE);
|
||||
file_export_lib->set_access(EditorFileDialog::ACCESS_FILESYSTEM);
|
||||
file_export_lib->clear_filters();
|
||||
file_export_lib->add_filter("*.glb");
|
||||
file_export_lib->add_filter("*.gltf");
|
||||
file_export_lib->set_title(TTR("Export Mesh GLTF2"));
|
||||
String gltf_scene_name = TTR("Export GLTF...");
|
||||
add_tool_menu_item(gltf_scene_name, this, "convert_scene_to_gltf2", DEFVAL(Variant()));
|
||||
}
|
||||
|
||||
void SceneExporterGLTFPlugin::_gltf2_dialog_action(String p_file) {
|
||||
Node *root = editor->get_tree()->get_edited_scene_root();
|
||||
if (!root) {
|
||||
editor->show_accept(TTR("This operation can't be done without a scene."), TTR("OK"));
|
||||
return;
|
||||
}
|
||||
List<String> deps;
|
||||
convert_gltf2->save_scene(root, p_file, p_file, 0, 1000.0f, &deps);
|
||||
EditorFileSystem::get_singleton()->scan_changes();
|
||||
}
|
||||
|
||||
void SceneExporterGLTFPlugin::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("convert_scene_to_gltf2"), &SceneExporterGLTFPlugin::convert_scene_to_gltf2);
|
||||
ClassDB::bind_method(D_METHOD("_gltf2_dialog_action", "file"), &SceneExporterGLTFPlugin::_gltf2_dialog_action);
|
||||
}
|
||||
|
||||
void SceneExporterGLTFPlugin::convert_scene_to_gltf2(Variant p_null) {
|
||||
Node *root = editor->get_tree()->get_edited_scene_root();
|
||||
if (!root) {
|
||||
editor->show_accept(TTR("This operation can't be done without a scene."), TTR("OK"));
|
||||
return;
|
||||
}
|
||||
String filename = String(root->get_filename().get_file().get_basename());
|
||||
if (filename.empty()) {
|
||||
filename = root->get_name();
|
||||
}
|
||||
file_export_lib->set_current_file(filename + String(".gltf"));
|
||||
file_export_lib->popup_centered_ratio();
|
||||
}
|
55
modules/gltf/editor_scene_exporter_gltf_plugin.h
Normal file
55
modules/gltf/editor_scene_exporter_gltf_plugin.h
Normal file
|
@ -0,0 +1,55 @@
|
|||
/*************************************************************************/
|
||||
/* editor_scene_exporter_gltf_plugin.h */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2021 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 EDITOR_SCENE_EXPORTER_GLTF_PLUGIN_H
|
||||
#define EDITOR_SCENE_EXPORTER_GLTF_PLUGIN_H
|
||||
|
||||
#include "editor/editor_plugin.h"
|
||||
#include "editor_scene_importer_gltf.h"
|
||||
|
||||
class SceneExporterGLTFPlugin : public EditorPlugin {
|
||||
GDCLASS(SceneExporterGLTFPlugin, EditorPlugin);
|
||||
|
||||
Ref<PackedSceneGLTF> convert_gltf2;
|
||||
EditorNode *editor = nullptr;
|
||||
EditorFileDialog *file_export_lib = nullptr;
|
||||
void _gltf2_dialog_action(String p_file);
|
||||
void convert_scene_to_gltf2(Variant p_null);
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
public:
|
||||
virtual String get_name() const;
|
||||
bool has_main_screen() const;
|
||||
SceneExporterGLTFPlugin(class EditorNode *p_node);
|
||||
};
|
||||
|
||||
#endif // EDITOR_SCENE_EXPORTER_GLTF_PLUGIN_H
|
187
modules/gltf/editor_scene_importer_gltf.cpp
Normal file
187
modules/gltf/editor_scene_importer_gltf.cpp
Normal file
|
@ -0,0 +1,187 @@
|
|||
/*************************************************************************/
|
||||
/* editor_scene_importer_gltf.cpp */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2021 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 "core/crypto/crypto_core.h"
|
||||
#include "core/io/json.h"
|
||||
#include "core/math/disjoint_set.h"
|
||||
#include "core/math/math_defs.h"
|
||||
#include "core/os/file_access.h"
|
||||
#include "core/os/os.h"
|
||||
#include "editor/import/resource_importer_scene.h"
|
||||
#include "modules/gltf/gltf_state.h"
|
||||
#include "modules/regex/regex.h"
|
||||
#include "scene/3d/bone_attachment.h"
|
||||
#include "scene/3d/camera.h"
|
||||
#include "scene/3d/mesh_instance.h"
|
||||
#include "scene/animation/animation_player.h"
|
||||
#include "scene/resources/packed_scene.h"
|
||||
#include "scene/resources/surface_tool.h"
|
||||
|
||||
#include "modules/gltf/editor_scene_importer_gltf.h"
|
||||
|
||||
uint32_t EditorSceneImporterGLTF::get_import_flags() const {
|
||||
return ImportFlags::IMPORT_SCENE | ImportFlags::IMPORT_ANIMATION;
|
||||
}
|
||||
|
||||
void EditorSceneImporterGLTF::get_extensions(List<String> *r_extensions) const {
|
||||
r_extensions->push_back("gltf");
|
||||
r_extensions->push_back("glb");
|
||||
}
|
||||
|
||||
Node *EditorSceneImporterGLTF::import_scene(const String &p_path,
|
||||
uint32_t p_flags, int p_bake_fps,
|
||||
List<String> *r_missing_deps,
|
||||
Error *r_err) {
|
||||
Ref<PackedSceneGLTF> importer;
|
||||
importer.instance();
|
||||
return importer->import_scene(p_path, p_flags, p_bake_fps, r_missing_deps, r_err, Ref<GLTFState>());
|
||||
}
|
||||
|
||||
Ref<Animation> EditorSceneImporterGLTF::import_animation(const String &p_path,
|
||||
uint32_t p_flags,
|
||||
int p_bake_fps) {
|
||||
return Ref<Animation>();
|
||||
}
|
||||
|
||||
void PackedSceneGLTF::_bind_methods() {
|
||||
ClassDB::bind_method(
|
||||
D_METHOD("export_gltf", "node", "path", "flags", "bake_fps"),
|
||||
&PackedSceneGLTF::export_gltf, DEFVAL(0), DEFVAL(1000.0f));
|
||||
ClassDB::bind_method(D_METHOD("pack_gltf", "path", "flags", "bake_fps", "state"),
|
||||
&PackedSceneGLTF::pack_gltf, DEFVAL(0), DEFVAL(1000.0f), DEFVAL(Ref<GLTFState>()));
|
||||
ClassDB::bind_method(D_METHOD("import_gltf_scene", "path", "flags", "bake_fps", "state"),
|
||||
&PackedSceneGLTF::import_gltf_scene, DEFVAL(0), DEFVAL(1000.0f), DEFVAL(Ref<GLTFState>()));
|
||||
}
|
||||
Node *PackedSceneGLTF::import_gltf_scene(const String &p_path, uint32_t p_flags, float p_bake_fps, Ref<GLTFState> r_state) {
|
||||
Error err = FAILED;
|
||||
List<String> deps;
|
||||
return import_scene(p_path, p_flags, p_bake_fps, &deps, &err, r_state);
|
||||
}
|
||||
|
||||
Node *PackedSceneGLTF::import_scene(const String &p_path, uint32_t p_flags,
|
||||
int p_bake_fps,
|
||||
List<String> *r_missing_deps,
|
||||
Error *r_err,
|
||||
Ref<GLTFState> r_state) {
|
||||
if (r_state == Ref<GLTFState>()) {
|
||||
r_state.instance();
|
||||
}
|
||||
r_state->use_named_skin_binds =
|
||||
p_flags & EditorSceneImporter::IMPORT_USE_NAMED_SKIN_BINDS;
|
||||
r_state->use_legacy_names =
|
||||
p_flags & EditorSceneImporter::IMPORT_USE_LEGACY_NAMES;
|
||||
|
||||
Ref<GLTFDocument> gltf_document;
|
||||
gltf_document.instance();
|
||||
Error err = gltf_document->parse(r_state, p_path);
|
||||
*r_err = err;
|
||||
ERR_FAIL_COND_V(err != Error::OK, nullptr);
|
||||
|
||||
Spatial *root = memnew(Spatial);
|
||||
if (r_state->use_legacy_names) {
|
||||
root->set_name(gltf_document->_legacy_validate_node_name(r_state->scene_name));
|
||||
} else {
|
||||
root->set_name(r_state->scene_name);
|
||||
}
|
||||
for (int32_t root_i = 0; root_i < r_state->root_nodes.size(); root_i++) {
|
||||
gltf_document->_generate_scene_node(r_state, root, root, r_state->root_nodes[root_i]);
|
||||
}
|
||||
gltf_document->_process_mesh_instances(r_state, root);
|
||||
if (r_state->animations.size()) {
|
||||
AnimationPlayer *ap = memnew(AnimationPlayer);
|
||||
root->add_child(ap);
|
||||
ap->set_owner(root);
|
||||
for (int i = 0; i < r_state->animations.size(); i++) {
|
||||
gltf_document->_import_animation(r_state, ap, i, p_bake_fps);
|
||||
}
|
||||
}
|
||||
|
||||
return cast_to<Spatial>(root);
|
||||
}
|
||||
|
||||
void PackedSceneGLTF::pack_gltf(String p_path, int32_t p_flags,
|
||||
real_t p_bake_fps, Ref<GLTFState> r_state) {
|
||||
Error err = FAILED;
|
||||
List<String> deps;
|
||||
Node *root = import_scene(p_path, p_flags, p_bake_fps, &deps, &err, r_state);
|
||||
ERR_FAIL_COND(err != OK);
|
||||
pack(root);
|
||||
}
|
||||
|
||||
void PackedSceneGLTF::save_scene(Node *p_node, const String &p_path,
|
||||
const String &p_src_path, uint32_t p_flags,
|
||||
int p_bake_fps, List<String> *r_missing_deps,
|
||||
Error *r_err) {
|
||||
Error err = FAILED;
|
||||
if (r_err) {
|
||||
*r_err = err;
|
||||
}
|
||||
Ref<GLTFDocument> gltf_document;
|
||||
gltf_document.instance();
|
||||
Ref<GLTFState> state;
|
||||
state.instance();
|
||||
err = gltf_document->serialize(state, p_node, p_path);
|
||||
if (r_err) {
|
||||
*r_err = err;
|
||||
}
|
||||
}
|
||||
|
||||
void PackedSceneGLTF::_build_parent_hierachy(Ref<GLTFState> state) {
|
||||
// build the hierarchy
|
||||
for (GLTFNodeIndex node_i = 0; node_i < state->nodes.size(); node_i++) {
|
||||
for (int j = 0; j < state->nodes[node_i]->children.size(); j++) {
|
||||
GLTFNodeIndex child_i = state->nodes[node_i]->children[j];
|
||||
ERR_FAIL_INDEX(child_i, state->nodes.size());
|
||||
if (state->nodes.write[child_i]->parent != -1) {
|
||||
continue;
|
||||
}
|
||||
state->nodes.write[child_i]->parent = node_i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Error PackedSceneGLTF::export_gltf(Node *p_root, String p_path,
|
||||
int32_t p_flags,
|
||||
real_t p_bake_fps) {
|
||||
ERR_FAIL_COND_V(!p_root, FAILED);
|
||||
List<String> deps;
|
||||
Error err;
|
||||
String path = p_path;
|
||||
int32_t flags = p_flags;
|
||||
real_t baked_fps = p_bake_fps;
|
||||
Ref<PackedSceneGLTF> exporter;
|
||||
exporter.instance();
|
||||
exporter->save_scene(p_root, path, "", flags, baked_fps, &deps, &err);
|
||||
int32_t error_code = err;
|
||||
if (error_code != 0) {
|
||||
return Error(error_code);
|
||||
}
|
||||
return OK;
|
||||
}
|
96
modules/gltf/editor_scene_importer_gltf.h
Normal file
96
modules/gltf/editor_scene_importer_gltf.h
Normal file
|
@ -0,0 +1,96 @@
|
|||
/*************************************************************************/
|
||||
/* editor_scene_importer_gltf.h */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2021 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 EDITOR_SCENE_IMPORTER_GLTF_H
|
||||
#define EDITOR_SCENE_IMPORTER_GLTF_H
|
||||
|
||||
#include "core/io/json.h"
|
||||
#include "core/object.h"
|
||||
#include "core/project_settings.h"
|
||||
#include "core/vector.h"
|
||||
#include "editor/import/resource_importer_scene.h"
|
||||
#include "modules/csg/csg_shape.h"
|
||||
#include "modules/gridmap/grid_map.h"
|
||||
#include "scene/3d/mesh_instance.h"
|
||||
#include "scene/3d/multimesh_instance.h"
|
||||
#include "scene/3d/skeleton.h"
|
||||
#include "scene/3d/spatial.h"
|
||||
#include "scene/animation/animation_player.h"
|
||||
#include "scene/gui/check_box.h"
|
||||
#include "scene/main/node.h"
|
||||
#include "scene/resources/packed_scene.h"
|
||||
#include "scene/resources/surface_tool.h"
|
||||
|
||||
#include "gltf_document.h"
|
||||
#include "gltf_state.h"
|
||||
|
||||
class AnimationPlayer;
|
||||
class BoneAttachment;
|
||||
class EditorSceneImporterMeshNode3D;
|
||||
|
||||
#ifdef TOOLS_ENABLED
|
||||
class EditorSceneImporterGLTF : public EditorSceneImporter {
|
||||
GDCLASS(EditorSceneImporterGLTF, EditorSceneImporter);
|
||||
|
||||
public:
|
||||
virtual uint32_t get_import_flags() const;
|
||||
virtual void get_extensions(List<String> *r_extensions) const;
|
||||
virtual Node *import_scene(const String &p_path, uint32_t p_flags,
|
||||
int p_bake_fps,
|
||||
List<String> *r_missing_deps = NULL,
|
||||
Error *r_err = NULL);
|
||||
virtual Ref<Animation> import_animation(const String &p_path,
|
||||
uint32_t p_flags, int p_bake_fps);
|
||||
};
|
||||
#endif
|
||||
|
||||
class PackedSceneGLTF : public PackedScene {
|
||||
GDCLASS(PackedSceneGLTF, PackedScene);
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
public:
|
||||
virtual void save_scene(Node *p_node, const String &p_path, const String &p_src_path,
|
||||
uint32_t p_flags, int p_bake_fps,
|
||||
List<String> *r_missing_deps, Error *r_err = NULL);
|
||||
virtual void _build_parent_hierachy(Ref<GLTFState> state);
|
||||
virtual Error export_gltf(Node *p_root, String p_path, int32_t p_flags = 0,
|
||||
real_t p_bake_fps = 1000.0f);
|
||||
virtual Node *import_scene(const String &p_path, uint32_t p_flags,
|
||||
int p_bake_fps,
|
||||
List<String> *r_missing_deps,
|
||||
Error *r_err,
|
||||
Ref<GLTFState> r_state);
|
||||
virtual Node *import_gltf_scene(const String &p_path, uint32_t p_flags, float p_bake_fps, Ref<GLTFState> r_state = Ref<GLTFState>());
|
||||
virtual void pack_gltf(String p_path, int32_t p_flags = 0,
|
||||
real_t p_bake_fps = 1000.0f, Ref<GLTFState> r_state = Ref<GLTFState>());
|
||||
};
|
||||
#endif // EDITOR_SCENE_IMPORTER_GLTF_H
|
189
modules/gltf/gltf_accessor.cpp
Normal file
189
modules/gltf/gltf_accessor.cpp
Normal file
|
@ -0,0 +1,189 @@
|
|||
/*************************************************************************/
|
||||
/* gltf_accessor.cpp */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2021 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"); // GLTFDocument::GLTFType
|
||||
ADD_PROPERTY(PropertyInfo(Variant::POOL_REAL_ARRAY, "min"), "set_min", "get_min"); // Vector<real_t>
|
||||
ADD_PROPERTY(PropertyInfo(Variant::POOL_REAL_ARRAY, "max"), "set_max", "get_max"); // Vector<real_t>
|
||||
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 = (GLTFDocument::GLTFType)p_type; // TODO: Register enum
|
||||
}
|
||||
|
||||
PoolVector<float> GLTFAccessor::get_min() {
|
||||
return min;
|
||||
}
|
||||
|
||||
void GLTFAccessor::set_min(PoolVector<float> p_min) {
|
||||
min = p_min;
|
||||
}
|
||||
|
||||
PoolVector<float> GLTFAccessor::get_max() {
|
||||
return max;
|
||||
}
|
||||
|
||||
void GLTFAccessor::set_max(PoolVector<float> 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;
|
||||
}
|
104
modules/gltf/gltf_accessor.h
Normal file
104
modules/gltf/gltf_accessor.h
Normal file
|
@ -0,0 +1,104 @@
|
|||
/*************************************************************************/
|
||||
/* gltf_accessor.h */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2021 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/resource.h"
|
||||
#include "gltf_document.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;
|
||||
GLTFDocument::GLTFType
|
||||
type = GLTFDocument::TYPE_SCALAR;
|
||||
PoolVector<float> min;
|
||||
PoolVector<float> 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);
|
||||
|
||||
PoolVector<float> get_min();
|
||||
void set_min(PoolVector<float> p_min);
|
||||
|
||||
PoolVector<float> get_max();
|
||||
void set_max(PoolVector<float> 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
|
53
modules/gltf/gltf_animation.cpp
Normal file
53
modules/gltf/gltf_animation.cpp
Normal file
|
@ -0,0 +1,53 @@
|
|||
/*************************************************************************/
|
||||
/* gltf_animation.cpp */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2021 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;
|
||||
}
|
||||
|
||||
Map<int, GLTFAnimation::Track> &GLTFAnimation::get_tracks() {
|
||||
return tracks;
|
||||
}
|
||||
|
||||
GLTFAnimation::GLTFAnimation() {
|
||||
}
|
74
modules/gltf/gltf_animation.h
Normal file
74
modules/gltf/gltf_animation.h
Normal file
|
@ -0,0 +1,74 @@
|
|||
/*************************************************************************/
|
||||
/* gltf_animation.h */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2021 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/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 <class T>
|
||||
struct Channel {
|
||||
Interpolation interpolation;
|
||||
Vector<float> times;
|
||||
Vector<T> values;
|
||||
};
|
||||
|
||||
struct Track {
|
||||
Channel<Vector3> translation_track;
|
||||
Channel<Quat> rotation_track;
|
||||
Channel<Vector3> scale_track;
|
||||
Vector<Channel<float>> weight_tracks;
|
||||
};
|
||||
|
||||
public:
|
||||
bool get_loop() const;
|
||||
void set_loop(bool p_val);
|
||||
Map<int, GLTFAnimation::Track> &get_tracks();
|
||||
GLTFAnimation();
|
||||
|
||||
private:
|
||||
bool loop = false;
|
||||
Map<int, Track> tracks;
|
||||
};
|
||||
#endif // GLTF_ANIMATION_H
|
90
modules/gltf/gltf_buffer_view.cpp
Normal file
90
modules/gltf/gltf_buffer_view.cpp
Normal file
|
@ -0,0 +1,90 @@
|
|||
/*************************************************************************/
|
||||
/* gltf_buffer_view.cpp */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2021 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"
|
||||
|
||||
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;
|
||||
}
|
68
modules/gltf/gltf_buffer_view.h
Normal file
68
modules/gltf/gltf_buffer_view.h
Normal file
|
@ -0,0 +1,68 @@
|
|||
/*************************************************************************/
|
||||
/* gltf_buffer_view.h */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2021 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/resource.h"
|
||||
#include "gltf_document.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
|
47
modules/gltf/gltf_camera.cpp
Normal file
47
modules/gltf/gltf_camera.cpp
Normal file
|
@ -0,0 +1,47 @@
|
|||
/*************************************************************************/
|
||||
/* gltf_camera.cpp */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2021 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_zfar"), &GLTFCamera::get_zfar);
|
||||
ClassDB::bind_method(D_METHOD("set_zfar", "zfar"), &GLTFCamera::set_zfar);
|
||||
ClassDB::bind_method(D_METHOD("get_znear"), &GLTFCamera::get_znear);
|
||||
ClassDB::bind_method(D_METHOD("set_znear", "znear"), &GLTFCamera::set_znear);
|
||||
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "perspective"), "set_perspective", "get_perspective"); // bool
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "fov_size"), "set_fov_size", "get_fov_size"); // float
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "zfar"), "set_zfar", "get_zfar"); // float
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "znear"), "set_znear", "get_znear"); // float
|
||||
}
|
58
modules/gltf/gltf_camera.h
Normal file
58
modules/gltf/gltf_camera.h
Normal file
|
@ -0,0 +1,58 @@
|
|||
/*************************************************************************/
|
||||
/* gltf_camera.h */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2021 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/resource.h"
|
||||
|
||||
class GLTFCamera : public Resource {
|
||||
GDCLASS(GLTFCamera, Resource);
|
||||
|
||||
private:
|
||||
bool perspective = true;
|
||||
float fov_size = 75.0;
|
||||
float zfar = 4000.0;
|
||||
float znear = 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_zfar() const { return zfar; }
|
||||
void set_zfar(float p_val) { zfar = p_val; }
|
||||
float get_znear() const { return znear; }
|
||||
void set_znear(float p_val) { znear = p_val; }
|
||||
};
|
||||
#endif // GLTF_CAMERA_H
|
6735
modules/gltf/gltf_document.cpp
Normal file
6735
modules/gltf/gltf_document.cpp
Normal file
File diff suppressed because it is too large
Load diff
437
modules/gltf/gltf_document.h
Normal file
437
modules/gltf/gltf_document.h
Normal file
|
@ -0,0 +1,437 @@
|
|||
/*************************************************************************/
|
||||
/* gltf_document.h */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2021 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_DOCUMENT_H
|
||||
#define GLTF_DOCUMENT_H
|
||||
|
||||
#include "editor/import/resource_importer_scene.h"
|
||||
#include "gltf_animation.h"
|
||||
#include "scene/2d/node_2d.h"
|
||||
#include "scene/3d/bone_attachment.h"
|
||||
#include "scene/3d/light.h"
|
||||
#include "scene/3d/mesh_instance.h"
|
||||
#include "scene/3d/skeleton.h"
|
||||
#include "scene/3d/spatial.h"
|
||||
#include "scene/animation/animation_player.h"
|
||||
#include "scene/resources/material.h"
|
||||
#include "scene/resources/texture.h"
|
||||
|
||||
class GLTFState;
|
||||
class GLTFSkin;
|
||||
class GLTFNode;
|
||||
class GLTFSpecGloss;
|
||||
class GLTFSkeleton;
|
||||
|
||||
using GLTFAccessorIndex = int;
|
||||
using GLTFAnimationIndex = int;
|
||||
using GLTFBufferIndex = int;
|
||||
using GLTFBufferViewIndex = int;
|
||||
using GLTFCameraIndex = int;
|
||||
using GLTFImageIndex = int;
|
||||
using GLTFMaterialIndex = int;
|
||||
using GLTFMeshIndex = int;
|
||||
using GLTFLightIndex = int;
|
||||
using GLTFNodeIndex = int;
|
||||
using GLTFSkeletonIndex = int;
|
||||
using GLTFSkinIndex = int;
|
||||
using GLTFTextureIndex = int;
|
||||
|
||||
class GLTFDocument : public Resource {
|
||||
GDCLASS(GLTFDocument, Resource);
|
||||
friend class GLTFState;
|
||||
friend class GLTFSkin;
|
||||
friend class GLTFSkeleton;
|
||||
|
||||
public:
|
||||
const int32_t JOINT_GROUP_SIZE = 4;
|
||||
enum GLTFType {
|
||||
TYPE_SCALAR,
|
||||
TYPE_VEC2,
|
||||
TYPE_VEC3,
|
||||
TYPE_VEC4,
|
||||
TYPE_MAT2,
|
||||
TYPE_MAT3,
|
||||
TYPE_MAT4,
|
||||
};
|
||||
|
||||
enum {
|
||||
ARRAY_BUFFER = 34962,
|
||||
ELEMENT_ARRAY_BUFFER = 34963,
|
||||
|
||||
TYPE_BYTE = 5120,
|
||||
TYPE_UNSIGNED_BYTE = 5121,
|
||||
TYPE_SHORT = 5122,
|
||||
TYPE_UNSIGNED_SHORT = 5123,
|
||||
TYPE_UNSIGNED_INT = 5125,
|
||||
TYPE_FLOAT = 5126,
|
||||
|
||||
COMPONENT_TYPE_BYTE = 5120,
|
||||
COMPONENT_TYPE_UNSIGNED_BYTE = 5121,
|
||||
COMPONENT_TYPE_SHORT = 5122,
|
||||
COMPONENT_TYPE_UNSIGNED_SHORT = 5123,
|
||||
COMPONENT_TYPE_INT = 5125,
|
||||
COMPONENT_TYPE_FLOAT = 5126,
|
||||
};
|
||||
|
||||
private:
|
||||
template <class T>
|
||||
static Array to_array(const Vector<T> &p_inp) {
|
||||
Array ret;
|
||||
for (int i = 0; i < p_inp.size(); i++) {
|
||||
ret.push_back(p_inp[i]);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
static Array to_array(const Set<T> &p_inp) {
|
||||
Array ret;
|
||||
typename Set<T>::Element *elem = p_inp.front();
|
||||
while (elem) {
|
||||
ret.push_back(elem->get());
|
||||
elem = elem->next();
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
static void set_from_array(Vector<T> &r_out, const Array &p_inp) {
|
||||
r_out.clear();
|
||||
for (int i = 0; i < p_inp.size(); i++) {
|
||||
r_out.push_back(p_inp[i]);
|
||||
}
|
||||
}
|
||||
|
||||
template <class T>
|
||||
static void set_from_array(Set<T> &r_out, const Array &p_inp) {
|
||||
r_out.clear();
|
||||
for (int i = 0; i < p_inp.size(); i++) {
|
||||
r_out.insert(p_inp[i]);
|
||||
}
|
||||
}
|
||||
template <class K, class V>
|
||||
static Dictionary to_dict(const Map<K, V> &p_inp) {
|
||||
Dictionary ret;
|
||||
for (typename Map<K, V>::Element *E = p_inp.front(); E; E = E->next()) {
|
||||
ret[E->key()] = E->value();
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
template <class K, class V>
|
||||
static void set_from_dict(Map<K, V> &r_out, const Dictionary &p_inp) {
|
||||
r_out.clear();
|
||||
Array keys = p_inp.keys();
|
||||
for (int i = 0; i < keys.size(); i++) {
|
||||
r_out[keys[i]] = p_inp[keys[i]];
|
||||
}
|
||||
}
|
||||
double _filter_number(double p_float);
|
||||
String _get_component_type_name(const uint32_t p_component);
|
||||
int _get_component_type_size(const int component_type);
|
||||
Error _parse_scenes(Ref<GLTFState> state);
|
||||
Error _parse_nodes(Ref<GLTFState> state);
|
||||
String _get_type_name(const GLTFType p_component);
|
||||
String _get_accessor_type_name(const GLTFDocument::GLTFType p_type);
|
||||
String _gen_unique_name(Ref<GLTFState> state, const String &p_name);
|
||||
String _sanitize_animation_name(const String &name);
|
||||
String _gen_unique_animation_name(Ref<GLTFState> state, const String &p_name);
|
||||
String _sanitize_bone_name(Ref<GLTFState> state, const String &name);
|
||||
String _gen_unique_bone_name(Ref<GLTFState> state,
|
||||
const GLTFSkeletonIndex skel_i,
|
||||
const String &p_name);
|
||||
GLTFTextureIndex _set_texture(Ref<GLTFState> state, Ref<Texture> p_texture);
|
||||
Ref<Texture> _get_texture(Ref<GLTFState> state,
|
||||
const GLTFTextureIndex p_texture);
|
||||
Error _parse_json(const String &p_path, Ref<GLTFState> state);
|
||||
Error _parse_glb(const String &p_path, Ref<GLTFState> state);
|
||||
void _compute_node_heights(Ref<GLTFState> state);
|
||||
Error _parse_buffers(Ref<GLTFState> state, const String &p_base_path);
|
||||
Error _parse_buffer_views(Ref<GLTFState> state);
|
||||
GLTFType _get_type_from_str(const String &p_string);
|
||||
Error _parse_accessors(Ref<GLTFState> state);
|
||||
Error _decode_buffer_view(Ref<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(Ref<GLTFState> state,
|
||||
const GLTFAccessorIndex p_accessor,
|
||||
const bool p_for_vertex);
|
||||
Vector<float> _decode_accessor_as_floats(Ref<GLTFState> state,
|
||||
const GLTFAccessorIndex p_accessor,
|
||||
const bool p_for_vertex);
|
||||
Vector<int> _decode_accessor_as_ints(Ref<GLTFState> state,
|
||||
const GLTFAccessorIndex p_accessor,
|
||||
const bool p_for_vertex);
|
||||
Vector<Vector2> _decode_accessor_as_vec2(Ref<GLTFState> state,
|
||||
const GLTFAccessorIndex p_accessor,
|
||||
const bool p_for_vertex);
|
||||
Vector<Vector3> _decode_accessor_as_vec3(Ref<GLTFState> state,
|
||||
const GLTFAccessorIndex p_accessor,
|
||||
const bool p_for_vertex);
|
||||
Vector<Color> _decode_accessor_as_color(Ref<GLTFState> state,
|
||||
const GLTFAccessorIndex p_accessor,
|
||||
const bool p_for_vertex);
|
||||
Vector<Quat> _decode_accessor_as_quat(Ref<GLTFState> state,
|
||||
const GLTFAccessorIndex p_accessor,
|
||||
const bool p_for_vertex);
|
||||
Vector<Transform2D> _decode_accessor_as_xform2d(Ref<GLTFState> state,
|
||||
const GLTFAccessorIndex p_accessor,
|
||||
const bool p_for_vertex);
|
||||
Vector<Basis> _decode_accessor_as_basis(Ref<GLTFState> state,
|
||||
const GLTFAccessorIndex p_accessor,
|
||||
const bool p_for_vertex);
|
||||
Vector<Transform> _decode_accessor_as_xform(Ref<GLTFState> state,
|
||||
const GLTFAccessorIndex p_accessor,
|
||||
const bool p_for_vertex);
|
||||
Error _parse_meshes(Ref<GLTFState> state);
|
||||
Error _serialize_textures(Ref<GLTFState> state);
|
||||
Error _serialize_images(Ref<GLTFState> state, const String &p_path);
|
||||
Error _serialize_lights(Ref<GLTFState> state);
|
||||
Error _parse_images(Ref<GLTFState> state, const String &p_base_path);
|
||||
Error _parse_textures(Ref<GLTFState> state);
|
||||
Error _parse_materials(Ref<GLTFState> state);
|
||||
void _set_texture_transform_uv1(const Dictionary &d, Ref<SpatialMaterial> material);
|
||||
void spec_gloss_to_rough_metal(Ref<GLTFSpecGloss> r_spec_gloss,
|
||||
Ref<SpatialMaterial> p_material);
|
||||
static void spec_gloss_to_metal_base_color(const Color &p_specular_factor,
|
||||
const Color &p_diffuse,
|
||||
Color &r_base_color,
|
||||
float &r_metallic);
|
||||
GLTFNodeIndex _find_highest_node(Ref<GLTFState> state,
|
||||
const Vector<GLTFNodeIndex> &subset);
|
||||
bool _capture_nodes_in_skin(Ref<GLTFState> state, Ref<GLTFSkin> skin,
|
||||
const GLTFNodeIndex node_index);
|
||||
void _capture_nodes_for_multirooted_skin(Ref<GLTFState> state, Ref<GLTFSkin> skin);
|
||||
Error _expand_skin(Ref<GLTFState> state, Ref<GLTFSkin> skin);
|
||||
Error _verify_skin(Ref<GLTFState> state, Ref<GLTFSkin> skin);
|
||||
Error _parse_skins(Ref<GLTFState> state);
|
||||
Error _determine_skeletons(Ref<GLTFState> state);
|
||||
Error _reparent_non_joint_skeleton_subtrees(
|
||||
Ref<GLTFState> state, Ref<GLTFSkeleton> skeleton,
|
||||
const Vector<GLTFNodeIndex> &non_joints);
|
||||
Error _reparent_to_fake_joint(Ref<GLTFState> state, Ref<GLTFSkeleton> skeleton,
|
||||
const GLTFNodeIndex node_index);
|
||||
Error _determine_skeleton_roots(Ref<GLTFState> state,
|
||||
const GLTFSkeletonIndex skel_i);
|
||||
Error _create_skeletons(Ref<GLTFState> state);
|
||||
Error _map_skin_joints_indices_to_skeleton_bone_indices(Ref<GLTFState> state);
|
||||
Error _serialize_skins(Ref<GLTFState> state);
|
||||
Error _create_skins(Ref<GLTFState> state);
|
||||
bool _skins_are_same(const Ref<Skin> skin_a, const Ref<Skin> skin_b);
|
||||
void _remove_duplicate_skins(Ref<GLTFState> state);
|
||||
Error _serialize_cameras(Ref<GLTFState> state);
|
||||
Error _parse_cameras(Ref<GLTFState> state);
|
||||
Error _parse_lights(Ref<GLTFState> state);
|
||||
Error _parse_animations(Ref<GLTFState> state);
|
||||
Error _serialize_animations(Ref<GLTFState> state);
|
||||
BoneAttachment *_generate_bone_attachment(Ref<GLTFState> state,
|
||||
Skeleton *skeleton,
|
||||
const GLTFNodeIndex node_index,
|
||||
const GLTFNodeIndex bone_index);
|
||||
Spatial *_generate_mesh_instance(Ref<GLTFState> state, Node *scene_parent, const GLTFNodeIndex node_index);
|
||||
Camera *_generate_camera(Ref<GLTFState> state, Node *scene_parent,
|
||||
const GLTFNodeIndex node_index);
|
||||
Spatial *_generate_light(Ref<GLTFState> state, Node *scene_parent, const GLTFNodeIndex node_index);
|
||||
Spatial *_generate_spatial(Ref<GLTFState> state, Node *scene_parent,
|
||||
const GLTFNodeIndex node_index);
|
||||
void _assign_scene_names(Ref<GLTFState> state);
|
||||
template <class T>
|
||||
T _interpolate_track(const Vector<float> &p_times, const Vector<T> &p_values,
|
||||
const float p_time,
|
||||
const GLTFAnimation::Interpolation p_interp);
|
||||
GLTFAccessorIndex _encode_accessor_as_quats(Ref<GLTFState> state,
|
||||
const Vector<Quat> p_attribs,
|
||||
const bool p_for_vertex);
|
||||
GLTFAccessorIndex _encode_accessor_as_weights(Ref<GLTFState> state,
|
||||
const Vector<Color> p_attribs,
|
||||
const bool p_for_vertex);
|
||||
GLTFAccessorIndex _encode_accessor_as_joints(Ref<GLTFState> state,
|
||||
const Vector<Color> p_attribs,
|
||||
const bool p_for_vertex);
|
||||
GLTFAccessorIndex _encode_accessor_as_floats(Ref<GLTFState> state,
|
||||
const Vector<real_t> p_attribs,
|
||||
const bool p_for_vertex);
|
||||
GLTFAccessorIndex _encode_accessor_as_vec2(Ref<GLTFState> state,
|
||||
const Vector<Vector2> p_attribs,
|
||||
const bool p_for_vertex);
|
||||
|
||||
void _calc_accessor_vec2_min_max(int i, const int element_count, Vector<double> &type_max, Vector2 attribs, Vector<double> &type_min) {
|
||||
if (i == 0) {
|
||||
for (int32_t type_i = 0; type_i < element_count; type_i++) {
|
||||
type_max.write[type_i] = attribs[(i * element_count) + type_i];
|
||||
type_min.write[type_i] = attribs[(i * element_count) + type_i];
|
||||
}
|
||||
}
|
||||
for (int32_t type_i = 0; type_i < element_count; type_i++) {
|
||||
type_max.write[type_i] = MAX(attribs[(i * element_count) + type_i], type_max[type_i]);
|
||||
type_min.write[type_i] = MIN(attribs[(i * element_count) + type_i], type_min[type_i]);
|
||||
type_max.write[type_i] = _filter_number(type_max.write[type_i]);
|
||||
type_min.write[type_i] = _filter_number(type_min.write[type_i]);
|
||||
}
|
||||
}
|
||||
|
||||
GLTFAccessorIndex _encode_accessor_as_vec3(Ref<GLTFState> state,
|
||||
const Vector<Vector3> p_attribs,
|
||||
const bool p_for_vertex);
|
||||
GLTFAccessorIndex _encode_accessor_as_color(Ref<GLTFState> state,
|
||||
const Vector<Color> p_attribs,
|
||||
const bool p_for_vertex);
|
||||
|
||||
void _calc_accessor_min_max(int p_i, const int p_element_count, Vector<double> &p_type_max, Vector<double> p_attribs, Vector<double> &p_type_min);
|
||||
|
||||
GLTFAccessorIndex _encode_accessor_as_ints(Ref<GLTFState> state,
|
||||
const Vector<int32_t> p_attribs,
|
||||
const bool p_for_vertex);
|
||||
GLTFAccessorIndex _encode_accessor_as_xform(Ref<GLTFState> state,
|
||||
const Vector<Transform> p_attribs,
|
||||
const bool p_for_vertex);
|
||||
Error _encode_buffer_view(Ref<GLTFState> state, const double *src,
|
||||
const int count, const GLTFType type,
|
||||
const int component_type, const bool normalized,
|
||||
const int byte_offset, const bool for_vertex,
|
||||
GLTFBufferViewIndex &r_accessor);
|
||||
Error _encode_accessors(Ref<GLTFState> state);
|
||||
Error _encode_buffer_views(Ref<GLTFState> state);
|
||||
Error _serialize_materials(Ref<GLTFState> state);
|
||||
Error _serialize_meshes(Ref<GLTFState> state);
|
||||
Error _serialize_nodes(Ref<GLTFState> state);
|
||||
Error _serialize_scenes(Ref<GLTFState> state);
|
||||
String interpolation_to_string(const GLTFAnimation::Interpolation p_interp);
|
||||
GLTFAnimation::Track _convert_animation_track(Ref<GLTFState> state,
|
||||
GLTFAnimation::Track p_track,
|
||||
Ref<Animation> p_animation, Transform p_bone_rest,
|
||||
int32_t p_track_i,
|
||||
GLTFNodeIndex p_node_i);
|
||||
Error _encode_buffer_bins(Ref<GLTFState> state, const String &p_path);
|
||||
Error _encode_buffer_glb(Ref<GLTFState> state, const String &p_path);
|
||||
Error _serialize_bone_attachment(Ref<GLTFState> state);
|
||||
Dictionary _serialize_texture_transform_uv1(Ref<SpatialMaterial> p_material);
|
||||
Dictionary _serialize_texture_transform_uv2(Ref<SpatialMaterial> p_material);
|
||||
Error _serialize_version(Ref<GLTFState> state);
|
||||
Error _serialize_file(Ref<GLTFState> state, const String p_path);
|
||||
Error _serialize_extensions(Ref<GLTFState> state) const;
|
||||
|
||||
public:
|
||||
// http://www.itu.int/rec/R-REC-BT.601
|
||||
// http://www.itu.int/dms_pubrec/itu-r/rec/bt/R-REC-BT.601-7-201103-I!!PDF-E.pdf
|
||||
static constexpr float R_BRIGHTNESS_COEFF = 0.299f;
|
||||
static constexpr float G_BRIGHTNESS_COEFF = 0.587f;
|
||||
static constexpr float B_BRIGHTNESS_COEFF = 0.114f;
|
||||
|
||||
private:
|
||||
// https://github.com/microsoft/glTF-SDK/blob/master/GLTFSDK/Source/PBRUtils.cpp#L9
|
||||
// https://bghgary.github.io/glTF/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
|
||||
static float solve_metallic(float p_dielectric_specular, float diffuse,
|
||||
float specular,
|
||||
float p_one_minus_specular_strength);
|
||||
static float get_perceived_brightness(const Color p_color);
|
||||
static float get_max_component(const Color &p_color);
|
||||
|
||||
public:
|
||||
String _sanitize_scene_name(Ref<GLTFState> state, const String &p_name);
|
||||
String _legacy_validate_node_name(const String &p_name);
|
||||
|
||||
void _process_mesh_instances(Ref<GLTFState> state, Node *scene_root);
|
||||
void _generate_scene_node(Ref<GLTFState> state, Node *scene_parent,
|
||||
Spatial *scene_root,
|
||||
const GLTFNodeIndex node_index);
|
||||
void _generate_skeleton_bone_node(Ref<GLTFState> state, Node *scene_parent, Spatial *scene_root, const GLTFNodeIndex node_index);
|
||||
void _import_animation(Ref<GLTFState> state, AnimationPlayer *ap,
|
||||
const GLTFAnimationIndex index, const int bake_fps);
|
||||
GLTFMeshIndex _convert_mesh_instance(Ref<GLTFState> state,
|
||||
MeshInstance *p_mesh_instance);
|
||||
void _convert_mesh_instances(Ref<GLTFState> state);
|
||||
GLTFCameraIndex _convert_camera(Ref<GLTFState> state, Camera *p_camera);
|
||||
void _convert_light_to_gltf(Light *light, Ref<GLTFState> state, Spatial *spatial, Ref<GLTFNode> gltf_node);
|
||||
GLTFLightIndex _convert_light(Ref<GLTFState> state, Light *p_light);
|
||||
GLTFSkeletonIndex _convert_skeleton(Ref<GLTFState> state, Skeleton *p_skeleton);
|
||||
void _convert_spatial(Ref<GLTFState> state, Spatial *p_spatial, Ref<GLTFNode> p_node);
|
||||
void _convert_scene_node(Ref<GLTFState> state, Node *p_current, Node *p_root,
|
||||
const GLTFNodeIndex p_gltf_current,
|
||||
const GLTFNodeIndex p_gltf_root);
|
||||
|
||||
#ifdef MODULE_CSG_ENABLED
|
||||
void _convert_csg_shape_to_gltf(Node *p_current, GLTFNodeIndex p_gltf_parent, Ref<GLTFNode> gltf_node, Ref<GLTFState> state);
|
||||
#endif // MODULE_CSG_ENABLED
|
||||
|
||||
void _create_gltf_node(Ref<GLTFState> state,
|
||||
Node *p_scene_parent,
|
||||
GLTFNodeIndex current_node_i,
|
||||
GLTFNodeIndex p_parent_node_index,
|
||||
GLTFNodeIndex p_root_gltf_node,
|
||||
Ref<GLTFNode> gltf_node);
|
||||
void _convert_animation_player_to_gltf(
|
||||
AnimationPlayer *animation_player, Ref<GLTFState> state,
|
||||
const GLTFNodeIndex &p_gltf_current,
|
||||
const GLTFNodeIndex &p_gltf_root_index,
|
||||
Ref<GLTFNode> p_gltf_node, Node *p_scene_parent,
|
||||
Node *p_root);
|
||||
void _check_visibility(Node *p_node, bool &retflag);
|
||||
void _convert_camera_to_gltf(Camera *camera, Ref<GLTFState> state,
|
||||
Spatial *spatial,
|
||||
Ref<GLTFNode> gltf_node);
|
||||
#ifdef MODULE_GRIDMAP_ENABLED
|
||||
void _convert_grid_map_to_gltf(
|
||||
Node *p_scene_parent,
|
||||
const GLTFNodeIndex &p_parent_node_index,
|
||||
const GLTFNodeIndex &p_root_node_index,
|
||||
Ref<GLTFNode> gltf_node, Ref<GLTFState> state,
|
||||
Node *p_root_node);
|
||||
#endif // MODULE_GRIDMAP_ENABLED
|
||||
void _convert_mult_mesh_instance_to_gltf(
|
||||
Node *p_scene_parent,
|
||||
const GLTFNodeIndex &p_parent_node_index,
|
||||
const GLTFNodeIndex &p_root_node_index,
|
||||
Ref<GLTFNode> gltf_node, Ref<GLTFState> state,
|
||||
Node *p_root_node);
|
||||
void _convert_skeleton_to_gltf(
|
||||
Node *p_scene_parent, Ref<GLTFState> state,
|
||||
const GLTFNodeIndex &p_parent_node_index,
|
||||
const GLTFNodeIndex &p_root_node_index,
|
||||
Ref<GLTFNode> gltf_node, Node *p_root_node);
|
||||
void _convert_bone_attachment_to_gltf(Node *p_scene_parent,
|
||||
Ref<GLTFState> state,
|
||||
Ref<GLTFNode> gltf_node,
|
||||
bool &retflag);
|
||||
void _convert_mesh_to_gltf(Node *p_scene_parent,
|
||||
Ref<GLTFState> state, Spatial *spatial,
|
||||
Ref<GLTFNode> gltf_node);
|
||||
void _convert_animation(Ref<GLTFState> state, AnimationPlayer *ap,
|
||||
String p_animation_track_name);
|
||||
Error serialize(Ref<GLTFState> state, Node *p_root, const String &p_path);
|
||||
Error parse(Ref<GLTFState> state, String p_paths, bool p_read_binary = false);
|
||||
};
|
||||
|
||||
#endif // GLTF_DOCUMENT_H
|
101
modules/gltf/gltf_light.cpp
Normal file
101
modules/gltf/gltf_light.cpp
Normal file
|
@ -0,0 +1,101 @@
|
|||
/*************************************************************************/
|
||||
/* gltf_light.cpp */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2021 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_type"), &GLTFLight::get_type);
|
||||
ClassDB::bind_method(D_METHOD("set_type", "type"), &GLTFLight::set_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::REAL, "intensity"), "set_intensity", "get_intensity"); // float
|
||||
ADD_PROPERTY(PropertyInfo(Variant::STRING, "type"), "set_type", "get_type"); // String
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "range"), "set_range", "get_range"); // float
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "inner_cone_angle"), "set_inner_cone_angle", "get_inner_cone_angle"); // float
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "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_type() {
|
||||
return type;
|
||||
}
|
||||
|
||||
void GLTFLight::set_type(String p_type) {
|
||||
type = p_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;
|
||||
}
|
72
modules/gltf/gltf_light.h
Normal file
72
modules/gltf/gltf_light.h
Normal file
|
@ -0,0 +1,72 @@
|
|||
/*************************************************************************/
|
||||
/* gltf_light.h */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2021 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/engine.h"
|
||||
#include "core/resource.h"
|
||||
|
||||
class GLTFLight : public Resource {
|
||||
GDCLASS(GLTFLight, Resource)
|
||||
friend class GLTFDocument;
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
private:
|
||||
Color color;
|
||||
float intensity = 0.0f;
|
||||
String type;
|
||||
float range = 0.0f;
|
||||
float inner_cone_angle = 0.0f;
|
||||
float outer_cone_angle = 0.0f;
|
||||
|
||||
public:
|
||||
Color get_color();
|
||||
void set_color(Color p_color);
|
||||
|
||||
float get_intensity();
|
||||
void set_intensity(float p_intensity);
|
||||
|
||||
String get_type();
|
||||
void set_type(String p_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
|
57
modules/gltf/gltf_mesh.cpp
Normal file
57
modules/gltf/gltf_mesh.cpp
Normal file
|
@ -0,0 +1,57 @@
|
|||
/*************************************************************************/
|
||||
/* gltf_mesh.cpp */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2021 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"
|
||||
|
||||
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);
|
||||
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "mesh"), "set_mesh", "get_mesh");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::POOL_REAL_ARRAY, "blend_weights"), "set_blend_weights", "get_blend_weights"); // Vector<float>
|
||||
}
|
||||
|
||||
Ref<ArrayMesh> GLTFMesh::get_mesh() {
|
||||
return mesh;
|
||||
}
|
||||
|
||||
void GLTFMesh::set_mesh(Ref<ArrayMesh> p_mesh) {
|
||||
mesh = p_mesh;
|
||||
}
|
||||
|
||||
Vector<float> GLTFMesh::get_blend_weights() {
|
||||
return blend_weights;
|
||||
}
|
||||
|
||||
void GLTFMesh::set_blend_weights(Vector<float> p_blend_weights) {
|
||||
blend_weights = p_blend_weights;
|
||||
}
|
54
modules/gltf/gltf_mesh.h
Normal file
54
modules/gltf/gltf_mesh.h
Normal file
|
@ -0,0 +1,54 @@
|
|||
/*************************************************************************/
|
||||
/* gltf_mesh.h */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2021 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/resource.h"
|
||||
#include "editor/import/resource_importer_scene.h"
|
||||
#include "scene/resources/mesh.h"
|
||||
|
||||
class GLTFMesh : public Resource {
|
||||
GDCLASS(GLTFMesh, Resource);
|
||||
|
||||
private:
|
||||
Ref<ArrayMesh> mesh;
|
||||
Vector<float> blend_weights;
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
public:
|
||||
Ref<ArrayMesh> get_mesh();
|
||||
void set_mesh(Ref<ArrayMesh> p_mesh);
|
||||
Vector<float> get_blend_weights();
|
||||
void set_blend_weights(Vector<float> p_blend_weights);
|
||||
};
|
||||
#endif // GLTF_MESH_H
|
178
modules/gltf/gltf_node.cpp
Normal file
178
modules/gltf/gltf_node.cpp
Normal file
|
@ -0,0 +1,178 @@
|
|||
/*************************************************************************/
|
||||
/* gltf_node.cpp */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2021 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_translation"), &GLTFNode::get_translation);
|
||||
ClassDB::bind_method(D_METHOD("set_translation", "translation"), &GLTFNode::set_translation);
|
||||
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::TRANSFORM, "xform"), "set_xform", "get_xform"); // Transform
|
||||
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, "translation"), "set_translation", "get_translation"); // Vector3
|
||||
ADD_PROPERTY(PropertyInfo(Variant::QUAT, "rotation"), "set_rotation", "get_rotation"); // Quat
|
||||
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "scale"), "set_scale", "get_scale"); // Vector3
|
||||
ADD_PROPERTY(PropertyInfo(Variant::POOL_INT_ARRAY, "children"), "set_children", "get_children"); // Vector<int>
|
||||
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;
|
||||
}
|
||||
|
||||
Transform GLTFNode::get_xform() {
|
||||
return xform;
|
||||
}
|
||||
|
||||
void GLTFNode::set_xform(Transform 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_translation() {
|
||||
return translation;
|
||||
}
|
||||
|
||||
void GLTFNode::set_translation(Vector3 p_translation) {
|
||||
translation = p_translation;
|
||||
}
|
||||
|
||||
Quat GLTFNode::get_rotation() {
|
||||
return rotation;
|
||||
}
|
||||
|
||||
void GLTFNode::set_rotation(Quat p_rotation) {
|
||||
rotation = p_rotation;
|
||||
}
|
||||
|
||||
Vector3 GLTFNode::get_scale() {
|
||||
return scale;
|
||||
}
|
||||
|
||||
void GLTFNode::set_scale(Vector3 p_scale) {
|
||||
scale = p_scale;
|
||||
}
|
||||
|
||||
Vector<int> GLTFNode::get_children() {
|
||||
return children;
|
||||
}
|
||||
|
||||
void GLTFNode::set_children(Vector<int> p_children) {
|
||||
children = p_children;
|
||||
}
|
||||
|
||||
GLTFLightIndex GLTFNode::get_light() {
|
||||
return light;
|
||||
}
|
||||
|
||||
void GLTFNode::set_light(GLTFLightIndex p_light) {
|
||||
light = p_light;
|
||||
}
|
101
modules/gltf/gltf_node.h
Normal file
101
modules/gltf/gltf_node.h
Normal file
|
@ -0,0 +1,101 @@
|
|||
/*************************************************************************/
|
||||
/* gltf_node.h */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2021 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/resource.h"
|
||||
#include "gltf_document.h"
|
||||
|
||||
class GLTFNode : public Resource {
|
||||
GDCLASS(GLTFNode, Resource);
|
||||
friend class GLTFDocument;
|
||||
friend class PackedSceneGLTF;
|
||||
|
||||
private:
|
||||
// matrices need to be transformed to this
|
||||
GLTFNodeIndex parent = -1;
|
||||
int height = -1;
|
||||
Transform xform;
|
||||
GLTFMeshIndex mesh = -1;
|
||||
GLTFCameraIndex camera = -1;
|
||||
GLTFSkinIndex skin = -1;
|
||||
GLTFSkeletonIndex skeleton = -1;
|
||||
bool joint = false;
|
||||
Vector3 translation;
|
||||
Quat rotation;
|
||||
Vector3 scale = Vector3(1, 1, 1);
|
||||
Vector<int> 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);
|
||||
|
||||
Transform get_xform();
|
||||
void set_xform(Transform 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_translation();
|
||||
void set_translation(Vector3 p_translation);
|
||||
|
||||
Quat get_rotation();
|
||||
void set_rotation(Quat p_rotation);
|
||||
|
||||
Vector3 get_scale();
|
||||
void set_scale(Vector3 p_scale);
|
||||
|
||||
Vector<int> get_children();
|
||||
void set_children(Vector<int> p_children);
|
||||
|
||||
GLTFLightIndex get_light();
|
||||
void set_light(GLTFLightIndex p_light);
|
||||
};
|
||||
#endif // GLTF_NODE_H
|
95
modules/gltf/gltf_skeleton.cpp
Normal file
95
modules/gltf/gltf_skeleton.cpp
Normal file
|
@ -0,0 +1,95 @@
|
|||
/*************************************************************************/
|
||||
/* gltf_skeleton.cpp */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2021 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"
|
||||
|
||||
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::POOL_INT_ARRAY, "joints"), "set_joints", "get_joints"); // PoolVector<GLTFNodeIndex>
|
||||
ADD_PROPERTY(PropertyInfo(Variant::POOL_INT_ARRAY, "roots"), "set_roots", "get_roots"); // PoolVector<GLTFNodeIndex>
|
||||
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<String>
|
||||
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"); // Map<int32_t,
|
||||
}
|
||||
|
||||
PoolVector<GLTFNodeIndex> GLTFSkeleton::get_joints() {
|
||||
return joints;
|
||||
}
|
||||
|
||||
void GLTFSkeleton::set_joints(PoolVector<GLTFNodeIndex> p_joints) {
|
||||
joints = p_joints;
|
||||
}
|
||||
|
||||
PoolVector<GLTFNodeIndex> GLTFSkeleton::get_roots() {
|
||||
return roots;
|
||||
}
|
||||
|
||||
void GLTFSkeleton::set_roots(PoolVector<GLTFNodeIndex> p_roots) {
|
||||
roots = p_roots;
|
||||
}
|
||||
|
||||
Skeleton *GLTFSkeleton::get_godot_skeleton() {
|
||||
return godot_skeleton;
|
||||
}
|
||||
|
||||
Array GLTFSkeleton::get_unique_names() {
|
||||
return GLTFDocument::to_array(unique_names);
|
||||
}
|
||||
|
||||
void GLTFSkeleton::set_unique_names(Array p_unique_names) {
|
||||
GLTFDocument::set_from_array(unique_names, p_unique_names);
|
||||
}
|
||||
|
||||
Dictionary GLTFSkeleton::get_godot_bone_node() {
|
||||
return GLTFDocument::to_dict(godot_bone_node);
|
||||
}
|
||||
|
||||
void GLTFSkeleton::set_godot_bone_node(Dictionary p_indict) {
|
||||
GLTFDocument::set_from_dict(godot_bone_node, p_indict);
|
||||
}
|
||||
|
||||
BoneAttachment *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();
|
||||
}
|
101
modules/gltf/gltf_skeleton.h
Normal file
101
modules/gltf/gltf_skeleton.h
Normal file
|
@ -0,0 +1,101 @@
|
|||
/*************************************************************************/
|
||||
/* gltf_skeleton.h */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2021 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/resource.h"
|
||||
#include "gltf_document.h"
|
||||
|
||||
class GLTFSkeleton : public Resource {
|
||||
GDCLASS(GLTFSkeleton, Resource);
|
||||
friend class GLTFDocument;
|
||||
|
||||
private:
|
||||
// The *synthesized* skeletons joints
|
||||
PoolVector<GLTFNodeIndex> joints;
|
||||
|
||||
// The roots of the skeleton. If there are multiple, each root must have the
|
||||
// same parent (ie roots are siblings)
|
||||
PoolVector<GLTFNodeIndex> roots;
|
||||
|
||||
// The created Skeleton for the scene
|
||||
Skeleton *godot_skeleton = nullptr;
|
||||
|
||||
// Set of unique bone names for the skeleton
|
||||
Set<String> unique_names;
|
||||
|
||||
Map<int32_t, GLTFNodeIndex> godot_bone_node;
|
||||
|
||||
PoolVector<BoneAttachment *> bone_attachments;
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
public:
|
||||
PoolVector<GLTFNodeIndex> get_joints();
|
||||
void set_joints(PoolVector<GLTFNodeIndex> p_joints);
|
||||
|
||||
PoolVector<GLTFNodeIndex> get_roots();
|
||||
void set_roots(PoolVector<GLTFNodeIndex> p_roots);
|
||||
|
||||
Skeleton *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);
|
||||
|
||||
//Map<int32_t, GLTFNodeIndex> get_godot_bone_node() {
|
||||
// return this->godot_bone_node;
|
||||
//}
|
||||
//void set_godot_bone_node(Map<int32_t, GLTFNodeIndex> 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);
|
||||
//}
|
||||
|
||||
BoneAttachment *get_bone_attachment(int idx);
|
||||
|
||||
int32_t get_bone_attachment_count();
|
||||
};
|
||||
#endif // GLTF_SKELETON_H
|
155
modules/gltf/gltf_skin.cpp
Normal file
155
modules/gltf/gltf_skin.cpp
Normal file
|
@ -0,0 +1,155 @@
|
|||
/*************************************************************************/
|
||||
/* gltf_skin.cpp */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2021 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"
|
||||
|
||||
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::POOL_INT_ARRAY, "joints_original"), "set_joints_original", "get_joints_original"); // Vector<GLTFNodeIndex>
|
||||
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "inverse_binds", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_INTERNAL), "set_inverse_binds", "get_inverse_binds"); // Vector<Transform>
|
||||
ADD_PROPERTY(PropertyInfo(Variant::POOL_INT_ARRAY, "joints"), "set_joints", "get_joints"); // Vector<GLTFNodeIndex>
|
||||
ADD_PROPERTY(PropertyInfo(Variant::POOL_INT_ARRAY, "non_joints"), "set_non_joints", "get_non_joints"); // Vector<GLTFNodeIndex>
|
||||
ADD_PROPERTY(PropertyInfo(Variant::POOL_INT_ARRAY, "roots"), "set_roots", "get_roots"); // Vector<GLTFNodeIndex>
|
||||
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"); // Map<int,
|
||||
ADD_PROPERTY(PropertyInfo(Variant::DICTIONARY, "joint_i_to_name", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_INTERNAL), "set_joint_i_to_name", "get_joint_i_to_name"); // Map<int,
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "godot_skin"), "set_godot_skin", "get_godot_skin"); // Ref<Skin>
|
||||
}
|
||||
|
||||
GLTFNodeIndex GLTFSkin::get_skin_root() {
|
||||
return skin_root;
|
||||
}
|
||||
|
||||
void GLTFSkin::set_skin_root(GLTFNodeIndex p_skin_root) {
|
||||
skin_root = p_skin_root;
|
||||
}
|
||||
|
||||
Vector<GLTFNodeIndex> GLTFSkin::get_joints_original() {
|
||||
return joints_original;
|
||||
}
|
||||
|
||||
void GLTFSkin::set_joints_original(Vector<GLTFNodeIndex> p_joints_original) {
|
||||
joints_original = p_joints_original;
|
||||
}
|
||||
|
||||
Array GLTFSkin::get_inverse_binds() {
|
||||
return GLTFDocument::to_array(inverse_binds);
|
||||
}
|
||||
|
||||
void GLTFSkin::set_inverse_binds(Array p_inverse_binds) {
|
||||
GLTFDocument::set_from_array(inverse_binds, p_inverse_binds);
|
||||
}
|
||||
|
||||
Vector<GLTFNodeIndex> GLTFSkin::get_joints() {
|
||||
return joints;
|
||||
}
|
||||
|
||||
void GLTFSkin::set_joints(Vector<GLTFNodeIndex> p_joints) {
|
||||
joints = p_joints;
|
||||
}
|
||||
|
||||
Vector<GLTFNodeIndex> GLTFSkin::get_non_joints() {
|
||||
return non_joints;
|
||||
}
|
||||
|
||||
void GLTFSkin::set_non_joints(Vector<GLTFNodeIndex> p_non_joints) {
|
||||
non_joints = p_non_joints;
|
||||
}
|
||||
|
||||
Vector<GLTFNodeIndex> GLTFSkin::get_roots() {
|
||||
return roots;
|
||||
}
|
||||
|
||||
void GLTFSkin::set_roots(Vector<GLTFNodeIndex> 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 GLTFDocument::to_dict(joint_i_to_bone_i);
|
||||
}
|
||||
|
||||
void GLTFSkin::set_joint_i_to_bone_i(Dictionary p_joint_i_to_bone_i) {
|
||||
GLTFDocument::set_from_dict(joint_i_to_bone_i, p_joint_i_to_bone_i);
|
||||
}
|
||||
|
||||
Dictionary GLTFSkin::get_joint_i_to_name() {
|
||||
Dictionary ret;
|
||||
Map<int, StringName>::Element *elem = joint_i_to_name.front();
|
||||
while (elem) {
|
||||
ret[elem->key()] = String(elem->value());
|
||||
elem = elem->next();
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
void GLTFSkin::set_joint_i_to_name(Dictionary p_joint_i_to_name) {
|
||||
joint_i_to_name = Map<int, StringName>();
|
||||
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<Skin> GLTFSkin::get_godot_skin() {
|
||||
return godot_skin;
|
||||
}
|
||||
|
||||
void GLTFSkin::set_godot_skin(Ref<Skin> p_godot_skin) {
|
||||
godot_skin = p_godot_skin;
|
||||
}
|
109
modules/gltf/gltf_skin.h
Normal file
109
modules/gltf/gltf_skin.h
Normal file
|
@ -0,0 +1,109 @@
|
|||
/*************************************************************************/
|
||||
/* gltf_skin.h */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2021 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/resource.h"
|
||||
#include "gltf_document.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<GLTFNodeIndex> joints_original;
|
||||
Vector<Transform> 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<GLTFNodeIndex> joints;
|
||||
|
||||
// All Nodes that are caught in-between skin joint nodes, and are not
|
||||
// defined as joints by any skin
|
||||
Vector<GLTFNodeIndex> 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<GLTFNodeIndex> 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
|
||||
Map<int, int> joint_i_to_bone_i;
|
||||
Map<int, StringName> 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<Skin> godot_skin;
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
public:
|
||||
GLTFNodeIndex get_skin_root();
|
||||
void set_skin_root(GLTFNodeIndex p_skin_root);
|
||||
|
||||
Vector<GLTFNodeIndex> get_joints_original();
|
||||
void set_joints_original(Vector<GLTFNodeIndex> p_joints_original);
|
||||
|
||||
Array get_inverse_binds();
|
||||
void set_inverse_binds(Array p_inverse_binds);
|
||||
|
||||
Vector<GLTFNodeIndex> get_joints();
|
||||
void set_joints(Vector<GLTFNodeIndex> p_joints);
|
||||
|
||||
Vector<GLTFNodeIndex> get_non_joints();
|
||||
void set_non_joints(Vector<GLTFNodeIndex> p_non_joints);
|
||||
|
||||
Vector<GLTFNodeIndex> get_roots();
|
||||
void set_roots(Vector<GLTFNodeIndex> 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<Skin> get_godot_skin();
|
||||
void set_godot_skin(Ref<Skin> p_godot_skin);
|
||||
};
|
||||
#endif // GLTF_SKIN_H
|
90
modules/gltf/gltf_spec_gloss.cpp
Normal file
90
modules/gltf/gltf_spec_gloss.cpp
Normal file
|
@ -0,0 +1,90 @@
|
|||
/*************************************************************************/
|
||||
/* gltf_spec_gloss.cpp */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2021 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<Image>
|
||||
ADD_PROPERTY(PropertyInfo(Variant::COLOR, "diffuse_factor"), "set_diffuse_factor", "get_diffuse_factor"); // Color
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "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<Image>
|
||||
}
|
||||
|
||||
Ref<Image> GLTFSpecGloss::get_diffuse_img() {
|
||||
return diffuse_img;
|
||||
}
|
||||
|
||||
void GLTFSpecGloss::set_diffuse_img(Ref<Image> 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<Image> GLTFSpecGloss::get_spec_gloss_img() {
|
||||
return spec_gloss_img;
|
||||
}
|
||||
|
||||
void GLTFSpecGloss::set_spec_gloss_img(Ref<Image> p_spec_gloss_img) {
|
||||
spec_gloss_img = p_spec_gloss_img;
|
||||
}
|
67
modules/gltf/gltf_spec_gloss.h
Normal file
67
modules/gltf/gltf_spec_gloss.h
Normal file
|
@ -0,0 +1,67 @@
|
|||
/*************************************************************************/
|
||||
/* gltf_spec_gloss.h */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2021 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/image.h"
|
||||
#include "core/resource.h"
|
||||
|
||||
class GLTFSpecGloss : public Resource {
|
||||
GDCLASS(GLTFSpecGloss, Resource);
|
||||
friend class GLTFDocument;
|
||||
|
||||
private:
|
||||
Ref<Image> 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<Image> spec_gloss_img = nullptr;
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
public:
|
||||
Ref<Image> get_diffuse_img();
|
||||
void set_diffuse_img(Ref<Image> 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<Image> get_spec_gloss_img();
|
||||
void set_spec_gloss_img(Ref<Image> p_spec_gloss_img);
|
||||
};
|
||||
#endif // GLTF_SPEC_GLOSS_H
|
307
modules/gltf/gltf_state.cpp
Normal file
307
modules/gltf/gltf_state.cpp
Normal file
|
@ -0,0 +1,307 @@
|
|||
/*************************************************************************/
|
||||
/* gltf_state.cpp */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2021 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_state.h"
|
||||
|
||||
void GLTFState::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_json"), &GLTFState::get_json);
|
||||
ClassDB::bind_method(D_METHOD("set_json", "json"), &GLTFState::set_json);
|
||||
ClassDB::bind_method(D_METHOD("get_major_version"), &GLTFState::get_major_version);
|
||||
ClassDB::bind_method(D_METHOD("set_major_version", "major_version"), &GLTFState::set_major_version);
|
||||
ClassDB::bind_method(D_METHOD("get_minor_version"), &GLTFState::get_minor_version);
|
||||
ClassDB::bind_method(D_METHOD("set_minor_version", "minor_version"), &GLTFState::set_minor_version);
|
||||
ClassDB::bind_method(D_METHOD("get_glb_data"), &GLTFState::get_glb_data);
|
||||
ClassDB::bind_method(D_METHOD("set_glb_data", "glb_data"), &GLTFState::set_glb_data);
|
||||
ClassDB::bind_method(D_METHOD("get_use_named_skin_binds"), &GLTFState::get_use_named_skin_binds);
|
||||
ClassDB::bind_method(D_METHOD("set_use_named_skin_binds", "use_named_skin_binds"), &GLTFState::set_use_named_skin_binds);
|
||||
ClassDB::bind_method(D_METHOD("get_nodes"), &GLTFState::get_nodes);
|
||||
ClassDB::bind_method(D_METHOD("set_nodes", "nodes"), &GLTFState::set_nodes);
|
||||
ClassDB::bind_method(D_METHOD("get_buffers"), &GLTFState::get_buffers);
|
||||
ClassDB::bind_method(D_METHOD("set_buffers", "buffers"), &GLTFState::set_buffers);
|
||||
ClassDB::bind_method(D_METHOD("get_buffer_views"), &GLTFState::get_buffer_views);
|
||||
ClassDB::bind_method(D_METHOD("set_buffer_views", "buffer_views"), &GLTFState::set_buffer_views);
|
||||
ClassDB::bind_method(D_METHOD("get_accessors"), &GLTFState::get_accessors);
|
||||
ClassDB::bind_method(D_METHOD("set_accessors", "accessors"), &GLTFState::set_accessors);
|
||||
ClassDB::bind_method(D_METHOD("get_meshes"), &GLTFState::get_meshes);
|
||||
ClassDB::bind_method(D_METHOD("set_meshes", "meshes"), &GLTFState::set_meshes);
|
||||
ClassDB::bind_method(D_METHOD("get_animation_players_count", "idx"), &GLTFState::get_animation_players_count);
|
||||
ClassDB::bind_method(D_METHOD("get_animation_player", "idx"), &GLTFState::get_animation_player);
|
||||
ClassDB::bind_method(D_METHOD("get_materials"), &GLTFState::get_materials);
|
||||
ClassDB::bind_method(D_METHOD("set_materials", "materials"), &GLTFState::set_materials);
|
||||
ClassDB::bind_method(D_METHOD("get_scene_name"), &GLTFState::get_scene_name);
|
||||
ClassDB::bind_method(D_METHOD("set_scene_name", "scene_name"), &GLTFState::set_scene_name);
|
||||
ClassDB::bind_method(D_METHOD("get_root_nodes"), &GLTFState::get_root_nodes);
|
||||
ClassDB::bind_method(D_METHOD("set_root_nodes", "root_nodes"), &GLTFState::set_root_nodes);
|
||||
ClassDB::bind_method(D_METHOD("get_textures"), &GLTFState::get_textures);
|
||||
ClassDB::bind_method(D_METHOD("set_textures", "textures"), &GLTFState::set_textures);
|
||||
ClassDB::bind_method(D_METHOD("get_images"), &GLTFState::get_images);
|
||||
ClassDB::bind_method(D_METHOD("set_images", "images"), &GLTFState::set_images);
|
||||
ClassDB::bind_method(D_METHOD("get_skins"), &GLTFState::get_skins);
|
||||
ClassDB::bind_method(D_METHOD("set_skins", "skins"), &GLTFState::set_skins);
|
||||
ClassDB::bind_method(D_METHOD("get_cameras"), &GLTFState::get_cameras);
|
||||
ClassDB::bind_method(D_METHOD("set_cameras", "cameras"), &GLTFState::set_cameras);
|
||||
ClassDB::bind_method(D_METHOD("get_lights"), &GLTFState::get_lights);
|
||||
ClassDB::bind_method(D_METHOD("set_lights", "lights"), &GLTFState::set_lights);
|
||||
ClassDB::bind_method(D_METHOD("get_unique_names"), &GLTFState::get_unique_names);
|
||||
ClassDB::bind_method(D_METHOD("set_unique_names", "unique_names"), &GLTFState::set_unique_names);
|
||||
ClassDB::bind_method(D_METHOD("get_unique_animation_names"), &GLTFState::get_unique_animation_names);
|
||||
ClassDB::bind_method(D_METHOD("set_unique_animation_names", "unique_animation_names"), &GLTFState::set_unique_animation_names);
|
||||
ClassDB::bind_method(D_METHOD("get_skeletons"), &GLTFState::get_skeletons);
|
||||
ClassDB::bind_method(D_METHOD("set_skeletons", "skeletons"), &GLTFState::set_skeletons);
|
||||
ClassDB::bind_method(D_METHOD("get_skeleton_to_node"), &GLTFState::get_skeleton_to_node);
|
||||
ClassDB::bind_method(D_METHOD("set_skeleton_to_node", "skeleton_to_node"), &GLTFState::set_skeleton_to_node);
|
||||
ClassDB::bind_method(D_METHOD("get_animations"), &GLTFState::get_animations);
|
||||
ClassDB::bind_method(D_METHOD("set_animations", "animations"), &GLTFState::set_animations);
|
||||
ClassDB::bind_method(D_METHOD("get_scene_node", "idx"), &GLTFState::get_scene_node);
|
||||
|
||||
ADD_PROPERTY(PropertyInfo(Variant::DICTIONARY, "json"), "set_json", "get_json"); // Dictionary
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "major_version"), "set_major_version", "get_major_version"); // int
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "minor_version"), "set_minor_version", "get_minor_version"); // int
|
||||
ADD_PROPERTY(PropertyInfo(Variant::POOL_BYTE_ARRAY, "glb_data"), "set_glb_data", "get_glb_data"); // Vector<uint8_t>
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "use_named_skin_binds"), "set_use_named_skin_binds", "get_use_named_skin_binds"); // bool
|
||||
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "nodes", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_INTERNAL | PROPERTY_USAGE_EDITOR), "set_nodes", "get_nodes"); // Vector<Ref<GLTFNode>>
|
||||
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "buffers"), "set_buffers", "get_buffers"); // Vector<Vector<uint8_t>
|
||||
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "buffer_views", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_INTERNAL | PROPERTY_USAGE_EDITOR), "set_buffer_views", "get_buffer_views"); // Vector<Ref<GLTFBufferView>>
|
||||
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "accessors", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_INTERNAL | PROPERTY_USAGE_EDITOR), "set_accessors", "get_accessors"); // Vector<Ref<GLTFAccessor>>
|
||||
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "meshes", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_INTERNAL | PROPERTY_USAGE_EDITOR), "set_meshes", "get_meshes"); // Vector<Ref<GLTFMesh>>
|
||||
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "materials", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_INTERNAL | PROPERTY_USAGE_EDITOR), "set_materials", "get_materials"); // Vector<Ref<Material>
|
||||
ADD_PROPERTY(PropertyInfo(Variant::STRING, "scene_name"), "set_scene_name", "get_scene_name"); // String
|
||||
ADD_PROPERTY(PropertyInfo(Variant::POOL_INT_ARRAY, "root_nodes"), "set_root_nodes", "get_root_nodes"); // Vector<int>
|
||||
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "textures", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_INTERNAL | PROPERTY_USAGE_EDITOR), "set_textures", "get_textures"); // Vector<Ref<GLTFTexture>>
|
||||
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "images", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_INTERNAL | PROPERTY_USAGE_EDITOR), "set_images", "get_images"); // Vector<Ref<Texture>
|
||||
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "skins", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_INTERNAL | PROPERTY_USAGE_EDITOR), "set_skins", "get_skins"); // Vector<Ref<GLTFSkin>>
|
||||
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "cameras", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_INTERNAL | PROPERTY_USAGE_EDITOR), "set_cameras", "get_cameras"); // Vector<Ref<GLTFCamera>>
|
||||
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "lights", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_INTERNAL | PROPERTY_USAGE_EDITOR), "set_lights", "get_lights"); // Vector<Ref<GLTFLight>>
|
||||
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<String>
|
||||
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "unique_animation_names", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_INTERNAL | PROPERTY_USAGE_EDITOR), "set_unique_animation_names", "get_unique_animation_names"); // Set<String>
|
||||
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "skeletons", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_INTERNAL | PROPERTY_USAGE_EDITOR), "set_skeletons", "get_skeletons"); // Vector<Ref<GLTFSkeleton>>
|
||||
ADD_PROPERTY(PropertyInfo(Variant::DICTIONARY, "skeleton_to_node", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_INTERNAL | PROPERTY_USAGE_EDITOR), "set_skeleton_to_node", "get_skeleton_to_node"); // Map<GLTFSkeletonIndex,
|
||||
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "animations", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_INTERNAL | PROPERTY_USAGE_EDITOR), "set_animations", "get_animations"); // Vector<Ref<GLTFAnimation>>
|
||||
}
|
||||
|
||||
Dictionary GLTFState::get_json() {
|
||||
return json;
|
||||
}
|
||||
|
||||
void GLTFState::set_json(Dictionary p_json) {
|
||||
json = p_json;
|
||||
}
|
||||
|
||||
int GLTFState::get_major_version() {
|
||||
return major_version;
|
||||
}
|
||||
|
||||
void GLTFState::set_major_version(int p_major_version) {
|
||||
major_version = p_major_version;
|
||||
}
|
||||
|
||||
int GLTFState::get_minor_version() {
|
||||
return minor_version;
|
||||
}
|
||||
|
||||
void GLTFState::set_minor_version(int p_minor_version) {
|
||||
minor_version = p_minor_version;
|
||||
}
|
||||
|
||||
Vector<uint8_t> GLTFState::get_glb_data() {
|
||||
return glb_data;
|
||||
}
|
||||
|
||||
void GLTFState::set_glb_data(Vector<uint8_t> p_glb_data) {
|
||||
glb_data = p_glb_data;
|
||||
}
|
||||
|
||||
bool GLTFState::get_use_named_skin_binds() {
|
||||
return use_named_skin_binds;
|
||||
}
|
||||
|
||||
void GLTFState::set_use_named_skin_binds(bool p_use_named_skin_binds) {
|
||||
use_named_skin_binds = p_use_named_skin_binds;
|
||||
}
|
||||
|
||||
Array GLTFState::get_nodes() {
|
||||
return GLTFDocument::to_array(nodes);
|
||||
}
|
||||
|
||||
void GLTFState::set_nodes(Array p_nodes) {
|
||||
GLTFDocument::set_from_array(nodes, p_nodes);
|
||||
}
|
||||
|
||||
Array GLTFState::get_buffers() {
|
||||
return GLTFDocument::to_array(buffers);
|
||||
}
|
||||
|
||||
void GLTFState::set_buffers(Array p_buffers) {
|
||||
GLTFDocument::set_from_array(buffers, p_buffers);
|
||||
}
|
||||
|
||||
Array GLTFState::get_buffer_views() {
|
||||
return GLTFDocument::to_array(buffer_views);
|
||||
}
|
||||
|
||||
void GLTFState::set_buffer_views(Array p_buffer_views) {
|
||||
GLTFDocument::set_from_array(buffer_views, p_buffer_views);
|
||||
}
|
||||
|
||||
Array GLTFState::get_accessors() {
|
||||
return GLTFDocument::to_array(accessors);
|
||||
}
|
||||
|
||||
void GLTFState::set_accessors(Array p_accessors) {
|
||||
GLTFDocument::set_from_array(accessors, p_accessors);
|
||||
}
|
||||
|
||||
Array GLTFState::get_meshes() {
|
||||
return GLTFDocument::to_array(meshes);
|
||||
}
|
||||
|
||||
void GLTFState::set_meshes(Array p_meshes) {
|
||||
GLTFDocument::set_from_array(meshes, p_meshes);
|
||||
}
|
||||
|
||||
Array GLTFState::get_materials() {
|
||||
return GLTFDocument::to_array(materials);
|
||||
}
|
||||
|
||||
void GLTFState::set_materials(Array p_materials) {
|
||||
GLTFDocument::set_from_array(materials, p_materials);
|
||||
}
|
||||
|
||||
String GLTFState::get_scene_name() {
|
||||
return scene_name;
|
||||
}
|
||||
|
||||
void GLTFState::set_scene_name(String p_scene_name) {
|
||||
scene_name = p_scene_name;
|
||||
}
|
||||
|
||||
Array GLTFState::get_root_nodes() {
|
||||
return GLTFDocument::to_array(root_nodes);
|
||||
}
|
||||
|
||||
void GLTFState::set_root_nodes(Array p_root_nodes) {
|
||||
GLTFDocument::set_from_array(root_nodes, p_root_nodes);
|
||||
}
|
||||
|
||||
Array GLTFState::get_textures() {
|
||||
return GLTFDocument::to_array(textures);
|
||||
}
|
||||
|
||||
void GLTFState::set_textures(Array p_textures) {
|
||||
GLTFDocument::set_from_array(textures, p_textures);
|
||||
}
|
||||
|
||||
Array GLTFState::get_images() {
|
||||
return GLTFDocument::to_array(images);
|
||||
}
|
||||
|
||||
void GLTFState::set_images(Array p_images) {
|
||||
GLTFDocument::set_from_array(images, p_images);
|
||||
}
|
||||
|
||||
Array GLTFState::get_skins() {
|
||||
return GLTFDocument::to_array(skins);
|
||||
}
|
||||
|
||||
void GLTFState::set_skins(Array p_skins) {
|
||||
GLTFDocument::set_from_array(skins, p_skins);
|
||||
}
|
||||
|
||||
Array GLTFState::get_cameras() {
|
||||
return GLTFDocument::to_array(cameras);
|
||||
}
|
||||
|
||||
void GLTFState::set_cameras(Array p_cameras) {
|
||||
GLTFDocument::set_from_array(cameras, p_cameras);
|
||||
}
|
||||
|
||||
Array GLTFState::get_lights() {
|
||||
return GLTFDocument::to_array(lights);
|
||||
}
|
||||
|
||||
void GLTFState::set_lights(Array p_lights) {
|
||||
GLTFDocument::set_from_array(lights, p_lights);
|
||||
}
|
||||
|
||||
Array GLTFState::get_unique_names() {
|
||||
return GLTFDocument::to_array(unique_names);
|
||||
}
|
||||
|
||||
void GLTFState::set_unique_names(Array p_unique_names) {
|
||||
GLTFDocument::set_from_array(unique_names, p_unique_names);
|
||||
}
|
||||
|
||||
Array GLTFState::get_unique_animation_names() {
|
||||
return GLTFDocument::to_array(unique_animation_names);
|
||||
}
|
||||
|
||||
void GLTFState::set_unique_animation_names(Array p_unique_animation_names) {
|
||||
GLTFDocument::set_from_array(unique_animation_names, p_unique_animation_names);
|
||||
}
|
||||
|
||||
Array GLTFState::get_skeletons() {
|
||||
return GLTFDocument::to_array(skeletons);
|
||||
}
|
||||
|
||||
void GLTFState::set_skeletons(Array p_skeletons) {
|
||||
GLTFDocument::set_from_array(skeletons, p_skeletons);
|
||||
}
|
||||
|
||||
Dictionary GLTFState::get_skeleton_to_node() {
|
||||
return GLTFDocument::to_dict(skeleton_to_node);
|
||||
}
|
||||
|
||||
void GLTFState::set_skeleton_to_node(Dictionary p_skeleton_to_node) {
|
||||
GLTFDocument::set_from_dict(skeleton_to_node, p_skeleton_to_node);
|
||||
}
|
||||
|
||||
Array GLTFState::get_animations() {
|
||||
return GLTFDocument::to_array(animations);
|
||||
}
|
||||
|
||||
void GLTFState::set_animations(Array p_animations) {
|
||||
GLTFDocument::set_from_array(animations, p_animations);
|
||||
}
|
||||
|
||||
Node *GLTFState::get_scene_node(GLTFNodeIndex idx) {
|
||||
if (!scene_nodes.has(idx)) {
|
||||
return nullptr;
|
||||
}
|
||||
return scene_nodes[idx];
|
||||
}
|
||||
|
||||
int GLTFState::get_animation_players_count(int idx) {
|
||||
return animation_players.size();
|
||||
}
|
||||
|
||||
AnimationPlayer *GLTFState::get_animation_player(int idx) {
|
||||
ERR_FAIL_INDEX_V(idx, animation_players.size(), nullptr);
|
||||
return animation_players[idx];
|
||||
}
|
186
modules/gltf/gltf_state.h
Normal file
186
modules/gltf/gltf_state.h
Normal file
|
@ -0,0 +1,186 @@
|
|||
/*************************************************************************/
|
||||
/* gltf_state.h */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2021 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 "core/resource.h"
|
||||
#include "core/vector.h"
|
||||
#include "editor_scene_importer_gltf.h"
|
||||
#include "gltf_accessor.h"
|
||||
#include "gltf_animation.h"
|
||||
#include "gltf_buffer_view.h"
|
||||
#include "gltf_camera.h"
|
||||
#include "gltf_document.h"
|
||||
#include "gltf_light.h"
|
||||
#include "gltf_mesh.h"
|
||||
#include "gltf_node.h"
|
||||
#include "gltf_skeleton.h"
|
||||
#include "gltf_skin.h"
|
||||
#include "gltf_texture.h"
|
||||
#include "scene/animation/animation_player.h"
|
||||
#include "scene/resources/texture.h"
|
||||
|
||||
class GLTFState : public Resource {
|
||||
GDCLASS(GLTFState, Resource);
|
||||
friend class GLTFDocument;
|
||||
friend class PackedSceneGLTF;
|
||||
|
||||
String filename;
|
||||
Dictionary json;
|
||||
int major_version = 0;
|
||||
int minor_version = 0;
|
||||
Vector<uint8_t> glb_data;
|
||||
|
||||
bool use_named_skin_binds = false;
|
||||
bool use_legacy_names = 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;
|
||||
Map<Ref<Material>, GLTFMaterialIndex> material_cache;
|
||||
Vector<Ref<Material>> materials;
|
||||
|
||||
String scene_name;
|
||||
Vector<int> root_nodes;
|
||||
Vector<Ref<GLTFTexture>> textures;
|
||||
Vector<Ref<Texture>> images;
|
||||
|
||||
Vector<Ref<GLTFSkin>> skins;
|
||||
Vector<Ref<GLTFCamera>> cameras;
|
||||
Vector<Ref<GLTFLight>> lights;
|
||||
Set<String> unique_names;
|
||||
Set<String> unique_animation_names;
|
||||
|
||||
Vector<Ref<GLTFSkeleton>> skeletons;
|
||||
Map<GLTFSkeletonIndex, GLTFNodeIndex> skeleton_to_node;
|
||||
Vector<Ref<GLTFAnimation>> animations;
|
||||
Map<GLTFNodeIndex, Node *> scene_nodes;
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
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(Map<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;
|
||||
//}
|
||||
|
||||
//Map<Ref<Material>, GLTFMaterialIndex> get_material_cache() {
|
||||
// return this->material_cache;
|
||||
//}
|
||||
//void set_material_cache(Map<Ref<Material>, GLTFMaterialIndex> p_material_cache) {
|
||||
// this->material_cache = p_material_cache;
|
||||
//}
|
||||
};
|
||||
#endif // GLTF_STATE_H
|
46
modules/gltf/gltf_texture.cpp
Normal file
46
modules/gltf/gltf_texture.cpp
Normal file
|
@ -0,0 +1,46 @@
|
|||
/*************************************************************************/
|
||||
/* gltf_texture.cpp */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2021 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;
|
||||
}
|
51
modules/gltf/gltf_texture.h
Normal file
51
modules/gltf/gltf_texture.h
Normal file
|
@ -0,0 +1,51 @@
|
|||
/*************************************************************************/
|
||||
/* gltf_texture.h */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2021 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/resource.h"
|
||||
#include "gltf_document.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
|
88
modules/gltf/register_types.cpp
Normal file
88
modules/gltf/register_types.cpp
Normal file
|
@ -0,0 +1,88 @@
|
|||
/*************************************************************************/
|
||||
/* register_types.cpp */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2021 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 "register_types.h"
|
||||
|
||||
#include "editor/editor_node.h"
|
||||
#include "editor_scene_exporter_gltf_plugin.h"
|
||||
#include "editor_scene_importer_gltf.h"
|
||||
#include "gltf_accessor.h"
|
||||
#include "gltf_animation.h"
|
||||
#include "gltf_buffer_view.h"
|
||||
#include "gltf_camera.h"
|
||||
#include "gltf_document.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"
|
||||
|
||||
#ifndef _3D_DISABLED
|
||||
#ifdef TOOLS_ENABLED
|
||||
static void _editor_init() {
|
||||
Ref<EditorSceneImporterGLTF> import_gltf;
|
||||
import_gltf.instance();
|
||||
ResourceImporterScene::get_singleton()->add_importer(import_gltf);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
void register_gltf_types() {
|
||||
#ifndef _3D_DISABLED
|
||||
#ifdef TOOLS_ENABLED
|
||||
ClassDB::APIType prev_api = ClassDB::get_current_api();
|
||||
ClassDB::set_current_api(ClassDB::API_EDITOR);
|
||||
ClassDB::register_class<EditorSceneImporterGLTF>();
|
||||
ClassDB::register_class<GLTFMesh>();
|
||||
EditorPlugins::add_by_type<SceneExporterGLTFPlugin>();
|
||||
ClassDB::set_current_api(prev_api);
|
||||
EditorNode::add_init_callback(_editor_init);
|
||||
#endif
|
||||
ClassDB::register_class<GLTFSpecGloss>();
|
||||
ClassDB::register_class<GLTFNode>();
|
||||
ClassDB::register_class<GLTFAnimation>();
|
||||
ClassDB::register_class<GLTFBufferView>();
|
||||
ClassDB::register_class<GLTFAccessor>();
|
||||
ClassDB::register_class<GLTFTexture>();
|
||||
ClassDB::register_class<GLTFSkeleton>();
|
||||
ClassDB::register_class<GLTFSkin>();
|
||||
ClassDB::register_class<GLTFCamera>();
|
||||
ClassDB::register_class<GLTFLight>();
|
||||
ClassDB::register_class<GLTFState>();
|
||||
ClassDB::register_class<GLTFDocument>();
|
||||
ClassDB::register_class<PackedSceneGLTF>();
|
||||
#endif
|
||||
}
|
||||
|
||||
void unregister_gltf_types() {
|
||||
}
|
32
modules/gltf/register_types.h
Normal file
32
modules/gltf/register_types.h
Normal file
|
@ -0,0 +1,32 @@
|
|||
/*************************************************************************/
|
||||
/* register_types.h */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2021 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. */
|
||||
/*************************************************************************/
|
||||
|
||||
void register_gltf_types();
|
||||
void unregister_gltf_types();
|
Loading…
Reference in a new issue