Better cacti rendering
This commit is contained in:
2
chunk.py
2
chunk.py
@@ -62,7 +62,7 @@ def get_skylight_array(level):
|
||||
|
||||
# This set holds blocks ids that can be seen through, for occlusion calculations
|
||||
transparent_blocks = set([0, 6, 8, 9, 18, 20, 37, 38, 39, 40, 50, 51, 52, 53,
|
||||
59, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 74, 75, 76, 77, 79, 83, 85])
|
||||
59, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 74, 75, 76, 77, 79, 81, 83, 85])
|
||||
|
||||
def render_and_save(chunkfile, cachedir, cave=False):
|
||||
"""Used as the entry point for the multiprocessing workers (since processes
|
||||
|
||||
26
textures.py
26
textures.py
@@ -112,15 +112,20 @@ def _split_terrain(terrain):
|
||||
# This maps terainids to 16x16 images
|
||||
terrain_images = _split_terrain(_get_terrain_image())
|
||||
|
||||
def _transform_image(img):
|
||||
def _transform_image(img, texID):
|
||||
"""Takes a PIL image and rotates it left 45 degrees and shrinks the y axis
|
||||
by a factor of 2. Returns the resulting image, which will be 24x12 pixels
|
||||
|
||||
"""
|
||||
|
||||
# Resize to 17x17, since the diagonal is approximately 24 pixels, a nice
|
||||
# even number that can be split in half twice
|
||||
img = img.resize((17, 17), Image.BILINEAR)
|
||||
if texID in (69,): # cacti
|
||||
# Resize to 15x15, since the cactus texture is a little smaller than the other textures
|
||||
img = img.resize((15, 15), Image.BILINEAR)
|
||||
|
||||
else:
|
||||
# Resize to 17x17, since the diagonal is approximately 24 pixels, a nice
|
||||
# even number that can be split in half twice
|
||||
img = img.resize((17, 17), Image.BILINEAR)
|
||||
|
||||
# Build the Affine transformation matrix for this perspective
|
||||
transform = numpy.matrix(numpy.identity(3))
|
||||
@@ -164,7 +169,7 @@ def _build_block(top, side, texID=None):
|
||||
"""
|
||||
img = Image.new("RGBA", (24,24), (38,92,255,0))
|
||||
|
||||
top = _transform_image(top)
|
||||
top = _transform_image(top, texID)
|
||||
|
||||
if not side:
|
||||
img.paste(top, (0,0), top)
|
||||
@@ -192,9 +197,14 @@ def _build_block(top, side, texID=None):
|
||||
img.paste(otherside, (6,3), otherside)
|
||||
return img
|
||||
|
||||
img.paste(side, (0,6), side)
|
||||
img.paste(otherside, (12,6), otherside)
|
||||
img.paste(top, (0,0), top)
|
||||
if texID in (69,): # cacti!
|
||||
img.paste(side, (2,6), side)
|
||||
img.paste(otherside, (10,6), otherside)
|
||||
img.paste(top, (0,2), top)
|
||||
else:
|
||||
img.paste(side, (0,6), side)
|
||||
img.paste(otherside, (12,6), otherside)
|
||||
img.paste(top, (0,0), top)
|
||||
|
||||
# Manually touch up 6 pixels that leave a gap because of how the
|
||||
# shearing works out. This makes the blocks perfectly tessellate-able
|
||||
|
||||
Reference in New Issue
Block a user