Testing
35
main.py
@@ -71,14 +71,6 @@ def main():
|
|||||||
# 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 wto 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
|
# create a building at the relative position 0,0 with 20 blocks length and 20 blocks width, with a normal shape and 10 floors
|
||||||
|
|
||||||
# build it with your custom materials
|
# build it with your custom materials
|
||||||
@@ -87,26 +79,25 @@ def main():
|
|||||||
height = get_height_building_from_center(
|
height = get_height_building_from_center(
|
||||||
center, (buildings[0][0], buildings[0][2]), length_world)
|
center, (buildings[0][0], buildings[0][2]), length_world)
|
||||||
start = (min(buildings[0][0], buildings[1][0]) + origin[0], buildings[0]
|
start = (min(buildings[0][0], buildings[1][0]) + origin[0], buildings[0]
|
||||||
[1], min(buildings[0][2], buildings[1][2]) + origin[1])
|
[1]+height, min(buildings[0][2], buildings[1][2]) + origin[1])
|
||||||
end = (max(buildings[0][0], buildings[1][0]) + origin[0], buildings[1]
|
end = (max(buildings[0][0], buildings[1][0]) + origin[0],
|
||||||
|
buildings[1]
|
||||||
[1], max(buildings[0][2], buildings[1][2]) + origin[1])
|
[1], max(buildings[0][2], buildings[1][2]) + origin[1])
|
||||||
|
|
||||||
transform = Transform(start, rotation=0)
|
print("---", start, end)
|
||||||
editor.transform.push(transform)
|
|
||||||
|
|
||||||
building = Building(random_data["buildings"], [
|
building = Building(random_data["buildings"], [
|
||||||
(0, 0, 0), (end[0] - start[0], height, end[2] - start[2])], baseShape, DIRECTION.EAST)
|
start, end], baseShape, DIRECTION.EAST)
|
||||||
building.build(editor, ["stone_bricks", "glass_pane", "glass", "cobblestone_wall", "stone_brick_stairs",
|
building.build(editor, ["stone_bricks", "glass_pane", "glass", "cobblestone_wall", "stone_brick_stairs",
|
||||||
"oak_planks", "white_concrete", "cobblestone", "stone_brick_slab", "iron_bars"])
|
"oak_planks", "white_concrete", "cobblestone", "stone_brick_slab", "iron_bars"])
|
||||||
|
|
||||||
for buildings in rectangle_house_mountain:
|
# for buildings in rectangle_house_mountain:
|
||||||
start = (buildings[0][0] + origin[0], buildings[0]
|
# start = (buildings[0][0] + origin[0], buildings[0]
|
||||||
[1], buildings[0][2] + origin[1])
|
# [1], buildings[0][2] + origin[1])
|
||||||
end = (buildings[1][0] + origin[0], buildings[1]
|
# end = (buildings[1][0] + origin[0], buildings[1]
|
||||||
[1], buildings[1][2] + origin[1])
|
# [1], buildings[1][2] + origin[1])
|
||||||
house = House(editor, start, end,
|
# house = House(editor, start, end,
|
||||||
entranceDirection[random.randint(0, 3)], blocks)
|
# entranceDirection[random.randint(0, 3)], blocks)
|
||||||
house.build()
|
# house.build()
|
||||||
|
|
||||||
|
|
||||||
def get_height_building_from_center(center, position, length_world):
|
def get_height_building_from_center(center, position, length_world):
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 407 B After Width: | Height: | Size: 345 B |
|
Before Width: | Height: | Size: 145 B After Width: | Height: | Size: 525 B |
|
Before Width: | Height: | Size: 889 B After Width: | Height: | Size: 863 B |
|
Before Width: | Height: | Size: 927 B After Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 811 B After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 5.3 KiB After Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 5.3 KiB |
|
Before Width: | Height: | Size: 3.0 KiB After Width: | Height: | Size: 6.1 KiB |
|
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 5.3 KiB |
|
Before Width: | Height: | Size: 599 B After Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 3.1 KiB |
|
Before Width: | Height: | Size: 522 B After Width: | Height: | Size: 760 B |
|
Before Width: | Height: | Size: 5.8 KiB After Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 563 B After Width: | Height: | Size: 466 B |
|
Before Width: | Height: | Size: 5.9 KiB After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 491 B After Width: | Height: | Size: 769 B |
|
Before Width: | Height: | Size: 387 B After Width: | Height: | Size: 339 B |
|
Before Width: | Height: | Size: 891 B After Width: | Height: | Size: 1.0 KiB |
|
Before Width: | Height: | Size: 6.9 KiB After Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 5.5 KiB After Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 348 B After Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 657 B After Width: | Height: | Size: 154 B |
@@ -97,7 +97,7 @@ def area_of_rectangles(rectangles):
|
|||||||
|
|
||||||
|
|
||||||
def generate_building(image: str | Image.Image, heightmap: str | Image.Image, output: str = './world_maker/data/building.png',
|
def generate_building(image: str | Image.Image, heightmap: str | Image.Image, output: str = './world_maker/data/building.png',
|
||||||
number_of_try: int = 1, min_width: int = 10, max_width: int = 25):
|
number_of_try: int = 3, min_width: int = 10, max_width: int = 25):
|
||||||
print("[Building] Start generating building position...")
|
print("[Building] Start generating building position...")
|
||||||
image = handle_import_image(image).convert('L')
|
image = handle_import_image(image).convert('L')
|
||||||
rectangles_output = []
|
rectangles_output = []
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ def world_maker():
|
|||||||
'./world_maker/data/mountain_map.png').save('./world_maker/data/city_map.png')
|
'./world_maker/data/mountain_map.png').save('./world_maker/data/city_map.png')
|
||||||
|
|
||||||
rectangle_building = generate_building(
|
rectangle_building = generate_building(
|
||||||
'./world_maker/data/city_map.png', './world_maker/data/heightmap.png', output='./world_maker/data/building.png')
|
'./world_maker/data/city_map.png', './world_maker/data/heightmap.png', output='./world_maker/data/building.png', min_width=16, max_width=30)
|
||||||
rectangle_building = rectangle_2D_to_3D(rectangle_building)
|
rectangle_building = rectangle_2D_to_3D(rectangle_building)
|
||||||
|
|
||||||
# Houses
|
# Houses
|
||||||
@@ -60,7 +60,8 @@ def world_maker():
|
|||||||
|
|
||||||
rectangle_mountain = generate_building(
|
rectangle_mountain = generate_building(
|
||||||
'./world_maker/data/mountain_map.png', './world_maker/data/heightmap.png', output='./world_maker/data/building_moutain.png')
|
'./world_maker/data/mountain_map.png', './world_maker/data/heightmap.png', output='./world_maker/data/building_moutain.png')
|
||||||
rectangle_mountain = rectangle_2D_to_3D(rectangle_mountain)
|
rectangle_mountain = rectangle_2D_to_3D(
|
||||||
|
rectangle_mountain)
|
||||||
|
|
||||||
# Road
|
# Road
|
||||||
heightmap_smooth_2 = filter_smooth(heightmap, 4)
|
heightmap_smooth_2 = filter_smooth(heightmap, 4)
|
||||||
|
|||||||