This commit is contained in:
Eclairsombre
2024-06-15 15:02:26 +02:00
parent 4056807caa
commit 01059a53be
6 changed files with 0 additions and 660 deletions

View File

@@ -1,9 +1,7 @@
from time import sleep from time import sleep
from gdpc import Editor, Block, geometry from gdpc import Editor, Block, geometry
from list_block import *
import numpy as np import numpy as np
from skimage.morphology import skeletonize
import math import math
import matplotlib.pyplot as plt import matplotlib.pyplot as plt

View File

@@ -1,335 +0,0 @@
from gdpc import Editor, Block, geometry
from list_block import *
import numpy as np
import math
class House :
def __init__(self, editor,startX, startY, startZ, endX, endY, endZ,style,houseDirection="north"):
self.editor = editor
self.startX = startX
self.startY = startY
self.startZ = startZ
self.endX = endX
self.endY = endY
self.endZ = endZ
self.houseDirection = houseDirection
self.hasGarder = True
self.gardenSide = "right"
self.hasGarage = True
self.wall = style['mur']
self.ground = style['sol']
self.grass = style['grass']
self.path = style['chemin']
self.fence = style['fence']
self.glass = style['glass']
self.door = style['door']
self.roof = style['toit']
def placeGround(self,CoStart, CoEnd,block):
for x in range(CoStart[0], CoEnd[0]):
for z in range(CoStart[2], CoEnd[2]):
self.editor.placeBlock((x, CoStart[1], z), Block(block) )
def placeRoof(self,CoStart,CoEnd):
for x in range(CoStart[0], CoEnd[0]):
for z in range(CoStart[2], CoEnd[2]):
self.editor.placeBlock((x, CoEnd[1]-1, z), Block(self.roof))
def placeWall(self,CoStart,CoEnd):
if CoStart[0] == CoEnd[0]:
for y in range(CoStart[1]+1, CoEnd[1]-1):
for z in range(CoStart[2], CoEnd[2]):
self.editor.placeBlock((CoStart[0], y, z), Block(self.wall))
CoStart = (CoStart[0],CoStart[1],CoStart[2]+1)
CoEnd = (CoEnd[0],CoEnd[1],CoEnd[2]-1)
elif CoStart[2] == CoEnd[2]:
for y in range(CoStart[1]+1, CoEnd[1]-1):
for x in range(CoStart[0], CoEnd[0]):
self.editor.placeBlock((x, y, CoStart[2]), Block(self.wall))
CoStart = (CoStart[0]+1,CoStart[1],CoStart[2])
CoEnd = (CoEnd[0]-1,CoEnd[1],CoEnd[2])
self.placeWindow(CoStart,CoEnd)
def placeDoor(self, direction="north", x=0, z=0, y=0):
door_directions = {
"south": {"facing": "north", "half": "lower"},
"north": {"facing": "south", "half": "lower"},
"east": {"facing": "west", "half": "lower"},
"west": {"facing": "east", "half": "lower"}
}
door_properties = door_directions.get(direction)
if door_properties:
self.editor.placeBlock((x, y + 1, z), Block(self.door, door_properties))
self.editor.placeBlock((x, y + 2, z), Block(self.door, {"facing": door_properties["facing"], "half": "upper"}))
self.doorDirection = direction
def placeWindow(self, CoStart, CoEnd):
x = abs(CoEnd[0] - CoStart[0])
z = abs(CoEnd[2] - CoStart[2])
type = Block(self.glass)
def placeBlock(axis, is_x_axis):
print(axis, is_x_axis)
if axis % 2 == 0:
if axis == 4:
if is_x_axis:
self.editor.placeBlock((CoStart[0] + 1, CoStart[1] + 2, CoStart[2]), type)
self.editor.placeBlock((CoStart[0] + 2, CoStart[1] + 2, CoStart[2]), type)
else:
self.editor.placeBlock((CoStart[0], CoStart[1] + 2, CoStart[2] + 1), type)
self.editor.placeBlock((CoStart[0], CoStart[1] + 2, CoStart[2] + 2), type)
else:
for i in range(axis // 2):
if i % 2 == 0:
if is_x_axis:
self.editor.placeBlock((CoStart[0] + i * 2 + 1, CoStart[1] + 2, CoStart[2]), type)
self.editor.placeBlock((CoStart[0] + i * 2 + 2, CoStart[1] + 2, CoStart[2]), type)
else:
self.editor.placeBlock((CoStart[0], CoStart[1] + 2, CoStart[2] + 1 + i * 2), type)
self.editor.placeBlock((CoStart[0], CoStart[1] + 2, CoStart[2] + i * 2 + 2), type)
else:
if axis <= 5:
for i in range(axis):
if is_x_axis:
self.editor.placeBlock((CoStart[0] + i, CoStart[1] + 2, CoStart[2]), type)
else:
self.editor.placeBlock((CoStart[0], CoStart[1] + 2, CoStart[2] + i), type)
else:
for i in range(axis // 3):
if 3 * (i + 1) + i > abs(CoEnd[2] - CoStart[2]):
break
else:
if is_x_axis:
self.editor.placeBlock((CoStart[0], CoStart[1] + 2, CoStart[2] + i * 4), type)
self.editor.placeBlock((CoStart[0], CoStart[1] + 2, CoStart[2] + i * 4 + 1), type)
self.editor.placeBlock((CoStart[0], CoStart[1] + 2, CoStart[2] + i * 4 + 2), type)
else:
self.editor.placeBlock((CoStart[0], CoStart[1] + 2, CoStart[2] + i * 4), type)
self.editor.placeBlock((CoStart[0], CoStart[1] + 2, CoStart[2] + i * 4 + 1), type)
self.editor.placeBlock((CoStart[0], CoStart[1] + 2, CoStart[2] + i * 4 + 2), type)
if CoStart[0] == CoEnd[0]:
placeBlock(z, False)
if CoStart[2] == CoEnd[2]:
placeBlock(x, True)
def clearInside(self):
for x in range(self.startX+1, self.endX):
for y in range(self.startY+1, self.endY):
for z in range(self.startZ+1, self.endZ):
self.editor.placeBlock((x, y, z), air)
def deleteWall(self,CoStart,CoEnd):
if CoStart[0] == CoEnd[0]:
for y in range(CoStart[1]+1, CoEnd[1]-1):
for z in range(CoStart[2], CoEnd[2]):
self.editor.placeBlock((CoStart[0], y, z), air)
elif CoStart[2] == CoEnd[2]:
for y in range(CoStart[1]+1, CoEnd[1]-1):
for x in range(CoStart[0], CoEnd[0]):
self.editor.placeBlock((x, y, CoStart[2]), air)
def placeGarage(self,CoStart,CoEnd):
self.deleteWall(CoStart,CoEnd)
def placeHouse(self):
self.clear()
self.clearInside()
self.placeGround((self.startX, self.startY, self.startZ), (self.endX, self.endY, self.endZ),self.ground)
if self.hasGarder:
if self.houseDirection == "north" :
if self.gardenSide == "left":
self.placeGround((self.startX+ (self.endX - self.startX)//2, self.startY, self.startZ), (self.endX, self.endY, self.startZ + (self.endZ - self.startZ)//2), self.grass)
self.placeRoof((self.startX, self.startY, self.startZ), (self.endX - (self.endX - self.startX)//2, self.endY, self.endZ))
self.placeRoof((self.startX + (self.endX - self.startX)//2, self.startY, self.startZ + (self.endZ - self.startZ)//2), (self.endX, self.endY, self.endZ))
self.placeWall((self.startX, self.startY, self.startZ), (self.startX +(self.endX - self.startX)//2 , self.endY, self.startZ))
self.placeWall((self.startX, self.startY, self.startZ), (self.startX, self.endY, self.endZ ))
self.placeWall((self.startX, self.startY, self.endZ-1), (self.endX , self.endY, self.endZ-1))
self.placeWall((self.endX-1, self.startY, self.startZ+ (self.endZ - self.startZ)//2), (self.endX-1, self.endY, self.endZ))
self.placeWall((self.startX + (self.endX - self.startX)//2 , self.startY, self.startZ+ (self.endZ - self.startZ)//2), (self.endX , self.endY, self.startZ+ (self.endZ - self.startZ)//2))
self.placeWall((self.startX + (self.endX - self.startX)//2 -1, self.startY, self.startZ), (self.startX + (self.endX - self.startX)//2 -1, self.endY, self.startZ+ (self.endZ - self.startZ)//2 ))
self.placeDoor("north", self.endX - (self.endX -self.startX) // 4 -1 , (self.startZ + self.endZ) //2,self.startY)
if self.hasGarage:
self.placeGarage((self.startX+1, self.startY, self.startZ), (self.startX +(self.endX - self.startX)//2 -1 , self.endY, self.startZ))
else:
self.placeGround((self.startX, self.startY, self.startZ), (self.startX + (self.endX-self.startX)//2, self.endY, self.startZ + (self.endZ - self.startZ)//2), self.grass)
self.placeRoof((self.endX- (self.endX - self.startX)//2, self.startY, self.startZ), (self.endX , self.endY, self.endZ))
self.placeRoof((self.startX , self.startY, self.startZ + (self.endZ - self.startZ)//2), (self.endX - (self.endX - self.startX)//2, self.endY, self.endZ))
self.placeWall((self.startX, self.startY, self.startZ+ (self.endZ - self.startZ)//2), (self.endX - (self.endX - self.startX)//2, self.endY, self.startZ+ (self.endZ - self.startZ)//2))
self.placeWall((self.startX, self.startY, self.startZ+ (self.endZ - self.startZ)//2), (self.startX, self.endY, self.endZ ))
self.placeWall((self.startX, self.startY, self.endZ-1), (self.endX , self.endY, self.endZ-1))
self.placeWall((self.endX-1, self.startY, self.startZ), (self.endX-1, self.endY, self.endZ))
self.placeWall((self.startX+ (self.endX - self.startX)//2, self.startY, self.startZ), (self.endX, self.endY, self.startZ))
self.placeWall((self.startX+ (self.endX - self.startX)//2, self.startY, self.startZ), (self.startX+ (self.endX - self.startX)//2, self.endY, self.startZ+ (self.endZ - self.startZ)//2))
self.placeDoor("north", self.startX + (self.endX -self.startX) // 4 , (self.startZ + self.endZ) //2,self.startY)
if self.hasGarage:
self.placeGarage((self.startX+ (self.endX - self.startX)//2 +1, self.startY, self.startZ), (self.endX-1, self.endY, self.startZ))
elif self.houseDirection == "south":
if self.gardenSide == "left":
self.placeGround((self.startX , self.startY, self.startZ + (self.endZ - self.startZ)//2), (self.startX+ (self.endX - self.startX)//2, self.endY, self.endZ), self.grass)
self.placeRoof((self.startX, self.startY, self.startZ), (self.endX, self.endY, self.startZ + (self.endZ - self.startZ)//2))
self.placeRoof((self.startX + (self.endX - self.startX)//2, self.startY, self.startZ), (self.endX, self.endY, self.endZ))
self.placeWall((self.startX, self.startY, self.startZ), (self.endX , self.endY, self.startZ))
self.placeWall((self.startX, self.startY, self.startZ), (self.startX , self.endY, self.startZ + (self.endZ - self.startZ)//2))
self.placeWall((self.startX, self.startY, self.startZ + (self.endZ - self.startZ)//2 -1), (self.startX + (self.endX - self.startX)//2 , self.endY, self.startZ + (self.endZ - self.startZ)//2 -1))
self.placeWall((self.startX + (self.endX - self.startX)//2, self.startY, self.endZ-1), (self.endX , self.endY, self.endZ-1))
self.placeWall((self.startX + (self.endX - self.startX)//2, self.startY, self.startZ + (self.endZ - self.startZ)//2), (self.startX + (self.endX - self.startX)//2, self.endY, self.endZ))
self.placeWall((self.endX-1, self.startY, self.startZ), (self.endX-1, self.endY, self.endZ))
self.placeDoor("south", self.startX + (self.endX -self.startX) // 4 , (self.startZ + self.endZ) //2 -1,self.startY)
if self.hasGarage:
self.placeGarage((self.startX+1, self.startY, self.startZ + (self.endZ - self.startZ)//2 +1), (self.startX +(self.endX - self.startX)//2 -1, self.endY, self.endZ -1))
else:
self.placeGround((self.startX + (self.endX - self.startX)//2, self.startY, self.startZ+ (self.endZ - self.startZ)//2), (self.endX, self.endY, self.endZ), self.grass)
self.placeRoof((self.startX, self.startY, self.startZ), (self.startX+(self.endX - self.startX)//2 , self.endY, self.endZ))
self.placeRoof((self.startX + (self.endX - self.startX)//2, self.startY, self.startZ), (self.endX, self.endY, self.startZ+(self.endZ - self.startZ)//2))
self.placeWall((self.startX, self.startY, self.startZ), (self.endX , self.endY, self.startZ))
self.placeWall((self.startX, self.startY, self.startZ), (self.startX , self.endY, self.endZ))
self.placeWall((self.startX, self.startY, self.endZ-1), (self.startX + (self.endX - self.startX)//2 , self.endY, self.endZ-1))
self.placeWall((self.startX + (self.endX - self.startX)//2 -1, self.startY, self.startZ + (self.endZ - self.startZ)//2), (self.startX + (self.endX - self.startX)//2 -1, self.endY, self.endZ ))
self.placeWall((self.startX + (self.endX - self.startX)//2, self.startY, self.startZ + (self.endZ - self.startZ)//2 -1), (self.endX , self.endY, self.startZ + (self.endZ - self.startZ)//2 -1))
self.placeWall((self.endX -1, self.startY, self.startZ ), (self.endX -1, self.endY, self.startZ+ (self.endZ - self.startZ)//2))
self.placeDoor("south", self.endX - (self.endX -self.startX) // 4 -1 , (self.startZ + self.endZ) //2 -1,self.startY)
if self.hasGarage:
self.placeGarage((self.startX+ (self.endX - self.startX)//2 +1, self.startY, self.startZ + (self.endZ - self.startZ)//2 +1), (self.endX-1, self.endY, self.endZ -1))
elif self.houseDirection == "west":
if self.gardenSide == "left":
self.placeGround((self.startX, self.startY, self.startZ), (self.startX + (self.endX - self.startX)//2, self.endY, self.startZ+ (self.endZ - self.startZ)//2), self.grass)
self.placeRoof((self.startX + (self.endX - self.startX)//2, self.startY, self.startZ), (self.endX, self.endY, self.endZ))
self.placeRoof((self.startX, self.startY, self.startZ+ (self.endZ - self.startZ)//2), (self.startX + (self.endX - self.startX)//2, self.endY, self.endZ))
self.placeWall((self.startX+ (self.endX - self.startX)//2, self.startY, self.startZ), (self.endX, self.endY, self.startZ))
self.placeWall((self.startX+ (self.endX - self.startX)//2, self.startY, self.startZ), (self.startX+ (self.endX - self.startX)//2, self.endY, self.startZ+ (self.endZ - self.startZ)//2))
self.placeWall((self.endX-1, self.startY, self.startZ), (self.endX-1, self.endY, self.endZ))
self.placeWall((self.startX, self.startY, self.startZ+ (self.endZ - self.startZ)//2), (self.startX+ (self.endX - self.startX)//2, self.endY, self.startZ+ (self.endZ - self.startZ)//2))
self.placeWall((self.startX, self.startY, self.startZ+ (self.endZ - self.startZ)//2), (self.startX, self.endY, self.endZ))
self.placeWall((self.startX, self.startY, self.endZ-1), (self.endX, self.endY, self.endZ-1))
self.placeDoor("west", self.endX - (self.endX -self.startX) // 2 , self.startZ + (self.endZ - self.startZ)//4 ,self.startY)
if self.hasGarage:
self.placeGarage((self.startX, self.startY, self.startZ+ (self.endZ - self.startZ)//2 +1), (self.startX , self.endY, self.endZ -1))
else:
self.placeGround((self.startX, self.startY, self.startZ+ (self.endZ - self.startZ)//2 ), (self.startX+ (self.endX-self.startX)//2, self.endY, self.endZ), self.grass)
self.placeRoof((self.startX + (self.endX - self.startX)//2, self.startY, self.startZ+ (self.endZ - self.startZ)//2), (self.endX, self.endY, self.endZ))
self.placeRoof((self.startX, self.startY, self.startZ), (self.endX, self.endY, self.startZ+ (self.endZ - self.startZ)//2))
self.placeWall((self.startX, self.startY, self.startZ+ (self.endZ - self.startZ)//2 -1), (self.startX+ (self.endX - self.startX)//2, self.endY, self.startZ+ (self.endZ - self.startZ)//2 -1))
self.placeWall((self.startX, self.startY, self.startZ), (self.endX, self.endY, self.startZ))
self.placeWall((self.startX, self.startY, self.startZ), (self.startX, self.endY, self.startZ+ (self.endZ - self.startZ)//2))
self.placeWall((self.startX + (self.endX - self.startX)//2, self.startY, self.endZ-1), (self.endX, self.endY, self.endZ-1))
self.placeWall((self.startX + (self.endX - self.startX)//2, self.startY, self.startZ+ (self.endZ - self.startZ)//2), (self.startX + (self.endX - self.startX)//2, self.endY, self.endZ))
self.placeWall((self.endX-1, self.startY, self.startZ), (self.endX-1, self.endY, self.endZ))
self.placeDoor("west", self.startX + (self.endX -self.startX) // 2 , self.endZ - (self.endZ - self.startZ)//4 -1,self.startY)
if self.hasGarage:
self.placeGarage((self.startX, self.startY, self.startZ+1), (self.startX, self.endY, self.startZ+ (self.endZ - self.startZ)//2 -1))
elif self.houseDirection == "east":
if self.gardenSide == "left":
self.placeGround((self.startX + (self.endX - self.startX)//2, self.startY, self.startZ+ (self.endZ - self.startZ)//2), (self.endX , self.endY, self.endZ, self.grass), self.grass)
self.placeRoof((self.startX, self.startY, self.startZ), (self.startX + (self.endX - self.startX)//2, self.endY, self.endZ))
self.placeRoof((self.startX + (self.endX - self.startX)//2, self.startY, self.startZ), (self.endX, self.endY, self.startZ+ (self.endZ - self.startZ)//2))
self.placeWall((self.startX, self.startY, self.startZ), (self.endX , self.endY, self.startZ))
self.placeWall((self.startX, self.startY, self.startZ), (self.startX, self.endY, self.endZ))
self.placeWall((self.startX, self.startY, self.endZ-1), (self.startX + (self.endX - self.startX)//2, self.endY, self.endZ-1))
self.placeWall((self.startX + (self.endX - self.startX)//2 -1, self.startY, self.startZ+ (self.endZ - self.startZ)//2), (self.startX + (self.endX - self.startX)//2 -1, self.endY, self.endZ))
self.placeWall((self.startX + (self.endX - self.startX)//2, self.startY, self.startZ+ (self.endZ - self.startZ)//2 -1), (self.endX , self.endY, self.startZ+ (self.endZ - self.startZ)//2 -1))
self.placeWall((self.endX-1, self.startY, self.startZ), (self.endX-1, self.endY, self.startZ+ (self.endZ - self.startZ)//2))
self.placeDoor("east", self.startX + (self.endX -self.startX) // 2 -1 ,self.endZ - (self.endZ - self.startZ)//4 -1,self.startY)
if self.hasGarage:
self.placeGarage((self.endX-1, self.startY, self.startZ +1), (self.endX-1, self.endY, self.startZ+ (self.endZ - self.startZ)//2 -1))
else :
self.placeGround((self.startX+ (self.endX -self.startX) // 2 , self.startY, self.startZ), (self.endX, self.endY, self.startZ+ (self.endZ - self.startZ)//2), self.grass)
self.placeRoof((self.startX, self.startY, self.startZ), (self.startX + (self.endX - self.startX)//2, self.endY, self.endZ))
self.placeRoof((self.startX + (self.endX - self.startX)//2, self.startY, self.startZ+ (self.endZ - self.startZ)//2), (self.endX, self.endY, self.endZ))
self.placeWall((self.startX, self.startY, self.startZ), (self.startX+ (self.endX - self.startX)//2 , self.endY, self.startZ))
self.placeWall((self.startX, self.startY, self.startZ), (self.startX, self.endY, self.endZ))
self.placeWall((self.startX, self.startY, self.endZ-1), (self.endX , self.endY, self.endZ-1))
self.placeWall((self.startX + (self.endX - self.startX)//2, self.startY, self.startZ+ (self.endZ - self.startZ)//2), (self.endX , self.endY, self.startZ+ (self.endZ - self.startZ)//2))
self.placeWall((self.startX + (self.endX - self.startX)//2 -1, self.startY, self.startZ), (self.startX + (self.endX - self.startX)//2 -1, self.endY, self.startZ+ (self.endZ - self.startZ)//2 ))
self.placeWall((self.endX-1, self.startY, self.startZ+ (self.endZ - self.startZ)//2), (self.endX-1, self.endY, self.endZ))
self.placeDoor("east", self.endX - (self.endX -self.startX) // 2 -1 , self.startZ + (self.endZ - self.startZ)//4 ,self.startY)
if self.hasGarage:
self.placeGarage((self.endX-1, self.startY, self.startZ+ (self.endZ - self.startZ)//2 +1), (self.endX-1, self.endY, self.endZ -1))
else:
self.houseWithoutGarden(self.houseDirection)
def placeDoorBasedOnDirection(self, direction):
if direction in ["north", "south"]:
z = self.startZ if direction == "north" else self.endZ - 1
if (self.endX - self.startX) % 2 != 0:
self.placeDoor(direction, (self.startX + self.endX)//2, z, self.startY)
else:
self.placeDoor(direction, (self.startX + self.endX)//2, z, self.startY)
self.placeDoor(direction, ((self.startX + self.endX)//2)-1, z, self.startY)
else:
x = self.startX if direction == "west" else self.endX - 1
if (self.endZ - self.startZ) % 2 != 0:
self.placeDoor(direction, x, (self.startZ + self.endZ)//2, self.startY)
else:
self.placeDoor(direction, x, (self.startZ + self.endZ)//2, self.startY)
self.placeDoor(direction, x, ((self.startZ + self.endZ)//2)-1, self.startY)
def houseWithoutGarden(self, direction="north"):
self.placeRoof((self.startX, self.startY, self.startZ), (self.endX, self.endY, self.endZ))
self.placeWall((self.startX, self.startY, self.startZ), (self.endX, self.endY, self.startZ))
self.placeWall((self.startX, self.startY, self.startZ), (self.startX, self.endY, self.endZ))
self.placeWall((self.startX, self.startY, self.endZ-1), (self.endX, self.endY, self.endZ-1))
self.placeWall((self.endX-1, self.startY, self.startZ), (self.endX-1, self.endY, self.endZ))
self.placeDoorBasedOnDirection(direction)
def clear(self):
for x in range(self.startX-1, self.endX+1):
for y in range(self.startY-1, self.endY+1):
for z in range(self.startZ-1, self.endZ+1):
self.editor.placeBlock((x, y, z), air)
if __name__ == "__main__":
editor = Editor(buffering=True)
buildArea = editor.getBuildArea()
coordinates_min = [min(buildArea.begin[i], buildArea.last[i]) for i in range(3)]
coordinates_max = [max(buildArea.begin[i], buildArea.last[i]) for i in range(3)]
house = House(editor,coordinates_min[0],coordinates_min[1],coordinates_min[2],coordinates_max[0],coordinates_max[1],coordinates_max[2], style_basique,"east")
# house.placeHouse()
house.clear()
editor.flushBuffer()

View File

@@ -1,26 +0,0 @@
import numpy as np
from skimage.morphology import skeletonize
import matplotlib.pyplot as plt
# Créer un tableau de booléens
image = np.ones((20, 20), dtype=bool)
image[1:-1, 1:-1] = True
# Effectuer la squelettisation
skeleton = skeletonize(image)
# Afficher les résultats
fig, axes = plt.subplots(nrows=1, ncols=2, figsize=(8, 4), sharex=True, sharey=True)
ax = axes.ravel()
ax[0].imshow(image, cmap=plt.cm.gray)
ax[0].axis('off')
ax[0].set_title('original', fontsize=20)
ax[1].imshow(skeleton, cmap=plt.cm.gray)
ax[1].axis('off')
ax[1].set_title('skeleton', fontsize=20)
fig.tight_layout()
plt.show()

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

View File

@@ -1,70 +0,0 @@
from gdpc import Block
air = Block('air')
style_basique={
'mur':"white_concrete",
'sol':"oak_planks",
'toit':"oak_planks",
'grass':"grass_block",
'chemin':"quartz_block",
'fence':'oak_fence',
'toit_esca':'oak_stairs',
'toit_planche':"oak_planks",
'toit_slab':'oak_slab',
'glass':"glass",
'door':'oak_door'
}
style_jungle={
'mur':"light_gray_concrete",
'sol':"acacia_planks",
'grass':"grass_block",
'chemin':"podzol",
'fence':'acacia_fence',
'toit_esca':'acacia_stairs',
'toit_planche':"acacia_planks",
'toit_slab':'acacia_slab',
'glass':"glass",
'door':'acacia_door'
}
style_end={
'mur':"purple_concrete",
'sol':"crimson_planks",
'grass':"grass_block",
'chemin':"amethyst_block",
'fence':'crimson_fence',
'toit_esca':'crimson_stairs',
'toit_planche':"crimson_planks",
'toit_slab':'crimson_slab',
'glass':"glass",
'door':'crimson_door'
}
style_birch={
'mur':"yellow_concrete",
'sol':"birch_planks",
'grass':"grass_block",
'chemin':"rooted_dirt",
'fence':'birch_fence',
'toit_esca':'birch_stairs',
'toit_planche':"birch_planks",
'toit_slab':'birch_slab',
'glass':"glass",
'door':'birch_door'
}

227
temp.py
View File

@@ -1,227 +0,0 @@
for i in range(-1, width+1):
for j in range(-1, depth+1):
if width<depth:
if width%2 != 0:
if (i == width//2 ):
self.editor.placeBlock((x + i, self.coordinates_max[1]+n, z + j), Block("blackstone_slab",{"type":"bottom"}))
self.grid3d[ x_plan3d+i, height+n, z_plan3d+j] = True
if j== -1 :
if not self.grid3d[ x_plan3d+i, height+n, z_plan3d+j-1]:
self.editor.placeBlock((x + i, self.coordinates_max[1]+n, z + j-1), Block("quartz_slab",{"type":"bottom"}))
self.grid3d[ x_plan3d+i, height+n, z_plan3d+j-1] = True
if not self.grid3d[ x_plan3d+i, height+n-1, z_plan3d+j-1]:
self.editor.placeBlock((x + i, self.coordinates_max[1]+n-1, z + j-1), Block("quartz_slab",{"type":"top"}))
self.grid3d[ x_plan3d+i, height+n-1, z_plan3d+j-1] = True
elif j == depth:
if not self.grid3d[ x_plan3d+i, height+n, z_plan3d+j+1]:
self.editor.placeBlock((x + i, self.coordinates_max[1]+n, z + j+1), Block("quartz_slab",{"type":"bottom"}))
self.grid3d[ x_plan3d+i, height+n, z_plan3d+j+1] = True
if not self.grid3d[ x_plan3d+i, height+n-1, z_plan3d+j+1]:
self.editor.placeBlock((x + i, self.coordinates_max[1]+n-1, z + j+1), Block("quartz_slab",{"type":"top"}))
self.grid3d[ x_plan3d+i, height+n-1, z_plan3d+j+1] = True
else:
if depth%2 != 0:
if (j == depth//2 ):
self.editor.placeBlock((x + i, self.coordinates_max[1]+n, z + j), Block("blackstone_slab",{"type":"bottom"}))
self.grid3d[ x_plan3d+i, height+n, z_plan3d+j] = True
if i== -1 :
if not self.grid3d[ x_plan3d+i-1, height+n, z_plan3d+j]:
self.editor.placeBlock((x + i-1, self.coordinates_max[1]+n, z + j), Block("quartz_slab",{"type":"bottom"}))
self.grid3d[ x_plan3d+i-1, height+n, z_plan3d+j] = True
if not self.grid3d[ x_plan3d+i-1, height+n-1, z_plan3d+j]:
self.editor.placeBlock((x + i-1, self.coordinates_max[1]+n-1, z + j), Block("quartz_slab",{"type":"top"}))
self.grid3d[ x_plan3d+i-1, height+n-1, z_plan3d+j] = True
elif i == width:
if not self.grid3d[ x_plan3d+i+1, height+n, z_plan3d+j]:
self.editor.placeBlock((x + i+1, self.coordinates_max[1]+n, z + j), Block("quartz_slab",{"type":"bottom"}))
self.grid3d[ x_plan3d+i+1, height+n, z_plan3d+j] = True
if not self.grid3d[ x_plan3d+i+1, height+n-1, z_plan3d+j]:
self.editor.placeBlock((x + i+1, self.coordinates_max[1]+n-1, z + j), Block("quartz_slab",{"type":"top"}))
self.grid3d[ x_plan3d+i+1, height+n-1, z_plan3d+j] = True
if width<depth:
h = 0
for i in range(-1, width//2):
for j in range(-1, depth+1):
if i != -1:
if h % 1 == 0:
self.editor.placeBlock((x + i, self.coordinates_max[1]+h, z + j), Block("blackstone_slab",{"type":"top"}))
self.editor.placeBlock((x + width-1-i, self.coordinates_max[1]+h, z + j), Block("blackstone_slab",{"type":"top"}))
self.grid3d[ x_plan3d+ i, round(height+h), z_plan3d+ j] = True
self.grid3d[ x_plan3d+ width-1-i, round(height+h), z_plan3d+ j] = True
if j == -1 :
self.editor.placeBlock((x + i, self.coordinates_max[1]+h, z + j -1), Block("quartz_block"))
self.editor.placeBlock((x + width-1-i, self.coordinates_max[1]+h, z + j -1), Block("quartz_block"))
self.grid3d[ x_plan3d+ i, round(height+h), z_plan3d+ j-1] = True
self.grid3d[ x_plan3d+ width-1-i, round(height+h), z_plan3d+ j-1] = True
elif j == depth:
self.editor.placeBlock((x + i, self.coordinates_max[1]+h, z + j +1), Block("quartz_block"))
self.editor.placeBlock((x + width-1-i, self.coordinates_max[1]+h, z + j +1), Block("quartz_block"))
self.grid3d[ x_plan3d+ i, round(height+h), z_plan3d+ j+1] = True
self.grid3d[ x_plan3d+ width-1-i, round(height+h), z_plan3d+ j+1] = True
else:
self.editor.placeBlock((x + i, self.coordinates_max[1]+h, z + j), Block("blackstone_slab",{"type":"bottom"}))
self.editor.placeBlock((x + width-1-i, self.coordinates_max[1]+h, z + j), Block("blackstone_slab",{"type":"bottom"}))
self.editor.placeBlock((x + i, self.coordinates_max[1]+h-0.5, z + j), Block("C"))
self.editor.placeBlock((x + width-1-i, self.coordinates_max[1]+h-0.5, z + j), Block("blackstone"))
self.grid3d[ x_plan3d+ i, round(height+h+0.5), z_plan3d+ j] = True
self.grid3d[ x_plan3d+ width-1-i, round(height+h+0.5), z_plan3d+ j] = True
self.grid3d[ x_plan3d+ i, round(height+h-0.5), z_plan3d+ j] = True
self.grid3d[ x_plan3d+ width-1-i, round(height+h-0.5), z_plan3d+ j] = True
if j == -1 :
self.editor.placeBlock((x + i, self.coordinates_max[1]+h, z + j -1), Block("quartz_slab", {"type": "bottom"}))
self.editor.placeBlock((x + width-1-i, self.coordinates_max[1]+h, z + j -1), Block("quartz_slab", {"type": "bottom"}))
self.editor.placeBlock((x + i, self.coordinates_max[1]+h-1, z + j -1), Block("quartz_slab", {"type": "top"}))
self.editor.placeBlock((x + width-1-i, self.coordinates_max[1]+h-1, z + j -1), Block("quartz_slab", {"type": "top"}))
self.grid3d[ x_plan3d+ i, round(height+h-1), z_plan3d+ j-1] = True
self.grid3d[ x_plan3d+ width-1-i, round(height+h-1), z_plan3d+ j-1] = True
self.grid3d[ x_plan3d+ i, round(height+h), z_plan3d+ j-1] = True
self.grid3d[ x_plan3d+ width-1-i, round(height+h), z_plan3d+ j-1] = True
elif j == depth:
self.editor.placeBlock((x + i, self.coordinates_max[1]+h, z + j +1), Block("quartz_slab", {"type": "bottom"}))
self.editor.placeBlock((x + width-1-i, self.coordinates_max[1]+h, z + j +1), Block("quartz_slab", {"type": "bottom"}))
self.editor.placeBlock((x + i, self.coordinates_max[1]+h-1, z + j +1), Block("quartz_slab", {"type": "top"}))
self.editor.placeBlock((x + width-1-i, self.coordinates_max[1]+h-1, z + j +1), Block("quartz_slab", {"type": "top"}))
self.grid3d[ x_plan3d+ i, round(height+h-1), z_plan3d+ j+1] = True
self.grid3d[ x_plan3d+ width-1-i, round(height+h-1), z_plan3d+ j+1] = True
self.grid3d[ x_plan3d+ i, round(height+h), z_plan3d+ j+1] = True
self.grid3d[ x_plan3d+ width-1-i, round(height+h), z_plan3d+ j+1] = True
else:
self.editor.placeBlock((x + i, self.coordinates_max[1]+h, z + j), Block("blackstone_slab",{"type":"bottom"}))
self.editor.placeBlock((x + width-1-i, self.coordinates_max[1]+h, z + j), Block("blackstone_slab",{"type":"bottom"}))
self.grid3d[ x_plan3d+ i, round(height+h), z_plan3d+ j] = True
self.grid3d[ x_plan3d+ width-1-i, round(height+h), z_plan3d+ j] = True
if j == -1 :
self.editor.placeBlock((x + i, self.coordinates_max[1]+h, z + j -1), Block("quartz_slab", {"type": "bottom"}))
self.editor.placeBlock((x + width-1-i, self.coordinates_max[1]+h, z + j -1), Block("quartz_slab", {"type": "bottom"}))
if not self.grid3d[ x_plan3d+i, height+h-1, z_plan3d+j-1]:
self.editor.placeBlock((x + i, self.coordinates_max[1]+h-1, z + j -1), Block("quartz_slab", {"type": "top"}))
self.grid3d[ x_plan3d+i, height+h-1, z_plan3d+j-1] = True
if not self.grid3d[ x_plan3d+width-1-i, height+h-1, z_plan3d+j-1]:
self.editor.placeBlock((x + width-1-i, self.coordinates_max[1]+h-1, z + j -1), Block("quartz_slab", {"type": "top"}))
self.grid3d[ x_plan3d+width-1-i, height+h-1, z_plan3d+j-1] = True
self.grid3d[ x_plan3d+ i, round(height+h-1), z_plan3d+ j-1] = True
self.grid3d[ x_plan3d+ width-1-i, round(height+h-1), z_plan3d+ j-1] = True
elif j == depth:
self.editor.placeBlock((x + i, self.coordinates_max[1]+h, z + j +1), Block("quartz_slab", {"type": "bottom"}))
self.editor.placeBlock((x + width-1-i, self.coordinates_max[1]+h, z + j +1), Block("quartz_slab", {"type": "bottom"}))
if not self.grid3d[ x_plan3d+i, height+h-1, z_plan3d+j+1]:
self.editor.placeBlock((x + i, self.coordinates_max[1]+h-1, z + j +1), Block("quartz_slab", {"type": "top"}))
self.grid3d[ x_plan3d+i, height+h-1, z_plan3d+j+1] = True
if not self.grid3d[ x_plan3d+width-1-i, height+h-1, z_plan3d+j+1]:
self.editor.placeBlock((x + width-1-i, self.coordinates_max[1]+h-1, z + j +1), Block("quartz_slab", {"type": "top"}))
self.grid3d[ x_plan3d+width-1-i, height+h-1, z_plan3d+j+1] = True
self.grid3d[ x_plan3d+ i, round(height+h-1), z_plan3d+ j+1] = True
self.grid3d[ x_plan3d+ width-1-i, round(height+h-1), z_plan3d+ j+1] = True
if i != -1:
h += 0.5
else:
h = 0
for i in range(-1, depth//2):
for j in range(-1, width+1):
if i != -1:
if h % 1 == 0:
self.editor.placeBlock((x + j, self.coordinates_max[1]+h, z + i), Block("blackstone_slab",{"type":"top"}))
self.editor.placeBlock((x + j, self.coordinates_max[1]+h, z + depth-1-i), Block("blackstone_slab",{"type":"top"}))
self.grid3d[ x_plan3d+j, round(height+h), z_plan3d+ i] = True
self.grid3d[ x_plan3d+j, round(height+h), z_plan3d+ depth-1-i] = True
if j == -1 :
self.editor.placeBlock((x + j -1, self.coordinates_max[1]+h, z + i ), Block("quartz_block"))
self.editor.placeBlock((x + j -1, self.coordinates_max[1]+h, z + depth-1-i ), Block("quartz_block"))
self.grid3d[ x_plan3d+j-1, round(height+h), z_plan3d+ i] = True
self.grid3d[ x_plan3d+j-1, round(height+h), z_plan3d+ depth-1-i] = True
elif j == width:
self.editor.placeBlock((x + j +1, self.coordinates_max[1]+h, z + i ), Block("quartz_block"))
self.editor.placeBlock((x + j +1, self.coordinates_max[1]+h, z + depth-1-i ), Block("quartz_block"))
self.grid3d[ x_plan3d+j+1, round(height+h), z_plan3d+ i] = True
self.grid3d[ x_plan3d+j+1, round(height+h), z_plan3d+ depth-1-i] = True
else:
self.editor.placeBlock((x + j, self.coordinates_max[1]+h, z + i), Block("blackstone_slab",{"type":"bottom"}))
self.editor.placeBlock((x + j, self.coordinates_max[1]+h, z + depth-1-i), Block("blackstone_slab",{"type":"bottom"}))
self.editor.placeBlock((x + j, self.coordinates_max[1]+h-0.5, z + i), Block("blackstone"))
self.editor.placeBlock((x + j, self.coordinates_max[1]+h-0.5, z + depth-1-i), Block("blackstone"))
self.grid3d[ j, round(height+h+0.5), i] = True
self.grid3d[ j, round(height+h+0.5), depth-1-i] = True
self.grid3d[ j, round(height+h-0.5), i] = True
self.grid3d[ j, round(height+h-0.5), depth-1-i] = True
if j == -1 :
self.editor.placeBlock((x + j -1, self.coordinates_max[1]+h, z + i ), Block("quartz_slab", {"type": "bottom"}))
self.editor.placeBlock((x + j -1, self.coordinates_max[1]+h, z + depth-1-i ), Block("quartz_slab", {"type": "bottom"}))
self.editor.placeBlock((x + j -1, self.coordinates_max[1]+h-1, z + i ), Block("quartz_slab", {"type": "top"}))
self.editor.placeBlock((x + j -1, self.coordinates_max[1]+h-1, z + depth-1-i ), Block("quartz_slab", {"type": "top"}))
self.grid3d[ j, round(height+h), i] = True
self.grid3d[ j, round(height+h), depth-1-i] = True
self.grid3d[ j, round(height+h-1), i] = True
self.grid3d[ j, round(height+h-1), depth-1-i] = True
elif j == width:
self.editor.placeBlock((x + j +1, self.coordinates_max[1]+h, z + i ), Block("quartz_slab", {"type": "bottom"}))
self.editor.placeBlock((x + j +1, self.coordinates_max[1]+h, z + depth-1-i ), Block("quartz_slab", {"type": "bottom"}))
self.editor.placeBlock((x + j +1, self.coordinates_max[1]+h-1, z + i ), Block("quartz_slab", {"type": "top"}))
self.editor.placeBlock((x + j +1, self.coordinates_max[1]+h-1, z + depth-1-i ), Block("quartz_slab", {"type": "top"}))
self.grid3d[ j, round(height+h), i] = True
self.grid3d[ j, round(height+h), depth-1-i] = True
self.grid3d[ j, round(height+h-1), i] = True
self.grid3d[ j, round(height+h-1), depth-1-i] = True
else:
self.editor.placeBlock((x + j, self.coordinates_max[1]+h, z + i), Block("blackstone_slab",{"type":"bottom"}))
self.editor.placeBlock((x + j, self.coordinates_max[1]+h, z + depth-1-i), Block("blackstone_slab",{"type":"bottom"}))
self.grid3d[ j, round(height+h), i] = True
self.grid3d[ j, round(height+h), depth-1-i] = True
if j == -1 :
self.editor.placeBlock((x + j -1, self.coordinates_max[1]+h, z + i ), Block("quartz_slab", {"type": "bottom"}))
self.editor.placeBlock((x + j -1, self.coordinates_max[1]+h, z + depth-1-i ), Block("quartz_slab", {"type": "bottom"}))
if not self.grid3d[ j, height+h-1, i]:
self.editor.placeBlock((x + j -1, self.coordinates_max[1]+h-1, z + i ), Block("quartz_slab", {"type": "top"}))
self.grid3d[ j, height+h-1, i] = True
if not self.grid3d[ j, height+h-1, depth-1-i]:
self.editor.placeBlock((x + j -1, self.coordinates_max[1]+h-1, z + depth-1-i ), Block("quartz_slab", {"type": "top"}))
self.grid3d[ j, height+h-1, depth-1-i] = True
self.grid3d[ j, round(height+h), i] = True
self.grid3d[ j, round(height+h), depth-1-i] = True
elif j == width:
self.editor.placeBlock((x + j +1, self.coordinates_max[1]+h, z + i ), Block("quartz_slab", {"type": "bottom"}))
self.editor.placeBlock((x + j +1, self.coordinates_max[1]+h, z + depth-1-i ), Block("quartz_slab", {"type": "bottom"}))
if not self.grid3d[ j, height+h-1, i]:
self.editor.placeBlock((x + j +1, self.coordinates_max[1]+h-1, z + i ), Block("quartz_slab", {"type": "top"}))
self.grid3d[ j, height+h-1, i] = True
if not self.grid3d[ j, height+h-1, depth-1-i]:
self.editor.placeBlock((x + j +1, self.coordinates_max[1]+h-1, z + depth-1-i ), Block("quartz_slab", {"type": "top"}))
self.grid3d[ j, height+h-1, depth-1-i] = True
self.grid3d[ j, round(height+h), i] = True
self.grid3d[ j, round(height+h), depth-1-i] = True
self.grid3d[ j, round(height+h), i] = True
self.grid3d[ j, round(height+h), depth-1-i] = True
if i != -1:
h += 0.5