best viewed in syntax highlighting text editor such as Textpad

#!/usr/bin/perl

 

system("perl c:/bin/title.pl");

 

my $optionsSet=0;    # --- preset values for these options

my $offsetScale=700; # -----------------------------------

my $useRandScale = "n";

my $shkName ="default";

my $tileName = "tile";

my $directory = "C:/INNOVATIONS_PROJECT/production/";

 

 

            #--- render options ----

my $width=20;     #-------- use the defaults --------

my $height=20;    

my $startFrame=1;

my $endFrame=1;

           

 

print "SET DIRECTORIES ? \n";

print "enter tile name : \n";

$tileName=<STDIN>;

chop $tileName;

print "do you wish to render (y/n) : ";

$renderChoice=<STDIN>;

chop $renderChoice;

if($renderChoice eq "y")

{

  print "name of scene to be rendered : ";

  $scene=<STDIN>;

  print "render options? (y/n) : ";

  $ops=<STDIN>;

  chop $ops;

  if($ops eq "y")

   {

    $optionsSet=1;

    print "  tile x : ";

    $width=<STDIN>;

    chop $width;

    print "  tile y : ";

    $height=<STDIN>;

    chop $height;

    print "  start frame : ";

    $startFrame=<STDIN>;

    chop $startFrame;

    print "  end frame : ";

    $endFrame=<STDIN>;

    chop $endFrame;

   }

}

else

{

print "do you wish to assemble (y/n) : ";

$assembleChoice=<STDIN>;

chop $assembleChoice;

      if($assembleChoice eq "n")

      {exit 0;}

 

      print "\ngive file name for shake comp : \n";

      print "...a sensible name............: ";

      $shkName=<STDIN>;

      chop $shkName;

 

 

if($optionsSet == 0)

{

  print "comp options? (y/n) : ";

  $c_ops=<STDIN>;

  chop $c_ops;

  if($c_ops eq "y")

   {

    print "  start frame : ";

    $startFrame=<STDIN>;

    chop $startFrame;

    print "  end frame : ";

    $endFrame=<STDIN>;

    chop $endFrame;

    print "scaling factor to apply to UV coords : ";

    $offsetScale=<STDIN>;

    chop $offsetScale;

   }

}

}

system ("cp c:/bin/blank.txt ./assemblySCRIPTS/$shkName.shk"); # make a blank shake script to write in

 

#get the current directory and use as path for files and folders from now on

$directory = `pwd`;

chop $directory;

 

 

#******** multi render ********

 

if(open(DATA,"$directory/uvPos.txt")) #attempt to open the data file to read in the number of cameras and the uvs

# attach txt file to handle DATA

 

{

     

      $outputDir="outputIMAGES";

 

      #--- camera options ----

      $numberCAMs=<DATA>;   #read in from data file. will be the first line of file

      print ("number of cameras is $numberCAMs");

 

      if($renderChoice eq "y") # -- if we are rendering, not just assembling

      {

 

         for($i=0;$i<$numberCAMs;$i++) #main rendering loop

            {

             $currentCAM="cam$i"; #number the camera

             $currentOutName="$tileName$i"; #number each image sequence eg final will be : tileName1.#.tif

 

             system ("Render -x $width -y $height -s $startFrame -e $endFrame -cam $currentCAM -rd $outputDir -im $currentOutName -pad 4 $scene"); #call the maya renderer with all the settings we have set up

            }

      }    

}

 

#************** compile shake tree *************

 

 

 

if(open(SHK,">./assemblySCRIPTS/$shkName.shk")) #----- open for writing

{

 

   $directory=~ s/://i;

   while($directory=~ /\\/)#whilst there is still a back slash

      {

      $directory=~ s/\\/\//i; #replace back slash with foward slash

      }

 

      # a bit of a header

  

   print SHK ("// Auto generated by ben...., LLC\n\nSetTimeRange(\"1-$endFrame\");\nSetFieldRendering(0);\nSetFps(25);\nSetMotionBlur(1, 1, 0);\nSetQuality(1);\nSetProxyScale(1, 1);\nSetProxyFilter(\"default\");\nSetPixelScale(1, 1);\nSetDefaultWidth(720);\nSetDefaultHeight(576);\nSetDefaultBytes(1);\nSetDefaultAspect(0.938086);\nSetDefaultViewerAspect(1.066);\nSetTimecodeMode(\"25 FPS\");\n\n\n// Input nodes\n");

 

   print SHK ( "backPlate = Color(1000, 1000, 1, 0.4, 0.4, 0.4, 1, 0);\n\n" ); #a mount backing

  

   #global controls to use in shake

   print SHK ("GlobalScaler = Checker(100, 100, 1, 50, xSize, float uSCALE = $offsetScale, float vSCALE = $offsetScale, float tileSCALE = 1,float fovAMOUNT = 0,float fovSCALE = 1.2, float rndAMOUNT = 0);\n\n"); # this will be used to drive the x(u) and y(v) scaling

     

    for($i=0;$i<$numberCAMs;$i++)

    {#write all the tiles as input in to shake script    

     print SHK ("tile_$i = FileIn(\"//Benscomputer/$directory/$outputDir/$tileName$i\.$startFrame-$endFrame#.iff\",  \n \"Auto\", 0, 0);\n\n");

    }

    

   print SHK ( "// Processing nodes\n\n\n\n" );

   

    for($i=0;$i<$numberCAMs;$i++)

    {#write all the layering connects

     #------- get the offset values from data file ------#

      $tileScale=<DATA>;

      $u=<DATA>;

      $v=<DATA>;

      $xpan=$u;#*$offsetScale;

      $ypan=$v;#*$offsetScale;

    

 

      #complicated expression to control scale, and allow rotation

      print SHK ("Move2D$i = Move2D(tile_$i, 0, 0, 0, 0.9380863, GlobalScaler.tileSCALE * (($tileScale*GlobalScaler.fovSCALE) * GlobalScaler.fovAMOUNT + (1-GlobalScaler.fovAMOUNT)) * ((rnd($i)+0.5)*GlobalScaler.rndAMOUNT + (1-GlobalScaler.rndAMOUNT)), GlobalScaler.tileSCALE * (($tileScale*GlobalScaler.fovSCALE) * GlobalScaler.fovAMOUNT + (1-GlobalScaler.fovAMOUNT)) * ((rnd($i-1)+0.5)*GlobalScaler.rndAMOUNT + (1-GlobalScaler.rndAMOUNT)), 0, 0, width/2, height/2, \"default\", xFilter, \"trsx\", 0, 0, 0.5, 0, 0, time);\n\n");   

 

      print SHK ( "Pan$i = Pan(Move2D$i, $xpan*GlobalScaler.uSCALE, $ypan*GlobalScaler.vSCALE, 0, 0.5, 0);\n\n");

      print SHK ("AddShadow$i = AddShadow(Pan$i, 0.5 + 1.5*rnd($i),  0.5 + 1.5*rnd($i), 56, 0.01, 0.02,0.05, 0.3);\n\n");

      print SHK ("ContrastRGB$i = ContrastRGB(AddShadow$i,0.8 + 0.4 * rnd(-$i+1),0.8 + 0.4 * rnd($i+5),0.8 + 0.4 * rnd($i*2), 1, 0.5, 0.5, 0.5, 0.5, 0, 0, 0, 0);\n\n");

 

      if($i==0)

     {

      print SHK ( "Over$i = Over(ContrastRGB$i, backPlate, 1, 1, 0);\n\n");

     }

     else

     {

      $previous=$i-1;

      print SHK ( "Over$i = Over(ContrastRGB$i,Over$previous , 1, 1, 0);\n\n");

     }

    }

 

  $lastNODE = $numberCAMs-1;

  print SHK ( "// User Interface settings\n\n" );

  print SHK ( "SetKey(\n");

  print SHK ( "   \"nodeView.Over$lastNODE.x\", \"0\",\n

            \"nodeView.Over$lastNODE.y\", \"-600\",\n

            \"nodeView.GlobalScaler.x\", \"100\",\n

            \"nodeView.GlobalScaler.y\", \"-600\",\n

            \"nodeView.xPan\", \"0\",\n

            \"nodeView.yPan\", \"0\",\n

            \"nodeView.zoom\", \"0.05\"\n" );

  print SHK ( ");");

           

 

 

  print "\n\n\n\n"; 

  close(DATA);

  close(SHK);

  system ("shake ./assemblySCRIPTS/$shkName.shk"); # -- close up the files and open the

  # -----newly generated script with shake for tweaking and inspection.

}