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 */
|
2017-08-27 14:16:55 +02:00
|
|
|
/* https://godotengine.org */
|
2017-01-16 08:04:19 +01:00
|
|
|
/*************************************************************************/
|
2022-01-03 21:27:34 +01:00
|
|
|
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
|
|
|
|
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
|
2017-01-16 08:04:19 +01: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. */
|
|
|
|
/*************************************************************************/
|
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
|
|
|
|
2017-03-05 14:21:25 +01:00
|
|
|
#include "editor/editor_plugin.h"
|
2020-03-26 22:49:16 +01:00
|
|
|
#include "scene/3d/mesh_instance_3d.h"
|
2016-05-23 22:10:26 +02:00
|
|
|
#include "scene/gui/spin_box.h"
|
|
|
|
|
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 {
|
|
|
|
MENU_OPTION_CREATE_STATIC_TRIMESH_BODY,
|
|
|
|
MENU_OPTION_CREATE_TRIMESH_COLLISION_SHAPE,
|
2020-01-31 16:30:27 +01:00
|
|
|
MENU_OPTION_CREATE_SINGLE_CONVEX_COLLISION_SHAPE,
|
2021-07-07 21:14:12 +02:00
|
|
|
MENU_OPTION_CREATE_SIMPLIFIED_CONVEX_COLLISION_SHAPE,
|
2020-01-31 16:30:27 +01:00
|
|
|
MENU_OPTION_CREATE_MULTIPLE_CONVEX_COLLISION_SHAPES,
|
2016-05-23 22:10:26 +02:00
|
|
|
MENU_OPTION_CREATE_NAVMESH,
|
|
|
|
MENU_OPTION_CREATE_OUTLINE_MESH,
|
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
|
|
|
};
|
|
|
|
|
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
|
|
|
|
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;
|
|
|
|
|
2016-05-23 22:10:26 +02:00
|
|
|
void _menu_option(int p_option);
|
|
|
|
void _create_outline_mesh();
|
|
|
|
|
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);
|
|
|
|
static void _bind_methods();
|
|
|
|
|
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
|