2021-03-19 20:57:52 +08:00
|
|
|
/*************************************************************************/
|
|
|
|
/* scene_import_settings.h */
|
|
|
|
/*************************************************************************/
|
|
|
|
/* This file is part of: */
|
|
|
|
/* GODOT ENGINE */
|
|
|
|
/* https://godotengine.org */
|
|
|
|
/*************************************************************************/
|
2022-01-04 04:27:34 +08:00
|
|
|
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
|
|
|
|
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
|
2021-03-19 20:57:52 +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. */
|
|
|
|
/*************************************************************************/
|
|
|
|
|
2022-05-02 22:28:25 +08:00
|
|
|
#ifndef SCENE_IMPORT_SETTINGS_H
|
|
|
|
#define SCENE_IMPORT_SETTINGS_H
|
2021-03-19 20:57:52 +08:00
|
|
|
|
|
|
|
#include "editor/import/resource_importer_scene.h"
|
|
|
|
#include "scene/3d/camera_3d.h"
|
|
|
|
#include "scene/3d/light_3d.h"
|
|
|
|
#include "scene/3d/mesh_instance_3d.h"
|
|
|
|
#include "scene/gui/dialogs.h"
|
|
|
|
#include "scene/gui/item_list.h"
|
|
|
|
#include "scene/gui/menu_button.h"
|
|
|
|
#include "scene/gui/option_button.h"
|
|
|
|
#include "scene/gui/split_container.h"
|
|
|
|
#include "scene/gui/subviewport_container.h"
|
|
|
|
#include "scene/gui/tab_container.h"
|
|
|
|
#include "scene/gui/tree.h"
|
|
|
|
#include "scene/resources/primitive_meshes.h"
|
|
|
|
|
2022-02-12 09:46:22 +08:00
|
|
|
class EditorFileDialog;
|
|
|
|
class EditorInspector;
|
2021-03-19 20:57:52 +08:00
|
|
|
class SceneImportSettingsData;
|
|
|
|
|
|
|
|
class SceneImportSettings : public ConfirmationDialog {
|
|
|
|
GDCLASS(SceneImportSettings, ConfirmationDialog)
|
|
|
|
|
|
|
|
static SceneImportSettings *singleton;
|
|
|
|
|
|
|
|
enum Actions {
|
|
|
|
ACTION_EXTRACT_MATERIALS,
|
|
|
|
ACTION_CHOOSE_MESH_SAVE_PATHS,
|
|
|
|
ACTION_CHOOSE_ANIMATION_SAVE_PATHS,
|
|
|
|
};
|
|
|
|
|
|
|
|
Node *scene = nullptr;
|
|
|
|
|
2022-04-04 21:06:57 +08:00
|
|
|
HSplitContainer *tree_split = nullptr;
|
|
|
|
HSplitContainer *property_split = nullptr;
|
|
|
|
TabContainer *data_mode = nullptr;
|
|
|
|
Tree *scene_tree = nullptr;
|
|
|
|
Tree *mesh_tree = nullptr;
|
|
|
|
Tree *material_tree = nullptr;
|
2021-03-19 20:57:52 +08:00
|
|
|
|
2022-04-04 21:06:57 +08:00
|
|
|
EditorInspector *inspector = nullptr;
|
2021-03-19 20:57:52 +08:00
|
|
|
|
2022-04-04 21:06:57 +08:00
|
|
|
SubViewport *base_viewport = nullptr;
|
2021-03-19 20:57:52 +08:00
|
|
|
|
2022-04-04 21:06:57 +08:00
|
|
|
Camera3D *camera = nullptr;
|
2022-08-01 07:20:24 +08:00
|
|
|
Ref<CameraAttributesPractical> camera_attributes;
|
2021-03-19 20:57:52 +08:00
|
|
|
bool first_aabb = false;
|
|
|
|
AABB contents_aabb;
|
|
|
|
|
2022-04-04 21:06:57 +08:00
|
|
|
DirectionalLight3D *light = nullptr;
|
2021-03-19 20:57:52 +08:00
|
|
|
Ref<ArrayMesh> selection_mesh;
|
2022-04-04 21:06:57 +08:00
|
|
|
MeshInstance3D *node_selected = nullptr;
|
2021-03-19 20:57:52 +08:00
|
|
|
|
2022-04-04 21:06:57 +08:00
|
|
|
MeshInstance3D *mesh_preview = nullptr;
|
2021-03-19 20:57:52 +08:00
|
|
|
Ref<SphereMesh> material_preview;
|
|
|
|
|
Improve collision generation usability in the new 3D scene import workflow.
With this PR it's possible to add a collision during the Mesh import, directly in editor.
To generate the shape is possible to chose between the following options:
- Decompose Convex: The Mesh is decomposed in one or many Convex Shapes (Using the VHACD library).
- Simple Convex: Is generated a convex shape that enclose the entire mesh.
- Trimesh: Generate a trimesh shape using the Mesh faces.
- Box: Add a primitive box shape, where you can tweak the `size`, `position`, `rotation`.
- Sphere: Add a primitive sphere shape, where you can tweak the `radius`, `position`, `rotation`.
- Cylinder: Add a primitive cylinder shape, where you can tweak the `height`, `radius`, `position`, `rotation`.
- Capsule: Add a primitive capsule shape, where you can tweak the `height`, `radius`, `position`, `rotation`.
It's also possible to chose the generated body, so you can create:
- Rigid Body
- Static Body
- Area
2021-08-23 00:19:13 +08:00
|
|
|
Ref<StandardMaterial3D> collider_mat;
|
|
|
|
|
2022-05-02 22:28:25 +08:00
|
|
|
float cam_rot_x = 0.0f;
|
|
|
|
float cam_rot_y = 0.0f;
|
|
|
|
float cam_zoom = 0.0f;
|
2021-03-19 20:57:52 +08:00
|
|
|
|
|
|
|
void _update_scene();
|
|
|
|
|
|
|
|
struct MaterialData {
|
|
|
|
bool has_import_id;
|
|
|
|
Ref<Material> material;
|
2022-04-04 21:06:57 +08:00
|
|
|
TreeItem *scene_node = nullptr;
|
|
|
|
TreeItem *mesh_node = nullptr;
|
|
|
|
TreeItem *material_node = nullptr;
|
2021-03-19 20:57:52 +08:00
|
|
|
|
|
|
|
float cam_rot_x = -Math_PI / 4;
|
|
|
|
float cam_rot_y = -Math_PI / 4;
|
|
|
|
float cam_zoom = 1;
|
|
|
|
|
2022-05-13 21:04:37 +08:00
|
|
|
HashMap<StringName, Variant> settings;
|
2021-03-19 20:57:52 +08:00
|
|
|
};
|
2022-05-13 21:04:37 +08:00
|
|
|
HashMap<String, MaterialData> material_map;
|
2021-03-19 20:57:52 +08:00
|
|
|
|
|
|
|
struct MeshData {
|
|
|
|
bool has_import_id;
|
|
|
|
Ref<Mesh> mesh;
|
2022-04-04 21:06:57 +08:00
|
|
|
TreeItem *scene_node = nullptr;
|
|
|
|
TreeItem *mesh_node = nullptr;
|
2021-03-19 20:57:52 +08:00
|
|
|
|
|
|
|
float cam_rot_x = -Math_PI / 4;
|
|
|
|
float cam_rot_y = -Math_PI / 4;
|
|
|
|
float cam_zoom = 1;
|
2022-05-13 21:04:37 +08:00
|
|
|
HashMap<StringName, Variant> settings;
|
2021-03-19 20:57:52 +08:00
|
|
|
};
|
2022-05-13 21:04:37 +08:00
|
|
|
HashMap<String, MeshData> mesh_map;
|
2021-03-19 20:57:52 +08:00
|
|
|
|
|
|
|
struct AnimationData {
|
|
|
|
Ref<Animation> animation;
|
2022-04-04 21:06:57 +08:00
|
|
|
TreeItem *scene_node = nullptr;
|
2022-05-13 21:04:37 +08:00
|
|
|
HashMap<StringName, Variant> settings;
|
2021-03-19 20:57:52 +08:00
|
|
|
};
|
2022-05-13 21:04:37 +08:00
|
|
|
HashMap<String, AnimationData> animation_map;
|
2021-03-19 20:57:52 +08:00
|
|
|
|
|
|
|
struct NodeData {
|
2022-04-04 21:06:57 +08:00
|
|
|
Node *node = nullptr;
|
|
|
|
TreeItem *scene_node = nullptr;
|
2022-05-13 21:04:37 +08:00
|
|
|
HashMap<StringName, Variant> settings;
|
2021-03-19 20:57:52 +08:00
|
|
|
};
|
2022-05-13 21:04:37 +08:00
|
|
|
HashMap<String, NodeData> node_map;
|
2021-03-19 20:57:52 +08:00
|
|
|
|
|
|
|
void _fill_material(Tree *p_tree, const Ref<Material> &p_material, TreeItem *p_parent);
|
|
|
|
void _fill_mesh(Tree *p_tree, const Ref<Mesh> &p_mesh, TreeItem *p_parent);
|
|
|
|
void _fill_animation(Tree *p_tree, const Ref<Animation> &p_anim, const String &p_name, TreeItem *p_parent);
|
|
|
|
void _fill_scene(Node *p_node, TreeItem *p_parent_item);
|
|
|
|
|
2022-05-19 23:00:06 +08:00
|
|
|
HashSet<Ref<Mesh>> mesh_set;
|
|
|
|
HashSet<Ref<Material>> material_set;
|
2021-03-19 20:57:52 +08:00
|
|
|
|
|
|
|
String selected_type;
|
|
|
|
String selected_id;
|
|
|
|
|
|
|
|
bool selecting = false;
|
|
|
|
|
Improve collision generation usability in the new 3D scene import workflow.
With this PR it's possible to add a collision during the Mesh import, directly in editor.
To generate the shape is possible to chose between the following options:
- Decompose Convex: The Mesh is decomposed in one or many Convex Shapes (Using the VHACD library).
- Simple Convex: Is generated a convex shape that enclose the entire mesh.
- Trimesh: Generate a trimesh shape using the Mesh faces.
- Box: Add a primitive box shape, where you can tweak the `size`, `position`, `rotation`.
- Sphere: Add a primitive sphere shape, where you can tweak the `radius`, `position`, `rotation`.
- Cylinder: Add a primitive cylinder shape, where you can tweak the `height`, `radius`, `position`, `rotation`.
- Capsule: Add a primitive capsule shape, where you can tweak the `height`, `radius`, `position`, `rotation`.
It's also possible to chose the generated body, so you can create:
- Rigid Body
- Static Body
- Area
2021-08-23 00:19:13 +08:00
|
|
|
void _update_view_gizmos();
|
2021-03-19 20:57:52 +08:00
|
|
|
void _update_camera();
|
|
|
|
void _select(Tree *p_from, String p_type, String p_id);
|
|
|
|
void _material_tree_selected();
|
|
|
|
void _mesh_tree_selected();
|
|
|
|
void _scene_tree_selected();
|
|
|
|
|
|
|
|
void _viewport_input(const Ref<InputEvent> &p_input);
|
|
|
|
|
2022-05-13 21:04:37 +08:00
|
|
|
HashMap<StringName, Variant> defaults;
|
2021-03-19 20:57:52 +08:00
|
|
|
|
2022-04-04 21:06:57 +08:00
|
|
|
SceneImportSettingsData *scene_import_settings_data = nullptr;
|
2021-03-19 20:57:52 +08:00
|
|
|
|
|
|
|
void _re_import();
|
|
|
|
|
|
|
|
String base_path;
|
|
|
|
|
2022-04-04 21:06:57 +08:00
|
|
|
MenuButton *action_menu = nullptr;
|
2021-03-19 20:57:52 +08:00
|
|
|
|
2022-04-04 21:06:57 +08:00
|
|
|
ConfirmationDialog *external_paths = nullptr;
|
|
|
|
Tree *external_path_tree = nullptr;
|
|
|
|
EditorFileDialog *save_path = nullptr;
|
|
|
|
OptionButton *external_extension_type = nullptr;
|
2021-03-19 20:57:52 +08:00
|
|
|
|
2022-04-04 21:06:57 +08:00
|
|
|
EditorFileDialog *item_save_path = nullptr;
|
2021-03-19 20:57:52 +08:00
|
|
|
|
|
|
|
void _menu_callback(int p_id);
|
|
|
|
void _save_dir_callback(const String &p_path);
|
|
|
|
|
2022-05-02 22:28:25 +08:00
|
|
|
int current_action = 0;
|
2021-03-19 20:57:52 +08:00
|
|
|
|
|
|
|
Vector<TreeItem *> save_path_items;
|
|
|
|
|
|
|
|
TreeItem *save_path_item = nullptr;
|
|
|
|
void _save_path_changed(const String &p_path);
|
2021-09-18 15:33:18 +08:00
|
|
|
void _browse_save_callback(Object *p_item, int p_column, int p_id, MouseButton p_button);
|
2021-03-19 20:57:52 +08:00
|
|
|
void _save_dir_confirm();
|
|
|
|
|
|
|
|
Dictionary base_subresource_settings;
|
|
|
|
|
2022-05-13 21:04:37 +08:00
|
|
|
void _load_default_subresource_settings(HashMap<StringName, Variant> &settings, const String &p_type, const String &p_import_id, ResourceImporterScene::InternalImportCategory p_category);
|
2021-03-19 20:57:52 +08:00
|
|
|
|
2022-04-12 22:07:09 +08:00
|
|
|
bool editing_animation = false;
|
|
|
|
|
2022-09-06 17:15:00 +08:00
|
|
|
Timer *update_view_timer = nullptr;
|
2022-04-12 22:07:09 +08:00
|
|
|
|
2021-03-19 20:57:52 +08:00
|
|
|
protected:
|
|
|
|
void _notification(int p_what);
|
|
|
|
|
|
|
|
public:
|
2022-04-12 22:07:09 +08:00
|
|
|
bool is_editing_animation() const { return editing_animation; }
|
Improve collision generation usability in the new 3D scene import workflow.
With this PR it's possible to add a collision during the Mesh import, directly in editor.
To generate the shape is possible to chose between the following options:
- Decompose Convex: The Mesh is decomposed in one or many Convex Shapes (Using the VHACD library).
- Simple Convex: Is generated a convex shape that enclose the entire mesh.
- Trimesh: Generate a trimesh shape using the Mesh faces.
- Box: Add a primitive box shape, where you can tweak the `size`, `position`, `rotation`.
- Sphere: Add a primitive sphere shape, where you can tweak the `radius`, `position`, `rotation`.
- Cylinder: Add a primitive cylinder shape, where you can tweak the `height`, `radius`, `position`, `rotation`.
- Capsule: Add a primitive capsule shape, where you can tweak the `height`, `radius`, `position`, `rotation`.
It's also possible to chose the generated body, so you can create:
- Rigid Body
- Static Body
- Area
2021-08-23 00:19:13 +08:00
|
|
|
void update_view();
|
2022-04-12 22:07:09 +08:00
|
|
|
void open_settings(const String &p_path, bool p_for_animation = false);
|
2021-03-19 20:57:52 +08:00
|
|
|
static SceneImportSettings *get_singleton();
|
2022-06-27 16:06:50 +08:00
|
|
|
Node *get_selected_node();
|
2021-03-19 20:57:52 +08:00
|
|
|
SceneImportSettings();
|
|
|
|
~SceneImportSettings();
|
|
|
|
};
|
|
|
|
|
2022-05-02 22:28:25 +08:00
|
|
|
#endif // SCENE_IMPORT_SETTINGS_H
|