Implemented seam visualization. Also changed the color of the default mesh outline to gray.

This commit is contained in:
Relintai 2022-01-18 21:11:37 +01:00
parent d0d636554d
commit 302e0a9680
3 changed files with 29 additions and 2 deletions

View File

@ -6,7 +6,8 @@ const MDIGizmo = preload("res://addons/mesh_data_resource_editor/MIDGizmo.gd")
var plugin
func _init():
create_material("main", Color(1, 0, 0))
create_material("main", Color(0.7, 0.7, 0.7))
create_material("seam", Color(1, 0, 0))
create_handle_material("handles")
func get_name():

View File

@ -122,6 +122,7 @@ func redraw():
var handles_material : SpatialMaterial = get_plugin().get_material("handles", self)
var material = get_plugin().get_material("main", self)
var seam_material = get_plugin().get_material("seam", self)
_mesh_outline_generator.setup(_mdr)
@ -133,6 +134,7 @@ func redraw():
_mesh_outline_generator.generate()
add_lines(_mesh_outline_generator.lines, material, false)
add_lines(_mesh_outline_generator.seam_lines, seam_material, false)
if _selected_points.size() > 0:
var vs : PoolVector3Array = PoolVector3Array()

View File

@ -4,13 +4,15 @@ extends Reference
var _mdr : MeshDataResource
var lines : PoolVector3Array
var seam_lines : PoolVector3Array
func setup(mdr : MeshDataResource) -> void:
_mdr = mdr
func generate():
lines.resize(0)
seam_lines.resize(0)
if !_mdr:
return
@ -33,9 +35,16 @@ func generate():
for j in range(3):
lines.append(vertices[indices[i + j]])
lines.append(vertices[indices[i + ((j + 1) % 3)]])
var seams : PoolIntArray = _mdr.seams
for i in range(0, seams.size(), 2):
seam_lines.append(vertices[seams[i]])
seam_lines.append(vertices[seams[i + 1]])
func generate_mark_edges():
lines.resize(0)
seam_lines.resize(0)
if !_mdr:
return
@ -75,9 +84,17 @@ func generate_mark_edges():
lines.append(pmid + Vector3(0, 0, -l))
lines.append(pmid + Vector3(0, l, 0))
lines.append(pmid + Vector3(0, -l, 0))
var seams : PoolIntArray = _mdr.seams
for i in range(0, seams.size(), 2):
seam_lines.append(vertices[seams[i]])
seam_lines.append(vertices[seams[i + 1]])
func generate_mark_faces():
lines.resize(0)
seam_lines.resize(0)
if !_mdr:
return
@ -123,3 +140,10 @@ func generate_mark_faces():
lines.append(pmid + Vector3(0, 0, -l))
lines.append(pmid + Vector3(0, l, 0))
lines.append(pmid + Vector3(0, -l, 0))
var seams : PoolIntArray = _mdr.seams
for i in range(0, seams.size(), 2):
seam_lines.append(vertices[seams[i]])
seam_lines.append(vertices[seams[i + 1]])