2017-03-05 22:47:28 +08:00
|
|
|
/*************************************************************************/
|
|
|
|
/* resource_importer_scene.h */
|
|
|
|
/*************************************************************************/
|
|
|
|
/* This file is part of: */
|
|
|
|
/* GODOT ENGINE */
|
2017-08-27 20:16:55 +08:00
|
|
|
/* https://godotengine.org */
|
2017-03-05 22:47:28 +08:00
|
|
|
/*************************************************************************/
|
|
|
|
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
|
2017-04-08 06:11:42 +08:00
|
|
|
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
|
2017-03-05 22:47:28 +08:00
|
|
|
/* */
|
|
|
|
/* 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. */
|
|
|
|
/*************************************************************************/
|
2017-02-04 20:48:04 +08:00
|
|
|
#ifndef RESOURCEIMPORTERSCENE_H
|
|
|
|
#define RESOURCEIMPORTERSCENE_H
|
|
|
|
|
|
|
|
#include "io/resource_import.h"
|
|
|
|
#include "scene/resources/animation.h"
|
2017-06-08 05:18:55 +08:00
|
|
|
#include "scene/resources/mesh.h"
|
2017-02-04 20:48:04 +08:00
|
|
|
#include "scene/resources/shape.h"
|
|
|
|
|
2017-02-05 07:31:15 +08:00
|
|
|
class Material;
|
|
|
|
|
2017-02-04 20:48:04 +08:00
|
|
|
class EditorSceneImporter : public Reference {
|
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
GDCLASS(EditorSceneImporter, Reference);
|
2017-02-04 20:48:04 +08:00
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
public:
|
2017-02-04 20:48:04 +08:00
|
|
|
enum ImportFlags {
|
2017-03-05 23:44:50 +08:00
|
|
|
IMPORT_SCENE = 1,
|
|
|
|
IMPORT_ANIMATION = 2,
|
|
|
|
IMPORT_ANIMATION_DETECT_LOOP = 4,
|
|
|
|
IMPORT_ANIMATION_OPTIMIZE = 8,
|
|
|
|
IMPORT_ANIMATION_FORCE_ALL_TRACKS_IN_ALL_CLIPS = 16,
|
|
|
|
IMPORT_ANIMATION_KEEP_VALUE_TRACKS = 32,
|
|
|
|
IMPORT_GENERATE_TANGENT_ARRAYS = 256,
|
|
|
|
IMPORT_FAIL_ON_MISSING_DEPENDENCIES = 512,
|
|
|
|
IMPORT_MATERIALS_IN_INSTANCES = 1024
|
2017-02-04 20:48:04 +08:00
|
|
|
|
|
|
|
};
|
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
virtual uint32_t get_import_flags() const = 0;
|
|
|
|
virtual void get_extensions(List<String> *r_extensions) const = 0;
|
|
|
|
virtual Node *import_scene(const String &p_path, uint32_t p_flags, int p_bake_fps, List<String> *r_missing_deps, Error *r_err = NULL) = 0;
|
|
|
|
virtual Ref<Animation> import_animation(const String &p_path, uint32_t p_flags) = 0;
|
2017-02-04 20:48:04 +08:00
|
|
|
|
|
|
|
EditorSceneImporter() {}
|
|
|
|
};
|
|
|
|
|
|
|
|
class EditorScenePostImport : public Reference {
|
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
GDCLASS(EditorScenePostImport, Reference);
|
2017-02-04 20:48:04 +08:00
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
protected:
|
2017-02-04 20:48:04 +08:00
|
|
|
static void _bind_methods();
|
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
public:
|
|
|
|
virtual Node *post_import(Node *p_scene);
|
2017-02-04 20:48:04 +08:00
|
|
|
EditorScenePostImport();
|
|
|
|
};
|
|
|
|
|
|
|
|
class ResourceImporterScene : public ResourceImporter {
|
2017-03-05 23:44:50 +08:00
|
|
|
GDCLASS(ResourceImporterScene, ResourceImporter)
|
2017-02-04 20:48:04 +08:00
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
Set<Ref<EditorSceneImporter> > importers;
|
2017-02-04 20:48:04 +08:00
|
|
|
|
|
|
|
static ResourceImporterScene *singleton;
|
|
|
|
|
2017-07-24 05:48:05 +08:00
|
|
|
enum Presets {
|
|
|
|
PRESET_SEPARATE_MATERIALS,
|
|
|
|
PRESET_SEPARATE_MESHES,
|
2017-09-19 16:51:00 +08:00
|
|
|
PRESET_SEPARATE_ANIMATIONS,
|
2017-09-08 19:06:09 +08:00
|
|
|
|
2017-08-30 08:54:26 +08:00
|
|
|
PRESET_SINGLE_SCENE,
|
2017-09-08 19:06:09 +08:00
|
|
|
|
2017-07-24 05:48:05 +08:00
|
|
|
PRESET_SEPARATE_MESHES_AND_MATERIALS,
|
2017-09-08 19:06:09 +08:00
|
|
|
PRESET_SEPARATE_MESHES_AND_ANIMATIONS,
|
2017-09-19 16:51:00 +08:00
|
|
|
PRESET_SEPARATE_MATERIALS_AND_ANIMATIONS,
|
|
|
|
PRESET_SEPARATE_MESHES_MATERIALS_AND_ANIMATIONS,
|
2017-09-08 19:06:09 +08:00
|
|
|
|
2017-07-24 05:48:05 +08:00
|
|
|
PRESET_MULTIPLE_SCENES,
|
|
|
|
PRESET_MULTIPLE_SCENES_AND_MATERIALS,
|
2017-09-21 07:59:19 +08:00
|
|
|
PRESET_MAX
|
2017-07-24 05:48:05 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
void _replace_owner(Node *p_node, Node *p_scene, Node *p_new_owner);
|
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
public:
|
2017-02-04 20:48:04 +08:00
|
|
|
static ResourceImporterScene *get_singleton() { return singleton; }
|
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
const Set<Ref<EditorSceneImporter> > &get_importers() const { return importers; }
|
2017-02-04 20:48:04 +08:00
|
|
|
|
|
|
|
void add_importer(Ref<EditorSceneImporter> p_importer) { importers.insert(p_importer); }
|
|
|
|
|
|
|
|
virtual String get_importer_name() const;
|
|
|
|
virtual String get_visible_name() const;
|
|
|
|
virtual void get_recognized_extensions(List<String> *p_extensions) const;
|
|
|
|
virtual String get_save_extension() const;
|
|
|
|
virtual String get_resource_type() const;
|
|
|
|
|
|
|
|
virtual int get_preset_count() const;
|
|
|
|
virtual String get_preset_name(int p_idx) const;
|
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
virtual void get_import_options(List<ImportOption> *r_options, int p_preset = 0) const;
|
|
|
|
virtual bool get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const;
|
2017-09-21 07:59:19 +08:00
|
|
|
virtual int get_import_order() const { return 100; } //after everything
|
2017-02-04 20:48:04 +08:00
|
|
|
|
2017-09-15 01:49:11 +08:00
|
|
|
void _make_external_resources(Node *p_node, const String &p_base_path, bool p_make_animations, bool p_make_materials, bool p_keep_materials, bool p_make_meshes, Map<Ref<Animation>, Ref<Animation> > &p_animations, Map<Ref<Material>, Ref<Material> > &p_materials, Map<Ref<ArrayMesh>, Ref<ArrayMesh> > &p_meshes);
|
2017-02-05 07:31:15 +08:00
|
|
|
|
2017-06-08 05:18:55 +08:00
|
|
|
Node *_fix_node(Node *p_node, Node *p_root, Map<Ref<ArrayMesh>, Ref<Shape> > &collision_map);
|
2017-02-04 20:48:04 +08:00
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
void _create_clips(Node *scene, const Array &p_clips, bool p_bake_all);
|
|
|
|
void _filter_anim_tracks(Ref<Animation> anim, Set<String> &keep);
|
|
|
|
void _filter_tracks(Node *scene, const String &p_text);
|
|
|
|
void _optimize_animations(Node *scene, float p_max_lin_error, float p_max_ang_error, float p_max_angle);
|
2017-02-04 20:48:04 +08:00
|
|
|
|
2017-03-05 23:44:50 +08:00
|
|
|
virtual Error import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = NULL);
|
2017-02-04 20:48:04 +08:00
|
|
|
|
|
|
|
ResourceImporterScene();
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // RESOURCEIMPORTERSCENE_H
|