#!/bin/csh -f
#
# Script used to raytrace/raycast and record
#
# arg[1] = frame #
# arg[2] = extension #
# arg[3] = pix name
# arg[4] = mask name
#
# To use, copy this script to your home directory using the commands:
#
# cp $ALIAS_LOCATION/Gifts/bin/render_record $HOME
# chmod +wx $HOME/render_record
#
# Then edit the STARTFRAME,VIDEO_DEVICE, and CONTROL_DEVICE entries
# below, and execute the renderer or raytracer from the command line
# with the command:
#
# renderer -f $HOME/render_record <sdlfile>
#
# A log file that shows the progress of the records will be created
# in /usr/tmp and called record.log 
#
# Edit the following lines to specify the start frame, video device,
# and video control device you wish to record on. If you want pix files
# deleted after recording (to save disk space), then set REMOVE to
# be true
#
set STARTFRAME="100"
set VIDEO_DEVICE="Accom"
set CONTROL_DEVICE="none"
set REMOVE="true"
#
#
#
set rtry="5"
set message=""
set try="0"
@   frameno=$2 + $STARTFRAME
set redo="true"
while ( "$redo" == "true" && "$rtry" > "1" )
@   try=$try + 1    
    if ( -e $3 ) then
    
        record -b $frameno -s $2 -e $2 -v$VIDEO_DEVICE -r$CONTROL_DEVICE $3:r

        if ( $status != "0" ) then
    
@           rtry=$rtry - 1
            set message="`date`: Record of $3 failed. Retry #$try"
        else

            set redo="false"
            if ( $REMOVE == "true" ) then

                set message="`date`: Record of $3 succeeded, removing $3"
	            /bin/rm $3
            else

                set message="`date`: Record of $3 succeeded, keeping $3"
            endif
        endif
    else
        set message="`date`: Could not find $3. Retry #$try"
        sleep 10
@       rtry=$rtry - 1
    endif
    echo $message >> /usr/tmp/record.log
end

