@tool extends EditorScript var data:Dictionary = {"bedroom1": [9.014084507042254, 4.366197183098592, 3.8732394366197185, 4.366197183098592, 3.8732394366197185, 2.323943661971831, 9.014084507042254, 2.323943661971831], "living_room": [14.15492957746479, 11.619718309859156, 9.014084507042254, 11.619718309859156, 9.014084507042254, 5.422535211267606, 14.15492957746479, 5.422535211267606], "bathroom1": [7.95774647887324, 7.464788732394367, 5.915492957746479, 7.464788732394367, 5.915492957746479, 4.366197183098592, 7.95774647887324, 4.366197183098592], "bedroom2": [7.95774647887324, 12.605633802816902, 4.859154929577465, 12.605633802816902, 4.859154929577465, 7.464788732394367, 7.95774647887324, 7.464788732394367], "bathroom2": [10.070422535211268, 15.704225352112676, 7.95774647887324, 15.704225352112676, 7.95774647887324, 13.661971830985916, 10.070422535211268, 13.661971830985916], "bedroom3": [14.15492957746479, 15.704225352112676, 10.070422535211268, 15.704225352112676, 10.070422535211268, 12.605633802816902, 14.15492957746479, 12.605633802816902], "kitchen": [13.169014084507042, 5.422535211267606, 9.014084507042254, 5.422535211267606, 9.014084507042254, 2.323943661971831, 13.169014084507042, 2.323943661971831], "corridor": [14.15492957746479, 12.605633802816902, 10.070422535211268, 12.605633802816902, 10.070422535211268, 13.661971830985916, 7.95774647887324, 13.661971830985916, 7.95774647887324, 4.366197183098592, 9.014084507042254, 4.366197183098592, 9.014084507042254, 11.619718309859156, 14.15492957746479, 11.619718309859156]} const architext_colors = [[0, 0, 0], [249, 222, 182], [195, 209, 217], [250, 120, 128], [126, 202, 234], [190, 0, 198], [255, 255, 255], [6, 53, 17], [17, 33, 58], [132, 151, 246], [197, 203, 159], [6, 53, 17],] const housegan_labels = {"living_room": 1, "kitchen": 2, "bedroom": 3, "bathroom": 4, "missing": 5, "closet": 6, "balcony": 7, "hallway": 8, "dining_room": 9, "laundry_room": 10, "corridor": 8} func create_room(name: String, coords: Array, parent: Node, root: Node, depth: float, inset: float, operation: int, color: Color, elevation: float) -> void: # Calculate the center of the room var center = Vector2.ZERO for i in range(0, coords.size(), 2): center += Vector2(coords[i], coords[i+1]) center /= (coords.size() / 2) # Create vertices for the room with inset var verts = PackedVector2Array() for i in range(0, coords.size(), 2): var vertex = Vector2(coords[i], coords[i+1]) var direction = (vertex - center).normalized() verts.append(vertex + direction * inset) # Create a new CSGPolygon3D with given name var polygon = CSGPolygon3D.new() polygon.polygon = verts polygon.name = name polygon.mode = CSGPolygon3D.MODE_DEPTH polygon.depth = depth polygon.operation = operation polygon.smooth_faces = true # Elevate the polygon if needed polygon.translate(Vector3(0, elevation, 0)) polygon.rotate_x(deg_to_rad(90)) # Apply color coding var material: StandardMaterial3D = StandardMaterial3D.new() for room_name in housegan_labels.keys(): if not name.begins_with(room_name): continue var color_values = architext_colors[housegan_labels[room_name]] material.albedo_color = Color(color_values[0]/255.0, color_values[1]/255.0, color_values[2]/255.0).srgb_to_linear() if color != Color.TRANSPARENT: material.albedo_color = color polygon.material = material # Add polygons to the parent node parent.add_child(polygon, true) polygon.owner = root func _run(): var root = get_scene() for child in root.get_children(): child.queue_free() # First layer of CSGCombiner3D var csg_combiner: CSGCombiner3D = CSGCombiner3D.new() csg_combiner.name = "CSGCombiner3D" root.add_child(csg_combiner, true) csg_combiner.owner = root csg_combiner.use_collision = true # Second layer of CSGCombiner3D for the place plate var csg_combiner_plate: CSGCombiner3D = CSGCombiner3D.new() csg_combiner_plate.name = "CSGCombiner3D_Plate" csg_combiner_plate.transform.origin.y = csg_combiner_plate.transform.origin.y - 0.1 csg_combiner.add_child(csg_combiner_plate, true) csg_combiner_plate.owner = root # Ensure all depths are positive var base_depth = 1.0 # Base depth for rooms var inset_depth = 0.4 # Additional depth for insets var foundation_depth = 0.2 # Depth for foundations for room_name in data.keys(): if room_name != "corridor": create_room(room_name, data[room_name], csg_combiner, root, base_depth, 0.0, CSGPolygon3D.OPERATION_UNION, Color.TRANSPARENT, 0.0) else: create_room(room_name, data[room_name], csg_combiner, root, 0.2, 0.0, CSGPolygon3D.OPERATION_UNION, Color.TRANSPARENT, 0.0) for room_name in data.keys(): if room_name != "corridor": create_room(room_name + "Inset", data[room_name], csg_combiner, root, base_depth + inset_depth, -0.24, CSGPolygon3D.OPERATION_SUBTRACTION, Color.TRANSPARENT, 0.05)