| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
#pragma once |
| 32 |
|
| 33 |
#include "editor/import/3d/resource_importer_scene.h" |
| 34 |
#include "scene/3d/camera_3d.h" |
| 35 |
#include "scene/3d/light_3d.h" |
| 36 |
#include "scene/3d/mesh_instance_3d.h" |
| 37 |
#include "scene/3d/skeleton_3d.h" |
| 38 |
#include "scene/gui/dialogs.h" |
| 39 |
#include "scene/gui/menu_button.h" |
| 40 |
#include "scene/gui/option_button.h" |
| 41 |
#include "scene/gui/panel_container.h" |
| 42 |
#include "scene/gui/slider.h" |
| 43 |
#include "scene/gui/split_container.h" |
| 44 |
#include "scene/gui/tab_container.h" |
| 45 |
#include "scene/gui/tree.h" |
| 46 |
#include "scene/resources/3d/primitive_meshes.h" |
| 47 |
#include "scene/resources/3d/sky_material.h" |
| 48 |
|
| 49 |
class EditorFileDialog; |
| 50 |
class EditorInspector; |
| 51 |
class SceneImportSettingsData; |
| 52 |
class Timer; |
| 53 |
|
| 54 |
class SceneImportSettingsDialog : public ConfirmationDialog { |
| 55 |
GDCLASS(SceneImportSettingsDialog, ConfirmationDialog) |
| 56 |
|
| 57 |
static SceneImportSettingsDialog *singleton; |
| 58 |
|
| 59 |
enum Actions { |
| 60 |
ACTION_EXTRACT_MATERIALS, |
| 61 |
ACTION_CHOOSE_MESH_SAVE_PATHS, |
| 62 |
ACTION_CHOOSE_ANIMATION_SAVE_PATHS, |
| 63 |
}; |
| 64 |
|
| 65 |
Node *scene = nullptr; |
| 66 |
|
| 67 |
HSplitContainer *tree_split = nullptr; |
| 68 |
HSplitContainer *property_split = nullptr; |
| 69 |
TabContainer *data_mode = nullptr; |
| 70 |
Tree *scene_tree = nullptr; |
| 71 |
Tree *mesh_tree = nullptr; |
| 72 |
Tree *material_tree = nullptr; |
| 73 |
|
| 74 |
EditorInspector *inspector = nullptr; |
| 75 |
|
| 76 |
SubViewport *base_viewport = nullptr; |
| 77 |
|
| 78 |
Camera3D *camera = nullptr; |
| 79 |
Ref<CameraAttributesPractical> camera_attributes; |
| 80 |
Ref<Environment> environment; |
| 81 |
Ref<Sky> sky; |
| 82 |
Ref<ProceduralSkyMaterial> procedural_sky_material; |
| 83 |
bool first_aabb = false; |
| 84 |
AABB contents_aabb; |
| 85 |
|
| 86 |
Button *light_1_switch = nullptr; |
| 87 |
Button *light_2_switch = nullptr; |
| 88 |
Button *light_rotate_switch = nullptr; |
| 89 |
|
| 90 |
struct ThemeCache { |
| 91 |
Ref<Texture2D> light_1_icon; |
| 92 |
Ref<Texture2D> light_2_icon; |
| 93 |
Ref<Texture2D> rotate_icon; |
| 94 |
} theme_cache; |
| 95 |
|
| 96 |
DirectionalLight3D *light1 = nullptr; |
| 97 |
DirectionalLight3D *light2 = nullptr; |
| 98 |
Ref<ArrayMesh> selection_mesh; |
| 99 |
MeshInstance3D *node_selected = nullptr; |
| 100 |
|
| 101 |
MeshInstance3D *mesh_preview = nullptr; |
| 102 |
Ref<SphereMesh> material_preview; |
| 103 |
|
| 104 |
AnimationPlayer *animation_player = nullptr; |
| 105 |
List<Skeleton3D *> skeletons; |
| 106 |
PanelContainer *animation_preview = nullptr; |
| 107 |
HSlider *animation_slider = nullptr; |
| 108 |
Button *animation_play_button = nullptr; |
| 109 |
Button *animation_stop_button = nullptr; |
| 110 |
Button *animation_toggle_skeleton_visibility = nullptr; |
| 111 |
Animation::LoopMode animation_loop_mode = Animation::LOOP_NONE; |
| 112 |
bool animation_pingpong = false; |
| 113 |
bool previous_import_as_skeleton = false; |
| 114 |
bool previous_rest_as_reset = false; |
| 115 |
MeshInstance3D *bones_mesh_preview = nullptr; |
| 116 |
|
| 117 |
Ref<StandardMaterial3D> collider_mat; |
| 118 |
|
| 119 |
float cam_rot_x = 0.0f; |
| 120 |
float cam_rot_y = 0.0f; |
| 121 |
float cam_zoom = 0.0f; |
| 122 |
|
| 123 |
void _update_scene(); |
| 124 |
|
| 125 |
struct MaterialData { |
| 126 |
bool has_import_id; |
| 127 |
Ref<Material> material; |
| 128 |
TreeItem *scene_node = nullptr; |
| 129 |
TreeItem *mesh_node = nullptr; |
| 130 |
TreeItem *material_node = nullptr; |
| 131 |
|
| 132 |
float cam_rot_x = -Math::PI / 4; |
| 133 |
float cam_rot_y = -Math::PI / 4; |
| 134 |
float cam_zoom = 1; |
| 135 |
|
| 136 |
HashMap<StringName, Variant> settings; |
| 137 |
}; |
| 138 |
HashMap<String, MaterialData> material_map; |
| 139 |
HashMap<Ref<Material>, String> unnamed_material_name_map; |
| 140 |
|
| 141 |
struct MeshData { |
| 142 |
bool has_import_id; |
| 143 |
Ref<Mesh> mesh; |
| 144 |
TreeItem *scene_node = nullptr; |
| 145 |
TreeItem *mesh_node = nullptr; |
| 146 |
|
| 147 |
float cam_rot_x = -Math::PI / 4; |
| 148 |
float cam_rot_y = -Math::PI / 4; |
| 149 |
float cam_zoom = 1; |
| 150 |
HashMap<StringName, Variant> settings; |
| 151 |
}; |
| 152 |
HashMap<String, MeshData> mesh_map; |
| 153 |
|
| 154 |
struct AnimationData { |
| 155 |
Ref<Animation> animation; |
| 156 |
TreeItem *scene_node = nullptr; |
| 157 |
HashMap<StringName, Variant> settings; |
| 158 |
}; |
| 159 |
HashMap<String, AnimationData> animation_map; |
| 160 |
|
| 161 |
struct NodeData { |
| 162 |
Node *node = nullptr; |
| 163 |
TreeItem *scene_node = nullptr; |
| 164 |
HashMap<StringName, Variant> settings; |
| 165 |
}; |
| 166 |
HashMap<String, NodeData> node_map; |
| 167 |
|
| 168 |
bool _get_current(const StringName &p_name, Variant &r_ret) const; |
| 169 |
void _set_default(const StringName &p_name, const Variant &p_value); |
| 170 |
void _fill_material(Tree *p_tree, const Ref<Material> &p_material, TreeItem *p_parent); |
| 171 |
void _fill_mesh(Tree *p_tree, const Ref<Mesh> &p_mesh, TreeItem *p_parent); |
| 172 |
void _fill_animation(Tree *p_tree, const Ref<Animation> &p_anim, const String &p_name, TreeItem *p_parent); |
| 173 |
void _fill_scene(Node *p_node, TreeItem *p_parent_item); |
| 174 |
|
| 175 |
HashSet<Ref<Mesh>> mesh_set; |
| 176 |
|
| 177 |
String selected_type; |
| 178 |
String selected_id; |
| 179 |
|
| 180 |
bool selecting = false; |
| 181 |
|
| 182 |
void _update_view_gizmos(); |
| 183 |
void _update_camera(); |
| 184 |
void _select(Tree *p_from, const String &p_type, const String &p_id); |
| 185 |
void _inspector_property_edited(const String &p_name); |
| 186 |
void _reset_bone_transforms(); |
| 187 |
void _play_animation(); |
| 188 |
void _stop_current_animation(); |
| 189 |
void _reset_animation(const String &p_animation_name = ""); |
| 190 |
void _animation_slider_value_changed(double p_value); |
| 191 |
void _animation_finished(const StringName &p_name); |
| 192 |
void _animation_update_skeleton_visibility(); |
| 193 |
void _material_tree_selected(); |
| 194 |
void _mesh_tree_selected(); |
| 195 |
void _scene_tree_selected(); |
| 196 |
void _skeleton_tree_entered(Skeleton3D *p_skeleton); |
| 197 |
void _cleanup(); |
| 198 |
void _on_light_1_switch_pressed(); |
| 199 |
void _on_light_2_switch_pressed(); |
| 200 |
void _on_light_rotate_switch_pressed(); |
| 201 |
|
| 202 |
void _viewport_input(const Ref<InputEvent> &p_input); |
| 203 |
|
| 204 |
HashMap<StringName, Variant> defaults; |
| 205 |
|
| 206 |
SceneImportSettingsData *scene_import_settings_data = nullptr; |
| 207 |
ResourceImporterScene *_resource_importer_scene = nullptr; |
| 208 |
|
| 209 |
void _re_import(); |
| 210 |
|
| 211 |
String base_path; |
| 212 |
|
| 213 |
MenuButton *action_menu = nullptr; |
| 214 |
|
| 215 |
ConfirmationDialog *external_paths = nullptr; |
| 216 |
Tree *external_path_tree = nullptr; |
| 217 |
EditorFileDialog *save_path = nullptr; |
| 218 |
OptionButton *external_extension_type = nullptr; |
| 219 |
|
| 220 |
EditorFileDialog *item_save_path = nullptr; |
| 221 |
|
| 222 |
void _menu_callback(int p_id); |
| 223 |
void _save_dir_callback(const String &p_path); |
| 224 |
|
| 225 |
int current_action = 0; |
| 226 |
|
| 227 |
Vector<TreeItem *> save_path_items; |
| 228 |
|
| 229 |
TreeItem *save_path_item = nullptr; |
| 230 |
void _save_path_changed(const String &p_path); |
| 231 |
void _browse_save_callback(Object *p_item, int p_column, int p_id, MouseButton p_button); |
| 232 |
void _save_dir_confirm(); |
| 233 |
|
| 234 |
Dictionary base_subresource_settings; |
| 235 |
|
| 236 |
void _load_default_subresource_settings(HashMap<StringName, Variant> &settings, const String &p_type, const String &p_import_id, ResourceImporterScene::InternalImportCategory p_category); |
| 237 |
|
| 238 |
bool generate_collider = false; |
| 239 |
|
| 240 |
Timer *update_view_timer = nullptr; |
| 241 |
|
| 242 |
protected: |
| 243 |
virtual void _update_theme_item_cache() override; |
| 244 |
void _notification(int p_what); |
| 245 |
|
| 246 |
public: |
| 247 |
ResourceImporterScene *get_resource_importer_scene() const { return _resource_importer_scene; } |
| 248 |
void request_generate_collider(); |
| 249 |
void update_view(); |
| 250 |
void open_settings(const String &p_path, const String &p_scene_import_type = "PackedScene"); |
| 251 |
static SceneImportSettingsDialog *get_singleton(); |
| 252 |
Node *get_selected_node(); |
| 253 |
SceneImportSettingsDialog(); |
| 254 |
~SceneImportSettingsDialog(); |
| 255 |
}; |