#! /bin/csh -f # Last edited on 2004-01-06 00:48:49 by stolfi set cmd = "$0"; set cmd = "${cmd:t}" set usage = "${cmd} [-export EXDIR] [-in DIR] NAME STATE LABEL TXUREFILE RAYOPTIONS" set runargs = "$*" echo '=====================================================================' echo '=== '"${cmd} ${runargs}" unset export unset dir while ( ( $#argv > 0 ) && ( "x$1" =~ x-* ) ) if ( ( $#argv >= 2 ) && ( "x$1" == "x-export" ) ) then set export = "$2"; shift; shift else if ( ( $#argv >= 2 ) && ( "x$1" == "x-in" ) ) then set dir = "$2"; shift; shift else echo "usage: ${usage}" ; exit 1 endif end if ( $#argv < 4 ) then echo ${usage}; exit 1 endif set name = "$1" ; shift set state = "$1" ; shift set label = "$1" ; shift set txurefile = "$1" ; shift set tmp = "/tmp/$$-${name}.ppm" set toolbin = "${STOLFIHOME}/posters/tools" # Convert the texture file to PPM format, with unit gamma. /bin/rm -f ${tmp} if ( "x${txurefile:e}" == "xgif" ) then cat ${txurefile} \ | giftopnm \ | pnmgamma 0.50 \ | pnmdepth 255 \ > ${tmp} else if ( "x${txurefile:e}" =~ xp[pgb]m ) then cat ${txurefile} \ | pnmdepth 255 \ > ${tmp} else echo "${txurefile:e}: unrecognized image type"; exit 1 endif set povfile = "button-${state}.pov" # Make sure that ${dir} exists and contains the required files: if ( ! $?{dir} ) then # Create a new dated directory, copy important files into it: set dir = `yy-mm-dd-hhmmss` mkdir ${dir} cp -p button-${state}.pov ${dir}/ cp -p button-${state}.sizes ${dir}/ else if ( ! ( -r ${povfile} ) ) then endif # Create the parameter files set parmfile = "button-parameters.inc" set labelfile = "button-label-${label}.inc" /bin/rm -f ${dir}/${parmfile} echo "#declare button_texture_file = "'"'"${tmp}"'"' >> ${dir}/${parmfile} if ( -r ${labelfile} ) then echo "#declare button_label_file = "'"'"${labelfile}"'"' >> ${dir}/${parmfile} else echo "#declare button_label_file = "'"'"button-label-none.inc"'"' >> ${dir}/${parmfile} endif # echo "${name} ${label} ${txurefile} $*" > button-in.comments # run-povray -good $* button-in.pov # echo "${name} ${label} ${txurefile} $*" > button-pair.comments # run-povray -good $* button-pair.pov echo "${runargs}" > ${dir}/button-out.comments /bin/rm -f .last ${toolbin}/run-povray-png -in ${dir} $* button-out.pov if ( $?export ) then if ( -r .last ) then set dir = "`cat .last`" set expfile = "${export}/flag-${name}-045x033.png" echo "exporting ${dir}/p.png to ${expfile}" cp -p ${dir}/p.png ${expfile} endif endif