2017-01-16 08:04:19 +01:00
|
|
|
/**************************************************************************/
|
2020-03-27 08:44:44 +01:00
|
|
|
/* mesh_instance_3d_editor_plugin.h */
|
2017-01-16 08:04:19 +01:00
|
|
|
/**************************************************************************/
|
|
|
|
/* 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. */
|
|
|
|
/**************************************************************************/
|
2018-01-05 00:50:27 +01:00
|
|
|
|
2022-07-23 23:41:51 +02:00
|
|
|
#ifndef MESH_INSTANCE_3D_EDITOR_PLUGIN_H
|
|
|
|
#define MESH_INSTANCE_3D_EDITOR_PLUGIN_H
|
2016-05-23 22:10:26 +02:00
|
|
|
|
2024-04-21 10:11:35 +02:00
|
|
|
#include "editor/plugins/editor_plugin.h"
|
2020-03-26 22:49:16 +01:00
|
|
|
#include "scene/3d/mesh_instance_3d.h"
|
2023-12-30 06:24:01 +01:00
|
|
|
#include "scene/gui/option_button.h"
|
2016-05-23 22:10:26 +02:00
|
|
|
|
2022-11-11 20:12:48 +01:00
|
|
|
class AcceptDialog;
|
|
|
|
class ConfirmationDialog;
|
|
|
|
class MenuButton;
|
2023-04-07 18:59:49 +02:00
|
|
|
class SpinBox;
|
2022-11-11 20:12:48 +01:00
|
|
|
|
2020-03-27 08:44:44 +01:00
|
|
|
class MeshInstance3DEditor : public Control {
|
|
|
|
GDCLASS(MeshInstance3DEditor, Control);
|
2016-05-23 22:10:26 +02:00
|
|
|
|
|
|
|
enum Menu {
|
2023-12-30 06:24:01 +01:00
|
|
|
MENU_OPTION_CREATE_COLLISION_SHAPE,
|
2016-05-23 22:10:26 +02:00
|
|
|
MENU_OPTION_CREATE_NAVMESH,
|
|
|
|
MENU_OPTION_CREATE_OUTLINE_MESH,
|
2022-06-19 02:01:19 +02:00
|
|
|
MENU_OPTION_CREATE_DEBUG_TANGENTS,
|
2017-12-09 18:11:26 +01:00
|
|
|
MENU_OPTION_CREATE_UV2,
|
|
|
|
MENU_OPTION_DEBUG_UV1,
|
|
|
|
MENU_OPTION_DEBUG_UV2,
|
2016-05-23 22:10:26 +02:00
|
|
|
};
|
|
|
|
|
2023-12-30 06:24:01 +01:00
|
|
|
enum ShapePlacement {
|
|
|
|
SHAPE_PLACEMENT_SIBLING,
|
|
|
|
SHAPE_PLACEMENT_STATIC_BODY_CHILD,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum ShapeType {
|
|
|
|
SHAPE_TYPE_TRIMESH,
|
|
|
|
SHAPE_TYPE_SINGLE_CONVEX,
|
|
|
|
SHAPE_TYPE_SIMPLIFIED_CONVEX,
|
|
|
|
SHAPE_TYPE_MULTIPLE_CONVEX,
|
|
|
|
};
|
|
|
|
|
2022-04-04 15:06:57 +02:00
|
|
|
MeshInstance3D *node = nullptr;
|
2016-05-23 22:10:26 +02:00
|
|
|
|
2022-04-04 15:06:57 +02:00
|
|
|
MenuButton *options = nullptr;
|
2016-05-23 22:10:26 +02:00
|
|
|
|
2022-04-04 15:06:57 +02:00
|
|
|
ConfirmationDialog *outline_dialog = nullptr;
|
|
|
|
SpinBox *outline_size = nullptr;
|
2016-05-23 22:10:26 +02:00
|
|
|
|
2023-12-30 06:24:01 +01:00
|
|
|
ConfirmationDialog *shape_dialog = nullptr;
|
|
|
|
OptionButton *shape_type = nullptr;
|
|
|
|
OptionButton *shape_placement = nullptr;
|
|
|
|
|
2022-04-04 15:06:57 +02:00
|
|
|
AcceptDialog *err_dialog = nullptr;
|
2016-05-23 22:10:26 +02:00
|
|
|
|
2022-04-04 15:06:57 +02:00
|
|
|
AcceptDialog *debug_uv_dialog = nullptr;
|
|
|
|
Control *debug_uv = nullptr;
|
2017-12-09 18:11:26 +01:00
|
|
|
Vector<Vector2> uv_lines;
|
|
|
|
|
2024-06-02 14:04:25 +02:00
|
|
|
ConfirmationDialog *navigation_mesh_dialog = nullptr;
|
|
|
|
|
2023-12-30 06:24:01 +01:00
|
|
|
void _create_collision_shape();
|
|
|
|
Vector<Ref<Shape3D>> create_shape_from_mesh(Ref<Mesh> p_mesh, int p_option, bool p_verbose);
|
2016-05-23 22:10:26 +02:00
|
|
|
void _menu_option(int p_option);
|
|
|
|
void _create_outline_mesh();
|
2024-06-02 14:04:25 +02:00
|
|
|
void _create_navigation_mesh();
|
2016-05-23 22:10:26 +02:00
|
|
|
|
2017-12-09 18:11:26 +01:00
|
|
|
void _create_uv_lines(int p_layer);
|
2020-03-27 08:44:44 +01:00
|
|
|
friend class MeshInstance3DEditorPlugin;
|
2016-05-23 22:10:26 +02:00
|
|
|
|
2017-12-09 18:11:26 +01:00
|
|
|
void _debug_uv_draw();
|
|
|
|
|
2016-05-23 22:10:26 +02:00
|
|
|
protected:
|
|
|
|
void _node_removed(Node *p_node);
|
2023-09-13 13:14:07 +02:00
|
|
|
|
|
|
|
void _notification(int p_what);
|
2016-05-23 22:10:26 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
public:
|
2020-03-26 22:49:16 +01:00
|
|
|
void edit(MeshInstance3D *p_mesh);
|
2020-03-27 08:44:44 +01:00
|
|
|
MeshInstance3DEditor();
|
2016-05-23 22:10:26 +02:00
|
|
|
};
|
|
|
|
|
2020-03-27 08:44:44 +01:00
|
|
|
class MeshInstance3DEditorPlugin : public EditorPlugin {
|
|
|
|
GDCLASS(MeshInstance3DEditorPlugin, EditorPlugin);
|
2016-05-23 22:10:26 +02:00
|
|
|
|
2022-04-04 15:06:57 +02:00
|
|
|
MeshInstance3DEditor *mesh_editor = nullptr;
|
2016-05-23 22:10:26 +02:00
|
|
|
|
|
|
|
public:
|
2020-07-10 12:34:39 +02:00
|
|
|
virtual String get_name() const override { return "MeshInstance3D"; }
|
|
|
|
bool has_main_screen() const override { return false; }
|
|
|
|
virtual void edit(Object *p_object) override;
|
|
|
|
virtual bool handles(Object *p_object) const override;
|
|
|
|
virtual void make_visible(bool p_visible) override;
|
2016-05-23 22:10:26 +02:00
|
|
|
|
2022-01-27 10:36:51 +01:00
|
|
|
MeshInstance3DEditorPlugin();
|
2020-03-27 08:44:44 +01:00
|
|
|
~MeshInstance3DEditorPlugin();
|
2016-05-23 22:10:26 +02:00
|
|
|
};
|
|
|
|
|
2022-07-23 23:41:51 +02:00
|
|
|
#endif // MESH_INSTANCE_3D_EDITOR_PLUGIN_H
|