Direct rotation control, closes #49
This commit is contained in:
@@ -122,7 +122,7 @@ text = "NPC Mode"
|
||||
unique_name_in_owner = true
|
||||
margin_top = 206.0
|
||||
margin_right = 248.0
|
||||
margin_bottom = 622.0
|
||||
margin_bottom = 650.0
|
||||
|
||||
[node name="HSeparator" type="HSeparator" parent="VBoxContainer/v_buildings"]
|
||||
margin_right = 248.0
|
||||
@@ -131,13 +131,13 @@ margin_bottom = 4.0
|
||||
[node name="base" type="PanelContainer" parent="VBoxContainer/v_buildings"]
|
||||
margin_top = 8.0
|
||||
margin_right = 248.0
|
||||
margin_bottom = 416.0
|
||||
margin_bottom = 444.0
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="VBoxContainer/v_buildings/base"]
|
||||
margin_left = 7.0
|
||||
margin_top = 7.0
|
||||
margin_right = 241.0
|
||||
margin_bottom = 401.0
|
||||
margin_bottom = 429.0
|
||||
|
||||
[node name="Label" type="Label" parent="VBoxContainer/v_buildings/base/VBoxContainer"]
|
||||
margin_right = 234.0
|
||||
@@ -200,110 +200,127 @@ margin_bottom = 114.0
|
||||
|
||||
[node name="building_position_x" type="LineEdit" parent="VBoxContainer/v_buildings/base/VBoxContainer/HBoxContainer2"]
|
||||
unique_name_in_owner = true
|
||||
margin_right = 63.0
|
||||
margin_right = 75.0
|
||||
margin_bottom = 24.0
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="building_position_y" type="LineEdit" parent="VBoxContainer/v_buildings/base/VBoxContainer/HBoxContainer2"]
|
||||
unique_name_in_owner = true
|
||||
margin_left = 67.0
|
||||
margin_right = 130.0
|
||||
margin_left = 79.0
|
||||
margin_right = 154.0
|
||||
margin_bottom = 24.0
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="building_position_z" type="LineEdit" parent="VBoxContainer/v_buildings/base/VBoxContainer/HBoxContainer2"]
|
||||
unique_name_in_owner = true
|
||||
margin_left = 134.0
|
||||
margin_right = 197.0
|
||||
margin_left = 158.0
|
||||
margin_right = 234.0
|
||||
margin_bottom = 24.0
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="buildings_set_building_position" type="Button" parent="VBoxContainer/v_buildings/base/VBoxContainer/HBoxContainer2"]
|
||||
[node name="HBoxContainer3" type="HBoxContainer" parent="VBoxContainer/v_buildings/base/VBoxContainer"]
|
||||
margin_top = 118.0
|
||||
margin_right = 234.0
|
||||
margin_bottom = 142.0
|
||||
|
||||
[node name="Label" type="Label" parent="VBoxContainer/v_buildings/base/VBoxContainer/HBoxContainer3"]
|
||||
margin_top = 5.0
|
||||
margin_right = 18.0
|
||||
margin_bottom = 19.0
|
||||
text = "rot"
|
||||
|
||||
[node name="building_rotation_y" type="LineEdit" parent="VBoxContainer/v_buildings/base/VBoxContainer/HBoxContainer3"]
|
||||
unique_name_in_owner = true
|
||||
margin_left = 201.0
|
||||
margin_right = 233.0
|
||||
margin_left = 22.0
|
||||
margin_right = 80.0
|
||||
margin_bottom = 24.0
|
||||
|
||||
[node name="buildings_set_building_position" type="Button" parent="VBoxContainer/v_buildings/base/VBoxContainer/HBoxContainer3"]
|
||||
unique_name_in_owner = true
|
||||
margin_left = 84.0
|
||||
margin_right = 116.0
|
||||
margin_bottom = 24.0
|
||||
text = "Set"
|
||||
|
||||
[node name="HSeparator3" type="HSeparator" parent="VBoxContainer/v_buildings/base/VBoxContainer"]
|
||||
margin_top = 118.0
|
||||
margin_top = 146.0
|
||||
margin_right = 234.0
|
||||
margin_bottom = 122.0
|
||||
margin_bottom = 150.0
|
||||
|
||||
[node name="Label4" type="Label" parent="VBoxContainer/v_buildings/base/VBoxContainer"]
|
||||
margin_top = 126.0
|
||||
margin_top = 154.0
|
||||
margin_right = 234.0
|
||||
margin_bottom = 140.0
|
||||
margin_bottom = 168.0
|
||||
text = "Mode"
|
||||
|
||||
[node name="buildings_edit_mode" type="OptionButton" parent="VBoxContainer/v_buildings/base/VBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
margin_top = 144.0
|
||||
margin_top = 172.0
|
||||
margin_right = 234.0
|
||||
margin_bottom = 164.0
|
||||
margin_bottom = 192.0
|
||||
text = "Select"
|
||||
items = [ "Select", null, false, 0, null, "Move", null, false, 1, null, "Rotate", null, false, 2, null, "Create", null, false, 3, null ]
|
||||
selected = 0
|
||||
|
||||
[node name="Label2" type="Label" parent="VBoxContainer/v_buildings/base/VBoxContainer"]
|
||||
margin_top = 168.0
|
||||
margin_top = 196.0
|
||||
margin_right = 234.0
|
||||
margin_bottom = 182.0
|
||||
margin_bottom = 210.0
|
||||
text = "Building type"
|
||||
|
||||
[node name="building_type" type="OptionButton" parent="VBoxContainer/v_buildings/base/VBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
margin_top = 186.0
|
||||
margin_top = 214.0
|
||||
margin_right = 234.0
|
||||
margin_bottom = 206.0
|
||||
margin_bottom = 234.0
|
||||
text = "Building Type"
|
||||
|
||||
[node name="HSeparator2" type="HSeparator" parent="VBoxContainer/v_buildings/base/VBoxContainer"]
|
||||
margin_top = 210.0
|
||||
margin_top = 238.0
|
||||
margin_right = 234.0
|
||||
margin_bottom = 214.0
|
||||
margin_bottom = 242.0
|
||||
|
||||
[node name="buildings_delete_building" type="Button" parent="VBoxContainer/v_buildings/base/VBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
margin_top = 218.0
|
||||
margin_top = 246.0
|
||||
margin_right = 234.0
|
||||
margin_bottom = 238.0
|
||||
margin_bottom = 266.0
|
||||
text = "Delete building"
|
||||
|
||||
[node name="buildings_create_building" type="Button" parent="VBoxContainer/v_buildings/base/VBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
margin_top = 242.0
|
||||
margin_top = 270.0
|
||||
margin_right = 234.0
|
||||
margin_bottom = 262.0
|
||||
margin_bottom = 290.0
|
||||
text = "Create building"
|
||||
|
||||
[node name="buildings_save" type="Button" parent="VBoxContainer/v_buildings/base/VBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
margin_top = 266.0
|
||||
margin_top = 294.0
|
||||
margin_right = 234.0
|
||||
margin_bottom = 286.0
|
||||
margin_bottom = 314.0
|
||||
text = "Save Buildings"
|
||||
|
||||
[node name="lines_list_building" type="ItemList" parent="VBoxContainer/v_buildings/base/VBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
margin_top = 290.0
|
||||
margin_top = 318.0
|
||||
margin_right = 234.0
|
||||
margin_bottom = 370.0
|
||||
margin_bottom = 398.0
|
||||
rect_min_size = Vector2( 0, 80 )
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="buildings_assign_to_line" type="Button" parent="VBoxContainer/v_buildings/base/VBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
margin_top = 374.0
|
||||
margin_top = 402.0
|
||||
margin_right = 234.0
|
||||
margin_bottom = 394.0
|
||||
margin_bottom = 422.0
|
||||
text = "Assign To Line"
|
||||
|
||||
[node name="v_navigation" type="VBoxContainer" parent="VBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
margin_top = 626.0
|
||||
margin_top = 654.0
|
||||
margin_right = 248.0
|
||||
margin_bottom = 648.0
|
||||
margin_bottom = 676.0
|
||||
|
||||
[node name="HSeparator" type="HSeparator" parent="VBoxContainer/v_navigation"]
|
||||
margin_right = 248.0
|
||||
@@ -317,9 +334,9 @@ text = "Navigation mode"
|
||||
|
||||
[node name="v_poi" type="VBoxContainer" parent="VBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
margin_top = 652.0
|
||||
margin_top = 680.0
|
||||
margin_right = 248.0
|
||||
margin_bottom = 674.0
|
||||
margin_bottom = 702.0
|
||||
|
||||
[node name="HSeparator" type="HSeparator" parent="VBoxContainer/v_poi"]
|
||||
margin_right = 248.0
|
||||
@@ -333,9 +350,9 @@ text = "POI mode"
|
||||
|
||||
[node name="v_road_lines" type="VBoxContainer" parent="VBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
margin_top = 678.0
|
||||
margin_top = 706.0
|
||||
margin_right = 248.0
|
||||
margin_bottom = 1637.0
|
||||
margin_bottom = 1665.0
|
||||
|
||||
[node name="HSeparator" type="HSeparator" parent="VBoxContainer/v_road_lines"]
|
||||
margin_right = 248.0
|
||||
@@ -713,9 +730,9 @@ text = "Close"
|
||||
|
||||
[node name="v_npc" type="VBoxContainer" parent="VBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
margin_top = 1641.0
|
||||
margin_top = 1669.0
|
||||
margin_right = 248.0
|
||||
margin_bottom = 1663.0
|
||||
margin_bottom = 1691.0
|
||||
|
||||
[node name="HSeparator" type="HSeparator" parent="VBoxContainer/v_npc"]
|
||||
margin_right = 248.0
|
||||
|
||||
@@ -94,10 +94,19 @@ private:
|
||||
"%building_position_y");
|
||||
LineEdit *position_z = editor->get_as_node<LineEdit>(
|
||||
"%building_position_z");
|
||||
LineEdit *position_rot = editor->get_as_node<LineEdit>(
|
||||
"%building_rotation_y");
|
||||
Transform xform = editor->get_selected_building_xform();
|
||||
position_x->set_text(String::num(xform.origin.x));
|
||||
position_y->set_text(String::num(xform.origin.y));
|
||||
position_z->set_text(String::num(xform.origin.z));
|
||||
Vector3 reference(0, 0, -1);
|
||||
Vector3 rotated =
|
||||
xform.basis.xform(reference).normalized();
|
||||
float angle = reference.signed_angle_to(
|
||||
rotated, Vector3(0, 1, 0));
|
||||
position_rot->set_text(
|
||||
String::num(angle * 180.0f / Math_PI));
|
||||
}
|
||||
}
|
||||
void handle_set_cursor()
|
||||
@@ -122,7 +131,12 @@ private:
|
||||
editor->get_as_node<LineEdit>("%building_position_y");
|
||||
LineEdit *position_z =
|
||||
editor->get_as_node<LineEdit>("%building_position_z");
|
||||
LineEdit *position_rot =
|
||||
editor->get_as_node<LineEdit>("%building_rotation_y");
|
||||
Transform xform = editor->get_selected_building_xform();
|
||||
xform.basis = Basis().rotated(
|
||||
Vector3(0, 1, 0),
|
||||
position_rot->get_text().to_float() * Math_PI / 180.0f);
|
||||
xform.origin.x = position_x->get_text().to_float();
|
||||
xform.origin.y = position_y->get_text().to_float();
|
||||
xform.origin.z = position_z->get_text().to_float();
|
||||
@@ -155,8 +169,10 @@ private:
|
||||
editor->get_as_node<LineEdit>("%building_position_y");
|
||||
LineEdit *position_z =
|
||||
editor->get_as_node<LineEdit>("%building_position_z");
|
||||
LineEdit *position_le[] = { position_x, position_y,
|
||||
position_z };
|
||||
LineEdit *position_rot =
|
||||
editor->get_as_node<LineEdit>("%building_rotation_y");
|
||||
LineEdit *position_le[] = { position_x, position_y, position_z,
|
||||
position_rot };
|
||||
Button *set_building_position = editor->get_as_node<Button>(
|
||||
"%buildings_set_building_position");
|
||||
int sz_cursor = (int)(sizeof(cursor_le) / sizeof(cursor_le[0]));
|
||||
|
||||
Reference in New Issue
Block a user