OverviewFilesCommitsIssuesDocsReleasesPeers

hyper-tps / scenes / test / proc_graph_editor_test.gd

70 lines · gd ref:
@tool
extends ProcGeometryNode

## Pre-builds a small graph for testing the visual graph editor.
## Select this node in the scene tree → "Proc Nodes" tab appears in bottom panel.

func _ready():
	_build_test_graph()
	call_deferred("_apply_material")

func _apply_material():
	var mesh_child = get_node_or_null("MeshOutput")
	if mesh_child and mesh_child is MeshInstance3D:
		var mat = StandardMaterial3D.new()
		mat.albedo_color = Color(0.45, 0.55, 0.35)
		mesh_child.material_override = mat

func _build_test_graph():
	var g = ProcNodeGraph.new()

	# 0: Grid mesh (10x10, 50x50 verts)
	var grid = MeshGridNode.new()
	grid.graph_position = Vector2(0, 0)
	g.add_node(grid)

	# 1: Grid size X
	var sx = ValueNode.new()
	sx.value = 10.0
	sx.graph_position = Vector2(-300, -100)
	g.add_node(sx)

	# 2: Grid size Y
	var sy = ValueNode.new()
	sy.value = 10.0
	sy.graph_position = Vector2(-300, 0)
	g.add_node(sy)

	# 3: Verts X
	var vx = ValueNode.new()
	vx.value = 50.0
	vx.graph_position = Vector2(-300, 100)
	g.add_node(vx)

	# 4: Verts Y
	var vy = ValueNode.new()
	vy.value = 50.0
	vy.graph_position = Vector2(-300, 200)
	g.add_node(vy)

	# 5: Displace
	var displace = DisplaceNode.new()
	displace.graph_position = Vector2(400, 0)
	g.add_node(displace)

	# 6: Strength
	var strength = ValueNode.new()
	strength.value = 1.5
	strength.graph_position = Vector2(100, 200)
	g.add_node(strength)

	# Connections
	g.connect_sockets(1, 0, 0, 0)  # sx → grid.SizeX
	g.connect_sockets(2, 0, 0, 1)  # sy → grid.SizeY
	g.connect_sockets(3, 0, 0, 2)  # vx → grid.VertsX
	g.connect_sockets(4, 0, 0, 3)  # vy → grid.VertsY
	g.connect_sockets(0, 0, 5, 0)  # grid.Geometry → displace.Geometry
	g.connect_sockets(6, 0, 5, 1)  # strength → displace.Strength

	self.graph = g