2021-03-19 13:57:52 +01:00
|
|
|
/**************************************************************************/
|
|
|
|
/* scene_import_settings.h */
|
|
|
|
/**************************************************************************/
|
|
|
|
/* This file is part of: */
|
|
|
|
/* GODOT ENGINE */
|
|
|
|
/* https://godotengine.org */
|
|
|
|
/**************************************************************************/
|
|
|
|
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
|
|
|
|
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
|
|
|
|
/* */
|
|
|
|
/* 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 16:28:25 +02:00
|
|
|
#ifndef SCENE_IMPORT_SETTINGS_H
|
|
|
|
#define SCENE_IMPORT_SETTINGS_H
|
2021-03-19 13:57:52 +01:00
|
|
|
|
2021-10-09 08:12:51 +02:00
|
|
|
#include "editor/import/3d/resource_importer_scene.h"
|
2021-03-19 13:57:52 +01:00
|
|
|
#include "scene/3d/camera_3d.h"
|
|
|
|
#include "scene/3d/light_3d.h"
|
|
|
|
#include "scene/3d/mesh_instance_3d.h"
|
2023-04-23 13:53:45 +02:00
|
|
|
#include "scene/3d/skeleton_3d.h"
|
2021-03-19 13:57:52 +01:00
|
|
|
#include "scene/gui/dialogs.h"
|
|
|
|
#include "scene/gui/item_list.h"
|
|
|
|
#include "scene/gui/menu_button.h"
|
|
|
|
#include "scene/gui/option_button.h"
|
2023-04-23 13:53:45 +02:00
|
|
|
#include "scene/gui/panel_container.h"
|
|
|
|
#include "scene/gui/slider.h"
|
2021-03-19 13:57:52 +01:00
|
|
|
#include "scene/gui/split_container.h"
|
|
|
|
#include "scene/gui/subviewport_container.h"
|
|
|
|
#include "scene/gui/tab_container.h"
|
|
|
|
#include "scene/gui/tree.h"
|
2021-08-13 18:42:45 +02:00
|
|
|
#include "scene/resources/3d/primitive_meshes.h"
|
2021-03-19 13:57:52 +01:00
|
|
|
|
2022-02-12 02:46:22 +01:00
|
|
|
class EditorFileDialog;
|
|
|
|
class EditorInspector;
|
2021-03-19 13:57:52 +01:00
|
|
|
class SceneImportSettingsData;
|
|
|
|
|
2023-10-06 09:00:36 +02:00
|
|
|
class SceneImportSettingsDialog : public ConfirmationDialog {
|
|
|
|
GDCLASS(SceneImportSettingsDialog, ConfirmationDialog)
|
2021-03-19 13:57:52 +01:00
|
|
|
|
2023-10-06 09:00:36 +02:00
|
|
|
static SceneImportSettingsDialog *singleton;
|
2021-03-19 13:57:52 +01:00
|
|
|
|
|
|
|
enum Actions {
|
|
|
|
ACTION_EXTRACT_MATERIALS,
|
|
|
|
ACTION_CHOOSE_MESH_SAVE_PATHS,
|
|
|
|
ACTION_CHOOSE_ANIMATION_SAVE_PATHS,
|
|
|
|
};
|
|
|
|
|
|
|
|
Node *scene = nullptr;
|
|
|
|
|
2022-04-04 15:06:57 +02: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 13:57:52 +01:00
|
|
|
|
2022-04-04 15:06:57 +02:00
|
|
|
EditorInspector *inspector = nullptr;
|
2021-03-19 13:57:52 +01:00
|
|
|
|
2022-04-04 15:06:57 +02:00
|
|
|
SubViewport *base_viewport = nullptr;
|
2021-03-19 13:57:52 +01:00
|
|
|
|
2022-04-04 15:06:57 +02:00
|
|
|
Camera3D *camera = nullptr;
|
2022-08-01 01:20:24 +02:00
|
|
|
Ref<CameraAttributesPractical> camera_attributes;
|
2021-03-19 13:57:52 +01:00
|
|
|
bool first_aabb = false;
|
|
|
|
AABB contents_aabb;
|
|
|
|
|
2022-04-04 15:06:57 +02:00
|
|
|
DirectionalLight3D *light = nullptr;
|
2021-03-19 13:57:52 +01:00
|
|
|
Ref<ArrayMesh> selection_mesh;
|
2022-04-04 15:06:57 +02:00
|
|
|
MeshInstance3D *node_selected = nullptr;
|
2021-03-19 13:57:52 +01:00
|
|
|
|
2022-04-04 15:06:57 +02:00
|
|
|
MeshInstance3D *mesh_preview = nullptr;
|
2021-03-19 13:57:52 +01:00
|
|
|
Ref<SphereMesh> material_preview;
|
|
|
|
|
2023-04-23 13:53:45 +02:00
|
|
|
AnimationPlayer *animation_player = nullptr;
|
|
|
|
List<Skeleton3D *> skeletons;
|
|
|
|
PanelContainer *animation_preview = nullptr;
|
|
|
|
HSlider *animation_slider = nullptr;
|
|
|
|
Button *animation_play_button = nullptr;
|
|
|
|
Button *animation_stop_button = nullptr;
|
|
|
|
Animation::LoopMode animation_loop_mode = Animation::LOOP_NONE;
|
|
|
|
bool animation_pingpong = false;
|
2024-02-25 09:36:39 +01:00
|
|
|
bool previous_import_as_skeleton = false;
|
2024-03-18 04:29:29 +01:00
|
|
|
bool previous_rest_as_reset = false;
|
2023-04-23 13:53:45 +02:00
|
|
|
|
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-22 18:19:13 +02:00
|
|
|
Ref<StandardMaterial3D> collider_mat;
|
|
|
|
|
2022-05-02 16:28:25 +02:00
|
|
|
float cam_rot_x = 0.0f;
|
|
|
|
float cam_rot_y = 0.0f;
|
|
|
|
float cam_zoom = 0.0f;
|
2021-03-19 13:57:52 +01:00
|
|
|
|
|
|
|
void _update_scene();
|
|
|
|
|
|
|
|
struct MaterialData {
|
|
|
|
bool has_import_id;
|
|
|
|
Ref<Material> material;
|
2022-04-04 15:06:57 +02:00
|
|
|
TreeItem *scene_node = nullptr;
|
|
|
|
TreeItem *mesh_node = nullptr;
|
|
|
|
TreeItem *material_node = nullptr;
|
2021-03-19 13:57:52 +01:00
|
|
|
|
|
|
|
float cam_rot_x = -Math_PI / 4;
|
|
|
|
float cam_rot_y = -Math_PI / 4;
|
|
|
|
float cam_zoom = 1;
|
|
|
|
|
2022-05-13 15:04:37 +02:00
|
|
|
HashMap<StringName, Variant> settings;
|
2021-03-19 13:57:52 +01:00
|
|
|
};
|
2022-05-13 15:04:37 +02:00
|
|
|
HashMap<String, MaterialData> material_map;
|
2022-12-09 17:01:40 +01:00
|
|
|
HashMap<Ref<Material>, String> unnamed_material_name_map;
|
2021-03-19 13:57:52 +01:00
|
|
|
|
|
|
|
struct MeshData {
|
|
|
|
bool has_import_id;
|
|
|
|
Ref<Mesh> mesh;
|
2022-04-04 15:06:57 +02:00
|
|
|
TreeItem *scene_node = nullptr;
|
|
|
|
TreeItem *mesh_node = nullptr;
|
2021-03-19 13:57:52 +01:00
|
|
|
|
|
|
|
float cam_rot_x = -Math_PI / 4;
|
|
|
|
float cam_rot_y = -Math_PI / 4;
|
|
|
|
float cam_zoom = 1;
|
2022-05-13 15:04:37 +02:00
|
|
|
HashMap<StringName, Variant> settings;
|
2021-03-19 13:57:52 +01:00
|
|
|
};
|
2022-05-13 15:04:37 +02:00
|
|
|
HashMap<String, MeshData> mesh_map;
|
2021-03-19 13:57:52 +01:00
|
|
|
|
|
|
|
struct AnimationData {
|
|
|
|
Ref<Animation> animation;
|
2022-04-04 15:06:57 +02:00
|
|
|
TreeItem *scene_node = nullptr;
|
2022-05-13 15:04:37 +02:00
|
|
|
HashMap<StringName, Variant> settings;
|
2021-03-19 13:57:52 +01:00
|
|
|
};
|
2022-05-13 15:04:37 +02:00
|
|
|
HashMap<String, AnimationData> animation_map;
|
2021-03-19 13:57:52 +01:00
|
|
|
|
|
|
|
struct NodeData {
|
2022-04-04 15:06:57 +02:00
|
|
|
Node *node = nullptr;
|
|
|
|
TreeItem *scene_node = nullptr;
|
2022-05-13 15:04:37 +02:00
|
|
|
HashMap<StringName, Variant> settings;
|
2021-03-19 13:57:52 +01:00
|
|
|
};
|
2022-05-13 15:04:37 +02:00
|
|
|
HashMap<String, NodeData> node_map;
|
2021-03-19 13:57:52 +01: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 17:00:06 +02:00
|
|
|
HashSet<Ref<Mesh>> mesh_set;
|
2021-03-19 13:57:52 +01: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-22 18:19:13 +02:00
|
|
|
void _update_view_gizmos();
|
2021-03-19 13:57:52 +01:00
|
|
|
void _update_camera();
|
2024-02-15 17:25:58 +01:00
|
|
|
void _select(Tree *p_from, const String &p_type, const String &p_id);
|
2023-04-23 13:53:45 +02:00
|
|
|
void _inspector_property_edited(const String &p_name);
|
|
|
|
void _reset_bone_transforms();
|
|
|
|
void _play_animation();
|
|
|
|
void _stop_current_animation();
|
|
|
|
void _reset_animation(const String &p_animation_name = "");
|
|
|
|
void _animation_slider_value_changed(double p_value);
|
|
|
|
void _animation_finished(const StringName &p_name);
|
2021-03-19 13:57:52 +01:00
|
|
|
void _material_tree_selected();
|
|
|
|
void _mesh_tree_selected();
|
|
|
|
void _scene_tree_selected();
|
2023-04-23 13:53:45 +02:00
|
|
|
void _cleanup();
|
2021-03-19 13:57:52 +01:00
|
|
|
|
|
|
|
void _viewport_input(const Ref<InputEvent> &p_input);
|
|
|
|
|
2022-05-13 15:04:37 +02:00
|
|
|
HashMap<StringName, Variant> defaults;
|
2021-03-19 13:57:52 +01:00
|
|
|
|
2022-04-04 15:06:57 +02:00
|
|
|
SceneImportSettingsData *scene_import_settings_data = nullptr;
|
2021-03-19 13:57:52 +01:00
|
|
|
|
|
|
|
void _re_import();
|
|
|
|
|
|
|
|
String base_path;
|
|
|
|
|
2022-04-04 15:06:57 +02:00
|
|
|
MenuButton *action_menu = nullptr;
|
2021-03-19 13:57:52 +01:00
|
|
|
|
2022-04-04 15:06:57 +02:00
|
|
|
ConfirmationDialog *external_paths = nullptr;
|
|
|
|
Tree *external_path_tree = nullptr;
|
|
|
|
EditorFileDialog *save_path = nullptr;
|
|
|
|
OptionButton *external_extension_type = nullptr;
|
2021-03-19 13:57:52 +01:00
|
|
|
|
2022-04-04 15:06:57 +02:00
|
|
|
EditorFileDialog *item_save_path = nullptr;
|
2021-03-19 13:57:52 +01:00
|
|
|
|
|
|
|
void _menu_callback(int p_id);
|
|
|
|
void _save_dir_callback(const String &p_path);
|
|
|
|
|
2022-05-02 16:28:25 +02:00
|
|
|
int current_action = 0;
|
2021-03-19 13:57:52 +01:00
|
|
|
|
|
|
|
Vector<TreeItem *> save_path_items;
|
|
|
|
|
|
|
|
TreeItem *save_path_item = nullptr;
|
|
|
|
void _save_path_changed(const String &p_path);
|
2021-09-18 09:33:18 +02:00
|
|
|
void _browse_save_callback(Object *p_item, int p_column, int p_id, MouseButton p_button);
|
2021-03-19 13:57:52 +01:00
|
|
|
void _save_dir_confirm();
|
|
|
|
|
|
|
|
Dictionary base_subresource_settings;
|
|
|
|
|
2022-05-13 15:04:37 +02: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 13:57:52 +01:00
|
|
|
|
2022-04-12 16:07:09 +02:00
|
|
|
bool editing_animation = false;
|
2023-01-19 20:34:05 +01:00
|
|
|
bool generate_collider = false;
|
2022-04-12 16:07:09 +02:00
|
|
|
|
2022-09-06 11:15:00 +02:00
|
|
|
Timer *update_view_timer = nullptr;
|
2022-04-12 16:07:09 +02:00
|
|
|
|
2021-03-19 13:57:52 +01:00
|
|
|
protected:
|
|
|
|
void _notification(int p_what);
|
|
|
|
|
|
|
|
public:
|
2022-04-12 16:07:09 +02:00
|
|
|
bool is_editing_animation() const { return editing_animation; }
|
2023-01-19 20:34:05 +01:00
|
|
|
void request_generate_collider();
|
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-22 18:19:13 +02:00
|
|
|
void update_view();
|
2022-04-12 16:07:09 +02:00
|
|
|
void open_settings(const String &p_path, bool p_for_animation = false);
|
2023-10-06 09:00:36 +02:00
|
|
|
static SceneImportSettingsDialog *get_singleton();
|
2022-06-27 10:06:50 +02:00
|
|
|
Node *get_selected_node();
|
2023-10-06 09:00:36 +02:00
|
|
|
SceneImportSettingsDialog();
|
|
|
|
~SceneImportSettingsDialog();
|
2021-03-19 13:57:52 +01:00
|
|
|
};
|
|
|
|
|
2022-05-02 16:28:25 +02:00
|
|
|
#endif // SCENE_IMPORT_SETTINGS_H
|