Fix/improve the --check-terrain option to work with the new texturepacks
Also, updated texturepack-related docs Related to #907
This commit is contained in:
@@ -540,7 +540,9 @@ values. The valid configuration keys are listed below.
|
||||
|
||||
``texturepath``
|
||||
This is a where a specific texture pack can be found to be used during this render.
|
||||
It can be either a folder or a zip file containing the texture pack.
|
||||
It can be either a folder or a zip file containing the texture pack. If specifying
|
||||
a folder, this option should point to a directory that *contains* the textures/ folder
|
||||
(it should not point to the textures folder directly).
|
||||
Its value should be a string.
|
||||
|
||||
.. _crop:
|
||||
|
||||
@@ -100,9 +100,10 @@ The first step is rendering the block sprites from the textures. Each block is
|
||||
"built" from its textures into an image of a cube and cached in a
|
||||
:class:`Textures` object.
|
||||
|
||||
Textures come from a terrain.png file in the form of 16 by 16 pixel images.
|
||||
(Higher resolution textures are resized and the process remains the same). In
|
||||
order to draw a cube out of the textuers, an `affine transformation`_ is applied to
|
||||
Textures come from files inside of a "textures" folder. If the file is square (has equal width
|
||||
and height dimensions), it is scaled down to 16 x 16 pixels. Non-square images are used with animated
|
||||
textures. In this case, the first frame of the animated texture is used, and also scaled to a 16 by 16 image.
|
||||
In order to draw a cube out of the textuers, an `affine transformation`_ is applied to
|
||||
the images for the top and sides of the cube in order to transform it to the
|
||||
appropriate perspective.
|
||||
|
||||
|
||||
@@ -124,7 +124,7 @@ Windows, Mac, and Linux as long as you have these software packages installed:
|
||||
|
||||
* Numpy
|
||||
|
||||
* Either a Minecraft Client installed or a terrain.png for the textures.
|
||||
* Either a Minecraft Client installed or a textures/ folder for the textures (possibly from a texturepack)
|
||||
|
||||
The first three are included in the Windows download. Also, there are additional
|
||||
requirements for compiling it (like a compiler). More details are available in
|
||||
|
||||
@@ -245,12 +245,12 @@ If you want or need to provide your own textures, you have several options:
|
||||
|
||||
wget -N http://s3.amazonaws.com/MinecraftDownload/minecraft.jar -P ~/.minecraft/bin/
|
||||
|
||||
* You can manually extract the terrain.png from minecraft.jar or your favorite
|
||||
* You can manually extract the textures folder from minecraft.jar or your favorite
|
||||
texture pack. If you've built the Overviewer from source or are using the
|
||||
windows exe, place the file in the same directory as overviewer.py or
|
||||
windows exe, place the folder in the same directory as overviewer.py or
|
||||
overviewer.exe.
|
||||
|
||||
* Specify any terrain.png or texture pack you want with the
|
||||
* Specify any texture pack you want with the
|
||||
:ref:`texturepath<option_texturepath>` option.
|
||||
|
||||
If you copy your world before you render it
|
||||
|
||||
@@ -136,21 +136,24 @@ def main():
|
||||
print("(build info not found)")
|
||||
return 0
|
||||
|
||||
if options.check_terrain:
|
||||
# if --check-terrain was specified, but we have NO config file, then we cannot
|
||||
# operate on a custom texture path. we do terrain checking with a custom texture
|
||||
# pack later on, after we've parsed the config file
|
||||
if options.check_terrain and not options.config:
|
||||
import hashlib
|
||||
from overviewer_core.textures import Textures
|
||||
# TODO custom textures path?
|
||||
tex = Textures()
|
||||
|
||||
logging.info("Looking for a few common texture files...")
|
||||
try:
|
||||
f = tex.find_file("terrain.png", verbose=True)
|
||||
f = tex.find_file("textures/blocks/stone.png", verbose=True)
|
||||
f = tex.find_file("textures/blocks/tallgrass.png", verbose=True)
|
||||
f = tex.find_file("textures/blocks/oreDiamond.png", verbose=True)
|
||||
f = tex.find_file("textures/blocks/wood.png", verbose=True)
|
||||
except IOError:
|
||||
logging.error("Could not find the file terrain.png")
|
||||
logging.error("Could not find the file stone.png")
|
||||
return 1
|
||||
|
||||
h = hashlib.sha1()
|
||||
h.update(f.read())
|
||||
logging.info("Hash of terrain.png file is: `%s`", h.hexdigest())
|
||||
return 0
|
||||
|
||||
# if no arguments are provided, print out a helpful message
|
||||
@@ -265,7 +268,20 @@ dir but you forgot to put quotes around the directory, since it contains spaces.
|
||||
logging.error(str(ex))
|
||||
return 1
|
||||
|
||||
if options.check_terrain: # we are already in the "if configfile" branch
|
||||
logging.info("Looking for a few common texture files...")
|
||||
for render_name, render in config['renders'].iteritems():
|
||||
logging.info("Looking at render %r", render_name)
|
||||
|
||||
# find or create the textures object
|
||||
texopts = util.dict_subset(render, ["texturepath"])
|
||||
|
||||
tex = textures.Textures(**texopts)
|
||||
f = tex.find_file("textures/blocks/stone.png", verbose=True)
|
||||
f = tex.find_file("textures/blocks/tallgrass.png", verbose=True)
|
||||
f = tex.find_file("textures/blocks/oreDiamond.png", verbose=True)
|
||||
f = tex.find_file("textures/blocks/wood.png", verbose=True)
|
||||
return 0
|
||||
|
||||
############################################################
|
||||
# Final validation steps and creation of the destination directory
|
||||
|
||||
@@ -159,7 +159,7 @@ class Textures(object):
|
||||
for packfilename in search_zip_paths:
|
||||
try:
|
||||
pack.getinfo(packfilename)
|
||||
if verbose: logging.info("Found %s in '%s'", packfilename, nery.find_file_local_path)
|
||||
if verbose: logging.info("Found %s in '%s'", packfilename, self.find_file_local_path)
|
||||
return pack.open(packfilename)
|
||||
except (KeyError, IOError):
|
||||
pass
|
||||
@@ -220,7 +220,7 @@ class Textures(object):
|
||||
if verbose: logging.info("Found %s in '%s'", filename, path)
|
||||
return open(path, mode)
|
||||
|
||||
raise TextureException("Could not find the file `{0}'. Try specifying the 'texturepath' option in your config file. Set it to the directory where I can find {0}. Also see <http://docs.overviewer.org/en/latest/running/#installing-the-textures>".format(filename))
|
||||
raise TextureException("Could not find the file `{0}'. Try specifying the 'texturepath' option in your config file.\nSet it to the directory where I can find {0}.\nAlso see <http://docs.overviewer.org/en/latest/running/#installing-the-textures>".format(filename))
|
||||
|
||||
def load_image_texture(self, filename):
|
||||
# Textures may be animated or in a different resolution than 16x16.
|
||||
|
||||
Reference in New Issue
Block a user