ifire commited on
Commit
6b56a65
1 Parent(s): edf0304

Add godot.

Browse files
Files changed (1) hide show
  1. godot.gd +51 -0
godot.gd ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ @tool
2
+ extends EditorScript
3
+
4
+ var data:Dictionary = { "bathroom1": [8.52112676056338, 8.52112676056338, 6.408450704225352, 8.52112676056338, 6.408450704225352, 6.408450704225352, 8.52112676056338, 6.408450704225352], "bedroom1": [9.507042253521128, 5.422535211267606, 6.408450704225352, 5.422535211267606, 6.408450704225352, 3.3098591549295775, 9.507042253521128, 3.3098591549295775], "living_room": [14.71830985915493, 10.563380281690142, 10.563380281690142, 10.563380281690142, 10.563380281690142, 7.464788732394367, 14.71830985915493, 7.464788732394367], "kitchen": [9.507042253521128, 12.605633802816902, 4.366197183098592, 12.605633802816902, 4.366197183098592, 10.563380281690142, 9.507042253521128, 10.563380281690142], "bedroom2": [13.661971830985916, 7.464788732394367, 10.563380281690142, 7.464788732394367, 10.563380281690142, 6.408450704225352, 9.507042253521128, 6.408450704225352, 9.507042253521128, 4.366197183098592, 13.661971830985916, 4.366197183098592], "bedroom3": [12.605633802816902, 14.71830985915493, 9.507042253521128, 14.71830985915493, 9.507042253521128, 11.619718309859156, 10.563380281690142, 11.619718309859156, 10.563380281690142, 10.563380281690142, 12.605633802816902, 10.563380281690142], "bathroom2": [9.507042253521128, 10.563380281690142, 6.408450704225352, 10.563380281690142, 6.408450704225352, 8.52112676056338, 9.507042253521128, 8.52112676056338], "bedroom4": [5.422535211267606, 9.507042253521128, 3.3098591549295775, 9.507042253521128, 3.3098591549295775, 5.422535211267606, 5.422535211267606, 5.422535211267606], "corridor": [9.507042253521128, 11.619718309859156, 9.507042253521128, 8.52112676056338, 8.52112676056338, 8.52112676056338, 8.52112676056338, 6.408450704225352, 6.408450704225352, 6.408450704225352, 6.408450704225352, 9.507042253521128, 5.422535211267606, 9.507042253521128, 5.422535211267606, 5.422535211267606, 9.507042253521128, 5.422535211267606, 9.507042253521128, 6.408450704225352, 10.563380281690142, 6.408450704225352, 10.563380281690142, 11.619718309859156]}
5
+
6
+ func create_room(name: String, coords: Array, parent: Node, root: Node) -> void:
7
+ # Create vertices for the room
8
+ var verts = PackedVector2Array()
9
+ for i in range(0, coords.size(), 2):
10
+ verts.append(Vector2(coords[i], coords[i+1]))
11
+
12
+ # Create a new CSGPolygon3D with given name
13
+ var polygon = CSGPolygon3D.new()
14
+ polygon.polygon = verts
15
+ polygon.name = name
16
+ polygon.mode = CSGPolygon3D.MODE_DEPTH
17
+ polygon.depth = 3.0 # Set the depth of the room
18
+
19
+ # Create a smaller CSGPolygon3D for the inside cutout
20
+ var inner_polygon = CSGPolygon3D.new()
21
+ inner_polygon.name = name + "_inner"
22
+ inner_polygon.operation = CSGCombiner3D.OPERATION_SUBTRACTION
23
+ inner_polygon.polygon = verts
24
+ inner_polygon.mode = CSGPolygon3D.MODE_DEPTH
25
+ inner_polygon.depth = 2.9 # Set the depth of the cutout
26
+ inner_polygon.scale = Vector3(0.9, 0.9, 1.0) # Scale down to create a cutout
27
+
28
+ parent.add_child(polygon, true)
29
+ polygon.owner = root
30
+ polygon.add_child(inner_polygon, true)
31
+ inner_polygon.owner = root
32
+
33
+
34
+ func _run():
35
+ var root = get_scene()
36
+ var csg_combiner: CSGCombiner3D = CSGCombiner3D.new()
37
+ csg_combiner.name = "CSGCombiner3D"
38
+ root.add_child(csg_combiner, true)
39
+ csg_combiner.owner = root
40
+
41
+ # Create rooms from the data
42
+ for room_name in data.keys():
43
+ create_room(room_name, data[room_name], csg_combiner, root)
44
+
45
+ csg_combiner.owner = root
46
+
47
+ # Create rooms from the data
48
+ for room_name in data.keys():
49
+ create_room(room_name, data[room_name], csg_combiner, root)
50
+
51
+ csg_combiner.rotate_x(deg_to_rad(-90))