#!/usr/bin/perl
#by taudas@nthstone.mi.org 7/1994

print "usage - pingpong.pl filenameprefix filenamesuffix startframe# endframe#\n";
print "creates a new segment of frames by linking in pingpong effect.\n";
print "assumes prefix#.suffix format for frame filenames.\n";
print "new segment starts with frame # endframe#+1.\n";
print "the endframe is not duplicated (endframe+1 = endframe-1).\n";

$filepre = shift;
$filesuf = shift;
$startframe = shift;
$endframe = shift;
print "filepre $filepre filesuf $filesuf start $startframe end $endframe\n";
$steps = $endframe-$startframe;
for($t=1;$t<=$steps;$t++) {
    $x = $startframe+$t-1; 		# frame# to be linked
    $y = $endframe+$steps+1-$t;		# frame# to link to
    &linkstep($t,$x,$y);
}

sub linkstep {
    print "linking step $_[0]\n";
    system("ln -fs $filepre$_[1].$filesuf $filepre$_[2].$filesuf");
}
