#!/bin/sh # # Unterrainerizer v0.1 # by Anna Wiggins (annabunches@gmail.com) # Licensed under the GPLv3, see accompanying file LICENSE for terms # # Takes any number of terrain RAW files and merges them into a single # PNG file (or other file type, as configured). # # The input files must be named according to this convention: # # mapname-nxm.raw # # Where mapname is the same for all maps, and n and m are the column and # row that this image occupies in the final image, starting from the # top-left. extension="png" ##### STOP EDITING HERE ##### ############################# # Make a unique random directory make_tmpdir() { tmpdir=/tmp/unterrainerizer-`uuidgen | perl -pe 's/-.*$//'` mkdir $tmpdir } clean_up() { echo "Cleaning up" rm -rf $tmpdir } # Extract the maps into separate files # Also sets max_x and max_y extract_maps() { echo "Extracting heightmaps from RAW files" # Find the greatest X and Y values index=0 max_x=0 max_y=0 for i in $@; do x=`echo $i | perl -pe 's/^.*-(.*)x.*.raw/\1/'` y=`echo $i | perl -pe 's/^.*-.*x(.*).raw/\1/'` if [ $x -gt $max_x ]; then max_x=$x; fi if [ $y -gt $max_y ]; then max_y=$y; fi out_name=${tmpdir}/${base_name}-${x}x${y}.${extension} unterrain_commands[$index]="(un-terrain \"${i}\" \"${out_name}\")" index+=1 done # We have to invert the order these are added so that montage will handle them correctly later index=0 for i in $(seq 0 $max_y); do for j in $(seq 0 $max_x); do extracted_maps[$index]=${tmpdir}/${base_name}-${j}x${i}.${extension} index+=1 done done gimp -id -b - &> /dev/null <