True roads very quick
|
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 2.0 KiB |
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 5.6 KiB After Width: | Height: | Size: 5.4 KiB |
|
Before Width: | Height: | Size: 9.4 KiB After Width: | Height: | Size: 9.8 KiB |
BIN
world_maker/data/full_road.png
Normal file
|
After Width: | Height: | Size: 3.8 KiB |
BIN
world_maker/data/full_road_heightmap.png
Normal file
|
After Width: | Height: | Size: 3.6 KiB |
BIN
world_maker/data/full_road_heightmap_smooth.png
Normal file
|
After Width: | Height: | Size: 23 KiB |
|
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 23 KiB |
BIN
world_maker/data/heightmap_smooth_2.png
Normal file
|
After Width: | Height: | Size: 23 KiB |
|
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 20 KiB |
|
Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 2.8 KiB |
BIN
world_maker/data/road_heightmap.png
Normal file
|
After Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 2.2 KiB |
|
Before Width: | Height: | Size: 49 KiB After Width: | Height: | Size: 48 KiB |
|
Before Width: | Height: | Size: 47 KiB After Width: | Height: | Size: 48 KiB |
|
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.9 KiB |
@@ -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',
|
||||
number_of_try: int = 3, min_width: int = 10, max_width: int = 25):
|
||||
number_of_try: int = 1, min_width: int = 10, max_width: int = 25):
|
||||
print("[Building] Start generating building position...")
|
||||
image = handle_import_image(image).convert('L')
|
||||
rectangles_output = []
|
||||
|
||||
@@ -7,10 +7,13 @@ from world_maker.Position import Position
|
||||
from random import randint
|
||||
from world_maker.pack_rectangle import generate_building
|
||||
|
||||
import numpy as np
|
||||
|
||||
|
||||
def world_maker():
|
||||
world = World()
|
||||
heightmap, watermap, treemap = get_data(world)
|
||||
# world = World()
|
||||
# heightmap, watermap, treemap = get_data(world)
|
||||
heightmap, watermap, treemap = get_data_no_update()
|
||||
|
||||
heightmap_smooth = filter_smooth(heightmap, 4)
|
||||
heightmap_smooth.save('./world_maker/data/heightmap_smooth.png')
|
||||
@@ -34,6 +37,7 @@ def world_maker():
|
||||
road = city.draw_roads(4)
|
||||
road.save('./world_maker/data/roadmap.png')
|
||||
|
||||
# Buildings
|
||||
subtract_map(smooth_sobel_water_map, road).save(
|
||||
'./world_maker/data/city_map.png')
|
||||
subtract_map('./world_maker/data/city_map.png',
|
||||
@@ -45,6 +49,7 @@ def world_maker():
|
||||
'./world_maker/data/city_map.png', './world_maker/data/heightmap.png', output='./world_maker/data/building.png')
|
||||
rectangle_building = rectangle_2D_to_3D(rectangle_building)
|
||||
|
||||
# Houses
|
||||
skeleton_mountain = skeleton_mountain_map(image_mountain_map)
|
||||
subtract_map('./world_maker/data/mountain_map.png',
|
||||
'./world_maker/data/skeleton_mountain_area.png').save('./world_maker/data/mountain_map.png')
|
||||
@@ -52,10 +57,24 @@ def world_maker():
|
||||
'./world_maker/data/skeleton_highway_area.png').save('./world_maker/data/mountain_map.png')
|
||||
subtract_map(smooth_sobel_water_map, filter_negative(
|
||||
'./world_maker/data/mountain_map.png')).save('./world_maker/data/mountain_map.png')
|
||||
|
||||
rectangle_mountain = generate_building(
|
||||
'./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)
|
||||
|
||||
# Road
|
||||
heightmap_smooth_2 = filter_smooth(heightmap, 4)
|
||||
heightmap_smooth_2.save('./world_maker/data/heightmap_smooth_2.png')
|
||||
overide_map('./world_maker/data/skeleton_highway_area.png',
|
||||
'./world_maker/data/skeleton_mountain_area.png').save('./world_maker/data/full_road.png')
|
||||
overide_map('./world_maker/data/full_road.png',
|
||||
'./world_maker/data/roadmap.png').save('./world_maker/data/full_road.png')
|
||||
|
||||
road_heightmap = subtract_map(
|
||||
heightmap_smooth_2, filter_negative('./world_maker/data/full_road.png'))
|
||||
|
||||
road_heightmap.save('./world_maker/data/road_heightmap.png')
|
||||
|
||||
# Terraforming
|
||||
# Smooth initialization
|
||||
overide_map('./world_maker/data/heightmap.png',
|
||||
@@ -63,14 +82,24 @@ def world_maker():
|
||||
overide_map('./world_maker/data/heightmap_with_building.png',
|
||||
'./world_maker/data/building.png').save('./world_maker/data/heightmap_with_building.png')
|
||||
filter_smooth(
|
||||
'./world_maker/data/heightmap_with_building.png', 2).save('./world_maker/data/heightmap_smooth.png')
|
||||
'./world_maker/data/heightmap_with_building.png', 2).save('./world_maker/data/heightmap_with_building.png')
|
||||
|
||||
overide_map('./world_maker/data/heightmap_with_building.png',
|
||||
road_heightmap).save('./world_maker/data/heightmap_with_building.png')
|
||||
|
||||
filter_smooth('./world_maker/data/heightmap_with_building.png',
|
||||
2).save('./world_maker/data/heightmap_with_building.png')
|
||||
|
||||
# Smooth repetition
|
||||
for i in range(10):
|
||||
overide_map('./world_maker/data/heightmap_with_building.png',
|
||||
'./world_maker/data/building_moutain.png').save('./world_maker/data/heightmap_with_building.png')
|
||||
overide_map('./world_maker/data/heightmap_with_building.png',
|
||||
'./world_maker/data/building.png').save('./world_maker/data/heightmap_with_building.png')
|
||||
filter_smooth(
|
||||
'./world_maker/data/heightmap_with_building.png', 2).save('./world_maker/data/heightmap_smooth.png')
|
||||
'./world_maker/data/heightmap_with_building.png', 2).save('./world_maker/data/heightmap_with_building.png')
|
||||
|
||||
filter_smooth(
|
||||
'./world_maker/data/heightmap_with_building.png', 2).save('./world_maker/data/heightmap_smooth.png')
|
||||
|
||||
return rectangle_mountain, rectangle_building, skeleton_highway, skeleton_mountain, road_grid
|
||||
|
||||