0

Better cacti rendering

This commit is contained in:
Andrew Chin
2010-09-27 21:32:26 -04:00
parent e83796c102
commit aa8a369aa8
2 changed files with 19 additions and 9 deletions

View File

@@ -62,7 +62,7 @@ def get_skylight_array(level):
# This set holds blocks ids that can be seen through, for occlusion calculations # 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, 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): def render_and_save(chunkfile, cachedir, cave=False):
"""Used as the entry point for the multiprocessing workers (since processes """Used as the entry point for the multiprocessing workers (since processes

View File

@@ -112,12 +112,17 @@ def _split_terrain(terrain):
# This maps terainids to 16x16 images # This maps terainids to 16x16 images
terrain_images = _split_terrain(_get_terrain_image()) 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 """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 by a factor of 2. Returns the resulting image, which will be 24x12 pixels
""" """
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 # Resize to 17x17, since the diagonal is approximately 24 pixels, a nice
# even number that can be split in half twice # even number that can be split in half twice
img = img.resize((17, 17), Image.BILINEAR) img = img.resize((17, 17), Image.BILINEAR)
@@ -164,7 +169,7 @@ def _build_block(top, side, texID=None):
""" """
img = Image.new("RGBA", (24,24), (38,92,255,0)) img = Image.new("RGBA", (24,24), (38,92,255,0))
top = _transform_image(top) top = _transform_image(top, texID)
if not side: if not side:
img.paste(top, (0,0), top) img.paste(top, (0,0), top)
@@ -192,6 +197,11 @@ def _build_block(top, side, texID=None):
img.paste(otherside, (6,3), otherside) img.paste(otherside, (6,3), otherside)
return img return img
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(side, (0,6), side)
img.paste(otherside, (12,6), otherside) img.paste(otherside, (12,6), otherside)
img.paste(top, (0,0), top) img.paste(top, (0,0), top)