Tuesday, January 19, 2010

Sample Project: World of Metamor Keep

Starting with a map, I created a 3d render of the world of Metamor Keep (http://metamorkeep.com/) as seen from space.




In order to do this I wrote a plugin for GIMP in order to create the terrain




#!/usr/bin/env python


from gimpfu import *

def color_offset(img, layer, ca, cb):

# Disable Undo
img.undo_group_start()



#pdb.gimp_message("hello world!")

#save the selection area
sel=pdb.gimp_selection_save(img)

#calculate the diameter
d=0
while pdb.gimp_selection_bounds(img)[0]:
pdb.gimp_selection_shrink(img,1)
d+=1

#load the selection area
pdb.gimp_selection_load(sel)

#do the gradient
n=0.0
while pdb.gimp_selection_bounds(img)[0]:
if n/Python-Fu/Effects/SGradient",
"RGB*",
[
(PF_COLOR, "ca", "InnerColor", (0,0,0)),
(PF_COLOR, "cb", "OuterColor", (255,255,255))

],
[],
color_offset)

main()



The code fills in a selection with a gradient based on the distance from the selection, making it easy to create pretty looking maps like this





















Total time to do everything was about 5 hours, but 2 of that was writing the plugin and 2 was rendering, so assuming that it'll go faster next time, this could be a 1-2 hour ($10-20) project.

No comments:

Post a Comment