إصلاح إحداثيات الخلل واتجاه الباب
This commit is contained in:
@@ -7,29 +7,28 @@ from buildings.Entrance import Entrance
|
|||||||
from buildings.Roof import Roof
|
from buildings.Roof import Roof
|
||||||
|
|
||||||
class Building:
|
class Building:
|
||||||
def __init__(self,rdata, position : tuple[int,int], size : tuple[int, int], matrice : list[list[int]], floors : int):
|
def __init__(self,rdata, positions : list[tuple[int,int,int]], matrice : list[list[int]], doors_direction : DIRECTION):
|
||||||
self.position = position
|
self.position = (0,0,0)
|
||||||
self.length, self.width = size
|
self.length, self.width, self.height = 0,0,0
|
||||||
self.matrice = matrice
|
self.matrice = matrice
|
||||||
self.floors = floors
|
|
||||||
|
|
||||||
# Generate every random components here
|
self.get_pos_and_size(positions)
|
||||||
tile_size = self.gen_tile_size()
|
tile_size = self.gen_tile_size()
|
||||||
|
|
||||||
self.foundations = Foundations(rdata["foundations"], size, matrice, tile_size,)
|
self.foundations = Foundations(rdata["foundations"], (self.length,self.width), matrice, tile_size,)
|
||||||
self.facade = Facade(rdata["facade"], self.foundations.vertices, self.foundations.is_inner_or_outer)
|
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)
|
self.entrance = Entrance(rdata, self.foundations.vertices, doors_direction, self.foundations.is_inner_or_outer)
|
||||||
self.roof = Roof(rdata["roof"], self.foundations.polygon)
|
self.roof = Roof(rdata["roof"], self.foundations.polygon)
|
||||||
|
|
||||||
def build(self, editor : Editor, materials : list[str]):
|
def build(self, editor : Editor, materials : list[str]):
|
||||||
for y in range(self.floors+1):
|
y=0
|
||||||
with editor.pushTransform((self.position[0], y*(self.foundations.floor_height+1) -1, self.position[1])):
|
while y < self.height:
|
||||||
if y == self.floors:
|
with editor.pushTransform((self.position[0], y -1, self.position[1])):
|
||||||
self.roof.build(editor, materials)
|
|
||||||
break
|
|
||||||
self.foundations.build(editor, materials)
|
self.foundations.build(editor, materials)
|
||||||
if y == 0: self.entrance.build(editor, materials)
|
if y == 0: self.entrance.build(editor, materials)
|
||||||
else : self.facade.build(editor, materials)
|
else : self.facade.build(editor, materials)
|
||||||
|
y+=self.foundations.floor_height+1
|
||||||
|
with editor.pushTransform((self.position[0], y -1, self.position[1])): self.roof.build(editor, materials)
|
||||||
|
|
||||||
def gen_tile_size(self) -> int:
|
def gen_tile_size(self) -> int:
|
||||||
# Tiles are constant square units different for each buildings
|
# Tiles are constant square units different for each buildings
|
||||||
@@ -40,4 +39,11 @@ class Building:
|
|||||||
if smaller_side <= 15 : return smaller_side // 5
|
if smaller_side <= 15 : return smaller_side // 5
|
||||||
|
|
||||||
return rd.randint(3, smaller_side // len(self.matrice))
|
return rd.randint(3, smaller_side // len(self.matrice))
|
||||||
|
|
||||||
|
def get_pos_and_size(self, pos : list[tuple[int,int,int]]) -> tuple[tuple[int,int],int,int]:
|
||||||
|
pos1, pos2 = pos[0], pos[1]
|
||||||
|
self.position = (min(pos1[0], pos2[0]), min(pos1[1], pos2[1]), min(pos1[2], pos2[2]))
|
||||||
|
self.length = abs(pos1[0] - pos2[0])
|
||||||
|
self.height = abs(pos1[1] - pos2[1])
|
||||||
|
self.width = abs(pos1[2] - pos2[2])
|
||||||
|
|
||||||
@@ -3,10 +3,9 @@ toit de balcon avec/sans pilliers
|
|||||||
collumn style
|
collumn style
|
||||||
rembard object
|
rembard object
|
||||||
détails facade
|
détails facade
|
||||||
rdc
|
Entrance style
|
||||||
toit (clim, chateau deau, pubs)
|
toit (clim, chateau deau, pubs)
|
||||||
tiles 3d
|
tiles 3d
|
||||||
textures object
|
|
||||||
opti textures
|
opti textures
|
||||||
opti géométrique
|
opti géométrique
|
||||||
opti gdpc
|
opti gdpc
|
||||||
@@ -17,4 +16,5 @@ matrices pré-distribués
|
|||||||
angles 270
|
angles 270
|
||||||
bug entrée au milieu du O
|
bug entrée au milieu du O
|
||||||
bug entrée dans le pillier
|
bug entrée dans le pillier
|
||||||
center le building dans son area (ou pas)
|
center le building dans son area (ou pas)
|
||||||
|
position building
|
||||||
6
main.py
6
main.py
@@ -6,26 +6,28 @@ from utils.YamlReader import YamlReader
|
|||||||
from buildings.Building import Building
|
from buildings.Building import Building
|
||||||
|
|
||||||
from utils.functions import *
|
from utils.functions import *
|
||||||
|
from utils.Enums import DIRECTION
|
||||||
|
|
||||||
editor = Editor(buffering=True)
|
editor = Editor(buffering=True)
|
||||||
|
|
||||||
# get every differents buildings shapes
|
# get every differents buildings shapes
|
||||||
f = JsonReader('buildings\shapes.json')
|
f = JsonReader('buildings\shapes.json')
|
||||||
shapes = f.data
|
shapes = f.data
|
||||||
|
baseShape = shapes[0]['matrice']
|
||||||
|
|
||||||
# get the random data for the buildings
|
# get the random data for the buildings
|
||||||
y = YamlReader('params.yml')
|
y = YamlReader('params.yml')
|
||||||
random_data = y.data
|
random_data = y.data
|
||||||
|
|
||||||
#move your editor to the position you wanna build on
|
#move your editor to the position you wanna build on
|
||||||
transform = Transform((0,-60,110),rotation = 0)
|
transform = Transform((75,-60,110),rotation = 0)
|
||||||
editor.transform.push(transform)
|
editor.transform.push(transform)
|
||||||
|
|
||||||
# clear the area you build on
|
# clear the area you build on
|
||||||
geometry.placeCuboid(editor, (-5,0,-8), (25,100,25), Block("air"))
|
geometry.placeCuboid(editor, (-5,0,-8), (25,100,25), Block("air"))
|
||||||
|
|
||||||
# create a building at the relative position 0,0 with 20 blocks length and 20 blocks width, with a normal shape and 10 floors
|
# create a building at the relative position 0,0 with 20 blocks length and 20 blocks width, with a normal shape and 10 floors
|
||||||
building = Building(random_data["buildings"], (0, 0), (20,20), shapes[0]['matrice'], 10)
|
building = Building(random_data["buildings"], [(0,0,0), (20,30,20)], baseShape, DIRECTION.EAST)
|
||||||
# build it with your custom materials
|
# build it with your custom materials
|
||||||
building.build(editor, ["stone_bricks","glass_pane","glass","cobblestone_wall","stone_brick_stairs","oak_planks","white_concrete","cobblestone","stone_brick_slab","iron_bars"])
|
building.build(editor, ["stone_bricks","glass_pane","glass","cobblestone_wall","stone_brick_stairs","oak_planks","white_concrete","cobblestone","stone_brick_slab","iron_bars"])
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user