Work on the mesh data resource editor plugin.

This commit is contained in:
Relintai 2021-02-09 01:40:13 +01:00
parent 06912c320e
commit 7cdf7f2f61
4 changed files with 79 additions and 4 deletions

View File

@ -0,0 +1,21 @@
tool
extends EditorSpatialGizmoPlugin
const MDIGizmo = preload("res://addons/mesh_data_resource_editor/MIDGizmo.gd")
func _init():
create_material("main", Color(1, 0, 0))
create_handle_material("handles")
func get_name():
return "MDIGizmo"
func get_priority():
return 100
func create_gizmo(spatial):
if spatial is MeshDataInstance:
print("new gizmo")
return MDIGizmo.new()
else:
return null

View File

@ -0,0 +1,52 @@
tool
extends EditorSpatialGizmo
var gizmo_size = 3.0
func set_handle(index: int, camera: Camera, point: Vector2):
#print(index)
#print(point)
pass
func redraw():
#print("MIDGizmo redraw")
clear()
var node : MeshDataInstance = get_spatial_node()
if !node:
return
var mdr : MeshDataResource = node.mesh_data
if !mdr:
return
var handles_material : SpatialMaterial = get_plugin().get_material("handles", self)
var handles : PoolVector3Array = mdr.array[ArrayMesh.ARRAY_VERTEX]
add_handles(handles, handles_material)
var material = get_plugin().get_material("main", self)
var lines : PoolVector3Array = PoolVector3Array()
var indices : PoolIntArray = mdr.array[ArrayMesh.ARRAY_INDEX]
if indices.size() % 3 == 0:
for i in range(0, len(indices), 3):
lines.append(handles[i])
lines.append(handles[i + 1])
lines.append(handles[i + 1])
lines.append(handles[i + 2])
lines.append(handles[i + 2])
lines.append(handles[i])
add_lines(lines, material, false)

View File

@ -1,10 +1,12 @@
tool tool
extends EditorPlugin extends EditorPlugin
const MdiGizmoPlugin = preload("res://addons/mesh_data_resource_editor/MDIGizmoPlugin.gd")
var gizmo_plugin = MdiGizmoPlugin.new()
func _enter_tree(): func _enter_tree():
pass add_spatial_gizmo_plugin(gizmo_plugin)
func _exit_tree(): func _exit_tree():
pass remove_spatial_gizmo_plugin(gizmo_plugin)

View File

@ -311,7 +311,7 @@ window/size/ui_scale_touch=1.0
[editor_plugins] [editor_plugins]
enabled=PoolStringArray( "Godoxel", "gdpose", "mesh_data_resource_editor" ) enabled=PoolStringArray( "Godoxel", "gdpose" )
[ess] [ess]