From 74939422e7db8a4da5b2c69f8dca4f4ff477ba8c Mon Sep 17 00:00:00 2001 From: AKreuzer Date: Sat, 15 Jun 2024 22:57:38 +0200 Subject: [PATCH 1/2] =?UTF-8?q?=D8=A5=D8=B5=D9=84=D8=A7=D8=AD=20=D8=A5?= =?UTF-8?q?=D8=AD=D8=AF=D8=A7=D8=AB=D9=8A=D8=A7=D8=AA=20=D8=A7=D9=84=D8=AE?= =?UTF-8?q?=D9=84=D9=84=20=D9=88=D8=A7=D8=AA=D8=AC=D8=A7=D9=87=20=D8=A7?= =?UTF-8?q?=D9=84=D8=A8=D8=A7=D8=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- buildings/Building.py | 32 +++++++++++++++++++------------- buildings/TODO | 6 +++--- main.py | 6 ++++-- 3 files changed, 26 insertions(+), 18 deletions(-) diff --git a/buildings/Building.py b/buildings/Building.py index 32ea625..b42adc9 100644 --- a/buildings/Building.py +++ b/buildings/Building.py @@ -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)) - \ No newline at end of file + + 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]) + \ No newline at end of file diff --git a/buildings/TODO b/buildings/TODO index 43f622d..680bb43 100644 --- a/buildings/TODO +++ b/buildings/TODO @@ -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) \ No newline at end of file +center le building dans son area (ou pas) +position building \ No newline at end of file diff --git a/main.py b/main.py index 059a03a..ae2568b 100644 --- a/main.py +++ b/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"]) From 43c77be3a1bdf9ff19d271181a58b57163102047 Mon Sep 17 00:00:00 2001 From: AKreuzer Date: Sat, 15 Jun 2024 23:02:23 +0200 Subject: [PATCH 2/2] =?UTF-8?q?=D8=AF=D9=85=D8=AC=20=D9=81=D8=B1=D8=B9=20?= =?UTF-8?q?=D8=A7=D9=84=D8=AA=D8=AA=D8=A8=D8=B9=20=D8=B9=D9=86=20=D8=A8?= =?UTF-8?q?=D8=B9=D8=AF=20"=D8=A7=D9=84=D9=85=D9=86=D8=A8=D8=B9/=D8=A7?= =?UTF-8?q?=D9=84=D8=B1=D8=A6=D9=8A=D8=B3=D9=8A"=20=D9=81=D9=8A=20=D8=A7?= =?UTF-8?q?=D9=84=D9=85=D9=84=D9=81=20=D8=A7=D9=84=D8=B1=D8=A6=D9=8A=D8=B3?= =?UTF-8?q?=D9=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.py | 26 +++----------------------- 1 file changed, 3 insertions(+), 23 deletions(-) diff --git a/main.py b/main.py index 285d50d..7e2c27f 100644 --- a/main.py +++ b/main.py @@ -5,6 +5,8 @@ def main(): if __name__ == '__main__': main() + + from gdpc import Editor, Block, geometry, Transform import networks.curve as curve import numpy as np @@ -36,26 +38,4 @@ 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,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"]) - - - - - - -# # Get a block -# block = editor.getBlock((0,48,0)) - -# # Place a block -# editor.placeBlock((0 , 5, 0), Block("stone")) - -# # Build a cube -# geometry.placeCuboid(editor, (458, 92, 488), (468, 99, 471), Block("oak_planks")) - -# curve = curve.Curve([(396, 132, 740), (435, 138, 730), -# (443, 161, 758), (417, 73, 729)]) -# curve.compute_curve() - -# for point in curve.computed_points: -# print(point) -# editor.placeBlock(point, Block("stone")) +building.build(editor, ["stone_bricks","glass_pane","glass","cobblestone_wall","stone_brick_stairs","oak_planks","white_concrete","cobblestone","stone_brick_slab","iron_bars"]) \ No newline at end of file