Tuesday, April 26, 2011

Starry night / topographic oceans

This has nothing to do with either van Gogh or Yes.

It's what I made of the volume beneath a Minecraft spawn point over a period of weeks, culminating in the use of a couple of simple Python filters.  The first converts 1% of a selected volume to glowstone.  The second converts all the blocks immediately adjacent to water into glass.  I used both on the ceiling of a 240x240x56 block volume, resulting in the following.

This view shows the effect of glowstone set in the obsidian ceiling. Sunrise is visible to the left; the far wall is too far away to render. The Temple of Rule 30 exterior is visible on to the right.

Starry Night
Replacing the ocean bottom with glass makes the ocean appear as a contour map of itself.

Topographic Oceans

Here's the MCEdit filter. It only replaces air adjacent to water with glass, so it's up to you to remove the rock/dirt/whatever from the surrounding volume before running the filter. Fair warning: I'm a Python newb.

from numpy import zeros, array

def perform(level, box, options):
 schema = level.extractSchematic(box)
 schema.removeEntitiesInBox(schema.bounds)
 schema.removeTileEntitiesInBox(schema.bounds)

 block_id = 20 # glass

 for y in range(1,schema.Height):
  water = schema.Blocks[:,:,y] == 9
  air = schema.Blocks[:,:,y] == 0
  
  # Shift the position of the water on this level to the four surrounding blocks and intersect this with air
  # to determine which sides should be contained in glass
  
  c= zeros(water.shape)
  c[:-1, :] += water[1:, :]
  c[1:, :] += water[:-1, :]
  c[:, :-1] += water[:, 1:]
  c[:, 1:] += water[:, :-1]
  glass = ((c > 0) & air) * block_id
  
  schema.Blocks[:,:,y] += glass

  # Now place glass below
  
  air = schema.Blocks[:,:,y-1] == 0
  glass = (water & air) * block_id
  schema.Blocks[:,:,y-1] += glass

 level.copyBlocksFrom(schema, schema.bounds, box.origin)