2023-01-05 12:25:55 +00:00
|
|
|
/**************************************************************************/
|
|
|
|
/* mesh_instance_3d_editor_plugin.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. */
|
|
|
|
/**************************************************************************/
|
2018-01-04 23:50:27 +00:00
|
|
|
|
2022-07-23 21:41:51 +00:00
|
|
|
#ifndef MESH_INSTANCE_3D_EDITOR_PLUGIN_H
|
|
|
|
#define MESH_INSTANCE_3D_EDITOR_PLUGIN_H
|
2016-05-23 20:10:26 +00:00
|
|
|
|
2017-03-05 13:21:25 +00:00
|
|
|
#include "editor/editor_plugin.h"
|
2020-03-26 21:49:16 +00:00
|
|
|
#include "scene/3d/mesh_instance_3d.h"
|
2016-05-23 20:10:26 +00:00
|
|
|
#include "scene/gui/spin_box.h"
|
|
|
|
|
2022-11-11 19:12:48 +00:00
|
|
|
class AcceptDialog;
|
|
|
|
class ConfirmationDialog;
|
|
|
|
class MenuButton;
|
|
|
|
|
2020-03-27 07:44:44 +00:00
|
|
|
class MeshInstance3DEditor : public Control {
|
|
|
|
GDCLASS(MeshInstance3DEditor, Control);
|
2016-05-23 20:10:26 +00:00
|
|
|
|
|
|
|
enum Menu {
|
|
|
|
MENU_OPTION_CREATE_STATIC_TRIMESH_BODY,
|
|
|
|
MENU_OPTION_CREATE_TRIMESH_COLLISION_SHAPE,
|
2020-01-31 15:30:27 +00:00
|
|
|
MENU_OPTION_CREATE_SINGLE_CONVEX_COLLISION_SHAPE,
|
2021-07-07 19:14:12 +00:00
|
|
|
MENU_OPTION_CREATE_SIMPLIFIED_CONVEX_COLLISION_SHAPE,
|
2020-01-31 15:30:27 +00:00
|
|
|
MENU_OPTION_CREATE_MULTIPLE_CONVEX_COLLISION_SHAPES,
|
2016-05-23 20:10:26 +00:00
|
|
|
MENU_OPTION_CREATE_NAVMESH,
|
|
|
|
MENU_OPTION_CREATE_OUTLINE_MESH,
|
2022-06-19 00:01:19 +00:00
|
|
|
MENU_OPTION_CREATE_DEBUG_TANGENTS,
|
2017-12-09 17:11:26 +00:00
|
|
|
MENU_OPTION_CREATE_UV2,
|
|
|
|
MENU_OPTION_DEBUG_UV1,
|
|
|
|
MENU_OPTION_DEBUG_UV2,
|
2016-05-23 20:10:26 +00:00
|
|
|
};
|
|
|
|
|
2022-04-04 13:06:57 +00:00
|
|
|
MeshInstance3D *node = nullptr;
|
2016-05-23 20:10:26 +00:00
|
|
|
|
2022-04-04 13:06:57 +00:00
|
|
|
MenuButton *options = nullptr;
|
2016-05-23 20:10:26 +00:00
|
|
|
|
2022-04-04 13:06:57 +00:00
|
|
|
ConfirmationDialog *outline_dialog = nullptr;
|
|
|
|
SpinBox *outline_size = nullptr;
|
2016-05-23 20:10:26 +00:00
|
|
|
|
2022-04-04 13:06:57 +00:00
|
|
|
AcceptDialog *err_dialog = nullptr;
|
2016-05-23 20:10:26 +00:00
|
|
|
|
2022-04-04 13:06:57 +00:00
|
|
|
AcceptDialog *debug_uv_dialog = nullptr;
|
|
|
|
Control *debug_uv = nullptr;
|
2017-12-09 17:11:26 +00:00
|
|
|
Vector<Vector2> uv_lines;
|
|
|
|
|
2016-05-23 20:10:26 +00:00
|
|
|
void _menu_option(int p_option);
|
|
|
|
void _create_outline_mesh();
|
|
|
|
|
2017-12-09 17:11:26 +00:00
|
|
|
void _create_uv_lines(int p_layer);
|
2020-03-27 07:44:44 +00:00
|
|
|
friend class MeshInstance3DEditorPlugin;
|
2016-05-23 20:10:26 +00:00
|
|
|
|
2017-12-09 17:11:26 +00:00
|
|
|
void _debug_uv_draw();
|
|
|
|
|
2016-05-23 20:10:26 +00:00
|
|
|
protected:
|
|
|
|
void _node_removed(Node *p_node);
|
|
|
|
static void _bind_methods();
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
public:
|
2020-03-26 21:49:16 +00:00
|
|
|
void edit(MeshInstance3D *p_mesh);
|
2020-03-27 07:44:44 +00:00
|
|
|
MeshInstance3DEditor();
|
2016-05-23 20:10:26 +00:00
|
|
|
};
|
|
|
|
|
2020-03-27 07:44:44 +00:00
|
|
|
class MeshInstance3DEditorPlugin : public EditorPlugin {
|
|
|
|
GDCLASS(MeshInstance3DEditorPlugin, EditorPlugin);
|
2016-05-23 20:10:26 +00:00
|
|
|
|
2022-04-04 13:06:57 +00:00
|
|
|
MeshInstance3DEditor *mesh_editor = nullptr;
|
2016-05-23 20:10:26 +00:00
|
|
|
|
|
|
|
public:
|
2020-07-10 10:34:39 +00: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 20:10:26 +00:00
|
|
|
|
2022-01-27 09:36:51 +00:00
|
|
|
MeshInstance3DEditorPlugin();
|
2020-03-27 07:44:44 +00:00
|
|
|
~MeshInstance3DEditorPlugin();
|
2016-05-23 20:10:26 +00:00
|
|
|
};
|
|
|
|
|
2022-07-23 21:41:51 +00:00
|
|
|
#endif // MESH_INSTANCE_3D_EDITOR_PLUGIN_H
|