#!/bin/sh

# Procedure for adding/altering the generation of textures by this program:
#  - Add the texture name to the proper texture group variable in ../set_vars
#  - Add the texture to the case-list in make_tex
#  - Add the proper function, called from make_tex

## \section{gentex (shell script)}
## 
## \subsection*{Purpose}
## Generate various texture mosaics
## 
## \subsection*{Description}
## This program generates the textured images used in testing and evaluation
## of the different filters. It assumes to find the Brodatz textures on the
## directory {\tt ~/textures/brodatz}, with names like {\tt D17.hips}.
## The program will, for each specified texture, generate one textured image
## with the name {\em texture-ID}{\tt .hips} and one reference image with the 
## name {\em texture-ID}{\tt .ref.hips}, the reference image has pixelvalue one
## for the all the pixels on the locations of one thexture, two at the next
## texture and so on.
##
## For most textures, this
## program adds lines to the description of each output file like
## "uniform_texture_region: 0 0 127 127", one line per uniform texture 
## region. The numbers indicate upper left and lower right corner of 
## one area for each uniform texture region.
## The purpose of this is enabling automatic extraction of each texture
## by programs that calculate i.e. texture-frequency.
## 
## \subsection*{Usage}
## \begin{verbatim}
## gentex [-overwrite] operation
## \end{verbatim}
## \begin{description}
##   \item[-overwrite]
## 	Overwrite files with the same name as the files the program generates.
## 	By default, the program will skip processing if the file of the
## 	specified texture already exists.
##   \item[-all]
## 	Generate all textures. For a list of all textures, run {\tt gentex}
## 	without parameters.
##   \item[-clean]
## 	Remove textures and reference frames generated by this program.
##   \item[{\em texture-ID}]
## 	For a list of all textures, run {\tt gentex -U}
## \end{description}
## 
## \subsection*{Date created}
## February 1993



# Set global variables with names etc.
. ${HOME}/set_vars
TMP=${TD}/tmp.			# First name of all temporary files
OVERWRITE=FALSE			# Default: no overwrite
HISTOEQ=FALSE			# Default: no histogram equalization


# Read and process the commandline

parseargs ()
{
  # Scan commandline and set reference frame
  for ARG in ${1} ${2} ${3} ${4} ${5} ${6} ${7} ${8} ${9}
  do
    case ${ARG} in
      -overwrite)	OVERWRITE=TRUE ;;
      -histoeq	)	HISTOEQ=TRUE ;;
      -all	)	make_all_tex ;;
      -clean 	)	clean ;;
      -U	)	print_usage ;;
      *		)	make_tex_check ${ARG} ;;
    esac
  done
}


make_tex_check ()
{
  # Check if file exists, and overwrite only if -overwrite option
  if (test ${OVERWRITE} = TRUE -o ! -r ${TD}/${1}${H}) then
    make_tex ${1}
  fi
}



make_tex ()
{
  # Create specified texture
  case ${1} in
    D55D68		) make_pair D55 D68 ;;
    D55D84		) make_pair D55 D84 ;;
    D17D77		) make_pair D17 D77  ;;
    D9D77		) make_pair D9 D77  ;;
    D17D55		) make_pair2 D17 D55 ;;
    D4D29		) make_pair3 D4 D29 ;;
    D92D5		) make_pair3 D92 D5 ;;
    Nat-4		) make_nat_4 ;;
    Nat-4${REF}		) make_nat_4_ref ;;
    Nat-5		) make_nat_5 ;;
    Nat-5${REF}		) make_nat_5_ref ;;
    Nat-5b		) make_nat_5b ;;
    Nat-5b${REF}	) make_nat_5b_ref ;;
    Nat-5c		) make_nat_5c ;;
    Nat-8		) make_nat_8  ;;
    Nat-8${REF}		) make_nat_8_ref  ;;
    Nat-16		) make_16 Nat-16 ;;
    Nat-16${REF}	) make_16_ref Nat-16;;
    Nat-16b		) make_16b ;;
    Nat-16c		) make_16c ;;
    D84_in_D68		) make_D84_in_D68  ;;
    D84_in_D68${REF}	) make_D84_in_D68_ref  ;;
    s-io		) make_s_io  ;;
    l-+			) make_l_plus  ;;
    tri-arr		) make_tri_arr  ;;
    odd-even		) make_odd_even  ;;
    ${PAIR_REF}		) make_pair_ref  ;;
    ${PAIR2_REF}	) make_pair2_ref  ;;
    ${PAIR3_REF}	) make_pair3_ref  ;;
    *			) parseargs -U ;;
  esac
}


make_all_tex ()
{
  # Generate all HIPS textures
  echo "Generating all ${H} texturesamples..."
  for TEX_IMG in ${ALL_COMP_TEX}
  do
    make_tex_check ${TEX_IMG}
  done 
}



print_usage ()
{
  # Print usage
  echo "Program for generating test-textures along with referenceimages"
  echo "Usage: ${0} [-overwrite] operation"
  echo "Operations:"
  for TEX_IMG in ${ALL_TEX}
  do
    echo "  ${TEX_IMG}    	-- generate the texture ${TEX_IMG}"
  done
  echo "  -all     	-- generate all hips-format textures and references"
  echo "  -clean    	-- remove ${H} and .ps files created by this program"
  echo "Reference images:"
  echo "  Nat-4${REF}"
  echo "  Nat-5${REF}"
  echo "  Nat-5b${REF}"
  echo "  Nat-8${REF}"
  echo "  Nat-16${REF}"
  echo "  D84_in_D68${REF}"
  echo "  ${PAIR_REF}	-- all 128x256 texture pairs"
  echo "  ${PAIR2_REF}	-- most 256x256 texture pairs"
  echo "  ${PAIR3_REF}	-- most 512x512 texture pairs"
  echo "Switches:"
  echo "  -overwrite	-- overwrite textures with the same name"
  echo "  -histoeq	-- apply histogram equalization (only for natural tex."
}



clean ()
{
  for TEX in ${ALL_TEX} 
  do
    rm -f ${TD}/${TEX}${H} ${TD}/${TEX}${REFH} ${TD}/${TEX}.ps 
  done
  rm -f ${TMP}* ${TD}/*~ ${PAIR_REFH} ${PAIR2_REFH} ${PAIR3_REFH}
}


# Functions for generating the specific textures

make_natural_mosaic ()
{
  # Requires parameters $TEX and $PARTS set before execution
  echo "\n${TEX} texture"
  rm -f ${TD}/${TEX}${REFH}
  cp ${MD}/${TEX}${REFH}.z ${TD}/${TEX}${REFH}.z
  chmod u+w ${TD}/${TEX}${REFH}.z
  gunzip ${TD}/${TEX}${REFH}.z
  ROWS=`hsize -rows ${TD}/${TEX}${REFH}`
  COLS=`hsize -cols ${TD}/${TEX}${REFH}`
  if [ ${HISTOEQ} = TRUE ]
  then
    PREPROCESS="histoeq"
  else
    PREPROCESS="cat"
  fi
  PART_FILES=""
  for PART in ${PARTS} ; do
    extract -p 50 50 -s ${ROWS} ${COLS} < ${BD}/${PART}${H} | \
	${PREPROCESS} > ${TMP}${PART}${H}
    PART_FILES="${PART_FILES} ${TMP}${PART}${H}"
  done
  colorkey ${TD}/${TEX}${REFH} ${PART_FILES} > ${TD}/${TEX}${H}
  rm -f ${PART_FILES}
}



make_pair ()
{
  TEX=${1}${2}
  PARTS="${1} ${2}"
  cp ${PAIR_REFH}.z ${MD}/${TEX}${REFH}.z
  make_natural_mosaic
  unif_tex_descr ${TD}/${TEX}${H} 0 0 127 127
  unif_tex_descr ${TD}/${TEX}${H} 0 128 127 255
  rm -f ${MD}/${TEX}${REFH}.z
}


make_pair2 ()
{
  TEX=${1}${2}
  PARTS="${1} ${2}"
  cp ${PAIR2_REFH}.z ${MD}/${TEX}${REFH}.z
  make_natural_mosaic
  unif_tex_descr ${TD}/${TEX}${H}   0   0  63  63
  unif_tex_descr ${TD}/${TEX}${H}  96 96  159 159
  rm -f ${MD}/${TEX}${REFH}.z
}


make_pair3 ()
{
  TEX=${1}${2}
  PARTS="${1} ${2}"
  cp ${PAIR3_REFH}.z ${MD}/${TEX}${REFH}.z
  make_natural_mosaic
  unif_tex_descr ${TD}/${TEX}${H}   0   0  63  63
  unif_tex_descr ${TD}/${TEX}${H}  96 96  159 159
  rm -f ${MD}/${TEX}${REFH}.z
}


make_nat_4 ()
{
  TEX=Nat-4
  PARTS="D29 D9 D33 D32"
  make_natural_mosaic
  unif_tex_descr ${TD}/${TEX}${H}   0   0 127 127
  unif_tex_descr ${TD}/${TEX}${H}   0 128 127 255
  unif_tex_descr ${TD}/${TEX}${H} 128   0 255 127
  unif_tex_descr ${TD}/${TEX}${H} 128 128 255 255
}


make_nat_5 ()
{
  TEX=Nat-5
  PARTS="D84 D55 D77 D17 D24"
  make_natural_mosaic
  unif_tex_descr ${TD}/${TEX}${H}   0   0  63  63
  unif_tex_descr ${TD}/${TEX}${H}   0 192  63 255
  unif_tex_descr ${TD}/${TEX}${H} 192   0 255  63
  unif_tex_descr ${TD}/${TEX}${H} 192 192 255 255
  unif_tex_descr ${TD}/${TEX}${H}  96 96  159 159
}


make_nat_5b ()
{
  TEX=Nat-5b
  PARTS="D77 D84 D55 D17 D24"
  make_natural_mosaic
  unif_tex_descr ${TD}/${TEX}${H}   0  96  63 159
  unif_tex_descr ${TD}/${TEX}${H}  96   0 159  63
  unif_tex_descr ${TD}/${TEX}${H}  96 192 159 255
  unif_tex_descr ${TD}/${TEX}${H} 192  96 255 159
  unif_tex_descr ${TD}/${TEX}${H}  96 96  159 159
}


make_nat_5c ()
{
  TEX=Nat-5c
  PARTS="D77 D84 D55 D53 D24"
  make_natural_mosaic
  unif_tex_descr ${TD}/${TEX}${H}   0  96  63 159
  unif_tex_descr ${TD}/${TEX}${H}  96   0 159  63
  unif_tex_descr ${TD}/${TEX}${H}  96 192 159 255
  unif_tex_descr ${TD}/${TEX}${H} 192  96 255 159
  unif_tex_descr ${TD}/${TEX}${H}  96 96  159 159
}


make_nat_8 ()
{
  TEX=Nat-8
  PARTS="D9 D16 D3 D12 D17 D6 D15 D20"
  make_natural_mosaic
  unif_tex_descr ${TD}/${TEX}${H}   0   0  63  63
  unif_tex_descr ${TD}/${TEX}${H}   0  64  63 127
  unif_tex_descr ${TD}/${TEX}${H}   0 128  63 191
  unif_tex_descr ${TD}/${TEX}${H}   0 192  63 255
  unif_tex_descr ${TD}/${TEX}${H}  64   0 127  63
  unif_tex_descr ${TD}/${TEX}${H}  64  64 127 127
  unif_tex_descr ${TD}/${TEX}${H}  64 128 127 191
  unif_tex_descr ${TD}/${TEX}${H}  64 192 127 255
}


make_16 ()
{
  TEX=${1}
  # D29 D12 D17 D55
  # D32 D5  D84 D68
  # D77 D24 D9  D4
  # D3  D33 D51 D54
  PARTS="D3 D24 D84 D55 D29 D33 D9 D68 D32 D12 D51 D4 D77 D5 D17 D54"
  make_natural_mosaic
  unif_tex_descr ${TD}/${TEX}${H}   0   0 127 127
  unif_tex_descr ${TD}/${TEX}${H}   0 128 127 255
  unif_tex_descr ${TD}/${TEX}${H}   0 256 127 383
  unif_tex_descr ${TD}/${TEX}${H}   0 384 127 511
  unif_tex_descr ${TD}/${TEX}${H} 128   0 255 127
  unif_tex_descr ${TD}/${TEX}${H} 128 128 255 255
  unif_tex_descr ${TD}/${TEX}${H} 128 256 255 383
  unif_tex_descr ${TD}/${TEX}${H} 128 384 255 511
  unif_tex_descr ${TD}/${TEX}${H} 256   0 383 127
  unif_tex_descr ${TD}/${TEX}${H} 256 128 383 255
  unif_tex_descr ${TD}/${TEX}${H} 256 256 383 383
  unif_tex_descr ${TD}/${TEX}${H} 256 384 383 511
  unif_tex_descr ${TD}/${TEX}${H} 384   0 511 127
  unif_tex_descr ${TD}/${TEX}${H} 384 128 511 255
  unif_tex_descr ${TD}/${TEX}${H} 384 256 511 383
  unif_tex_descr ${TD}/${TEX}${H} 384 384 511 511
}


make_16b ()
{
  TEX=Nat-16b
  PARTS="D29 D12 D17 D55 D32 D5 D84 D68 D77 D24 D9 D4 D3 D33 D51 D54"
  make_natural_mosaic
}


make_16c ()
{
  TEX=Nat-16c
  PARTS="D3 D4 D5 D6 D9 D21 D24 D29 D32 D33 D54 D55 D57 D68 D77 D84"
  make_natural_mosaic
}


make_D84_in_D68 ()
{
  TEX=D84_in_D68
  PARTS="D84 D68"
  make_natural_mosaic
  unif_tex_descr ${TD}/${TEX}${H} 192 192 255 255
  unif_tex_descr ${TD}/${TEX}${H}  32  32  95 95
}


make_s_io ()
{
  TEX="s-io"
  echo "\nS-IO texture pair, farro-phd page 55"
  mktex < ${TD}/s-io.tx | scale > ${TD}/s-io${H}
  unif_tex_descr ${TD}/s-io${H} 0 0 127 127
  unif_tex_descr ${TD}/s-io${H} 0 128 127 255
  cp ${PAIR_REFH}.z ${TD}/${TEX}${REFH}.z
  chmod u+w ${TD}/${TEX}${REFH}.z
  gunzip ${TD}/${TEX}${REFH}.z
}


make_l_plus ()
{
  TEX="l-+"
  echo "\nL + texture pair, farro-phd page 54"
  mktex < ${TD}/l-+.tx | scale > ${TD}/l-+${H}
  unif_tex_descr ${TD}/l-+${H} 0 0 127 127
  unif_tex_descr ${TD}/l-+${H} 0 128 127 255
  cp ${PAIR_REFH}.z ${TD}/${TEX}${REFH}.z
  chmod u+w ${TD}/${TEX}${REFH}.z
  gunzip ${TD}/${TEX}${REFH}.z
}


make_tri_arr ()
{
  TEX="tri-arr"
  echo "\nTriangle-arrow texture pair, farro-phd page 55"
  mktex < ${TD}/tri-arr.tx | scale > ${TD}/tri-arr${H}
  unif_tex_descr ${TD}/tri-arr${H} 0 0 127 127
  unif_tex_descr ${TD}/tri-arr${H} 0 128 127 255
  cp ${PAIR_REFH}.z ${TD}/${TEX}${REFH}.z
  chmod u+w ${TD}/${TEX}${REFH}.z
  gunzip ${TD}/${TEX}${REFH}.z
}


make_odd_even ()
{
  TEX="odd-even"
  echo "\nOdd-even texture pair, farro-phd page 54"
  oddeven -s 128 -odd > ${TMP}odd${H}
  oddeven -s 128 -even | joinframes ${TMP}odd${H} - > ${TD}/odd-even${H}
  rm -f ${TMP}*
  unif_tex_descr ${TD}/odd-even${H} 0 0 127 127
  unif_tex_descr ${TD}/odd-even${H} 0 128 127 255
  cp ${PAIR_REFH}.z ${TD}/${TEX}${REFH}.z
  chmod u+w ${TD}/${TEX}${REFH}.z
  gunzip ${TD}/${TEX}${REFH}.z
}




# Functions for generating the specific reference images

make_pair_ref ()
{
  echo "\nGeneral texture-pair reference frame"
  genframe -B -s 128 -g 1  > ${TMP}1${H}
  genframe -B -s 128 -g 2  > ${TMP}2${H}
  joinframes ${TMP}1${H} ${TMP}2${H} > ${PAIR_REFH}
  rm -f ${TMP}*
}


make_pair2_ref ()
{
  echo "\nTexture-pair (type 2) reference frame"
  genframe -B -s 256 -g 1  | \
    calcpix -o ${TMP}tex1 -s "opix=((128-r)*(128-r) + (128-c)*(128-c) \
      < 64*64 ? 0 : ipix)" \
    > ${TMP}1${H}
  genframe -B -s 256 -g 2  | \
    calcpix -o ${TMP}tex2 -s "opix=((128-r)*(128-r) + (128-c)*(128-c) \
      < 64*64 ? ipix : 0)" \
    > ${TMP}2${H}
  addseq ${TMP}1${H} ${TMP}2${H} | htob > ${PAIR2_REFH}
  rm -f ${TMP}*
}


make_pair3_ref ()
{
  echo "\nTexture-pair (type 3) reference frame"
  genframe -B -s 512 -g 1  | \
    calcpix -o ${TMP}tex1 -s "opix=((256-r)*(256-r) + (256-c)*(256-c) \
      < 160*160 ? 0 : ipix)" \
    > ${TMP}1${H}
  genframe -B -s 512 -g 2  | \
    calcpix -o ${TMP}tex2 -s "opix=((256-r)*(256-r) + (256-c)*(256-c) \
      < 160*160 ? ipix : 0)" \
    > ${TMP}2${H}
  addseq ${TMP}1${H} ${TMP}2${H} | htob > ${PAIR3_REFH}
  rm -f ${TMP}*
}


make_D84_in_D68_ref ()
{
  TEX=D84_in_D68
  # D84-in-D68 Reference frame
  echo "\nD84 in D68 reference frame"
  genframe -B -s 128 -g 1 > ${TMP}1.128${H}
  genframe -B -s 256 -g 2 > ${TMP}2.256${H}
  padimage -s 32 32 ${TMP}1.128${H} ${TMP}2.256${H} \
    > ${TD}/${TEX}${REFH}
  rm -f ${TMP}*
}


make_nat_4_ref ()
{
  TEX=Nat-4
  echo "\n${TEX} texture reference frame"
  genframe -B -s 128 -g 1 > ${TMP}0${H}
  genframe -B -s 128 -g 2 > ${TMP}1${H}
  genframe -B -s 128 -g 3 > ${TMP}2${H}
  genframe -B -s 128 -g 4 > ${TMP}3${H}
  joinframes -s 2 2 ${TMP}0${H} ${TMP}2${H} ${TMP}3${H} \
    ${TMP}1${H} > ${TD}/${TEX}${REFH}
  rm -f ${TMP}?${H}
}


make_nat_5_ref ()
{
  TEX=Nat-5
  # Nat-5 Reference frame
  echo "\n${TEX} texture reference frame"
  genframe -B -s 128 -g 1 > ${TMP}1${H}
  genframe -B -s 128 -g 2 > ${TMP}2${H}
  genframe -B -s 128 -g 3 > ${TMP}3${H}
  genframe -B -s 128 -g 4 > ${TMP}4${H}
  genframe -B -s 256 -g 5 > ${TMP}5.256${H}
  joinframes -s 2 2 ${TMP}3${H} ${TMP}2${H} ${TMP}1${H} \
    ${TMP}4${H} > ${TMP}${TEX}${REFH}
  calcpix -o ${TMP}${TEX}.1 -s "opix=((128-r)*(128-r) + (128-c)*(128-c) \
    < 64*64 ? 0 : ipix)" < ${TMP}${TEX}${REFH} > ${TMP}${TEX}.2${REFH}
  calcpix -o ${TMP}${TEX}.2 -s "opix=((128-r)*(128-r) + (128-c)*(128-c) \
    < 64*64 ? ipix : 0)" < ${TMP}5.256${H} > ${TMP}5.256.2${H}
  addseq ${TMP}${TEX}.2${REFH} ${TMP}5.256.2${H} > ${TMP}${TEX}.3${REFH}
  htob ${TMP}${TEX}.3${REFH} > ${TD}/${TEX}${REFH}
  rm -f ${TMP}*
}


make_nat_5b_ref ()
{
  TEX=Nat-5b
  # Nat-5 Reference frame
  echo "\n${TEX} texture reference frame"
  genframe -B -s 256 -g 1 | \
    calcpix -o ${TMP}${TEX} -s "opix=(r> c && r<=256-c ? ipix : 0)" \
      > ${TMP}1${H}
  genframe -B -s 256 -g 3 | \
    calcpix -o ${TMP}${TEX} -s "opix=(r> c && r> 256-c ? ipix : 0)" \
      > ${TMP}2${H}
  genframe -B -s 256 -g 2 | \
    calcpix -o ${TMP}${TEX} -s "opix=(r<=c && r<=256-c ? ipix : 0)" \
      > ${TMP}3${H}
  genframe -B -s 256 -g 4 | \
    calcpix -o ${TMP}${TEX} -s "opix=(r<=c && r> 256-c ? ipix : 0)" \
      > ${TMP}4${H}
  addseq ${TMP}1${H} ${TMP}2${H} | addseq ${TMP}3${H} | \
    addseq ${TMP}4${H} | \
      calcpix -o ${TMP}${TEX}.1 -s "opix=((128-r)*(128-r) + (128-c)*(128-c) \
        < 64*64 ? 0 : ipix)" > ${TMP}${TEX}.1${REFH}
  genframe -B -s 256 -g 5 > ${TMP}5${H}
  calcpix -o ${TMP}${TEX}.2 -s "opix=((128-r)*(128-r) + (128-c)*(128-c) \
    < 64*64 ? ipix : 0)" < ${TMP}5${H} > ${TMP}5.2${H}
  addseq ${TMP}${TEX}.1${REFH} ${TMP}5.2${H} > ${TMP}${TEX}.2${REFH}
  htob ${TMP}${TEX}.2${REFH} > ${TD}/${TEX}${REFH}
  rm -f ${TMP}*
}


make_nat_8_ref ()
{
  TEX=Nat-8
  # Nat-8 Reference frame
  echo "\n${TEX} texture reference frame"
  genframe -B -s 64 -g 1  > ${TMP}1${H}
  genframe -B -s 64 -g 2  > ${TMP}2${H}
  genframe -B -s 64 -g 3  > ${TMP}3${H}
  genframe -B -s 64 -g 4  > ${TMP}4${H}
  genframe -B -s 64 -g 5  > ${TMP}5${H}
  genframe -B -s 64 -g 6  > ${TMP}6${H}
  genframe -B -s 64 -g 7  > ${TMP}7${H}
  genframe -B -s 64 -g 8  > ${TMP}8${H}
  joinframes -s 2 4 ${TMP}3${H} ${TMP}6${H} ${TMP}1${H} ${TMP}4${H} \
    ${TMP}7${H} ${TMP}2${H} ${TMP}5${H} ${TMP}8${H} > ${TD}/${TEX}${REFH}
  rm -f ${TMP}*
}



make_16_ref ()
{
  TEX=${1}

  echo "\n${TEX} texture reference frame"
  for PART in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 ; do
    genframe -B -s 128 -g ${PART}  > ${TMP}${PART}${H}
  done
  joinframes -s 2 4 ${TMP}5${H} ${TMP}10${H} ${TMP}15${H} ${TMP}4${H} \
                    ${TMP}9${H} ${TMP}14${H} ${TMP}3${H} ${TMP}8${H} \
	> ${TMP}A${H}
  joinframes -s 2 4 ${TMP}13${H} ${TMP}2${H} ${TMP}7${H} ${TMP}12${H} \
                    ${TMP}1${H} ${TMP}6${H} ${TMP}11${H} ${TMP}16${H} \
	> ${TMP}B${H}
  joinframes -s 2 ${TMP}A${H} ${TMP}B${H} > ${TD}/Img-16${REFH}
  rm -f ${TMP}*
  ln -s ${TD}/Img-16${REFH} ${TD}/${TEX}${REFH}
}


# Function for adding description about uniform texture regions to the header
# First parameter: texture-file
# Second parameter: upper left corner, row number
# Third parameter: upper left corner, line number
# Fourth parameter: lower right corner, row number
# Fifth parameter: lower right corner, line number
unif_tex_descr ()
{
  adddesc -a "uniform_texture_region: $2 $3 $4 $5 " < ${1} > ${TMP}A${H}
  mv ${TMP}A${H} ${1}
}

# M A I N   P R O G R A M



# Test if no parameter is given => print usage information
if [ ${1}_ = '_' ] 
then
  parseargs -U
else
  # Parse the arguments and generate the textures
  parseargs $1 $2 $3 $4 $5 $6 $7 $8 $9
fi
