| 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/inspector/editor_inspector.h" |
| 34 |
#include "editor/plugins/editor_plugin.h" |
| 35 |
#include "scene/3d/camera_3d.h" |
| 36 |
#include "scene/3d/light_3d.h" |
| 37 |
#include "scene/3d/mesh_instance_3d.h" |
| 38 |
#include "scene/gui/subviewport_container.h" |
| 39 |
#include "scene/resources/camera_attributes.h" |
| 40 |
|
| 41 |
class SubViewport; |
| 42 |
class Button; |
| 43 |
|
| 44 |
class MeshEditor : public SubViewportContainer { |
| 45 |
GDCLASS(MeshEditor, SubViewportContainer); |
| 46 |
|
| 47 |
float rot_x; |
| 48 |
float rot_y; |
| 49 |
|
| 50 |
SubViewport *viewport = nullptr; |
| 51 |
MeshInstance3D *mesh_instance = nullptr; |
| 52 |
Node3D *rotation = nullptr; |
| 53 |
DirectionalLight3D *light1 = nullptr; |
| 54 |
DirectionalLight3D *light2 = nullptr; |
| 55 |
Camera3D *camera = nullptr; |
| 56 |
Ref<CameraAttributesPractical> camera_attributes; |
| 57 |
|
| 58 |
Ref<Mesh> mesh; |
| 59 |
|
| 60 |
Button *light_1_switch = nullptr; |
| 61 |
Button *light_2_switch = nullptr; |
| 62 |
|
| 63 |
struct ThemeCache { |
| 64 |
Ref<Texture2D> light_1_icon; |
| 65 |
Ref<Texture2D> light_2_icon; |
| 66 |
} theme_cache; |
| 67 |
|
| 68 |
void _on_light_1_switch_pressed(); |
| 69 |
void _on_light_2_switch_pressed(); |
| 70 |
void _update_rotation(); |
| 71 |
|
| 72 |
protected: |
| 73 |
virtual void _update_theme_item_cache() override; |
| 74 |
void _notification(int p_what); |
| 75 |
void gui_input(const Ref<InputEvent> &p_event) override; |
| 76 |
|
| 77 |
public: |
| 78 |
void edit(Ref<Mesh> p_mesh); |
| 79 |
MeshEditor(); |
| 80 |
}; |
| 81 |
|
| 82 |
class EditorInspectorPluginMesh : public EditorInspectorPlugin { |
| 83 |
GDCLASS(EditorInspectorPluginMesh, EditorInspectorPlugin); |
| 84 |
|
| 85 |
public: |
| 86 |
virtual bool can_handle(Object *p_object) override; |
| 87 |
virtual void parse_begin(Object *p_object) override; |
| 88 |
}; |
| 89 |
|
| 90 |
class MeshEditorPlugin : public EditorPlugin { |
| 91 |
GDCLASS(MeshEditorPlugin, EditorPlugin); |
| 92 |
|
| 93 |
public: |
| 94 |
virtual String get_plugin_name() const override { return "Mesh"; } |
| 95 |
|
| 96 |
MeshEditorPlugin(); |
| 97 |
}; |