Fully ported mdr editor's main ui.

This commit is contained in:
Relintai 2022-04-13 22:22:40 +02:00
parent 34607ff21e
commit c7de534f03
6 changed files with 624 additions and 169 deletions

View File

@ -22,7 +22,9 @@ SOFTWARE.
#include "mdi_ed.h"
#include "../mesh_data_resource.h"
#include "./uv_editor/mdr_ed_uv_previewer.h"
#include "./uv_editor/mdr_uv_rect_editor.h"
#include "./uv_editor/mdr_uv_rect_editor_popup.h"
#include "core/os/keyboard.h"
#include "mdi_ed_plugin.h"
@ -32,40 +34,17 @@ SOFTWARE.
#include "scene/gui/scroll_container.h"
#include "scene/gui/separator.h"
void MDIEd::_enter_tree() {
/*
uv_preview = get_node(uv_preview_path)
uv_editor = get_node(uv_editor_path)
if _plugin && uv_editor:
uv_editor.set_plugin(_plugin)
*/
}
void MDIEd::set_plugin(EditorPlugin *plugin) {
/*
_plugin = plugin
if uv_editor:
uv_editor.set_plugin(plugin)
*/
void MDIEd::set_plugin(MDIEdPlugin *plugin) {
_plugin = plugin;
uv_editor->set_plugin(plugin);
}
void MDIEd::set_mesh_data_resource(Ref<MeshDataResource> a) {
/*
if uv_preview:
uv_preview.set_mesh_data_resource(a)
if uv_editor:
uv_editor.set_mesh_data_resource(a)
*/
uv_preview->set_mesh_data_resource(a);
uv_editor->get_editor()->set_mesh_data_resource(a);
}
void MDIEd::set_mesh_data_instance(MeshDataInstance *a) {
/*
if uv_preview:
uv_preview.set_mesh_data_instance(a)
if uv_editor:
uv_editor.set_mesh_data_instance(a)
*/
uv_preview->set_mesh_data_instance(a);
uv_editor->get_editor()->set_mesh_data_instance(a);
}
void MDIEd::_unhandled_key_input(Ref<InputEventKey> event) {
if (event->is_echo()) {
@ -101,19 +80,13 @@ void MDIEd::_unhandled_key_input(Ref<InputEventKey> event) {
//Edit modes
void MDIEd::set_edit_mode_translate() {
/*
$VBoxContainer/Actions/Actions/VBoxContainer2/HBoxContainer/Translate.pressed = true
*/
_edit_mode_translate_button->set_pressed(true);
}
void MDIEd::set_edit_mode_rotate() {
/*
$VBoxContainer/Actions/Actions/VBoxContainer2/HBoxContainer/Rotate.pressed = true
*/
_edit_mode_rotate_button->set_pressed(true);
}
void MDIEd::set_edit_mode_scale() {
/*
$VBoxContainer/Actions/Actions/VBoxContainer2/HBoxContainer/Scale.pressed = true
*/
_edit_mode_scale_button->set_pressed(true);
}
void MDIEd::on_edit_mode_translate_toggled(bool on) {
@ -140,37 +113,22 @@ void MDIEd::on_edit_mode_scale_toggled(bool on) {
//axis locks
bool MDIEd::get_axis_x() {
/*
return $VBoxContainer/Actions/Actions/VBoxContainer2/HBoxContainer2/AxisX.pressed
*/
return false;
return _axis_lock_x_button->is_pressed();
}
bool MDIEd::get_axis_y() {
/*
return $VBoxContainer/Actions/Actions/VBoxContainer2/HBoxContainer2/AxisY.pressed
*/
return false;
return _axis_lock_y_button->is_pressed();
}
bool MDIEd::get_axis_z() {
/*
return $VBoxContainer/Actions/Actions/VBoxContainer2/HBoxContainer2/AxisZ.pressed
*/
return false;
return _axis_lock_z_button->is_pressed();
}
void MDIEd::set_axis_x(bool on) {
/*
$VBoxContainer/Actions/Actions/VBoxContainer2/HBoxContainer2/AxisX.pressed = on
*/
_axis_lock_x_button->set_pressed(on);
}
void MDIEd::set_axis_y(bool on) {
/*
$VBoxContainer/Actions/Actions/VBoxContainer2/HBoxContainer2/AxisY.pressed = on
*/
_axis_lock_y_button->set_pressed(on);
}
void MDIEd::set_axis_z(bool on) {
/*
$VBoxContainer/Actions/Actions/VBoxContainer2/HBoxContainer2/AxisZ.pressed = on
*/
_axis_lock_z_button->set_pressed(on);
}
void MDIEd::on_axis_x_toggled(bool on) {
@ -201,6 +159,10 @@ void MDIEd::on_selection_mode_vertex_toggled(bool on) {
if (_plugin) {
_plugin->set_selection_mode_vertex();
}
vertex_operations_container->show();
edge_operations_container->hide();
face_operations_container->hide();
}
}
void MDIEd::on_selection_mode_edge_toggled(bool on) {
@ -208,6 +170,10 @@ void MDIEd::on_selection_mode_edge_toggled(bool on) {
if (_plugin) {
_plugin->set_selection_mode_edge();
}
vertex_operations_container->hide();
edge_operations_container->show();
face_operations_container->hide();
}
}
void MDIEd::on_selection_mode_face_toggled(bool on) {
@ -215,92 +181,76 @@ void MDIEd::on_selection_mode_face_toggled(bool on) {
if (_plugin) {
_plugin->set_selection_mode_face();
}
vertex_operations_container->hide();
edge_operations_container->hide();
face_operations_container->show();
}
}
void MDIEd::set_selection_mode_vertex() {
/*
$VBoxContainer/Actions/Actions/VBoxContainer2/HBoxContainer3/Vertex.pressed = true
*/
_selection_mode_vertex_button->set_pressed(true);
}
void MDIEd::set_selection_mode_edge() {
/*
$VBoxContainer/Actions/Actions/VBoxContainer2/HBoxContainer3/Edge.pressed = true
*/
_selection_mode_edge_button->set_pressed(true);
}
void MDIEd::set_selection_mode_face() {
/*
$VBoxContainer/Actions/Actions/VBoxContainer2/HBoxContainer3/Face.pressed = true
*/
_selection_mode_face_button->set_pressed(true);
}
void MDIEd::_on_Extrude_pressed() {
_plugin->extrude();
void MDIEd::on_handle_selection_type_front_toggled(bool on) {
_plugin->handle_selection_type_front();
}
void MDIEd::_on_AddBox_pressed() {
_plugin->add_box();
void MDIEd::on_handle_selection_type_back_toggled(bool on) {
_plugin->handle_selection_type_back();
}
void MDIEd::_on_UnwrapButton_pressed() {
_plugin->uv_unwrap();
void MDIEd::on_handle_selection_type_all_toggled(bool on) {
_plugin->handle_selection_type_all();
}
void MDIEd::_on_add_triangle_pressed() {
_plugin->add_triangle();
void MDIEd::on_select_all_pressed() {
_plugin->select_all();
}
void MDIEd::_on_add_quad_pressed() {
_plugin->add_quad();
}
void MDIEd::_on_split_pressed() {
_plugin->split();
}
void MDIEd::_on_connect_to_first_selected_pressed() {
_plugin->connect_to_first_selected();
}
void MDIEd::_on_connect_to_avg_pressed() {
_plugin->connect_to_avg();
}
void MDIEd::_on_connect_to_last_selected_pressed() {
_plugin->connect_to_last_selected();
}
void MDIEd::_on_disconnect_pressed() {
_plugin->disconnect_action();
}
void MDIEd::_on_add_triangle_at_pressed() {
_plugin->add_triangle_at();
}
void MDIEd::_on_add_auad_at_pressed() {
_plugin->add_quad_at();
}
void MDIEd::_oncreate_face_pressed() {
void MDIEd::on_create_face_pressed() {
_plugin->create_face();
}
void MDIEd::_on_delete_pressed() {
_plugin->delete_selected();
void MDIEd::on_split_pressed() {
_plugin->split();
}
void MDIEd::_on_GenNormals_pressed() {
_plugin->generate_normals();
void MDIEd::on_connect_to_first_selected_pressed() {
_plugin->connect_to_first_selected();
}
void MDIEd::_on_RemDoubles_pressed() {
_plugin->remove_doubles();
void MDIEd::on_connect_to_avg_pressed() {
_plugin->connect_to_avg();
}
void MDIEd::_on_MergeOptimize_pressed() {
_plugin->merge_optimize();
void MDIEd::on_connect_to_last_selected_pressed() {
_plugin->connect_to_last_selected();
}
void MDIEd::_on_GenTangents_pressed() {
_plugin->generate_tangents();
//Edge ops
void MDIEd::on_extrude_pressed() {
_plugin->extrude();
}
void MDIEd::_on_mark_seam_pressed() {
void MDIEd::on_add_triangle_at_pressed() {
_plugin->add_triangle_at();
}
void MDIEd::on_add_quad_at_pressed() {
_plugin->add_quad_at();
}
void MDIEd::on_mark_seam_pressed() {
_plugin->mark_seam();
}
void MDIEd::_on_unmark_seam_pressed() {
void MDIEd::on_unmark_seam_pressed() {
_plugin->unmark_seam();
}
void MDIEd::_on_apply_seams_pressed() {
_plugin->apply_seam();
//Face ops
void MDIEd::on_delete_pressed() {
_plugin->delete_selected();
}
void MDIEd::_on_uv_edit_pressed() {
/*
$Popups/UVEditorPopup.popup_centered()
*/
void MDIEd::on_flip_face_pressed() {
_plugin->flip_selected_faces();
}
void MDIEd::on_pivot_average_toggled(bool on) {
@ -327,30 +277,48 @@ void MDIEd::on_visual_indicator_seam_toggled(bool on) {
void MDIEd::on_visual_indicator_handle_toggled(bool on) {
_plugin->visual_indicator_handle_set(on);
}
void MDIEd::_on_select_all_pressed() {
_plugin->select_all();
void MDIEd::on_generate_normals_pressed() {
_plugin->generate_normals();
}
void MDIEd::on_generate_tangents_pressed() {
_plugin->generate_tangents();
}
void MDIEd::onhandle_selection_type_front_toggled(bool on) {
_plugin->handle_selection_type_front();
void MDIEd::on_remove_doubles_pressed() {
_plugin->generate_tangents();
}
void MDIEd::onhandle_selection_type_back_toggled(bool on) {
_plugin->handle_selection_type_back();
void MDIEd::on_merge_optimize_pressed() {
_plugin->merge_optimize();
}
void MDIEd::onhandle_selection_type_all_toggled(bool on) {
_plugin->handle_selection_type_all();
}
void MDIEd::_on_clean_mesh_pressed() {
void MDIEd::on_clean_mesh_pressed() {
_plugin->clean_mesh();
}
void MDIEd::_on_flip_face_pressed() {
_plugin->flip_selected_faces();
void MDIEd::on_uv_edit_pressed() {
uv_editor->popup_centered();
}
void MDIEd::on_apply_seams_pressed() {
_plugin->apply_seam();
}
void MDIEd::on_unwrap_button_pressed() {
_plugin->uv_unwrap();
}
void MDIEd::on_add_box_pressed() {
_plugin->add_box();
}
void MDIEd::on_add_triangle_pressed() {
_plugin->add_triangle();
}
void MDIEd::on_add_quad_pressed() {
_plugin->add_quad();
}
void MDIEd::_on_disconnect_pressed() {
_plugin->disconnect_action();
}
MDIEd::MDIEd() {
uv_preview = nullptr;
//Main
VBoxContainer *main_cont = memnew(VBoxContainer);
add_child(main_cont);
@ -395,6 +363,7 @@ MDIEd::MDIEd() {
action_button->set_h_size_flags(SIZE_EXPAND_FILL);
action_button->connect("toggled", this, "on_edit_mode_translate_toggled");
action_buttons_container->add_child(action_button);
_edit_mode_translate_button = action_button;
action_button = memnew(Button);
action_button->set_text("R");
@ -406,6 +375,7 @@ MDIEd::MDIEd() {
action_button->set_h_size_flags(SIZE_EXPAND_FILL);
action_button->connect("toggled", this, "on_edit_mode_rotate_toggled");
action_buttons_container->add_child(action_button);
_edit_mode_rotate_button = action_button;
action_button = memnew(Button);
action_button->set_text("S");
@ -417,6 +387,7 @@ MDIEd::MDIEd() {
action_button->set_h_size_flags(SIZE_EXPAND_FILL);
action_button->connect("toggled", this, "on_edit_mode_scale_toggled");
action_buttons_container->add_child(action_button);
_edit_mode_scale_button = action_button;
// -- Actions -- Active Axis
action_label = memnew(Label);
@ -439,6 +410,7 @@ MDIEd::MDIEd() {
action_button->set_h_size_flags(SIZE_EXPAND_FILL);
action_button->connect("toggled", this, "on_axis_x_toggled");
action_buttons_container->add_child(action_button);
_axis_lock_x_button = action_button;
action_button = memnew(Button);
action_button->set_text("Y");
@ -448,6 +420,7 @@ MDIEd::MDIEd() {
action_button->set_h_size_flags(SIZE_EXPAND_FILL);
action_button->connect("toggled", this, "on_axis_y_toggled");
action_buttons_container->add_child(action_button);
_axis_lock_y_button = action_button;
action_button = memnew(Button);
action_button->set_text("Z");
@ -457,6 +430,7 @@ MDIEd::MDIEd() {
action_button->set_h_size_flags(SIZE_EXPAND_FILL);
action_button->connect("toggled", this, "on_axis_z_toggled");
action_buttons_container->add_child(action_button);
_axis_lock_z_button = action_button;
// -- Actions -- Selection Mode
action_label = memnew(Label);
@ -483,6 +457,7 @@ MDIEd::MDIEd() {
action_button->set_h_size_flags(SIZE_EXPAND_FILL);
action_button->connect("toggled", this, "on_selection_mode_vertex_toggled");
action_buttons_container->add_child(action_button);
_selection_mode_vertex_button = action_button;
action_button = memnew(Button);
action_button->set_text("E");
@ -494,6 +469,7 @@ MDIEd::MDIEd() {
action_button->set_h_size_flags(SIZE_EXPAND_FILL);
action_button->connect("toggled", this, "on_selection_mode_edge_toggled");
action_buttons_container->add_child(action_button);
_selection_mode_edge_button = action_button;
action_button = memnew(Button);
action_button->set_text("F");
@ -505,14 +481,402 @@ MDIEd::MDIEd() {
action_button->set_h_size_flags(SIZE_EXPAND_FILL);
action_button->connect("toggled", this, "on_selection_mode_face_toggled");
action_buttons_container->add_child(action_button);
_selection_mode_face_button = action_button;
// -- Main separator
main_cont->add_child(memnew(HSeparator));
// -- Main ScrollContainer
ScrollContainer *main_scroll_container = memnew(ScrollContainer);
main_scroll_container->set_v_size_flags(SIZE_EXPAND_FILL);
main_scroll_container->set_h_size_flags(SIZE_EXPAND_FILL);
main_scroll_container->set_enable_h_scroll(false);
main_cont->add_child(main_scroll_container);
VBoxContainer *scroll_container_content = memnew(VBoxContainer);
scroll_container_content->set_h_size_flags(SIZE_EXPAND_FILL);
main_scroll_container->add_child(scroll_container_content);
// -- Scroll -- Handle Selection type
action_buttons_container = memnew(HBoxContainer);
scroll_container_content->add_child(action_buttons_container);
action_label = memnew(Label);
action_label->set_text("H");
action_label->set_align(Label::ALIGN_CENTER);
action_label->set_valign(Label::VALIGN_CENTER);
action_label->set_tooltip("Handle Selection Type");
action_label->set_mouse_filter(Control::MOUSE_FILTER_STOP);
action_label->set_v_size_flags(SIZE_EXPAND_FILL | SIZE_SHRINK_CENTER);
action_buttons_container->add_child(action_label);
action_button_group.instance();
action_button = memnew(Button);
action_button->set_text("F");
action_button->set_toggle_mode(true);
action_button->set_pressed(true);
action_button->set_button_group(action_button_group);
action_button->set_custom_minimum_size(Size2(25, 20));
action_button->set_tooltip("Front");
action_button->set_h_size_flags(SIZE_EXPAND_FILL);
action_button->connect("toggled", this, "on_handle_selection_type_front_toggled");
action_buttons_container->add_child(action_button);
action_button = memnew(Button);
action_button->set_text("B");
action_button->set_toggle_mode(true);
action_button->set_pressed(false);
action_button->set_button_group(action_button_group);
action_button->set_custom_minimum_size(Size2(25, 20));
action_button->set_tooltip("Back");
action_button->set_h_size_flags(SIZE_EXPAND_FILL);
action_button->connect("toggled", this, "on_handle_selection_type_back_toggled");
action_buttons_container->add_child(action_button);
action_button = memnew(Button);
action_button->set_text("A");
action_button->set_toggle_mode(true);
action_button->set_pressed(false);
action_button->set_button_group(action_button_group);
action_button->set_custom_minimum_size(Size2(25, 20));
action_button->set_tooltip("All");
action_button->set_h_size_flags(SIZE_EXPAND_FILL);
action_button->connect("toggled", this, "on_handle_selection_type_all_toggled");
action_buttons_container->add_child(action_button);
// -- Scroll -- Pivot
action_buttons_container = memnew(HBoxContainer);
scroll_container_content->add_child(action_buttons_container);
action_label = memnew(Label);
action_label->set_text("P");
action_label->set_align(Label::ALIGN_CENTER);
action_label->set_valign(Label::VALIGN_CENTER);
action_label->set_tooltip("Pivot");
action_label->set_mouse_filter(Control::MOUSE_FILTER_STOP);
action_label->set_v_size_flags(SIZE_EXPAND_FILL | SIZE_SHRINK_CENTER);
action_buttons_container->add_child(action_label);
action_button = memnew(Button);
action_button->set_text("A");
action_button->set_toggle_mode(true);
action_button->set_pressed(true);
action_button->set_button_group(action_button_group);
action_button->set_custom_minimum_size(Size2(25, 20));
action_button->set_tooltip("Average");
action_button->set_h_size_flags(SIZE_EXPAND_FILL);
action_button->connect("toggled", this, "on_pivot_average_toggled");
action_buttons_container->add_child(action_button);
action_button = memnew(Button);
action_button->set_text("M");
action_button->set_toggle_mode(true);
action_button->set_pressed(false);
action_button->set_button_group(action_button_group);
action_button->set_custom_minimum_size(Size2(25, 20));
action_button->set_tooltip("Mesh Data Instance Origin");
action_button->set_h_size_flags(SIZE_EXPAND_FILL);
action_button->connect("toggled", this, "on_pivot_mdi_origin_toggled");
action_buttons_container->add_child(action_button);
action_button = memnew(Button);
action_button->set_text("W");
action_button->set_toggle_mode(true);
action_button->set_pressed(false);
action_button->set_button_group(action_button_group);
action_button->set_custom_minimum_size(Size2(25, 20));
action_button->set_tooltip("World Origin");
action_button->set_h_size_flags(SIZE_EXPAND_FILL);
action_button->connect("toggled", this, "on_pivot_world_origin_toggled");
action_buttons_container->add_child(action_button);
// -- Scroll -- Visual indicators
action_buttons_container = memnew(HBoxContainer);
scroll_container_content->add_child(action_buttons_container);
action_label = memnew(Label);
action_label->set_text("V");
action_label->set_align(Label::ALIGN_CENTER);
action_label->set_valign(Label::VALIGN_CENTER);
action_label->set_tooltip("Visual indicators");
action_label->set_mouse_filter(Control::MOUSE_FILTER_STOP);
action_label->set_v_size_flags(SIZE_EXPAND_FILL | SIZE_SHRINK_CENTER);
action_buttons_container->add_child(action_label);
action_button = memnew(Button);
action_button->set_text("O");
action_button->set_toggle_mode(true);
action_button->set_pressed(true);
action_button->set_custom_minimum_size(Size2(25, 20));
action_button->set_tooltip("Outline");
action_button->set_h_size_flags(SIZE_EXPAND_FILL);
action_button->connect("toggled", this, "on_handle_selection_type_front_toggled");
action_buttons_container->add_child(action_button);
action_button = memnew(Button);
action_button->set_text("S");
action_button->set_toggle_mode(true);
action_button->set_pressed(true);
action_button->set_custom_minimum_size(Size2(25, 20));
action_button->set_tooltip("Seam");
action_button->set_h_size_flags(SIZE_EXPAND_FILL);
action_button->connect("toggled", this, "on_handle_selection_type_back_toggled");
action_buttons_container->add_child(action_button);
action_button = memnew(Button);
action_button->set_text("H");
action_button->set_toggle_mode(true);
action_button->set_pressed(true);
action_button->set_custom_minimum_size(Size2(25, 20));
action_button->set_tooltip("Handle");
action_button->set_h_size_flags(SIZE_EXPAND_FILL);
action_button->connect("toggled", this, "on_handle_selection_type_all_toggled");
action_buttons_container->add_child(action_button);
// -- Scroll -- Separator
scroll_container_content->add_child(memnew(HSeparator));
// -- Scroll -- Select All Button
action_button = memnew(Button);
action_button->set_text("Select All");
action_button->connect("pressed", this, "on_select_all_pressed");
scroll_container_content->add_child(action_button);
// -- Scroll -- Separator
scroll_container_content->add_child(memnew(HSeparator));
// -- Scroll -- Vertex Operations
vertex_operations_container = memnew(VBoxContainer);
scroll_container_content->add_child(vertex_operations_container);
action_label = memnew(Label);
action_label->set_text("= Vertex =");
action_label->set_align(Label::ALIGN_CENTER);
action_label->set_valign(Label::VALIGN_CENTER);
vertex_operations_container->add_child(action_label);
action_button = memnew(Button);
action_button->set_text("Create Face");
action_button->connect("pressed", this, "on_create_face_pressed");
vertex_operations_container->add_child(action_button);
action_label = memnew(Label);
action_label->set_text("Connect");
action_label->set_align(Label::ALIGN_CENTER);
action_label->set_valign(Label::VALIGN_CENTER);
vertex_operations_container->add_child(action_label);
HBoxContainer *vertex_connect_operations_container = memnew(HBoxContainer);
vertex_operations_container->add_child(vertex_connect_operations_container);
action_button = memnew(Button);
action_button->set_text("x<");
action_button->set_tooltip("Move all vertices to the first one that was selected.");
action_button->set_h_size_flags(SIZE_EXPAND_FILL);
action_button->connect("pressed", this, "on_connect_to_first_selected_pressed");
vertex_connect_operations_container->add_child(action_button);
action_button = memnew(Button);
action_button->set_text(">x<");
action_button->set_tooltip("Move all selected vertices to their average.");
action_button->set_h_size_flags(SIZE_EXPAND_FILL);
action_button->connect("pressed", this, "on_connect_to_avg_pressed");
vertex_connect_operations_container->add_child(action_button);
action_button = memnew(Button);
action_button->set_text(">x");
action_button->set_tooltip("Move all selected vertices to the last that was selected.");
action_button->set_h_size_flags(SIZE_EXPAND_FILL);
action_button->connect("pressed", this, "on_connect_to_last_selected_pressed");
vertex_connect_operations_container->add_child(action_button);
// -- Scroll -- Edge Operations
edge_operations_container = memnew(VBoxContainer);
edge_operations_container->hide();
scroll_container_content->add_child(edge_operations_container);
action_label = memnew(Label);
action_label->set_text("= Edge =");
action_label->set_align(Label::ALIGN_CENTER);
action_label->set_valign(Label::VALIGN_CENTER);
edge_operations_container->add_child(action_label);
action_button = memnew(Button);
action_button->set_text("Extrude");
action_button->connect("pressed", this, "on_extrude_pressed");
edge_operations_container->add_child(action_button);
action_label = memnew(Label);
action_label->set_text("Append");
action_label->set_align(Label::ALIGN_CENTER);
action_label->set_valign(Label::VALIGN_CENTER);
edge_operations_container->add_child(action_label);
HBoxContainer *edge_operations_sub_container = memnew(HBoxContainer);
edge_operations_container->add_child(edge_operations_sub_container);
action_button = memnew(Button);
action_button->set_text("Tri");
action_button->set_h_size_flags(SIZE_EXPAND_FILL);
action_button->connect("pressed", this, "on_add_triangle_at_pressed");
edge_operations_sub_container->add_child(action_button);
action_button = memnew(Button);
action_button->set_text("Quad");
action_button->set_h_size_flags(SIZE_EXPAND_FILL);
action_button->connect("pressed", this, "on_add_quad_at_pressed");
edge_operations_sub_container->add_child(action_button);
action_label = memnew(Label);
action_label->set_text("Seam");
action_label->set_align(Label::ALIGN_CENTER);
action_label->set_valign(Label::VALIGN_CENTER);
edge_operations_container->add_child(action_label);
edge_operations_sub_container = memnew(HBoxContainer);
edge_operations_container->add_child(edge_operations_sub_container);
action_button = memnew(Button);
action_button->set_text("Mark");
action_button->set_h_size_flags(SIZE_EXPAND_FILL);
action_button->connect("pressed", this, "on_mark_seam_pressed");
edge_operations_sub_container->add_child(action_button);
action_button = memnew(Button);
action_button->set_text("Unmark");
action_button->set_h_size_flags(SIZE_EXPAND_FILL);
action_button->connect("pressed", this, "on_unmark_seam_pressed");
edge_operations_sub_container->add_child(action_button);
// -- Scroll -- Face Operations
face_operations_container = memnew(VBoxContainer);
face_operations_container->hide();
scroll_container_content->add_child(face_operations_container);
action_label = memnew(Label);
action_label->set_text("= Face =");
action_label->set_align(Label::ALIGN_CENTER);
action_label->set_valign(Label::VALIGN_CENTER);
face_operations_container->add_child(action_label);
action_button = memnew(Button);
action_button->set_text("Delete");
action_button->connect("pressed", this, "on_delete_pressed");
face_operations_container->add_child(action_button);
action_button = memnew(Button);
action_button->set_text("Flip");
action_button->connect("pressed", this, "on_flip_face_pressed");
face_operations_container->add_child(action_button);
// -- Scroll -- Separator
scroll_container_content->add_child(memnew(HSeparator));
// -- Scroll -- Operations
VBoxContainer *operations_container = memnew(VBoxContainer);
scroll_container_content->add_child(operations_container);
action_label = memnew(Label);
action_label->set_text("= Operations =");
action_label->set_align(Label::ALIGN_CENTER);
action_label->set_valign(Label::VALIGN_CENTER);
operations_container->add_child(action_label);
action_label = memnew(Label);
action_label->set_text("Generate");
action_label->set_align(Label::ALIGN_CENTER);
action_label->set_valign(Label::VALIGN_CENTER);
operations_container->add_child(action_label);
action_button = memnew(Button);
action_button->set_text("Normals");
action_button->connect("pressed", this, "on_generate_normals_pressed");
operations_container->add_child(action_button);
action_button = memnew(Button);
action_button->set_text("Tangents");
action_button->connect("pressed", this, "on_remove_doubles_pressed");
operations_container->add_child(action_button);
action_label = memnew(Label);
action_label->set_text("Optimizations");
action_label->set_align(Label::ALIGN_CENTER);
action_label->set_valign(Label::VALIGN_CENTER);
operations_container->add_child(action_label);
action_button = memnew(Button);
action_button->set_text("Rem Doubles");
action_button->connect("pressed", this, "on_remove_doubles_pressed");
operations_container->add_child(action_button);
action_button = memnew(Button);
action_button->set_text("Full Merge");
action_button->connect("pressed", this, "on_merge_optimize_pressed");
operations_container->add_child(action_button);
action_button = memnew(Button);
action_button->set_text("Clean");
action_button->set_tooltip("Clean mesh for example for unused verts.");
action_button->connect("pressed", this, "on_clean_mesh_pressed");
operations_container->add_child(action_button);
action_label = memnew(Label);
action_label->set_text("UV");
action_label->set_align(Label::ALIGN_CENTER);
action_label->set_valign(Label::VALIGN_CENTER);
operations_container->add_child(action_label);
uv_preview = memnew(MDREdUVPreviewer);
uv_preview->set_custom_minimum_size(Point2(100, 100));
operations_container->add_child(uv_preview);
action_button = memnew(Button);
action_button->set_text("Edit");
action_button->connect("pressed", this, "on_uv_edit_pressed");
operations_container->add_child(action_button);
action_button = memnew(Button);
action_button->set_text("Apply seams");
action_button->connect("pressed", this, "on_apply_seams_pressed");
operations_container->add_child(action_button);
action_button = memnew(Button);
action_button->set_text("Unwrap");
action_button->connect("pressed", this, "on_unwrap_button_pressed");
operations_container->add_child(action_button);
// -- Scroll -- Separator
scroll_container_content->add_child(memnew(HSeparator));
// -- Scroll -- Add
VBoxContainer *add_operations_container = memnew(VBoxContainer);
scroll_container_content->add_child(add_operations_container);
action_label = memnew(Label);
action_label->set_text("= Add =");
action_label->set_align(Label::ALIGN_CENTER);
action_label->set_valign(Label::VALIGN_CENTER);
add_operations_container->add_child(action_label);
action_button = memnew(Button);
action_button->set_text("Box");
action_button->connect("pressed", this, "on_add_box_pressed");
add_operations_container->add_child(action_button);
action_button = memnew(Button);
action_button->set_text("Tri");
action_button->connect("pressed", this, "on_add_triangle_pressed");
add_operations_container->add_child(action_button);
action_button = memnew(Button);
action_button->set_text("Quad");
action_button->connect("pressed", this, "on_add_quad_pressed");
add_operations_container->add_child(action_button);
// -- Scroll -- Separator
scroll_container_content->add_child(memnew(HSeparator));
//Popups
Control *popups_node = memnew(Control);
popups_node->set_mouse_filter(MOUSE_FILTER_IGNORE);
@ -540,4 +904,52 @@ void MDIEd::_bind_methods() {
ClassDB::bind_method(D_METHOD("on_selection_mode_vertex_toggled"), &MDIEd::on_selection_mode_vertex_toggled);
ClassDB::bind_method(D_METHOD("on_selection_mode_edge_toggled"), &MDIEd::on_selection_mode_edge_toggled);
ClassDB::bind_method(D_METHOD("on_selection_mode_face_toggled"), &MDIEd::on_selection_mode_face_toggled);
ClassDB::bind_method(D_METHOD("on_handle_selection_type_front_toggled"), &MDIEd::on_handle_selection_type_front_toggled);
ClassDB::bind_method(D_METHOD("on_handle_selection_type_back_toggled"), &MDIEd::on_handle_selection_type_back_toggled);
ClassDB::bind_method(D_METHOD("on_handle_selection_type_all_toggled"), &MDIEd::on_handle_selection_type_all_toggled);
ClassDB::bind_method(D_METHOD("on_pivot_average_toggled"), &MDIEd::on_pivot_average_toggled);
ClassDB::bind_method(D_METHOD("on_pivot_mdi_origin_toggled"), &MDIEd::on_pivot_mdi_origin_toggled);
ClassDB::bind_method(D_METHOD("on_pivot_world_origin_toggled"), &MDIEd::on_pivot_world_origin_toggled);
ClassDB::bind_method(D_METHOD("on_visual_indicator_outline_toggled"), &MDIEd::on_visual_indicator_outline_toggled);
ClassDB::bind_method(D_METHOD("on_visual_indicator_seam_toggled"), &MDIEd::on_visual_indicator_seam_toggled);
ClassDB::bind_method(D_METHOD("on_visual_indicator_handle_toggled"), &MDIEd::on_visual_indicator_handle_toggled);
ClassDB::bind_method(D_METHOD("on_select_all_pressed"), &MDIEd::on_select_all_pressed);
//Vertex
ClassDB::bind_method(D_METHOD("on_create_face_pressed"), &MDIEd::on_create_face_pressed);
//ClassDB::bind_method(D_METHOD("on_split_pressed"), &MDIEd::on_split_pressed);
ClassDB::bind_method(D_METHOD("on_connect_to_first_selected_pressed"), &MDIEd::on_connect_to_first_selected_pressed);
ClassDB::bind_method(D_METHOD("on_connect_to_avg_pressed"), &MDIEd::on_connect_to_avg_pressed);
ClassDB::bind_method(D_METHOD("on_connect_to_last_selected_pressed"), &MDIEd::on_connect_to_last_selected_pressed);
//Edge
ClassDB::bind_method(D_METHOD("on_extrude_pressed"), &MDIEd::on_extrude_pressed);
ClassDB::bind_method(D_METHOD("on_add_triangle_at_pressed"), &MDIEd::on_add_triangle_at_pressed);
ClassDB::bind_method(D_METHOD("on_add_quad_at_pressed"), &MDIEd::on_add_quad_at_pressed);
ClassDB::bind_method(D_METHOD("on_mark_seam_pressed"), &MDIEd::on_mark_seam_pressed);
ClassDB::bind_method(D_METHOD("on_unmark_seam_pressed"), &MDIEd::on_unmark_seam_pressed);
//Face
ClassDB::bind_method(D_METHOD("on_delete_pressed"), &MDIEd::on_delete_pressed);
ClassDB::bind_method(D_METHOD("on_flip_face_pressed"), &MDIEd::on_flip_face_pressed);
//Operations
ClassDB::bind_method(D_METHOD("on_generate_normals_pressed"), &MDIEd::on_generate_normals_pressed);
ClassDB::bind_method(D_METHOD("on_generate_tangents_pressed"), &MDIEd::on_generate_tangents_pressed);
ClassDB::bind_method(D_METHOD("on_remove_doubles_pressed"), &MDIEd::on_remove_doubles_pressed);
ClassDB::bind_method(D_METHOD("on_merge_optimize_pressed"), &MDIEd::on_merge_optimize_pressed);
ClassDB::bind_method(D_METHOD("on_clean_mesh_pressed"), &MDIEd::on_clean_mesh_pressed);
ClassDB::bind_method(D_METHOD("on_uv_edit_pressed"), &MDIEd::on_uv_edit_pressed);
ClassDB::bind_method(D_METHOD("on_apply_seams_pressed"), &MDIEd::on_apply_seams_pressed);
ClassDB::bind_method(D_METHOD("on_unwrap_button_pressed"), &MDIEd::on_unwrap_button_pressed);
ClassDB::bind_method(D_METHOD("on_add_box_pressed"), &MDIEd::on_add_box_pressed);
ClassDB::bind_method(D_METHOD("on_add_triangle_pressed"), &MDIEd::on_add_triangle_pressed);
ClassDB::bind_method(D_METHOD("on_add_quad_pressed"), &MDIEd::on_add_quad_pressed);
}

View File

@ -25,19 +25,20 @@ SOFTWARE.
#include "scene/gui/panel_container.h"
class EditorPlugin;
class MDIEdPlugin;
class MeshDataResource;
class MeshDataInstance;
class MDIEdPlugin;
class MDREdUVPreviewer;
class MDRUVRectEditorPopup;
class VBoxContainer;
class Button;
class MDIEd : public PanelContainer {
GDCLASS(MDIEd, PanelContainer);
public:
void _enter_tree();
void set_plugin(EditorPlugin *plugin);
void set_plugin(MDIEdPlugin *plugin);
void set_mesh_data_resource(Ref<MeshDataResource> a);
void set_mesh_data_instance(MeshDataInstance *a);
void _unhandled_key_input(Ref<InputEventKey> event);
@ -72,43 +73,55 @@ public:
void set_selection_mode_edge();
void set_selection_mode_face();
void _on_Extrude_pressed();
void _on_AddBox_pressed();
void _on_UnwrapButton_pressed();
void _on_add_triangle_pressed();
void _on_add_quad_pressed();
void _on_split_pressed();
void _on_connect_to_first_selected_pressed();
void _on_connect_to_avg_pressed();
void _on_connect_to_last_selected_pressed();
void _on_disconnect_pressed();
void _on_add_triangle_at_pressed();
void _on_add_auad_at_pressed();
void _oncreate_face_pressed();
void _on_delete_pressed();
void _on_GenNormals_pressed();
void _on_RemDoubles_pressed();
void _on_MergeOptimize_pressed();
void _on_GenTangents_pressed();
void _on_mark_seam_pressed();
void _on_unmark_seam_pressed();
void _on_apply_seams_pressed();
void _on_uv_edit_pressed();
void on_handle_selection_type_front_toggled(bool on);
void on_handle_selection_type_back_toggled(bool on);
void on_handle_selection_type_all_toggled(bool on);
void on_select_all_pressed();
//Vertex ops
void on_create_face_pressed();
void on_split_pressed();
void on_connect_to_first_selected_pressed();
void on_connect_to_avg_pressed();
void on_connect_to_last_selected_pressed();
//Edge ops
void on_extrude_pressed();
void on_add_triangle_at_pressed();
void on_add_quad_at_pressed();
void on_mark_seam_pressed();
void on_unmark_seam_pressed();
//Face ops
void on_delete_pressed();
void on_flip_face_pressed();
void on_pivot_average_toggled(bool on);
void on_pivot_mdi_origin_toggled(bool on);
void on_pivot_world_origin_toggled(bool on);
void on_visual_indicator_outline_toggled(bool on);
void on_visual_indicator_seam_toggled(bool on);
void on_visual_indicator_handle_toggled(bool on);
void _on_select_all_pressed();
void onhandle_selection_type_front_toggled(bool on);
void onhandle_selection_type_back_toggled(bool on);
void onhandle_selection_type_all_toggled(bool on);
//Ops
void on_generate_normals_pressed();
void on_generate_tangents_pressed();
void _on_clean_mesh_pressed();
void _on_flip_face_pressed();
void on_remove_doubles_pressed();
void on_merge_optimize_pressed();
void on_clean_mesh_pressed();
void on_uv_edit_pressed();
void on_apply_seams_pressed();
void on_unwrap_button_pressed();
void on_add_box_pressed();
void on_add_triangle_pressed();
void on_add_quad_pressed();
void _on_disconnect_pressed();
MDIEd();
~MDIEd();
@ -118,6 +131,22 @@ public:
MDREdUVPreviewer *uv_preview;
MDRUVRectEditorPopup *uv_editor;
VBoxContainer *vertex_operations_container;
VBoxContainer *edge_operations_container;
VBoxContainer *face_operations_container;
Button *_edit_mode_translate_button;
Button *_edit_mode_rotate_button;
Button *_edit_mode_scale_button;
Button *_axis_lock_x_button;
Button *_axis_lock_y_button;
Button *_axis_lock_z_button;
Button *_selection_mode_vertex_button;
Button *_selection_mode_edge_button;
Button *_selection_mode_face_button;
protected:
static void _bind_methods();
};

View File

@ -25,10 +25,11 @@ SOFTWARE.
#include "editor/editor_plugin.h"
#include "../../mesh_data_resource.h"
#include "../../nodes/mesh_data_instance.h"
#include "../mdi_ed_plugin.h"
//void MDRUVRectEditor::set_plugin(EditorPlugin *plugin) {
void MDRUVRectEditor::set_plugin(MDIEdPlugin *plugin) {
//$ScrollContainer/MarginContainer/RectView.set_plugin(plugin)
//}
}
void MDRUVRectEditor::set_mesh_data_resource(Ref<MeshDataResource> a) {
//$ScrollContainer/MarginContainer/RectView.set_mesh_data_resource(a)

View File

@ -29,12 +29,13 @@ SOFTWARE.
class EditorPlugin;
class MeshDataResource;
class MeshDataInstance;
class MDIEdPlugin;
class MDRUVRectEditor : public PanelContainer {
GDCLASS(MDRUVRectEditor, PanelContainer);
public:
//void set_plugin(EditorPlugin *plugin);
void set_plugin(MDIEdPlugin *plugin);
void set_mesh_data_resource(Ref<MeshDataResource> a);
void set_mesh_data_instance(MeshDataInstance *a);
void ok_pressed();

View File

@ -22,6 +22,7 @@ SOFTWARE.
#include "mdr_uv_rect_editor_popup.h"
#include "../mdi_ed_plugin.h"
#include "mdr_uv_rect_editor.h"
#include "scene/gui/button.h"
@ -32,6 +33,14 @@ void MDRUVRectEditorPopup::on_cancel_pressed() {
_editor->cancel_pressed();
}
MDRUVRectEditor *MDRUVRectEditorPopup::get_editor() {
return _editor;
}
void MDRUVRectEditorPopup::set_plugin(MDIEdPlugin *plugin) {
_editor->set_plugin(plugin);
}
MDRUVRectEditorPopup::MDRUVRectEditorPopup() {
_editor = memnew(MDRUVRectEditor);
_editor->set_h_size_flags(SIZE_EXPAND_FILL);

View File

@ -26,6 +26,7 @@ SOFTWARE.
#include "scene/gui/dialogs.h"
class MDRUVRectEditor;
class MDIEdPlugin;
class MDRUVRectEditorPopup : public ConfirmationDialog {
GDCLASS(MDRUVRectEditorPopup, ConfirmationDialog);
@ -36,6 +37,8 @@ public:
MDRUVRectEditor *get_editor();
void set_plugin(MDIEdPlugin *plugin);
MDRUVRectEditorPopup();
~MDRUVRectEditorPopup();