diff options
author | Juan Linietsky <juan@godotengine.org> | 2018-02-21 09:38:21 -0300 |
---|---|---|
committer | Juan Linietsky <juan@godotengine.org> | 2018-02-21 09:39:09 -0300 |
commit | 9e3a1e5401f9f807085547de0ecc3f527610daa4 (patch) | |
tree | ac58cd4f27e9dfe8ed550dfce9bfc442f29cd05a /editor/plugins/sprite_editor_plugin.h | |
parent | 1c77fdcc8516cf2f0c5083d4840a684b9ad90958 (diff) |
Add base support for 2D meshes in Godot, including Sprite -> Mesh2D conversion.
Diffstat (limited to 'editor/plugins/sprite_editor_plugin.h')
-rw-r--r-- | editor/plugins/sprite_editor_plugin.h | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/editor/plugins/sprite_editor_plugin.h b/editor/plugins/sprite_editor_plugin.h new file mode 100644 index 0000000000..17aa3eb1f9 --- /dev/null +++ b/editor/plugins/sprite_editor_plugin.h @@ -0,0 +1,73 @@ +#ifndef SPRITE_EDITOR_PLUGIN_H +#define SPRITE_EDITOR_PLUGIN_H + +#include "editor/editor_node.h" +#include "editor/editor_plugin.h" +#include "scene/2d/sprite.h" +#include "scene/gui/spin_box.h" + +class SpriteEditor : public Control { + + GDCLASS(SpriteEditor, Control); + + enum Menu { + MENU_OPTION_CREATE_MESH_2D, + }; + + Sprite *node; + + MenuButton *options; + + ConfirmationDialog *outline_dialog; + + AcceptDialog *err_dialog; + + ConfirmationDialog *debug_uv_dialog; + Control *debug_uv; + Vector<Vector2> uv_lines; + + Vector<Vector2> computed_vertices; + Vector<Vector2> computed_uv; + Vector<int> computed_indices; + + SpinBox *simplification; + SpinBox *island_merging; + Button *update_preview; + + void _menu_option(int p_option); + + //void _create_uv_lines(); + friend class SpriteEditorPlugin; + + void _debug_uv_draw(); + void _update_mesh_data(); + void _create_mesh_node(); + +protected: + void _node_removed(Node *p_node); + static void _bind_methods(); + +public: + void edit(Sprite *p_sprite); + SpriteEditor(); +}; + +class SpriteEditorPlugin : public EditorPlugin { + + GDCLASS(SpriteEditorPlugin, EditorPlugin); + + SpriteEditor *sprite_editor; + EditorNode *editor; + +public: + virtual String get_name() const { return "Sprite"; } + bool has_main_screen() const { return false; } + virtual void edit(Object *p_object); + virtual bool handles(Object *p_object) const; + virtual void make_visible(bool p_visible); + + SpriteEditorPlugin(EditorNode *p_node); + ~SpriteEditorPlugin(); +}; + +#endif // SPRITE_EDITOR_PLUGIN_H |