Put everything inside of main
55
main.py
@@ -1,52 +1,7 @@
|
|||||||
from gdpc import Editor, Block, geometry, Transform
|
from world_maker.world_maker import *
|
||||||
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 *
|
def main():
|
||||||
|
world_maker()
|
||||||
|
|
||||||
editor = Editor(buffering=True)
|
if __name__ == '__main__':
|
||||||
|
rectangle_house_mountain,rectangle_building, skeleton_highway, skeleton_mountain = main()
|
||||||
# get every differents buildings shapes
|
|
||||||
f = JsonReader('buildings\shapes.json')
|
|
||||||
shapes = f.data
|
|
||||||
|
|
||||||
# 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)
|
|
||||||
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)
|
|
||||||
# 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"))
|
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
from District import District, Road
|
from world_maker.District import District, Road
|
||||||
from Position import Position
|
from world_maker.Position import Position
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
from random import randint
|
from random import randint
|
||||||
from data_analysis import handle_import_image, detect_mountain
|
from world_maker.data_analysis import handle_import_image, detect_mountain
|
||||||
from typing import Union
|
from typing import Union
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from Position import Position
|
from world_maker.Position import Position
|
||||||
from typing import Union
|
from typing import Union
|
||||||
from random import randint
|
from random import randint
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
from gdpc import Editor, geometry, lookup
|
from gdpc import Editor, geometry, lookup
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
from Block import Block
|
from world_maker.Block import Block
|
||||||
|
|
||||||
waterBiomes = [
|
waterBiomes = [
|
||||||
"minecraft:ocean",
|
"minecraft:ocean",
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 696 B After Width: | Height: | Size: 597 B |
|
Before Width: | Height: | Size: 5.0 KiB After Width: | Height: | Size: 5.2 KiB |
|
Before Width: | Height: | Size: 7.7 KiB After Width: | Height: | Size: 8.3 KiB |
|
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 2.5 KiB After Width: | Height: | Size: 2.6 KiB |
|
Before Width: | Height: | Size: 35 KiB After Width: | Height: | Size: 36 KiB |
|
Before Width: | Height: | Size: 35 KiB After Width: | Height: | Size: 34 KiB |
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.3 KiB |
@@ -1,8 +1,8 @@
|
|||||||
import World
|
from world_maker.World import World
|
||||||
from PIL import Image, ImageFilter
|
from PIL import Image, ImageFilter
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from scipy import ndimage
|
from scipy import ndimage
|
||||||
from Skeleton import Skeleton
|
from world_maker.Skeleton import Skeleton
|
||||||
from typing import Union
|
from typing import Union
|
||||||
from random import randint
|
from random import randint
|
||||||
import cv2
|
import cv2
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
from PIL import Image
|
from PIL import Image
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from typing import Union
|
from typing import Union
|
||||||
from data_analysis import handle_import_image
|
from world_maker.data_analysis import handle_import_image
|
||||||
from random import randint
|
from random import randint
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,18 +1,18 @@
|
|||||||
import World
|
from world_maker.World import World
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
from data_analysis import get_data,filter_negative, rectangle_2D_to_3D, skeleton_mountain_map, highway_map, filter_sobel, skeleton_highway_map, \
|
from world_maker.data_analysis import (get_data,filter_negative, rectangle_2D_to_3D, skeleton_mountain_map, highway_map, filter_sobel, skeleton_highway_map, \
|
||||||
smooth_sobel_water, subtract_map, detect_mountain
|
smooth_sobel_water, subtract_map, detect_mountain)
|
||||||
from City import City
|
from world_maker.City import City
|
||||||
from Position import Position
|
from world_maker.Position import Position
|
||||||
from random import randint
|
from random import randint
|
||||||
from pack_rectangle import generate_building
|
from world_maker.pack_rectangle import generate_building
|
||||||
|
|
||||||
if __name__ == '__main__':
|
def world_maker():
|
||||||
#world = World.World()
|
world = World()
|
||||||
#heightmap, watermap, treemap = get_data(world)
|
heightmap, watermap, treemap = get_data(world)
|
||||||
#filter_sobel("./world_maker/data/heightmap.png").save('./world_maker/data/sobelmap.png')
|
filter_sobel("./world_maker/data/heightmap.png").save('./world_maker/data/sobelmap.png')
|
||||||
smooth_sobel_water = smooth_sobel_water()
|
smooth_sobel_water_map = smooth_sobel_water()
|
||||||
skeleton_highway_map(highway_map())
|
skeleton_highway = skeleton_highway_map(highway_map())
|
||||||
city = City()
|
city = City()
|
||||||
city.generate_district()
|
city.generate_district()
|
||||||
city.loop_expend_district()
|
city.loop_expend_district()
|
||||||
@@ -21,13 +21,14 @@ if __name__ == '__main__':
|
|||||||
image_mountain_map = city.get_district_mountain_map()
|
image_mountain_map = city.get_district_mountain_map()
|
||||||
road = city.draw_roads(4)
|
road = city.draw_roads(4)
|
||||||
road.save('./world_maker/data/roadmap.png')
|
road.save('./world_maker/data/roadmap.png')
|
||||||
subtract_map(smooth_sobel_water, road).save('./world_maker/data/city_map.png')
|
subtract_map(smooth_sobel_water_map, road).save('./world_maker/data/city_map.png')
|
||||||
subtract_map('./world_maker/data/city_map.png', './world_maker/data/skeleton_highway_area.png').save('./world_maker/data/city_map.png')
|
subtract_map('./world_maker/data/city_map.png', './world_maker/data/skeleton_highway_area.png').save('./world_maker/data/city_map.png')
|
||||||
subtract_map('./world_maker/data/city_map.png', './world_maker/data/mountain_map.png').save('./world_maker/data/city_map.png')
|
subtract_map('./world_maker/data/city_map.png', './world_maker/data/mountain_map.png').save('./world_maker/data/city_map.png')
|
||||||
rectangle_building = generate_building('./world_maker/data/city_map.png')
|
rectangle_building = generate_building('./world_maker/data/city_map.png')
|
||||||
rectangle_building = rectangle_2D_to_3D(rectangle_building)
|
rectangle_building = rectangle_2D_to_3D(rectangle_building)
|
||||||
|
|
||||||
skeleton_mountain_map(image_mountain_map)
|
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')
|
subtract_map('./world_maker/data/mountain_map.png', './world_maker/data/skeleton_mountain_area.png').save('./world_maker/data/mountain_map.png')
|
||||||
subtract_map(smooth_sobel_water, filter_negative('./world_maker/data/mountain_map.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')
|
rectangle_mountain = generate_building('./world_maker/data/mountain_map.png')
|
||||||
|
return rectangle_building, rectangle_mountain, skeleton_highway, skeleton_mountain
|
||||||
|
|||||||