Implemented add box and add quad.

This commit is contained in:
Relintai 2022-01-03 16:54:28 +01:00
parent b66331f8ab
commit 0bb573a2ee
3 changed files with 72 additions and 19 deletions

View File

@ -181,7 +181,7 @@ margin_bottom = 94.0
[node name="Operations" type="VBoxContainer" parent="VBoxContainer"]
margin_top = 98.0
margin_right = 1010.0
margin_bottom = 304.0
margin_bottom = 328.0
[node name="OperationsLabel" type="Label" parent="VBoxContainer/Operations"]
margin_right = 1010.0
@ -193,7 +193,7 @@ valign = 1
[node name="Operations" type="VBoxContainer" parent="VBoxContainer/Operations"]
margin_top = 18.0
margin_right = 1010.0
margin_bottom = 206.0
margin_bottom = 230.0
[node name="Extrude" type="Button" parent="VBoxContainer/Operations/Operations"]
margin_right = 1010.0
@ -236,21 +236,27 @@ margin_right = 1010.0
margin_bottom = 164.0
text = "Split"
[node name="SplitOffset" type="Button" parent="VBoxContainer/Operations/Operations"]
[node name="Connect" type="Button" parent="VBoxContainer/Operations/Operations"]
margin_top = 168.0
margin_right = 1010.0
margin_bottom = 188.0
text = "Split Offset"
text = "Connect"
[node name="Disconnect" type="Button" parent="VBoxContainer/Operations/Operations"]
margin_top = 192.0
margin_right = 1010.0
margin_bottom = 212.0
text = "Disconnect"
[node name="HSeparator3" type="HSeparator" parent="VBoxContainer"]
margin_top = 308.0
margin_top = 332.0
margin_right = 1010.0
margin_bottom = 312.0
margin_bottom = 336.0
[node name="Add" type="VBoxContainer" parent="VBoxContainer"]
margin_top = 316.0
margin_top = 340.0
margin_right = 1010.0
margin_bottom = 402.0
margin_bottom = 426.0
[node name="AddLabel" type="Label" parent="VBoxContainer/Add"]
margin_right = 1010.0
@ -282,12 +288,12 @@ margin_bottom = 68.0
text = "Quad"
[node name="HSeparator2" type="HSeparator" parent="VBoxContainer"]
margin_top = 406.0
margin_top = 430.0
margin_right = 1010.0
margin_bottom = 410.0
margin_bottom = 434.0
[node name="VBoxContainer" type="VBoxContainer" parent="VBoxContainer"]
margin_top = 414.0
margin_top = 438.0
margin_right = 1010.0
margin_bottom = 586.0
size_flags_horizontal = 3
@ -303,7 +309,7 @@ valign = 1
[node name="UVEditorScrollContainer" type="ScrollContainer" parent="VBoxContainer/VBoxContainer"]
margin_top = 18.0
margin_right = 1010.0
margin_bottom = 172.0
margin_bottom = 148.0
size_flags_horizontal = 3
size_flags_vertical = 3
__meta__ = {

View File

@ -3,6 +3,7 @@ extends EditorSpatialGizmo
var MeshOutline = preload("res://addons/mesh_data_resource_editor/utilities/mesh_outline.gd")
var MeshDecompose = preload("res://addons/mesh_data_resource_editor/utilities/mesh_decompose.gd")
var MeshAddUtils = preload("res://addons/mesh_data_resource_editor/utilities/mesh_add_utils.gd")
enum EditMode {
EDIT_MODE_NONE = 0,
@ -375,10 +376,13 @@ func on_mdr_changed() -> void:
redraw()
func add_triangle() -> void:
if !_mdr:
return
if _mdr:
MeshAddUtils.add_triangle(_mdr)
func add_quad() -> void:
pass
if _mdr:
MeshAddUtils.add_quad(_mdr)
func add_box() -> void:
if _mdr:
MeshAddUtils.add_box(_mdr)

View File

@ -2,7 +2,50 @@ tool
extends Object
static func add_triangle(mdr : MeshDataResource) -> void:
pass
var st : SurfaceTool = SurfaceTool.new()
st.begin(Mesh.PRIMITIVE_TRIANGLES)
st.add_uv(Vector2(0, 1))
st.add_vertex(Vector3(-0.5, -0.5, 0))
st.add_uv(Vector2(0.5, 0))
st.add_vertex(Vector3(0, 0.5, 0))
st.add_uv(Vector2(1, 1))
st.add_vertex(Vector3(0.5, -0.5, 0))
st.add_index(0)
st.add_index(1)
st.add_index(2)
st.generate_normals()
merge_in_surface_tool(mdr, st)
static func add_quad(mdr : MeshDataResource) -> void:
var st : SurfaceTool = SurfaceTool.new()
st.begin(Mesh.PRIMITIVE_TRIANGLES)
st.add_uv(Vector2(0, 1))
st.add_vertex(Vector3(-0.5, -0.5, 0))
st.add_uv(Vector2(0, 0))
st.add_vertex(Vector3(-0.5, 0.5, 0))
st.add_uv(Vector2(1, 0))
st.add_vertex(Vector3(0.5, 0.5, 0))
st.add_uv(Vector2(1, 1))
st.add_vertex(Vector3(0.5, -0.5, 0))
st.add_index(0)
st.add_index(1)
st.add_index(2)
st.add_index(2)
st.add_index(3)
st.add_index(0)
st.generate_normals()
merge_in_surface_tool(mdr, st)
static func add_box(mdr : MeshDataResource) -> void:
var st : SurfaceTool = SurfaceTool.new()