إصلاح إحداثيات الخلل واتجاه الباب
This commit is contained in:
@@ -7,29 +7,28 @@ from buildings.Entrance import Entrance
|
||||
from buildings.Roof import Roof
|
||||
|
||||
class Building:
|
||||
def __init__(self,rdata, position : tuple[int,int], size : tuple[int, int], matrice : list[list[int]], floors : int):
|
||||
self.position = position
|
||||
self.length, self.width = size
|
||||
def __init__(self,rdata, positions : list[tuple[int,int,int]], matrice : list[list[int]], doors_direction : DIRECTION):
|
||||
self.position = (0,0,0)
|
||||
self.length, self.width, self.height = 0,0,0
|
||||
self.matrice = matrice
|
||||
self.floors = floors
|
||||
|
||||
# Generate every random components here
|
||||
self.get_pos_and_size(positions)
|
||||
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.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)
|
||||
|
||||
def build(self, editor : Editor, materials : list[str]):
|
||||
for y in range(self.floors+1):
|
||||
with editor.pushTransform((self.position[0], y*(self.foundations.floor_height+1) -1, self.position[1])):
|
||||
if y == self.floors:
|
||||
self.roof.build(editor, materials)
|
||||
break
|
||||
y=0
|
||||
while y < self.height:
|
||||
with editor.pushTransform((self.position[0], y -1, self.position[1])):
|
||||
self.foundations.build(editor, materials)
|
||||
if y == 0: self.entrance.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:
|
||||
# Tiles are constant square units different for each buildings
|
||||
@@ -40,4 +39,11 @@ class Building:
|
||||
if smaller_side <= 15 : return smaller_side // 5
|
||||
|
||||
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
|
||||
rembard object
|
||||
détails facade
|
||||
rdc
|
||||
Entrance style
|
||||
toit (clim, chateau deau, pubs)
|
||||
tiles 3d
|
||||
textures object
|
||||
opti textures
|
||||
opti géométrique
|
||||
opti gdpc
|
||||
@@ -17,4 +16,5 @@ matrices pré-distribués
|
||||
angles 270
|
||||
bug entrée au milieu du O
|
||||
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 utils.functions import *
|
||||
from utils.Enums import DIRECTION
|
||||
|
||||
editor = Editor(buffering=True)
|
||||
|
||||
# get every differents buildings shapes
|
||||
f = JsonReader('buildings\shapes.json')
|
||||
shapes = f.data
|
||||
baseShape = shapes[0]['matrice']
|
||||
|
||||
# get the random data for the buildings
|
||||
y = YamlReader('params.yml')
|
||||
random_data = y.data
|
||||
|
||||
#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)
|
||||
|
||||
# clear the area you build on
|
||||
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
|
||||
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
|
||||
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