| 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/gui/spin_box.h" |
| 36 |
#include "scene/resources/shader.h" |
| 37 |
#include "scene/resources/texture.h" |
| 38 |
|
| 39 |
class ColorChannelSelector; |
| 40 |
|
| 41 |
class Texture3DEditor : public Control { |
| 42 |
GDCLASS(Texture3DEditor, Control); |
| 43 |
|
| 44 |
struct ThemeCache { |
| 45 |
Color outline_color; |
| 46 |
} theme_cache; |
| 47 |
|
| 48 |
SpinBox *layer = nullptr; |
| 49 |
Label *info = nullptr; |
| 50 |
Ref<Texture3D> texture; |
| 51 |
|
| 52 |
static inline Ref<Shader> texture_shader; |
| 53 |
Ref<ShaderMaterial> texture_material; |
| 54 |
|
| 55 |
Control *texture_rect = nullptr; |
| 56 |
|
| 57 |
ColorChannelSelector *channel_selector = nullptr; |
| 58 |
|
| 59 |
bool setting = false; |
| 60 |
|
| 61 |
void _draw_outline(); |
| 62 |
|
| 63 |
void _layer_changed(double) { |
| 64 |
if (!setting) { |
| 65 |
_update_material(false); |
| 66 |
} |
| 67 |
} |
| 68 |
|
| 69 |
void _texture_changed(); |
| 70 |
|
| 71 |
void _texture_rect_update_area(); |
| 72 |
void _texture_rect_draw(); |
| 73 |
|
| 74 |
void _update_material(bool p_texture_changed); |
| 75 |
void _update_gui(); |
| 76 |
|
| 77 |
void on_selected_channels_changed(); |
| 78 |
|
| 79 |
protected: |
| 80 |
void _notification(int p_what); |
| 81 |
|
| 82 |
public: |
| 83 |
static void init_shaders(); |
| 84 |
static void finish_shaders(); |
| 85 |
|
| 86 |
void edit(Ref<Texture3D> p_texture); |
| 87 |
|
| 88 |
Texture3DEditor(); |
| 89 |
~Texture3DEditor(); |
| 90 |
}; |
| 91 |
|
| 92 |
class EditorInspectorPlugin3DTexture : public EditorInspectorPlugin { |
| 93 |
GDCLASS(EditorInspectorPlugin3DTexture, EditorInspectorPlugin); |
| 94 |
|
| 95 |
public: |
| 96 |
virtual bool can_handle(Object *p_object) override; |
| 97 |
virtual void parse_begin(Object *p_object) override; |
| 98 |
}; |
| 99 |
|
| 100 |
class Texture3DEditorPlugin : public EditorPlugin { |
| 101 |
GDCLASS(Texture3DEditorPlugin, EditorPlugin); |
| 102 |
|
| 103 |
public: |
| 104 |
virtual String get_plugin_name() const override { return "Texture3D"; } |
| 105 |
|
| 106 |
Texture3DEditorPlugin(); |
| 107 |
}; |