Merge pull request #12 from KAymeric/main

إصلاح الخطأ
This commit is contained in:
Xeon0X
2024-06-15 23:04:21 +02:00
committed by GitHub
3 changed files with 57 additions and 17 deletions

View File

@@ -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
@@ -41,3 +40,10 @@ class Building:
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])

View File

@@ -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
@@ -18,3 +17,4 @@ 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

34
main.py
View File

@@ -5,3 +5,37 @@ def main():
if __name__ == '__main__': if __name__ == '__main__':
main() main()
from gdpc import Editor, Block, geometry, Transform
import networks.curve as curve
import numpy as np
from utils.JsonReader import JsonReader
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((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,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"])