poikilos
9 years ago
committed by
Jacob Gustafson
13 changed files with 615 additions and 190 deletions
After Width: | Height: | Size: 6.5 KiB |
Binary file not shown.
@ -0,0 +1,189 @@ |
|||
0 |
|||
1 |
|||
2 |
|||
3 |
|||
4 |
|||
5 |
|||
6 |
|||
7 |
|||
8 |
|||
9 |
|||
a |
|||
b |
|||
c |
|||
d |
|||
e |
|||
f |
|||
10 |
|||
11 |
|||
12 |
|||
13 |
|||
14 |
|||
15 |
|||
16 |
|||
17 |
|||
18 |
|||
19 |
|||
1a |
|||
1b |
|||
1c |
|||
1d |
|||
1e |
|||
1f |
|||
20 |
|||
21 |
|||
|
|||
ethereal:willow_trunk |
|||
moretrees:oak_trunk |
|||
technic:mineral_lead |
|||
moretrees:apple_tree_trunk |
|||
ethereal:banana |
|||
bushes:BushLeaves1 |
|||
bushes:BushLeaves2 |
|||
flowers:dandelion_white |
|||
ethereal:bush |
|||
tsm_pyramids:deco_stone3 |
|||
tsm_pyramids:deco_stone2 |
|||
whiteshell:whiteshell |
|||
ethereal:onion_4 |
|||
ethereal:quicksand2 |
|||
bushes:youngtree2_bottom |
|||
default:stone_with_iron |
|||
moretrees:apple_tree_leaves |
|||
seacoral:seacoraldirtcyan |
|||
ethereal:gray_dirt |
|||
seacoral:seacoraldirtlime |
|||
youngtrees:youngtree_middle |
|||
vines:vine_end |
|||
seaplants:seaplantsdirtseagrassgreen |
|||
ferns:fern_trunk_big |
|||
noairblocks:water_sourcex |
|||
ethereal:mushroom_dirt |
|||
default:pine_tree |
|||
ignore |
|||
seacoral:seacoraldirtmagenta |
|||
flowers:mushroom_red |
|||
ethereal:sandy |
|||
ethereal:jungle_dirt |
|||
ethereal:mushroom |
|||
clams:dirtalgae |
|||
flowers:tulip |
|||
seacoral:seacoralsandcyan |
|||
ethereal:willow_twig |
|||
default:sandstonebrick |
|||
ferns:tree_fern_leaves_giant |
|||
ethereal:orange |
|||
moretrees:sequoia_leaves |
|||
trunks:twig_9 |
|||
trunks:twig_7 |
|||
trunks:twig_5 |
|||
seacoral:seacoraldirtskyblue |
|||
moreores:mineral_silver |
|||
ethereal:banana_trunk |
|||
moretrees:pine_cone |
|||
seacoral:coralredviolet |
|||
moretrees:acorn |
|||
vines:vine_middle |
|||
technic:marble |
|||
seacoral:seacoralsandskyblue |
|||
ferns:fern_03 |
|||
ferns:fern_02 |
|||
ferns:fern_01 |
|||
moretrees:palm_trunk |
|||
seacoral:seacoralsandmagenta |
|||
seacoral:seacoralsandlime |
|||
default:pine_needles |
|||
ferns:fern_trunk_big_top |
|||
seaplants:seaplantsdirtkelpbrown |
|||
tsm_pyramids:trap |
|||
ethereal:birch_trunk |
|||
ferns:horsetail_02 |
|||
ferns:horsetail_03 |
|||
bushes:bushbranches4 |
|||
ferns:horsetail_01 |
|||
bushes:bushbranches2 |
|||
bushes:bushbranches3 |
|||
ferns:horsetail_04 |
|||
bushes:bushbranches1 |
|||
clams:sandalgae |
|||
moretrees:oak_leaves |
|||
ethereal:mushroom_pore |
|||
ferns:tree_fern_leave_big |
|||
bakedclay:orange |
|||
seacoral:seacoraldirtaqua |
|||
moretrees:sequoia_trunk |
|||
bakedclay:red |
|||
seaplants:seaplantssandkelpgreen |
|||
stairs:stair_cobble |
|||
ethereal:snowygrass |
|||
woodsoils:dirt_with_leaves_1 |
|||
moreores:mineral_tin |
|||
flowers:seaweed |
|||
ethereal:bamboo_leaves |
|||
ethereal:palm_trunk |
|||
seacoral:seacoralsandaqua |
|||
trunks:moss |
|||
seaplants:seaplantsdirtseagrassred |
|||
default:acacia_tree |
|||
default:jungleleaves |
|||
flowers:viola |
|||
seacoral:seacoralsandredviolet |
|||
flowers:rose |
|||
ethereal:bamboo |
|||
default:stone_with_copper |
|||
moretrees:jungletree_leaves_yellow |
|||
moretrees:coconut |
|||
ethereal:palmleaves |
|||
ethereal:green_dirt |
|||
seaplants:seaplantssandseagrassgreen |
|||
trunks:twig_8 |
|||
trunks:moss_fungus |
|||
air |
|||
flowers:waterlily |
|||
ethereal:redwood_leaves |
|||
trunks:twig_10 |
|||
trunks:twig_11 |
|||
trunks:twig_12 |
|||
trunks:twig_13 |
|||
seacoral:corallime |
|||
technic:mineral_zinc |
|||
ethereal:strawberry_7 |
|||
ethereal:prairie_dirt |
|||
default:grass_1 |
|||
default:grass_3 |
|||
default:grass_2 |
|||
default:grass_5 |
|||
default:grass_4 |
|||
ethereal:coconut |
|||
ethereal:bamboo_dirt |
|||
cavestuff:desert_pebble_2 |
|||
cavestuff:desert_pebble_1 |
|||
flowers:geranium |
|||
ethereal:bananaleaves |
|||
moretrees:jungletree_trunk |
|||
flowers:mushroom_brown |
|||
bakedclay:grey |
|||
default:acacia_leaves |
|||
youngtrees:youngtree_bottom |
|||
ferns:tree_fern_leave_big_end |
|||
lapis:pyrite_ore |
|||
flowers:dandelion_yellow |
|||
flowers:seaweed_2 |
|||
flowers:seaweed_3 |
|||
flowers:seaweed_4 |
|||
ethereal:orange_leaves |
|||
tsm_mines:dummy |
|||
moretrees:jungletree_leaves_red |
|||
seaplants:seaplantsdirtkelpgreen |
|||
ethereal:grove_dirt |
|||
tsm_pyramids:spawner_mummy |
|||
ethereal:mushroom_trunk |
|||
ethereal:fern |
|||
ethereal:birch_leaves |
|||
moretrees:palm_leaves |
|||
seacoral:coralcyan |
|||
ethereal:redwood_trunk |
|||
seaplants:seaplantssandkelpbrown |
|||
youngtrees:youngtree_top |
|||
seacoral:seacoraldirtredviolet |
|||
seaplants:seaplantssandseagrassred |
@ -0,0 +1,13 @@ |
|||
import os |
|||
from expertmm import * |
|||
|
|||
python_exe_path = "python" |
|||
|
|||
if os_name=="windows": |
|||
try: |
|||
alt_path = "C:\\python27\python.exe" |
|||
if os.path.isfile(alt_path): |
|||
python_exe_path = alt_path |
|||
#else may be in path--assume installer worked |
|||
except: |
|||
pass # do nothing |
@ -0,0 +1,105 @@ |
|||
import subprocess |
|||
import os |
|||
from minetestinfo import * |
|||
#python_exe_path is from: |
|||
from pythoninfo import * |
|||
|
|||
|
|||
class ChunkymapOfflineRenderer: |
|||
|
|||
minetestmapper_fast_sqlite_path = None |
|||
minetestmapper_custom_path = None |
|||
minetestmapper_py_path = None |
|||
backend_string = None |
|||
world_path = None |
|||
world_name = None |
|||
|
|||
def __init__(self): |
|||
|
|||
self.backend_string = get_world_var("backend") |
|||
|
|||
#region the following is also in singleimage.py |
|||
self.minetestmapper_fast_sqlite_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "minetestmapper-numpy.py") |
|||
self.minetestmapper_custom_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "minetestmapper-expertmm.py") |
|||
self.minetestmapper_py_path = self.minetestmapper_fast_sqlite_path |
|||
if (self.backend_string!="sqlite3"): |
|||
# Since minetestmapper-numpy has trouble with leveldb: |
|||
self.minetestmapper_py_path = self.minetestmapper_custom_path |
|||
print("Chose image generator script: "+self.minetestmapper_py_path) |
|||
if not os.path.isfile(self.minetestmapper_py_path): |
|||
print("ERROR: script does not exist, so exiting "+__file__+".") |
|||
sys.exit(2) |
|||
self.colors_path = os.path.join(os.path.dirname(os.path.abspath(self.minetestmapper_py_path)), "colors.txt") |
|||
if not os.path.isfile(self.colors_path): |
|||
print("ERROR: missing '"+self.colors_path+"', so exiting "+__file__+".") |
|||
sys.exit(2) |
|||
self.world_path = minetestinfo.get_var("primary_world_path") |
|||
if not os.path.isdir(self.world_path): |
|||
print("ERROR: missing world '"+self.world_path+"', so exiting "+__file__+".") |
|||
sys.exit(2) |
|||
else: |
|||
self.world_name = os.path.basename(self.world_path) |
|||
#endregion the following is also in singleimage.py |
|||
|
|||
def RenderSingleImage(self): |
|||
genresults_folder_path = os.path.join( os.path.join(os.path.dirname(os.path.abspath(__file__)), "chunkymap-genresults"), self.world_name) |
|||
if not os.path.isdir(genresults_folder_path): |
|||
os.makedirs(genresults_folder_path) |
|||
genresult_path = os.path.join(genresults_folder_path, "singleimage"+genresult_name_closer_string) |
|||
cmd_suffix = " > \""+genresult_path+"\"" |
|||
|
|||
#blank since singleimage mode: |
|||
#geometry_string = str(min_x)+":"+str(min_z)+"+"+str(int(max_x)-int(min_x)+1)+"+"+str(int(max_z)-int(min_z)+1) # +1 since max-min is exclusive and width must be inclusive for minetestmapper.py |
|||
#geometry_param = " --geometry "+geometry_string |
|||
geometry_param = "" |
|||
#expertmm_region_string = str(min_x) + ":" + str(max_x) + "," + str(min_z) + ":" + str(max_z) |
|||
|
|||
#cmd_no_out_string = python_exe_path+" "+self.minetestmapper_py_path+" --bgcolor '"+self.FLAG_EMPTY_HEXCOLOR+"' --input \""+minetestinfo.get_var("primary_world_path")+"\" --geometry "+geometry_string+" --output \""+tmp_png_path+"\"" |
|||
png_name = "singleimage.png" |
|||
tmp_png_path = os.path.join(genresults_folder_path, png_name) |
|||
squote = "" |
|||
if os_name!="windows": |
|||
squote = "'" |
|||
io_string = " --input \""+self.world_path+"\" --output \""+tmp_png_path+"\"" |
|||
if "numpy" in self.minetestmapper_py_path: |
|||
io_string = " \""+self.world_path+"\" \""+tmp_png_path+"\"" |
|||
#geometry_param = " --region " + str(min_x) + " " + str(max_x) + " " + str(min_z) + " " + str(max_z) |
|||
cmd_no_out_string = python_exe_path+" "+self.minetestmapper_py_path+" --bgcolor "+squote+FLAG_EMPTY_HEXCOLOR+squote+io_string |
|||
cmd_string = cmd_no_out_string + cmd_suffix |
|||
print("") |
|||
print("") |
|||
print("Running") |
|||
print(" "+cmd_string) |
|||
print(" # (this may take a while...)") |
|||
if os.path.isfile(tmp_png_path): |
|||
os.remove(tmp_png_path) |
|||
subprocess.call(cmd_string, shell=True) |
|||
final_png_path = tmp_png_path |
|||
www_chunkymapdata_path = os.path.join(minetestinfo.get_var("www_minetest_path"), "chunkymapdata") |
|||
www_chunkymapdata_worlds_path = os.path.join(www_chunkymapdata_path, "worlds") |
|||
www_chunkymapdata_world_path = os.path.join(www_chunkymapdata_worlds_path, self.world_name) |
|||
if os.path.isfile(tmp_png_path): |
|||
if not os.path.isdir(www_chunkymapdata_world_path): |
|||
os.makedirs(www_chunkymapdata_world_path) |
|||
if minetestinfo.contains("www_minetest_path"): |
|||
dest_png_path = os.path.join(www_chunkymapdata_world_path, png_name) |
|||
if os.path.isfile(dest_png_path): |
|||
os.remove(dest_png_path) |
|||
os.rename(tmp_png_path, dest_png_path) |
|||
final_png_path = dest_png_path |
|||
print("Map image saved to:") |
|||
print(" "+final_png_path) |
|||
if os.path.isfile(genresult_path): |
|||
print("Results:") |
|||
print(" "+genresult_path) |
|||
mtchunk = MTChunk() |
|||
mtchunk.set_from_genresult(genresult_path) |
|||
mtchunk.metadata["is_traversed"] = True |
|||
dest_yaml_name = "singleimage.yml" |
|||
dest_yaml_path = os.path.join(www_chunkymapdata_world_path, dest_yaml_name) |
|||
mtchunk.save_yaml(dest_yaml_path) |
|||
else: |
|||
print("No image could be generated from '"+self.world_path+"'") |
|||
|
|||
cmor = ChunkymapOfflineRenderer() |
|||
cmor.RenderSingleImage() |
After Width: | Height: | Size: 3.2 KiB |
Loading…
Reference in new issue