#!/bin/csh -f
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
#
#  This is a csh script which is used to create a new Wavefront user
#  directory.  It does the following:
#  1) create top level directory
#  2) create several sub directories
#  3) creates links to "standart" objects and textures
#  4) create a new preview file called "new"
#  5) creates new .modrc and .pvrc startup files
#
#
#  Author:     Wesley C. Barris
#              AHPCRC
#              Minnesota Supercomputer Center, Inc.
#  Date:       Sept. 12, 1990
#
#  Copyright @ 1990, Minnesota Supercomputer Center, Inc.
#
#  RESTRICTED RIGHTS LEGEND
#
#  Use, duplication, or disclosure of this software and its documentation
#  by the Government is subject to restrictions as set forth in subdivision
#  { (b) (3) (ii) } of the Rights in Technical Data and Computer Software
#  clause at 52.227-7013.
#
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
if ($#argv == 0 || $1 == '-help' || $1 == '-h') then
   echo "Usage: new_dir name"
else if ($#argv == 1) then
   if (-d $1) then
      echo "Whoa!  This directory already exists\! -- Aborting..."
   else if (-e $1) then
      echo "Whoa!  A file of this name already exists\! -- Aborting..."
   else
      if (-e ~/.modrc) then
      else
         cp $WF_CMD_DIR/RC/modrc ~/.modrc
         chmod 640 ~/.modrc
      endif
      if (-e ~/.pvrc) then
      else
         cp $WF_CMD_DIR/RC/pvrc ~/.pvrc
         chmod 640 ~/.pvrc
      endif
      echo "Making top level directory: $1..."
      mkdir $1
      cd $1
      echo "Making sub-directories..."
      mkdir $WF_OBJ_DIR
      mkdir $WF_SCMP_DIR
      echo "Linking to dumcam.obj..."
      ln -s $WF_AV_DIR/dat/project/dumcam.obj $WF_OBJ_DIR/dumcam.obj
      echo "Linking to white.lgt..."
      ln -s $WF_AV_DIR/dat/project/project/white.lgt white.lgt
#
#  Copy a fresh version of colors.mtl
#
      if (-d $WF_PRJ_DIR) then
         if (-e $WF_PRJ_DIR/colors.mtl) then
            echo "You already have a colors.mtl file in your WF_PRJ dir -- skipping."
         else
            echo "Copying colors.mtl to $WF_PRJ_DIR..."
            cp $WF_AV_DIR/dat/project/newcolors.mtl $WF_PRJ_DIR/colors.mtl
#           cat $WF_AV_DIR/proglib/obj_cnvt/master.mtl >>$WF_PRJ_DIR/colors.mtl
            cat $WF_CMD_DIR/MTL/4Dgifts.mtl >>$WF_PRJ_DIR/colors.mtl
            cat $WF_CMD_DIR/MTL/spectral.mtl >>$WF_PRJ_DIR/colors.mtl
         endif
      else
         echo "Copying colors.mtl to your directory..."
         cp $WF_AV_DIR/dat/project/newcolors.mtl colors.mtl
         cat $WF_CMD_DIR/MTL/4Dgifts.mtl >>colors.mtl
         cat $WF_CMD_DIR/MTL/spectral.mtl >>colors.mtl
      endif
#
#  Make a dummy preview file.
#
      echo "Creating a brand new preview file..."
      cp $WF_CMD_DIR/PV/new.pv $WF_SCMP_DIR/$1.pv
      chmod 644 $WF_SCMP_DIR/$1.pv
      echo "Use cd $1 to move into this directory\!\!\!"
   endif
else
   echo "Invalid number of arguments\!"
   echo "Usage: new_dir name"
endif
