#! /bin/sh

pipedir=/tmp/geomview

case "$1" in
  -M) pipedir=$2; shift 2 ;;
  -M*) pipedir="`expr "$1" : "-M\(.*\)"`"; shift ;;
  -*) shift $# ;;
esac

if [ $# -lt 2 ]; then
    echo "Usage: $0  [-Mpipedirectory]  symbolname   OOGLfile ...
Animate the given sequence of OOGL object files, writing them to the
given symbol (actually a named pipe).
Use in combination with:  geomview -M symbolname
Pipes created by default in $pipedir." >&2
    exit 1
fi

pipe=$pipedir/$1
shift

if [ ! -d $pipedir ] ; then
  mkdir $pipedir
  chmod a+w $pipedir
fi
if [ ! -p $pipe ] ; then
  /bin/rm -f $pipe
  /etc/mknod $pipe p
fi

exec >$pipe

for f in $@ ; do
	case "$f" in
	/*) g="$f";;
	*) g=${cwd:=`pwd`}/$f ;;
	esac

	echo \
"{ = INST transform	# Edit this to apply a transformation to all objects
	1 0 0 0
	0 1 0 0
	0 0 1 0
	0 0 0 1
unit < $g
}"
done
