balcony fixed
This commit is contained in:
11
buildings/TODO
Normal file
11
buildings/TODO
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
Encadrement fenêtre
|
||||||
|
toit de balcon avec/sans pilliers
|
||||||
|
border radius balcon
|
||||||
|
collumn style
|
||||||
|
détails facade
|
||||||
|
rdc
|
||||||
|
toit
|
||||||
|
tiles 3d
|
||||||
|
opti géométrique
|
||||||
|
opti textures
|
||||||
|
opti gdpc
|
||||||
@@ -10,13 +10,30 @@ class Balcony:
|
|||||||
self.windows = windows
|
self.windows = windows
|
||||||
self.max_width = max_width
|
self.max_width = max_width
|
||||||
self.length = self.get_len()
|
self.length = self.get_len()
|
||||||
self.has_multiple = self.has_multiple_balcony()
|
self.has_multiple = self.has_multiple()
|
||||||
|
self.has_details = self.has_details()
|
||||||
self.follow_window = self.follow_window()
|
self.follow_window = self.follow_window()
|
||||||
self.structure = self.get_structures()
|
self.structure = self.get_structures()
|
||||||
|
self.editor, self.materials = None,None
|
||||||
|
|
||||||
def build(self, editor : Editor, materials : list[str]):
|
def build(self, editor : Editor, materials : list[str]):
|
||||||
|
self.editor = editor
|
||||||
|
self.materials = materials
|
||||||
for s in self.structure:
|
for s in self.structure:
|
||||||
s.fill(editor, materials[0])
|
s.fill(editor, materials[0])
|
||||||
|
self.build_rembard(s)
|
||||||
|
self.build_details(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]))
|
||||||
|
geometry.placeCuboid(self.editor,(s.point2.x,1,-1),(s.point2.x,1,-self.length),Block(self.materials[3]))
|
||||||
|
geometry.placeCuboid(self.editor,(s.point1.x,1,-self.length),(s.point2.x,1,-self.length),Block(self.materials[3]))
|
||||||
|
|
||||||
|
def build_details(self, s : Vertice):
|
||||||
|
if not self.has_details: return
|
||||||
|
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 get_structures(self) -> list[Vertice]:
|
def get_structures(self) -> list[Vertice]:
|
||||||
attach_points = self.get_attach_points()
|
attach_points = self.get_attach_points()
|
||||||
@@ -29,51 +46,56 @@ class Balcony:
|
|||||||
|
|
||||||
structures = []
|
structures = []
|
||||||
centered = True
|
centered = True
|
||||||
while True:
|
while x1 > 0:
|
||||||
x1 -= 1
|
x1 -= 1
|
||||||
x2 += 1 if centered else 0
|
x2 += 1 if centered else 0
|
||||||
print(x1,x2, attach_points)
|
|
||||||
leng = attach_points[x2] - attach_points[x1] - 1
|
leng = attach_points[x2] - attach_points[x1] - 1
|
||||||
|
|
||||||
if x1 == 0:
|
if x1 == 0:
|
||||||
if leng >= min_wid: structures.append(self.create_structure(attach_points[x1], attach_points[x2]))
|
if leng >= min_wid: self.append_structure(structures, x1, x2, attach_points, len_attach_points, centered)
|
||||||
break
|
break
|
||||||
if leng < min_wid: continue
|
if leng < min_wid: continue
|
||||||
|
|
||||||
if growth_chance < rd.random():
|
if growth_chance < rd.random():
|
||||||
structures.append(self.create_structure(attach_points[x1], attach_points[x2]))
|
self.append_structure(structures, x1, x2, attach_points, len_attach_points, centered)
|
||||||
if not centered:
|
|
||||||
structures.append(self.create_structure(attach_points[len_attach_points-x1], attach_points[len_attach_points-x2]))
|
|
||||||
|
|
||||||
if not self.has_multiple: break
|
if not self.has_multiple: break
|
||||||
else:
|
else:
|
||||||
print(x1,min_wid, min_gap)
|
centered = False
|
||||||
if x1-min_wid < min_gap: break
|
if attach_points[x1]-min_wid < min_gap: break
|
||||||
gap = rd.randint(min_gap, x1-min_wid)
|
gap = rd.randint(min_gap, attach_points[x1]-min_wid)
|
||||||
x2 = x1-gap
|
x2 = x1-gap
|
||||||
x1 = x2-min_wid
|
x1 = x2-min_wid+1
|
||||||
|
|
||||||
|
|
||||||
return structures
|
return structures
|
||||||
|
|
||||||
def get_attach_points(self) -> list[int]:
|
def get_attach_points(self) -> list[int]:
|
||||||
points = [i for i in range(self.max_width)]
|
points = [i for i in range(self.max_width)]
|
||||||
if self.follow_window:
|
if self.follow_window:
|
||||||
|
pad = self.windows.padding
|
||||||
for w in self.windows.windows:
|
for w in self.windows.windows:
|
||||||
for i in range(w.x1, w.x2+1):
|
for i in range(pad+w.x1, pad+w.x2+1):
|
||||||
points.remove(i)
|
points.remove(i)
|
||||||
|
|
||||||
return points
|
return points
|
||||||
|
|
||||||
def create_structure(self, x1 : int, x2 : int) -> Vertice:
|
def create_structure(self, x1 : int, x2 : int) -> Vertice:
|
||||||
return Vertice(Point(x1,0,0), Point(x2,0,-self.length+1))
|
return Vertice(Point(x1,0,0), Point(x2,0,-self.length))
|
||||||
|
|
||||||
|
def append_structure(self, structures : list[Vertice], x1 : int, x2 : int, attach_points : list[int], len_attach_points : int, centered : bool):
|
||||||
|
structures.append(self.create_structure(attach_points[x1], attach_points[x2]))
|
||||||
|
if not centered:
|
||||||
|
structures.append(self.create_structure(attach_points[len_attach_points-x1], attach_points[len_attach_points-x2]))
|
||||||
|
|
||||||
def follow_window(self) -> bool:
|
def follow_window(self) -> bool:
|
||||||
return self.windows.ypadding > 3
|
return not self.windows.ypadding > 3
|
||||||
|
|
||||||
def has_multiple_balcony(self) -> bool:
|
def has_multiple(self) -> bool:
|
||||||
if self.max_width < self.rdata["multiple"]["min_width"]: return False
|
if self.max_width < self.rdata["multiple"]["min_width"]: return False
|
||||||
return self.rdata["multiple"]["proba"] >= rd.random()
|
return self.rdata["multiple"]["proba"] >= rd.random()
|
||||||
|
|
||||||
|
def has_details(self) -> bool:
|
||||||
|
return self.rdata["details"] >= rd.random()
|
||||||
|
|
||||||
def get_len(self) -> int:
|
def get_len(self) -> int:
|
||||||
return rd.randint(self.rdata["size"]["min_len"], self.rdata["size"]["max_len"])
|
return rd.randint(self.rdata["size"]["min_len"], self.rdata["size"]["max_len"])
|
||||||
@@ -42,13 +42,15 @@ buildings:
|
|||||||
inter_floor: 0.5
|
inter_floor: 0.5
|
||||||
balcony:
|
balcony:
|
||||||
proba : 0.25
|
proba : 0.25
|
||||||
growth: 0.8 # [growth]% chance to have min_width + 1 balcony length, [growth**2]% chance to have min_width + 2 balcony length, etc
|
growth: 0.5 # [growth]% chance to have min_width + 1 balcony length, [growth**2]% chance to have min_width + 2 balcony length, etc
|
||||||
size:
|
size:
|
||||||
min_len : 1
|
min_len : 1
|
||||||
max_len : 3
|
max_len : 3
|
||||||
min_width : 3
|
min_width : 3
|
||||||
multiple:
|
multiple:
|
||||||
# probability to have multiple balcony IF POSSIBLE
|
# probability to have multiple balcony IF POSSIBLE
|
||||||
proba: 0.5
|
# this feature need a very large facade
|
||||||
|
proba: 1
|
||||||
min_width: 5
|
min_width: 5
|
||||||
min_gap: 0
|
min_gap: 1
|
||||||
|
details: 0.35
|
||||||
Reference in New Issue
Block a user