0

Merge branch 'master' into lighting

Conflicts:
	chunk.py
	gmap.py
	textures.py
	world.py
This commit is contained in:
Aaron Griffith
2010-10-05 08:35:23 -04:00
10 changed files with 532 additions and 158 deletions

32
gmap.py
View File

@@ -26,14 +26,16 @@ from optparse import OptionParser
import re
import multiprocessing
import time
import logging
logging.basicConfig(level=logging.INFO,format="%(asctime)s [%(levelname)s] %(message)s")
import world
import quadtree
helptext = """
%prog [OPTIONS] <World # / Path to World> <tiles dest dir>
%prog -d <World # / Path to World / Path to cache dir> [tiles dest dir]
"""
%prog -d <World # / Path to World / Path to cache dir> [tiles dest dir]"""
def main():
try:
@@ -48,6 +50,9 @@ def main():
parser.add_option("--chunklist", dest="chunklist", help="A file containing, on each line, a path to a chunkfile to update. Instead of scanning the world directory for chunks, it will just use this list. Normal caching rules still apply.")
parser.add_option("--lighting", dest="lighting", help="Renders shadows using light data from each chunk.", action="store_true")
parser.add_option("--night", dest="night", help="Renders shadows using light data from each chunk, as if it were night. Implies --lighting.", action="store_true")
parser.add_option("--imgformat", dest="imgformat", help="The image output format to use. Currently supported: png(default), jpg. NOTE: png will always be used as the intermediate image format.")
parser.add_option("-q", "--quiet", dest="quiet", action="count", default=0, help="Print less output. You can specify this option multiple times.")
parser.add_option("-v", "--verbose", dest="verbose", action="count", default=0, help="Print more output. You can specify this option multiple times.")
options, args = parser.parse_args()
@@ -87,12 +92,28 @@ def main():
else:
chunklist = None
if options.imgformat:
if options.imgformat not in ('jpg','png'):
parser.error("Unknown imgformat!")
else:
imgformat = options.imgformat
else:
imgformat = 'png'
logging.getLogger().setLevel(
logging.getLogger().level + 10*options.quiet)
logging.getLogger().setLevel(
logging.getLogger().level - 10*options.verbose)
logging.info("Welcome to Minecraft Overviewer!")
logging.debug("Current log level: {0}".format(logging.getLogger().level))
# First generate the world's chunk images
w = world.WorldRenderer(worlddir, cachedir, chunklist=chunklist, lighting=options.lighting, night=options.night)
w.go(options.procs)
# Now generate the tiles
q = quadtree.QuadtreeGen(w, destdir, depth=options.zoom)
q = quadtree.QuadtreeGen(w, destdir, depth=options.zoom, imgformat=imgformat)
q.go(options.procs)
def delete_all(worlddir, tiledir):
@@ -104,7 +125,7 @@ def delete_all(worlddir, tiledir):
for f in filenames:
if matcher.match(f):
filepath = os.path.join(dirpath, f)
print "Deleting {0}".format(filepath)
logging.info("Deleting {0}".format(filepath))
os.unlink(filepath)
# Now delete all /hash/ files in the tile dir.
@@ -113,7 +134,7 @@ def delete_all(worlddir, tiledir):
for f in filenames:
if f.endswith(".hash"):
filepath = os.path.join(dirpath, f)
print "Deleting {0}".format(filepath)
logging.info("Deleting {0}".format(filepath))
os.unlink(filepath)
def list_worlds():
@@ -134,4 +155,5 @@ def list_worlds():
if __name__ == "__main__":
multiprocessing.freeze_support()
main()