place entrance (not fied)
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
import random as rd
|
||||
from utils.Enums import DIRECTION
|
||||
from gdpc import Editor, Block, geometry
|
||||
from buildings.Foundations import Foundations
|
||||
from buildings.Facade import Facade
|
||||
from buildings.Entrance import Entrance
|
||||
|
||||
class Building:
|
||||
def __init__(self,rdata, position : tuple[int,int], size : tuple[int, int], matrice : list[list[int]], floors : int):
|
||||
@@ -14,16 +17,17 @@ class Building:
|
||||
|
||||
self.foundations = Foundations(rdata["foundations"], size, matrice, tile_size,)
|
||||
self.facade = Facade(rdata["facade"], self.foundations.vertices, self.foundations.is_inner_or_outer)
|
||||
self.entrance = Entrance(rdata, self.foundations.vertices, DIRECTION.EAST, self.foundations.is_inner_or_outer)
|
||||
|
||||
def build(self, editor, materials : list[str]):
|
||||
def build(self, editor : Editor, materials : list[str]):
|
||||
for y in range(self.floors):
|
||||
with editor.pushTransform((self.position[0], y*(self.foundations.floor_height+1), self.position[1])):
|
||||
self.foundations.build(editor, materials)
|
||||
self.facade.build(editor, materials)
|
||||
if y == 0: self.entrance.build(editor, materials)
|
||||
else : self.facade.build(editor, materials)
|
||||
|
||||
def gen_tile_size(self) -> int:
|
||||
# Tiles are constant square units different for each buildings
|
||||
return self.length
|
||||
smaller_side = min(self.length, self.width)
|
||||
|
||||
# area is too small, will work but not very well
|
||||
|
||||
@@ -1,28 +1,55 @@
|
||||
import random as rd
|
||||
from utils.Enums import DIRECTION
|
||||
from gdpc import Editor, Block, geometry
|
||||
from utils.Enums import DIRECTION,COLLUMN_STYLE
|
||||
from buildings.geometry.Vertice import Vertice
|
||||
from buildings.Facade import Facade
|
||||
|
||||
class Entrance:
|
||||
def __init__(self, rdata, vertices : list[Vertice], direction : DIRECTION):
|
||||
def __init__(self, rdata, vertices : list[Vertice], direction : DIRECTION, collumn_style : COLLUMN_STYLE):
|
||||
self.vertices = vertices
|
||||
self.direction = direction
|
||||
self.rdata = rdata
|
||||
self.collumn_style = collumn_style
|
||||
self.is_centered = self.is_centered()
|
||||
self.door_vertices = self.get_door_vertices()
|
||||
self.door_vertice, self.facade = self.get_door_and_facade()
|
||||
|
||||
def build(self, editor : Editor, materials : list[str]):
|
||||
self.facade.build(editor, materials)
|
||||
self.door_vertice.fill(editor, materials[0])
|
||||
|
||||
def is_centered(self) -> bool:
|
||||
return rd.random() <= self.rdata["centered"]
|
||||
return rd.random() <= self.rdata["entrance"]["centered"]
|
||||
|
||||
def get_door_vertices(self) -> Vertice:
|
||||
def get_door_and_facade(self) -> tuple[Vertice, Facade]:
|
||||
oriented_vertices = self.get_oriented_vertices()
|
||||
facade_vertices = self.vertices.copy()
|
||||
door_vertice = None
|
||||
|
||||
if self.is_centered:
|
||||
oriented_vertices.sort(key = lambda v: v.point1.x if self.direction.value % 2 == 0 else v.point1.z) # if direction is north or south, sort by x, else sort by z
|
||||
mid = len(oriented_vertices) // 2
|
||||
ver1, ver2 = oriented_vertices[mid], oriented_vertices[-mid-1]
|
||||
if ver1.point1.position == ver2.point1.position:
|
||||
door_vertice = ver1
|
||||
else :
|
||||
door_vertice = Vertice(ver2.point1, ver1.point2)
|
||||
facade_vertices.remove(ver2)
|
||||
facade_vertices.remove(ver1)
|
||||
|
||||
else:
|
||||
door_vertice = rd.choice(oriented_vertices)
|
||||
facade_vertices.remove(door_vertice)
|
||||
|
||||
facade = Facade(self.rdata["facade"], facade_vertices, self.collumn_style)
|
||||
return(door_vertice, facade)
|
||||
|
||||
def get_oriented_vertices(self) -> list[Vertice]:
|
||||
# get the most off-centered vertices that are in the same direction as self.direction
|
||||
same_direction_vertices = sorted([v for v in self.vertices if v.direction == self.direction],
|
||||
lambda v: v.point1.z if self.direction.value % 2 == 0 else v.point1.x, # if direction is north or south, sort by x, else sort by z
|
||||
same_direction_vertices = sorted([v for v in self.vertices if v.facing == self.direction],
|
||||
key = lambda v: v.point1.z if self.direction.value % 2 == 0 else v.point1.x, # if direction is north or south, sort by x, else sort by z
|
||||
reverse = self.direction == DIRECTION.NORTH or self.direction == DIRECTION.WEST) # if direction is north or west, sort in reverse
|
||||
extremum = same_direction_vertices[0]
|
||||
return [v for v in same_direction_vertices if
|
||||
(v.poin1.x == extremum.point1.x and self.direction.value % 2 == 0) or
|
||||
(v.point1.x == extremum.point1.x and self.direction.value % 2 == 0) or
|
||||
(v.point1.z == extremum.point1.z and self.direction.value % 2 == 1)]
|
||||
|
||||
@@ -37,10 +37,10 @@ class Facade:
|
||||
def correct_corners(self,points : list[Point], v : Vertice):
|
||||
if self.padding == 0:
|
||||
if self.window.border_radius != 0 and self.window.width == self.length:
|
||||
if v.point1 in points:
|
||||
if points.count(v.point1) >= 2:
|
||||
self.editor.placeBlock((0,self.window.ypadding,0), Block(self.materials[8]))
|
||||
self.editor.placeBlock((0,self.window.ypadding+self.window.height,0), Block(self.materials[8], {"type": "top"}))
|
||||
if v.point2 in points:
|
||||
if points.count(v.point2) >= 2:
|
||||
self.editor.placeBlock((self.length-1,self.window.ypadding,0), Block(self.materials[8]))
|
||||
self.editor.placeBlock((self.length-1,self.window.ypadding+self.window.height,0), Block(self.materials[8], {"type": "top"}))
|
||||
|
||||
@@ -51,9 +51,9 @@ class Facade:
|
||||
elif self.inter_floor_border_style == INTER_FLOOR_BORDER.STAIRS:
|
||||
material = Block(self.materials[4], {"facing": "south", "half": "top"})
|
||||
|
||||
if v.point1 in points:
|
||||
if points.count(v.point1) >= 2:
|
||||
self.editor.placeBlock((-1,self.height,-1), material)
|
||||
if v.point2 in points:
|
||||
if points.count(v.point2) >= 2:
|
||||
self.editor.placeBlock((self.length,self.height,-1), material)
|
||||
|
||||
|
||||
|
||||
@@ -1,13 +1,16 @@
|
||||
Encadrement fenêtre
|
||||
toit de balcon avec/sans pilliers
|
||||
border radius balcon
|
||||
collumn style
|
||||
rembard object
|
||||
détails facade
|
||||
rdc
|
||||
toit
|
||||
toit (clim, chateau deau, pubs)
|
||||
tiles 3d
|
||||
textures object
|
||||
opti textures
|
||||
opti géométrique
|
||||
opti gdpc
|
||||
opti gdpc
|
||||
pilliers quand trop de fenêtres + pas de pilliers si tile trop petite
|
||||
limitateur taille
|
||||
facade lisses/ immeubles collés
|
||||
matrices pré-distribués
|
||||
@@ -61,16 +61,16 @@ class Tile:
|
||||
|
||||
def get_vertice(self,vertice : int|DIRECTION) -> Vertice:
|
||||
# gives the corresponding vertice :
|
||||
# 0 = north, 1 = west, 2 = south, 3 = east
|
||||
# 0 = north, 1 = east, 2 = south, 3 = west
|
||||
match(vertice):
|
||||
case 0 :
|
||||
return Vertice(self.north_west, self.north_east, DIRECTION.NORTH)
|
||||
case 1 :
|
||||
return Vertice(self.north_west, self.south_west, DIRECTION.WEST)
|
||||
return Vertice(self.north_east, self.south_east, DIRECTION.EAST)
|
||||
case 2 :
|
||||
return Vertice(self.south_west, self.south_east, DIRECTION.SOUTH)
|
||||
case 3 :
|
||||
return Vertice(self.north_east, self.south_east, DIRECTION.EAST)
|
||||
return Vertice(self.north_west, self.south_west, DIRECTION.WEST)
|
||||
case DIRECTION.WEST :
|
||||
return self.west_vertice
|
||||
case DIRECTION.EAST :
|
||||
|
||||
Reference in New Issue
Block a user