From 110240b53a4480097f1e9d75e0eb372b888012b6 Mon Sep 17 00:00:00 2001 From: Sam Steele Date: Thu, 30 Sep 2010 18:35:46 -0700 Subject: [PATCH 1/4] Ignore .pyc files --- .gitignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0d20b64 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.pyc From cf971c17c6b7735d496501f43f63c953241353db Mon Sep 17 00:00:00 2001 From: Sam Steele Date: Thu, 30 Sep 2010 18:36:10 -0700 Subject: [PATCH 2/4] Render snow as half-blocks --- chunk.py | 9 +++++++-- textures.py | 4 ++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/chunk.py b/chunk.py index fef3a84..aa2aed1 100644 --- a/chunk.py +++ b/chunk.py @@ -312,12 +312,17 @@ class ChunkRenderer(object): img.paste(t[0], (imgx, imgy), t[1]) # Draw edge lines + if blockid in (44,78,): # step block, snow + half = 6 + else: + half = 0 + if blockid not in transparent_blocks: draw = ImageDraw.Draw(img) if x != 15 and blocks[x+1,y,z] == 0: - draw.line(((imgx+12,imgy), (imgx+22,imgy+5)), fill=(0,0,0), width=1) + draw.line(((imgx+12,imgy+half), (imgx+22,imgy+5+half)), fill=(0,0,0), width=1) if y != 0 and blocks[x,y-1,z] == 0: - draw.line(((imgx,imgy+6), (imgx+12,imgy)), fill=(0,0,0), width=1) + draw.line(((imgx,imgy+6+half), (imgx+12,imgy+half)), fill=(0,0,0), width=1) finally: diff --git a/textures.py b/textures.py index 8d34b03..320d980 100644 --- a/textures.py +++ b/textures.py @@ -151,7 +151,7 @@ def _transform_image_side(img, blockID): """Takes an image and shears it for the left side of the cube (reflect for the right side)""" - if blockID in (44,): # step block + if blockID in (44,78,): # step block, snow # make the top half transpartent # (don't just crop img, since we want the size of # img to be unchanged @@ -213,7 +213,7 @@ def _build_block(top, side, blockID=None): img.paste(side, (2,6), side) img.paste(otherside, (10,6), otherside) img.paste(top, (0,2), top) - elif blockID in (44,): # half step + elif blockID in (44,78,): # half step, snow # shift each texture down 6 pixels img.paste(side, (0,12), side) img.paste(otherside, (12,12), otherside) From 5d22e1cd6f667bbba7242d1f7a0ba2551b598778 Mon Sep 17 00:00:00 2001 From: Sam Steele Date: Thu, 30 Sep 2010 22:47:10 -0700 Subject: [PATCH 3/4] Fix whitespace formatting, make snow 1/4th of block --- chunk.py | 14 ++++++++------ textures.py | 17 ++++++++++++++--- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/chunk.py b/chunk.py index 474bc76..91f8ac5 100644 --- a/chunk.py +++ b/chunk.py @@ -334,17 +334,19 @@ class ChunkRenderer(object): img.paste(t[0], (imgx, imgy), t[1]) # Draw edge lines - if blockid in (44,78,): # step block, snow - half = 6 - else: - half = 0 + if blockid in (44,): # step block + increment = 6 + elif blockid in (78,): # snow + increment = 9 + else: + increment = 0 if blockid not in transparent_blocks: draw = ImageDraw.Draw(img) if x != 15 and blocks[x+1,y,z] == 0: - draw.line(((imgx+12,imgy+half), (imgx+22,imgy+5+half)), fill=(0,0,0), width=1) + draw.line(((imgx+12,imgy+increment), (imgx+22,imgy+5+increment)), fill=(0,0,0), width=1) if y != 0 and blocks[x,y-1,z] == 0: - draw.line(((imgx,imgy+6+half), (imgx+12,imgy+half)), fill=(0,0,0), width=1) + draw.line(((imgx,imgy+6+increment), (imgx+12,imgy+increment)), fill=(0,0,0), width=1) finally: diff --git a/textures.py b/textures.py index b9285d4..5bb7382 100644 --- a/textures.py +++ b/textures.py @@ -151,14 +151,20 @@ def _transform_image_side(img, blockID): """Takes an image and shears it for the left side of the cube (reflect for the right side)""" - if blockID in (44,78,): # step block, snow - # make the top half transpartent + if blockID in (44,): # step block + # make the top half transparent # (don't just crop img, since we want the size of # img to be unchanged mask = img.crop((0,8,16,16)) n = Image.new(img.mode, img.size, (38,92,255,0)) n.paste(mask,(0,0,16,8), mask) img = n + if blockID in (78,): # snow + # make the top three quarters transparent + mask = img.crop((0,12,16,16)) + n = Image.new(img.mode, img.size, (38,92,255,0)) + n.paste(mask,(0,12,16,16), mask) + img = n # Size of the cube side before shear img = img.resize((12,12)) @@ -215,11 +221,16 @@ def _build_block(top, side, blockID=None): img.paste(side, (2,6), side) img.paste(otherside, (10,6), otherside) img.paste(top, (0,2), top) - elif blockID in (44,78,): # half step, snow + elif blockID in (44,): # half step # shift each texture down 6 pixels img.paste(side, (0,12), side) img.paste(otherside, (12,12), otherside) img.paste(top, (0,6), top) + elif blockID in (78,): # snow + # shift each texture down 9 pixels + img.paste(side, (0,6), side) + img.paste(otherside, (12,6), otherside) + img.paste(top, (0,9), top) else: img.paste(side, (0,6), side) img.paste(otherside, (12,6), otherside) From 93af1ef15817a9667a34eb0a608e358cc08acdc6 Mon Sep 17 00:00:00 2001 From: Sam Steele Date: Thu, 30 Sep 2010 23:52:50 -0700 Subject: [PATCH 4/4] Add snow to the transparent_blocks array --- chunk.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/chunk.py b/chunk.py index 91f8ac5..322f6c2 100644 --- a/chunk.py +++ b/chunk.py @@ -66,7 +66,7 @@ def get_blockdata_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, 44, 50, 51, 52, 53, - 59, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 74, 75, 76, 77, 79, 81, 83, 85]) + 59, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 74, 75, 76, 77, 78, 79, 81, 83, 85]) def render_and_save(chunkfile, cachedir, cave=False): """Used as the entry point for the multiprocessing workers (since processes @@ -341,7 +341,7 @@ class ChunkRenderer(object): else: increment = 0 - if blockid not in transparent_blocks: + if blockid not in transparent_blocks or blockid in (78,): #special case snow so the outline is still drawn draw = ImageDraw.Draw(img) if x != 15 and blocks[x+1,y,z] == 0: draw.line(((imgx+12,imgy+increment), (imgx+22,imgy+5+increment)), fill=(0,0,0), width=1)