2023-01-10 15:26:54 +01:00
|
|
|
/**************************************************************************/
|
|
|
|
/* mesh_instance_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-05 00:50:27 +01:00
|
|
|
|
2016-05-23 22:10:26 +02:00
|
|
|
#ifndef MESH_INSTANCE_EDITOR_PLUGIN_H
|
|
|
|
#define MESH_INSTANCE_EDITOR_PLUGIN_H
|
|
|
|
|
2017-03-05 14:21:25 +01:00
|
|
|
#include "editor/editor_node.h"
|
2017-03-05 16:44:50 +01:00
|
|
|
#include "editor/editor_plugin.h"
|
2016-05-23 22:10:26 +02:00
|
|
|
#include "scene/3d/mesh_instance.h"
|
|
|
|
#include "scene/gui/spin_box.h"
|
|
|
|
|
2017-12-13 13:26:55 +01:00
|
|
|
class MeshInstanceEditor : public Control {
|
|
|
|
GDCLASS(MeshInstanceEditor, 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-10 00:31:05 +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
|
|
|
};
|
|
|
|
|
|
|
|
MeshInstance *node;
|
|
|
|
|
|
|
|
MenuButton *options;
|
|
|
|
|
|
|
|
ConfirmationDialog *outline_dialog;
|
|
|
|
SpinBox *outline_size;
|
|
|
|
|
|
|
|
AcceptDialog *err_dialog;
|
|
|
|
|
2017-12-09 18:11:26 +01:00
|
|
|
AcceptDialog *debug_uv_dialog;
|
|
|
|
Control *debug_uv;
|
|
|
|
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);
|
2017-03-05 16:44:50 +01:00
|
|
|
friend class MeshInstanceEditorPlugin;
|
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:
|
2016-05-23 22:10:26 +02:00
|
|
|
void edit(MeshInstance *p_mesh);
|
|
|
|
MeshInstanceEditor();
|
|
|
|
};
|
|
|
|
|
|
|
|
class MeshInstanceEditorPlugin : public EditorPlugin {
|
2017-03-05 16:44:50 +01:00
|
|
|
GDCLASS(MeshInstanceEditorPlugin, EditorPlugin);
|
2016-05-23 22:10:26 +02:00
|
|
|
|
|
|
|
MeshInstanceEditor *mesh_editor;
|
|
|
|
EditorNode *editor;
|
|
|
|
|
|
|
|
public:
|
|
|
|
virtual String get_name() const { return "MeshInstance"; }
|
|
|
|
bool has_main_screen() const { return false; }
|
2017-08-12 18:52:50 +02:00
|
|
|
virtual void edit(Object *p_object);
|
|
|
|
virtual bool handles(Object *p_object) const;
|
2016-05-23 22:10:26 +02:00
|
|
|
virtual void make_visible(bool p_visible);
|
|
|
|
|
|
|
|
MeshInstanceEditorPlugin(EditorNode *p_node);
|
|
|
|
~MeshInstanceEditorPlugin();
|
|
|
|
};
|
|
|
|
|
2022-07-25 12:33:41 +02:00
|
|
|
#endif // MESH_INSTANCE_EDITOR_PLUGIN_H
|