diff --git a/buildings/elements/Balcony.py b/buildings/elements/Balcony.py index 6f1bc1f..cc11be8 100644 --- a/buildings/elements/Balcony.py +++ b/buildings/elements/Balcony.py @@ -1,5 +1,7 @@ import random as rd -from gdpc import Editor, Block, geometry, Transform +from gdpc import Editor, Block, geometry +from utils.functions import * +from utils.Enums import BALCONY_BORDER_RADIUS from buildings.geometry.Point import Point from buildings.geometry.Vertice import Vertice from buildings.elements.Window import Window @@ -12,6 +14,7 @@ class Balcony: self.length = self.get_len() self.has_multiple = self.has_multiple() self.has_details = self.has_details() + self.border_radius = self.has_border_radius() self.follow_window = self.follow_window() self.structure = self.get_structures() self.editor, self.materials = None,None @@ -23,6 +26,7 @@ class Balcony: s.fill(editor, materials[0]) self.build_rembard(s) self.build_details(s) + self.build_border_radius(s) def build_rembard(self, s : Vertice): geometry.placeCuboid(self.editor,(s.point1.x,1,-1),(s.point1.x,1,-self.length),Block(self.materials[3])) @@ -34,8 +38,27 @@ class Balcony: geometry.placeCuboid(self.editor,(s.point1.x,0,-1),(s.point1.x,0,-self.length),Block(self.materials[4], {"facing": "east", "half": "top"})) geometry.placeCuboid(self.editor,(s.point2.x,0,-1),(s.point2.x,0,-self.length),Block(self.materials[4], {"facing": "west", "half": "top"})) geometry.placeCuboid(self.editor,(s.point1.x,0,-self.length),(s.point2.x,0,-self.length),Block(self.materials[4], {"facing": "south", "half": "top"})) + + def build_border_radius(self, s : Vertice): + if self.border_radius == BALCONY_BORDER_RADIUS.NONE: return + + geometry.placeCuboid(self.editor,(s.point1.x,0,-self.length),(s.point1.x,1,-self.length),Block("air")) + geometry.placeCuboid(self.editor,(s.point2.x,0,-self.length),(s.point2.x,1,-self.length),Block("air")) + self.editor.placeBlock((s.point1.x+1,1,-self.length+1), Block(self.materials[3])) + self.editor.placeBlock((s.point2.x-1,1,-self.length+1), Block(self.materials[3])) + + if self.has_details: + self.editor.placeBlock((s.point1.x,0,-self.length+1), Block(self.materials[4], {"facing": "south", "half": "top"})) + self.editor.placeBlock((s.point1.x+1,0,-self.length), Block(self.materials[4], {"facing": "east", "half": "top"})) + self.editor.placeBlock((s.point2.x,0,-self.length+1), Block(self.materials[4], {"facing": "south", "half": "top"})) + self.editor.placeBlock((s.point2.x-1,0,-self.length), Block(self.materials[4], {"facing": "west", "half": "top"})) + + if self.border_radius == BALCONY_BORDER_RADIUS.FULL: + self.editor.placeBlock((s.point1.x+1,0,-self.length+1), Block(self.materials[4], {"facing": "east", "half": "top"})) + self.editor.placeBlock((s.point2.x-1,0,-self.length+1), Block(self.materials[4], {"facing": "west", "half": "top"})) def get_structures(self) -> list[Vertice]: + # structures are the base shape of the balcony attach_points = self.get_attach_points() len_attach_points = len(attach_points)-1 min_wid = self.rdata["size"]["min_width"] @@ -70,6 +93,7 @@ class Balcony: return structures def get_attach_points(self) -> list[int]: + # points where the structures can start/finish points = [i for i in range(self.max_width)] if self.follow_window: pad = self.windows.padding @@ -97,5 +121,9 @@ class Balcony: def has_details(self) -> bool: return self.rdata["details"] >= rd.random() + def has_border_radius(self) -> bool: + if self.length < 2: return BALCONY_BORDER_RADIUS.NONE + return select_random(self.rdata["border_radius"], BALCONY_BORDER_RADIUS) + def get_len(self) -> int: return rd.randint(self.rdata["size"]["min_len"], self.rdata["size"]["max_len"]) \ No newline at end of file diff --git a/buildings/elements/FacadeDetails.py b/buildings/elements/FacadeDetails.py new file mode 100644 index 0000000..9770cdc --- /dev/null +++ b/buildings/elements/FacadeDetails.py @@ -0,0 +1,19 @@ +from buildings.geometry.Vertice import Vertice + +class FacadeDetails: + def __init__(self,rdata , zones : list[Vertice]): + self.zones = zones + self.sizes = self.get_sizes() + + def get_sizes(self) -> list[tuple[int]]: + # foreach different zone sizes in self.zones, we will gen different details + sizes = [] + center_for_symetry = len(self.zones) // 2 + for zone in self.zones: + size = zone.point2.position - zone.point1.position + if size not in sizes : + sizes.append(size) + + return sizes + + \ No newline at end of file diff --git a/buildings/elements/Window.py b/buildings/elements/Window.py index 953d074..4028158 100644 --- a/buildings/elements/Window.py +++ b/buildings/elements/Window.py @@ -1,7 +1,7 @@ import random as rd import math from gdpc import Editor, Block, geometry, Transform -from utils.Enums import COLLUMN_STYLE, BORDER_RADIUS +from utils.Enums import WINDOW_BORDER_RADIUS from utils.functions import * from buildings.geometry.Point import Point from buildings.geometry.Vertice import Vertice @@ -39,10 +39,10 @@ class Window: geometry.placeCuboid(self.editor,(x1+x,0,0),(x2-x,self.height,0),Block(self.materials[3], {"up" : "true"})) def build_border_radius(self, x1 : int, x2 : int): - if self.border_radius != BORDER_RADIUS.NONE: + if self.border_radius != WINDOW_BORDER_RADIUS.NONE: self.editor.placeBlock((x1,self.height,0),Block(self.materials[4], {"facing": "west", "half": "top"})) self.editor.placeBlock((x2,self.height,0),Block(self.materials[4], {"facing": "east", "half": "top"})) - if self.border_radius == BORDER_RADIUS.TOP_AND_BOTTOM: + if self.border_radius == WINDOW_BORDER_RADIUS.TOP_AND_BOTTOM: self.editor.placeBlock((x1,0,0),Block(self.materials[4], {"facing": "west"})) self.editor.placeBlock((x2,0,0),Block(self.materials[4], {"facing": "east"})) @@ -143,4 +143,4 @@ class Window: return (data["vertical_crossbar"] >= rd.random(), data["horizontal_crossbar"] >= rd.random()) def border_radius(self): - return select_random(self.rdata["border_radius"], BORDER_RADIUS) \ No newline at end of file + return select_random(self.rdata["border_radius"], WINDOW_BORDER_RADIUS) \ No newline at end of file diff --git a/main.py b/main.py index 45fe8f5..116d074 100644 --- a/main.py +++ b/main.py @@ -7,7 +7,7 @@ from buildings.Building import Building from buildings.geometry.Vertice import Vertice from buildings.geometry.Point import Point -from utils.Enums import DIRECTION,COLLUMN_STYLE,BORDER_RADIUS +from utils.Enums import DIRECTION,COLLUMN_STYLE,WINDOW_BORDER_RADIUS from buildings.Facade import Facade from utils.functions import * @@ -42,7 +42,7 @@ for f in facade: # geometry.placeCuboid(editor, (-10,-60,-10), (85,-55,85), Block("air")) # B = Building((0,0), (75,75), shapes[7]['matrice']) -# B.foundations.polygon.fill_vertice(editor, "pink_wool", -60) +# B.foundations.polygon.fill_vertice(editor, "pink_wool", -60) # for collumn in B.foundations.collumns: # collumn.fill(editor, "white_concrete", -60, -55) # B.foundations.polygon.fill_polygon(editor, "white_concrete", -60) diff --git a/params.yml b/params.yml index c59eb99..cd6b099 100644 --- a/params.yml +++ b/params.yml @@ -53,4 +53,10 @@ buildings: proba: 1 min_width: 5 min_gap: 1 - details: 0.35 \ No newline at end of file + details: 0.35 + border_radius: + # proportion of each style + none: 6 + # no difference if there is no details + medium: 1 + full: 1 \ No newline at end of file diff --git a/utils/Enums.py b/utils/Enums.py index 2927857..3a33d02 100644 --- a/utils/Enums.py +++ b/utils/Enums.py @@ -12,7 +12,12 @@ class COLLUMN_STYLE(Enum): OUTER = 2 BOTH = 3 -class BORDER_RADIUS(Enum): +class WINDOW_BORDER_RADIUS(Enum): NONE = 0 TOP = 1 - TOP_AND_BOTTOM = 2 \ No newline at end of file + TOP_AND_BOTTOM = 2 + +class BALCONY_BORDER_RADIUS(Enum): + NONE = 0 + MEDIUM = 1 + FULL = 2 \ No newline at end of file