@tool
extends ProcGeometryNode
## Instance test: DistributePointsOnFaces(grid) → InstanceOnPoints(cube)
## Expected: many small cubes scattered across a grid surface via MultiMesh
## Also tests: RotateInstances to tilt them
func _ready():
_build_graph()
call_deferred("_apply_material")
func _apply_material():
# Material for the MultiMesh instances
var mm_child = get_node_or_null("MultiMeshOutput")
if mm_child and mm_child is MultiMeshInstance3D:
var mat = StandardMaterial3D.new()
mat.albedo_color = Color(0.9, 0.4, 0.1)
mat.roughness = 0.6
mm_child.material_override = mat
func _build_graph():
var g = ProcNodeGraph.new()
# 0: Grid as scatter surface
var grid = MeshGridNode.new()
g.add_node(grid)
var sx = ValueNode.new(); sx.value = 8.0; g.add_node(sx)
var sy = ValueNode.new(); sy.value = 8.0; g.add_node(sy)
var vx = ValueNode.new(); vx.value = 10.0; g.add_node(vx)
var vy = ValueNode.new(); vy.value = 10.0; g.add_node(vy)
# 5: Scatter points on grid
var scatter = DistributePointsOnFacesNode.new()
g.add_node(scatter)
var count = ValueNode.new(); count.value = 200.0; g.add_node(count)
var seed_val = ValueNode.new(); seed_val.value = 42.0; g.add_node(seed_val)
# 8: Small cube to instance
var cube = MeshCubeNode.new()
g.add_node(cube)
# 9: Instance on Points
var inst = InstanceOnPointsNode.new()
g.add_node(inst)
var inst_scale = ValueNode.new(); inst_scale.value = 0.15; g.add_node(inst_scale)
# 11: Rotate instances 45 degrees on Y
var rot = RotateInstancesNode.new()
g.add_node(rot)
var rot_val = VectorNode.new(); rot_val.value = Vector3(0, 45, 0); g.add_node(rot_val)
# --- Connections ---
g.connect_sockets(1, 0, 0, 0) # sx → grid
g.connect_sockets(2, 0, 0, 1) # sy → grid
g.connect_sockets(3, 0, 0, 2) # vx → grid
g.connect_sockets(4, 0, 0, 3) # vy → grid
g.connect_sockets(0, 0, 5, 0) # grid → scatter.Geometry
g.connect_sockets(6, 0, 5, 1) # count → scatter.Count
g.connect_sockets(7, 0, 5, 2) # seed → scatter.Seed
g.connect_sockets(5, 0, 9, 0) # scatter → instance.Points
g.connect_sockets(8, 0, 9, 1) # cube → instance.Instance
g.connect_sockets(10, 0, 9, 2) # scale → instance.Scale
g.connect_sockets(9, 0, 11, 0) # instance → rotate.Geometry
g.connect_sockets(12, 0, 11, 1) # rot_val → rotate.Rotation
self.graph = g
print("Instance test: 200 rotated cubes scattered on 8x8 grid (MultiMesh)")