| 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/plugins/editor_plugin.h" |
| 34 |
#include "scene/3d/mesh_instance_3d.h" |
| 35 |
#include "scene/gui/option_button.h" |
| 36 |
|
| 37 |
class AcceptDialog; |
| 38 |
class AspectRatioContainer; |
| 39 |
class ConfirmationDialog; |
| 40 |
class MenuButton; |
| 41 |
class SpinBox; |
| 42 |
|
| 43 |
class MeshInstance3DEditor : public Control { |
| 44 |
GDCLASS(MeshInstance3DEditor, Control); |
| 45 |
|
| 46 |
enum Menu { |
| 47 |
MENU_OPTION_CREATE_COLLISION_SHAPE, |
| 48 |
MENU_OPTION_CREATE_NAVMESH, |
| 49 |
MENU_OPTION_CREATE_OUTLINE_MESH, |
| 50 |
MENU_OPTION_CREATE_DEBUG_TANGENTS, |
| 51 |
MENU_OPTION_CREATE_UV2, |
| 52 |
MENU_OPTION_DEBUG_UV1, |
| 53 |
MENU_OPTION_DEBUG_UV2, |
| 54 |
}; |
| 55 |
|
| 56 |
enum ShapePlacement { |
| 57 |
SHAPE_PLACEMENT_SIBLING, |
| 58 |
SHAPE_PLACEMENT_STATIC_BODY_CHILD, |
| 59 |
}; |
| 60 |
|
| 61 |
enum ShapeType { |
| 62 |
SHAPE_TYPE_TRIMESH, |
| 63 |
SHAPE_TYPE_SINGLE_CONVEX, |
| 64 |
SHAPE_TYPE_SIMPLIFIED_CONVEX, |
| 65 |
SHAPE_TYPE_MULTIPLE_CONVEX, |
| 66 |
SHAPE_TYPE_BOUNDING_BOX, |
| 67 |
SHAPE_TYPE_CAPSULE, |
| 68 |
SHAPE_TYPE_CYLINDER, |
| 69 |
SHAPE_TYPE_SPHERE, |
| 70 |
SHAPE_TYPE_PRIMITIVE, |
| 71 |
}; |
| 72 |
|
| 73 |
enum ShapeAxis { |
| 74 |
SHAPE_AXIS_X, |
| 75 |
SHAPE_AXIS_Y, |
| 76 |
SHAPE_AXIS_Z, |
| 77 |
SHAPE_AXIS_LONGEST, |
| 78 |
}; |
| 79 |
|
| 80 |
MeshInstance3D *node = nullptr; |
| 81 |
|
| 82 |
MenuButton *options = nullptr; |
| 83 |
|
| 84 |
ConfirmationDialog *outline_dialog = nullptr; |
| 85 |
SpinBox *outline_size = nullptr; |
| 86 |
|
| 87 |
ConfirmationDialog *shape_dialog = nullptr; |
| 88 |
OptionButton *shape_type = nullptr; |
| 89 |
OptionButton *shape_placement = nullptr; |
| 90 |
Label *shape_axis_label = nullptr; |
| 91 |
OptionButton *shape_axis = nullptr; |
| 92 |
Transform3D shape_offset_transform; |
| 93 |
|
| 94 |
AcceptDialog *err_dialog = nullptr; |
| 95 |
|
| 96 |
AcceptDialog *debug_uv_dialog = nullptr; |
| 97 |
AspectRatioContainer *debug_uv_arc = nullptr; |
| 98 |
Control *debug_uv = nullptr; |
| 99 |
Vector<Vector2> uv_lines; |
| 100 |
|
| 101 |
ConfirmationDialog *navigation_mesh_dialog = nullptr; |
| 102 |
|
| 103 |
void _shape_dialog_about_to_popup(); |
| 104 |
void _shape_type_selected(int p_option); |
| 105 |
void _create_collision_shape(); |
| 106 |
Vector<Ref<Shape3D>> create_shape_from_mesh(Ref<Mesh> p_mesh, int p_option, bool p_verbose); |
| 107 |
void _menu_option(int p_option); |
| 108 |
void _create_outline_mesh(); |
| 109 |
void _create_navigation_mesh(); |
| 110 |
|
| 111 |
void _create_uv_lines(int p_layer); |
| 112 |
friend class MeshInstance3DEditorPlugin; |
| 113 |
|
| 114 |
void _debug_uv_draw(); |
| 115 |
|
| 116 |
protected: |
| 117 |
void _node_removed(Node *p_node); |
| 118 |
|
| 119 |
void _notification(int p_what); |
| 120 |
|
| 121 |
public: |
| 122 |
void edit(MeshInstance3D *p_mesh); |
| 123 |
MeshInstance3DEditor(); |
| 124 |
}; |
| 125 |
|
| 126 |
class MeshInstance3DEditorPlugin : public EditorPlugin { |
| 127 |
GDCLASS(MeshInstance3DEditorPlugin, EditorPlugin); |
| 128 |
|
| 129 |
MeshInstance3DEditor *mesh_editor = nullptr; |
| 130 |
|
| 131 |
public: |
| 132 |
virtual String get_plugin_name() const override { return "MeshInstance3D"; } |
| 133 |
bool has_main_screen() const override { return false; } |
| 134 |
virtual void edit(Object *p_object) override; |
| 135 |
virtual bool handles(Object *p_object) const override; |
| 136 |
virtual void make_visible(bool p_visible) override; |
| 137 |
|
| 138 |
MeshInstance3DEditorPlugin(); |
| 139 |
}; |