PDA

View Full Version : multi-camera batch render...



electroNIX
05-26-2003, 10:02 AM
Hi!

I just learned to use Powergons ;) and I used the script "multi-camera batch render" from Al Street at http://www.ats-3d.com...

But, it only has 5 possible cameras and the batchfile overwrites the older renders with the new ones if you render the same frame...

I am new to lscript, so please be nice :p

This is the original lscript from Al Streets Page...

/* mcbr.ls
* (c) 2002 Al Street www.ats-3d.com
* multi-camera batch render (MCBR)
* tested ok with UNC drives
* tested ok with mapped network drives
* tested ok on stand-alone system
*/

@version 2.2
@warnings
@script generic


// globals


cam; cam1..5; rendercam;
sf1..5; ef1..5; segmentStartFrame;
segmentEndFrame;
scriptName="(MCBR)";
scriptVer="v 0.1";
textFile; line; sf1 = 1; ef1;
insdir; sf; ef; contentdir; scenefilename;
base; drivePath; BaseName; sceneFilename;
curcamPrefix; scenefile; lines; curcamPrefixLoc;
camsize; camObj; AnyPrefix = nil;

generic
{
i = 1;
camera = getfirstitem(CAMERA);
camObj[1] = camera;
while(camera != nil)
{
camera = camera.next();
i++;
if(camera != nil) camObj[i] = camera;
else i--;
}
camsize = size(camObj);
insdir = getdir("Install");
contentdir = getdir("Content");
scenefilename = getfirstitem(SCENE);
scene = Scene();
cam = Camera();
ef1 = scene.frameend;
for(j = 1; j<= 5; j++) {rendercam[j] = nil;}
read_master();
if(!AnyPrefix)
{
warn("Save RGB Images not activated in master scene!"," Processing terminated.");
return;
}
requester();
sceneFilename[1] = drivePath + BaseName + "_segment_1.lws";
sf[1] = sf1; ef[1] = ef1; rendercam[1] = cam1;
if(cam2 != nil) {sf[2] = sf2; ef[2] = ef2; rendercam[2] = cam2; sceneFilename[2] = drivePath + BaseName + "_segment_2.lws";}
if(cam3 != nil) {sf[3] = sf3; ef[3] = ef3; rendercam[3] = cam3; sceneFilename[3] = drivePath + BaseName + "_segment_3.lws";}
if(cam4 != nil) {sf[4] = sf4; ef[4] = ef4; rendercam[4] = cam4; sceneFilename[4] = drivePath + BaseName + "_segment_4.lws";}
if(cam5 != nil) {sf[5] = sf5; ef[5] = ef5; rendercam[5] = cam5; sceneFilename[5] = drivePath + BaseName + "_segment_5.lws";}
write_scene();
write_bat(); // write the ScreamerNet batch file
}

/* -----------------------------------------------------------
* read_master() reads the master scene file
* ----------------------------------------------------------- */

read_master
{
SaveScene();
// scene = Scene();
// master = scene.filename; // info("master is ",master);
scenefilename = getfirstitem(SCENE);
filename = scenefilename.filename;
textFile = fullpath(filename);
// info("textFile = ",textFile);
base = split(textFile);

if(!base[1])
{
drivePath = base[2];
}
else
{
drivePath = base[1] + base[2];
}

BaseName = base[3];
// info(base[3]);
scenefile = File(filename); lines = scenefile.linecount();
// info("master file ",scenefile," has ",lines," lines.");

linePrefix = "SaveRGB 1"; // we'll need this later
curcamPrefix = "CurrentCamera"; // need to find this location also
len = sizeof(linePrefix);
len2 = sizeof(curcamPrefix);

for(i = 1;i <= lines; i++)
{
line[i] = scenefile.read() ;
if(strleft(line[i],len) == linePrefix)
{
linePrefixLoc = i; AnyPrefix = 1;
// info("SaveRGBImagesPrefix found on line ",i);
}
if(strleft(line[i],len2) == curcamPrefix)
{
curcamPrefixLoc = i;
// info("curcamPrefix found on line ",i);
}

}


}

/* -----------------------------------------------------------
* write_scene() writes the individual scene files
* for each render
* ----------------------------------------------------------- */

write_scene
{
// debug();
// write out the new file
// ** don't forget to check for UNC file compatibility **



for(j = 1; j <= 5; j++)
{
if(rendercam[j] != nil)
{
// get number of camera object
for(x = 1; x <= camsize; x++)
{
if(rendercam[j].id == camObj[x].id)
{
//info("camera is item ", x - 1);
renderCamNum = x - 1;
}
}
scenefile.open(sceneFilename[j],"w");
for(i = 1;i <= lines; i++)
{
if(i == 4) { scenefile.writeln("FirstFrame ",sf[j]); i++; }
if(i == 5) { scenefile.writeln("LastFrame ",ef[j]); i++; }
if(i == curcamPrefixLoc)
{
// info("rendercam = ",rendercam[j]);
scenefile.writeln(curcamPrefix, " ", renderCamNum);

//i++; // skip to the next line
}
else
{
scenefile.writeln(line[i]);
}
}
}
}
}

/* -----------------------------------------------------------
* write_bat() writes the ScreamerNet batch file
* LWSN -3 [-c<config file>] [-d<content dir>] [-q]
* <scene file> <first frame> <last frame> [<frame step>]
* ----------------------------------------------------------- */

write_bat
{
base = split(textFile);

if(!base[1])
{
drivePath = base[2];
}
else
{
drivePath = base[1] + base[2];
}

renderFilename = drivePath + "render.bat";

if((renderFile = File(renderFilename, "w")) == nil)
{ //error msg
error("could not open render batch file ",renderFilename);
return;
}
for(i=1; i<=5; i++)
{
if(rendercam[i] != nil)
{
SN = insdir + "\\LWSN -3 -d" + contentdir + " " + sceneFilename[i] + " " + string(sf[i]) + " " + string(ef[i]);
renderFile.writeln(SN);
}
}
renderFile.close();
}

/* -----------------------------------------------------------
* Requester
* ----------------------------------------------------------- */

requester
{
// reqbegin(scriptName+" "+scriptVer);
if(!reqbegin(" MCBR (c) 2002 by Al Street ver 1.0 "))
return;
reqsize(440,230);

row0 = 5; row1 = 35; row2 = 65; row3 = 95; row4 = 125; row5 = 155;

tx1 = ctltext("","Multi-Camera Batch Render -- www.ats-3d.com"); ctlposition(tx1,100,row0);
c1 = ctlinteger("Start Frame", sf1); ctlposition(c1,10,row1,100);
c2 = ctlinteger("End Frame", ef1); ctlposition(c2,130,row1,100);
c3 = ctlcameraitems("Camera",cam); ctlposition(c3,260,row1,150);

c4 = ctlinteger("Start Frame", 0); ctlposition(c4,10,row2,100);
c5 = ctlinteger("End Frame", 0); ctlposition(c5,130,row2,100);
c6 = ctlcameraitems("Camera"); ctlposition(c6,260,row2,150);

c7 = ctlinteger("Start Frame", 0); ctlposition(c7,10,row3,100);
c8 = ctlinteger("End Frame", 0); ctlposition(c8,130,row3,100);
c9 = ctlcameraitems("Camera"); ctlposition(c9,260,row3,150);

c10 = ctlinteger("Start Frame", 0); ctlposition(c10,10,row4,100);
c11 = ctlinteger("End Frame", 0); ctlposition(c11,130,row4,100);
c12 = ctlcameraitems("Camera"); ctlposition(c12,260,row4,150);

c13 = ctlinteger("Start Frame", 0); ctlposition(c13,10,row5,100);
c14 = ctlinteger("End Frame", 0); ctlposition(c14,130,row5,100);
c15 = ctlcameraitems("Camera"); ctlposition(c15,260,row5,150);

if (!reqpost()) return 0;
sf1 = getvalue(c1); ef1 = getvalue(c2); cam1 = getvalue(c3);
sf2 = getvalue(c4); ef2 = getvalue(c5); cam2 = getvalue(c6);
sf3 = getvalue(c7); ef3 = getvalue(c8); cam3 = getvalue(c9);
sf4 = getvalue(c10); ef4 = getvalue(c11); cam4 = getvalue(c12);
sf5 = getvalue(c13); ef5 = getvalue(c14); cam5 = getvalue(c15);

reqend();
}

electroNIX
05-26-2003, 10:04 AM
And this is my version with the ability to use 16 cameras...

Part1... because of the 10000 character limitation...

/* mcbr.ls
* (c) 2002 Al Street www.ats-3d.com
* multi-camera batch render (MCBR)
* tested ok with UNC drives
* tested ok with mapped network drives
* tested ok on stand-alone system
*/

@version 2.2
@warnings
@script generic


// globals


cam; cam1..16; rendercam;
sf1..16; ef1..16; segmentStartFrame;
segmentEndFrame;
scriptName="(MCBR)";
scriptVer="v 0.2";
textFile; line; sf1 = 1; ef1;
insdir; sf; ef; contentdir; scenefilename;
base; drivePath; BaseName; sceneFilename;
curcamPrefix; scenefile; lines; curcamPrefixLoc;
camsize; camObj; AnyPrefix = nil;

generic
{
i = 1;
camera = getfirstitem(CAMERA);
camObj[1] = camera;
while(camera != nil)
{
camera = camera.next();
i++;
if(camera != nil) camObj[i] = camera;
else i--;
}
camsize = size(camObj);
insdir = getdir("Install");
contentdir = getdir("Content");
scenefilename = getfirstitem(SCENE);
scene = Scene();
cam = Camera();
ef1 = scene.frameend;
for(j = 1; j<= 16; j++) {rendercam[j] = nil;}
read_master();
if(!AnyPrefix)
{
warn("Save RGB Images not activated in master scene!"," Processing terminated.");
return;
}
requester();
sceneFilename[1] = drivePath + BaseName + "_segment_1.lws";
sf[1] = sf1; ef[1] = ef1; rendercam[1] = cam1;
if(cam2 != nil) {sf[2] = sf2; ef[2] = ef2; rendercam[2] = cam2; sceneFilename[2] = drivePath + BaseName + "_segment_2.lws";}
if(cam3 != nil) {sf[3] = sf3; ef[3] = ef3; rendercam[3] = cam3; sceneFilename[3] = drivePath + BaseName + "_segment_3.lws";}
if(cam4 != nil) {sf[4] = sf4; ef[4] = ef4; rendercam[4] = cam4; sceneFilename[4] = drivePath + BaseName + "_segment_4.lws";}
if(cam5 != nil) {sf[5] = sf5; ef[5] = ef5; rendercam[5] = cam5; sceneFilename[5] = drivePath + BaseName + "_segment_5.lws";}
if(cam6 != nil) {sf[6] = sf6; ef[6] = ef6; rendercam[6] = cam6; sceneFilename[6] = drivePath + BaseName + "_segment_6.lws";}
if(cam7 != nil) {sf[7] = sf7; ef[7] = ef7; rendercam[7] = cam7; sceneFilename[7] = drivePath + BaseName + "_segment_7.lws";}
if(cam8 != nil) {sf[8] = sf8; ef[8] = ef8; rendercam[8] = cam8; sceneFilename[8] = drivePath + BaseName + "_segment_8.lws";}
if(cam9 != nil) {sf[9] = sf9; ef[9] = ef9; rendercam[9] = cam9; sceneFilename[9] = drivePath + BaseName + "_segment_9.lws";}
if(cam10 != nil) {sf[10] = sf10; ef[10] = ef10; rendercam[10] = cam10; sceneFilename[10] = drivePath + BaseName + "_segment_10.lws";}
if(cam11 != nil) {sf[11] = sf11; ef[11] = ef11; rendercam[11] = cam11; sceneFilename[11] = drivePath + BaseName + "_segment_11.lws";}
if(cam12 != nil) {sf[12] = sf12; ef[12] = ef12; rendercam[12] = cam12; sceneFilename[12] = drivePath + BaseName + "_segment_12.lws";}
if(cam13 != nil) {sf[13] = sf13; ef[13] = ef13; rendercam[13] = cam13; sceneFilename[13] = drivePath + BaseName + "_segment_13.lws";}
if(cam14 != nil) {sf[14] = sf14; ef[14] = ef14; rendercam[14] = cam14; sceneFilename[14] = drivePath + BaseName + "_segment_14.lws";}
if(cam15 != nil) {sf[15] = sf15; ef[15] = ef15; rendercam[15] = cam15; sceneFilename[15] = drivePath + BaseName + "_segment_15.lws";}
if(cam16 != nil) {sf[16] = sf16; ef[16] = ef16; rendercam[16] = cam16; sceneFilename[16] = drivePath + BaseName + "_segment_16.lws";}
write_scene();
write_bat(); // write the ScreamerNet batch file
}

/* -----------------------------------------------------------
* read_master() reads the master scene file
* ----------------------------------------------------------- */

read_master
{
SaveScene();
// scene = Scene();
// master = scene.filename; // info("master is ",master);
scenefilename = getfirstitem(SCENE);
filename = scenefilename.filename;
textFile = fullpath(filename);
// info("textFile = ",textFile);
base = split(textFile);

if(!base[1])
{
drivePath = base[2];
}
else
{
drivePath = base[1] + base[2];
}

BaseName = base[3];
// info(base[3]);
scenefile = File(filename); lines = scenefile.linecount();
// info("master file ",scenefile," has ",lines," lines.");

linePrefix = "SaveRGB 1"; // we'll need this later
curcamPrefix = "CurrentCamera"; // need to find this location also
len = sizeof(linePrefix);
len2 = sizeof(curcamPrefix);

for(i = 1;i <= lines; i++)
{
line[i] = scenefile.read() ;
if(strleft(line[i],len) == linePrefix)
{
linePrefixLoc = i; AnyPrefix = 1;
// info("SaveRGBImagesPrefix found on line ",i);
}
if(strleft(line[i],len2) == curcamPrefix)
{
curcamPrefixLoc = i;
// info("curcamPrefix found on line ",i);
}

}


}

/* -----------------------------------------------------------
* write_scene() writes the individual scene files
* for each render
* ----------------------------------------------------------- */

write_scene
{
// debug();
// write out the new file
// ** don't forget to check for UNC file compatibility **



for(j = 1; j <= 16; j++)
{
if(rendercam[j] != nil)
{
// get number of camera object
for(x = 1; x <= camsize; x++)
{
if(rendercam[j].id == camObj[x].id)
{
//info("camera is item ", x - 1);
renderCamNum = x - 1;
}
}
scenefile.open(sceneFilename[j],"w");
for(i = 1;i <= lines; i++)
{
if(i == 4) { scenefile.writeln("FirstFrame ",sf[j]); i++; }
if(i == 5) { scenefile.writeln("LastFrame ",ef[j]); i++; }
if(i == curcamPrefixLoc)
{
// info("rendercam = ",rendercam[j]);
scenefile.writeln(curcamPrefix, " ", renderCamNum);

//i++; // skip to the next line
}
else
{
scenefile.writeln(line[i]);
}
}
}
}
}

/* -----------------------------------------------------------
* write_bat() writes the ScreamerNet batch file
* LWSN -3 [-c<config file>] [-d<content dir>] [-q]
* <scene file> <first frame> <last frame> [<frame step>]
* ----------------------------------------------------------- */

write_bat
{
base = split(textFile);

if(!base[1])
{
drivePath = base[2];
}
else
{
drivePath = base[1] + base[2];
}

renderFilename = drivePath + "render.bat";

if((renderFile = File(renderFilename, "w")) == nil)
{ //error msg
error("could not open render batch file ",renderFilename);
return;
}
for(i=1; i<=16; i++)
{
if(rendercam[i] != nil)
{
SN = insdir + "\\LWSN -3 -d" + contentdir + " " + sceneFilename[i] + " " + string(sf[i]) + " " + string(ef[i]);
renderFile.writeln(SN);
}
}
renderFile.close();
}

electroNIX
05-26-2003, 10:05 AM
Part2...




/* -----------------------------------------------------------
* Requester
* ----------------------------------------------------------- */

requester
{
// reqbegin(scriptName+" "+scriptVer);
if(!reqbegin(" MCBR (c) 2002 by Al Street ver 1.0"))
return;
reqsize(440,630);

row0 = 5; row1 = 35; row2 = 65; row3 = 95; row4 = 125; row5 = 155; row6 = 185; row7 = 215; row8 = 245; row9 = 275; row10 = 305; row11 = 335; row12 = 365; row13 = 395; row14 = 425; row15 = 450; row16 = 480;

tx1 = ctltext("","Multi-Camera Batch Render -- www.ats-3d.com"); ctlposition(tx1,100,row0);
c1 = ctlinteger("Start Frame", sf1); ctlposition(c1,10,row1,100);
c2 = ctlinteger("End Frame", ef1); ctlposition(c2,130,row1,100);
c3 = ctlcameraitems("Camera",cam); ctlposition(c3,260,row1,150);

c4 = ctlinteger("Start Frame", 0); ctlposition(c4,10,row2,100);
c5 = ctlinteger("End Frame", 0); ctlposition(c5,130,row2,100);
c6 = ctlcameraitems("Camera"); ctlposition(c6,260,row2,150);

c7 = ctlinteger("Start Frame", 0); ctlposition(c7,10,row3,100);
c8 = ctlinteger("End Frame", 0); ctlposition(c8,130,row3,100);
c9 = ctlcameraitems("Camera"); ctlposition(c9,260,row3,150);

c10 = ctlinteger("Start Frame", 0); ctlposition(c10,10,row4,100);
c11 = ctlinteger("End Frame", 0); ctlposition(c11,130,row4,100);
c12 = ctlcameraitems("Camera"); ctlposition(c12,260,row4,150);

c13 = ctlinteger("Start Frame", 0); ctlposition(c13,10,row5,100);
c14 = ctlinteger("End Frame", 0); ctlposition(c14,130,row5,100);
c15 = ctlcameraitems("Camera"); ctlposition(c15,260,row5,150);

c16 = ctlinteger("Start Frame", 0); ctlposition(c16,10,row6,100);
c17 = ctlinteger("End Frame", 0); ctlposition(c17,130,row6,100);
c18 = ctlcameraitems("Camera"); ctlposition(c18,260,row6,150);

c19 = ctlinteger("Start Frame", 0); ctlposition(c19,10,row7,100);
c20 = ctlinteger("End Frame", 0); ctlposition(c20,130,row7,100);
c21 = ctlcameraitems("Camera"); ctlposition(c21,260,row7,150);

c22 = ctlinteger("Start Frame", 0); ctlposition(c22,10,row8,100);
c23 = ctlinteger("End Frame", 0); ctlposition(c23,130,row8,100);
c24 = ctlcameraitems("Camera"); ctlposition(c24,260,row8,150);

c25 = ctlinteger("Start Frame", 0); ctlposition(c25,10,row9,100);
c26 = ctlinteger("End Frame", 0); ctlposition(c26,130,row9,100);
c27 = ctlcameraitems("Camera"); ctlposition(c27,260,row9,150);

c28 = ctlinteger("Start Frame", 0); ctlposition(c28,10,row10,100);
c29 = ctlinteger("End Frame", 0); ctlposition(c29,130,row10,100);
c30 = ctlcameraitems("Camera"); ctlposition(c30,260,row10,150);

c31 = ctlinteger("Start Frame", 0); ctlposition(c31,10,row11,100);
c32 = ctlinteger("End Frame", 0); ctlposition(c32,130,row11,100);
c33 = ctlcameraitems("Camera"); ctlposition(c33,260,row11,150);

c34 = ctlinteger("Start Frame", 0); ctlposition(c34,10,row12,100);
c35 = ctlinteger("End Frame", 0); ctlposition(c35,130,row12,100);
c36 = ctlcameraitems("Camera"); ctlposition(c36,260,row12,150);

c37 = ctlinteger("Start Frame", 0); ctlposition(c37,10,row13,100);
c38 = ctlinteger("End Frame", 0); ctlposition(c38,130,row13,100);
c39 = ctlcameraitems("Camera"); ctlposition(c39,260,row13,150);

c40 = ctlinteger("Start Frame", 0); ctlposition(c40,10,row14,100);
c41 = ctlinteger("End Frame", 0); ctlposition(c41,130,row14,100);
c42 = ctlcameraitems("Camera"); ctlposition(c42,260,row14,150);

c43 = ctlinteger("Start Frame", 0); ctlposition(c43,10,row15,100);
c44 = ctlinteger("End Frame", 0); ctlposition(c44,130,row15,100);
c45 = ctlcameraitems("Camera"); ctlposition(c45,260,row15,150);

c46 = ctlinteger("Start Frame", 0); ctlposition(c46,10,row16,100);
c47 = ctlinteger("End Frame", 0); ctlposition(c47,130,row16,100);
c48 = ctlcameraitems("Camera"); ctlposition(c48,260,row16,150);


if (!reqpost()) return 0;

sf1 = getvalue(c1); ef1 = getvalue(c2); cam1 = getvalue(c3);
sf2 = getvalue(c4); ef2 = getvalue(c5); cam2 = getvalue(c6);
sf3 = getvalue(c7); ef3 = getvalue(c8); cam3 = getvalue(c9);
sf4 = getvalue(c10); ef4 = getvalue(c11); cam4 = getvalue(c12);
sf5 = getvalue(c13); ef5 = getvalue(c14); cam5 = getvalue(c15);
sf6 = getvalue(c16); ef1 = getvalue(c17); cam1 = getvalue(c18);
sf7 = getvalue(c19); ef2 = getvalue(c20); cam2 = getvalue(c21);
sf8 = getvalue(c22); ef3 = getvalue(c23); cam3 = getvalue(c24);
sf9 = getvalue(c25); ef4 = getvalue(c26); cam4 = getvalue(c27);
sf10 = getvalue(c28); ef5 = getvalue(c29); cam5 = getvalue(c30);
sf11 = getvalue(c31); ef1 = getvalue(c32); cam1 = getvalue(c33);
sf12 = getvalue(c34); ef2 = getvalue(c35); cam2 = getvalue(c36);
sf13 = getvalue(c37); ef3 = getvalue(c38); cam3 = getvalue(c39);
sf14 = getvalue(c40); ef4 = getvalue(c41); cam4 = getvalue(c42);
sf15 = getvalue(c43); ef5 = getvalue(c44); cam5 = getvalue(c45);
sf16 = getvalue(c46); ef5 = getvalue(c47); cam5 = getvalue(c48);


reqend();
}



But it doesnt creates a correct .bat and it would be very good if it automatically assigns the cameras to the slots...

like here -> c3 = ctlcameraitems("Camera",cam); <-
i have for example 16 cams, named from cam to cam15 and i want them directly attached to the slots from cam to cam15...

And it still overwrites the outputfile of the last rendered camera

I hope somebody can give me some tips...

electroNIX
05-26-2003, 10:09 AM
mmmh... i just realised, attaching the .ls files would have been easier...

:eek: