22 |
|
#include <signal.h> |
23 |
|
|
24 |
|
#include "platform.h" |
25 |
+ |
#include "rtprocess.h" |
26 |
|
#include "paths.h" |
27 |
< |
#include "rtio.h" |
27 |
< |
#include "rterror.h" |
28 |
< |
#include "rtmisc.h" |
27 |
> |
#include "standard.h" |
28 |
|
#include "view.h" |
29 |
|
#include "vars.h" |
30 |
|
#include "netproc.h" |
33 |
|
#define DEF_NBLUR 5 |
34 |
|
#endif |
35 |
|
/* default remote shell */ |
36 |
< |
#define REMSH "rsh" |
36 |
> |
#ifndef REMSH |
37 |
> |
#define REMSH "ssh" |
38 |
> |
#endif |
39 |
|
/* input variables (alphabetical by name) */ |
40 |
|
#define ANIMATE 0 /* animation command */ |
41 |
|
#define ARCHIVE 1 /* archiving command */ |
42 |
|
#define BASENAME 2 /* output image base name */ |
43 |
< |
#define DIRECTORY 3 /* working (sub)directory */ |
44 |
< |
#define DISKSPACE 4 /* how much disk space to use */ |
45 |
< |
#define END 5 /* ending frame number */ |
46 |
< |
#define EXPOSURE 6 /* how to compute exposure */ |
47 |
< |
#define HOST 7 /* rendering host machine */ |
48 |
< |
#define INTERP 8 /* # frames to interpolate */ |
49 |
< |
#define MBLUR 9 /* motion blur parameters */ |
50 |
< |
#define NEXTANIM 10 /* next animation file */ |
51 |
< |
#define OCTREE 11 /* octree file name */ |
52 |
< |
#define OVERSAMP 12 /* # times to oversample image */ |
53 |
< |
#define PFILT 13 /* pfilt options */ |
54 |
< |
#define PINTERP 14 /* pinterp options */ |
55 |
< |
#define RENDER 15 /* rendering options */ |
56 |
< |
#define RESOLUTION 16 /* desired final resolution */ |
57 |
< |
#define RIF 17 /* rad input file */ |
58 |
< |
#define RSH 18 /* remote shell script or program */ |
59 |
< |
#define RTRACE 19 /* use rtrace with pinterp? */ |
60 |
< |
#define START 20 /* starting frame number */ |
61 |
< |
#define TRANSFER 21 /* frame transfer command */ |
62 |
< |
#define VIEWFILE 22 /* animation frame views */ |
43 |
> |
#define DBLUR 3 /* depth of field blur */ |
44 |
> |
#define DIRECTORY 4 /* working (sub)directory */ |
45 |
> |
#define DISKSPACE 5 /* how much disk space to use */ |
46 |
> |
#define END 6 /* ending frame number */ |
47 |
> |
#define EXPOSURE 7 /* how to compute exposure */ |
48 |
> |
#define HOST 8 /* rendering host machine */ |
49 |
> |
#define INTERP 9 /* # frames to interpolate */ |
50 |
> |
#define MBLUR 10 /* motion blur parameters */ |
51 |
> |
#define NEXTANIM 11 /* next animation file */ |
52 |
> |
#define OCTREE 12 /* octree file name */ |
53 |
> |
#define OVERSAMP 13 /* # times to oversample image */ |
54 |
> |
#define PFILT 14 /* pfilt options */ |
55 |
> |
#define PINTERP 15 /* pinterp options */ |
56 |
> |
#define RENDER 16 /* rendering options */ |
57 |
> |
#define RESOLUTION 17 /* desired final resolution */ |
58 |
> |
#define RIF 18 /* rad input file */ |
59 |
> |
#define RSH 19 /* remote shell script or program */ |
60 |
> |
#define RTRACE 20 /* use rtrace with pinterp? */ |
61 |
> |
#define START 21 /* starting frame number */ |
62 |
> |
#define TRANSFER 22 /* frame transfer command */ |
63 |
> |
#define VIEWFILE 23 /* animation frame views */ |
64 |
|
|
65 |
< |
int NVARS = 23; /* total number of variables */ |
65 |
> |
int NVARS = 24; /* total number of variables */ |
66 |
|
|
67 |
|
VARIABLE vv[] = { /* variable-value pairs */ |
68 |
|
{"ANIMATE", 2, 0, NULL, onevalue}, |
69 |
|
{"ARCHIVE", 2, 0, NULL, onevalue}, |
70 |
|
{"BASENAME", 3, 0, NULL, onevalue}, |
71 |
+ |
{"DBLUR", 2, 0, NULL, onevalue}, |
72 |
|
{"DIRECTORY", 3, 0, NULL, onevalue}, |
73 |
|
{"DISKSPACE", 3, 0, NULL, fltvalue}, |
74 |
|
{"END", 2, 0, NULL, intvalue}, |
95 |
|
|
96 |
|
struct { |
97 |
|
char host[64]; /* control host name */ |
98 |
< |
int pid; /* control process id */ |
98 |
> |
RT_PID pid; /* control process id */ |
99 |
|
char cfname[128]; /* control file name */ |
100 |
|
int rnext; /* next frame to render */ |
101 |
|
int fnext; /* next frame to filter */ |
119 |
|
char *arcfirst, *arcnext; /* pointers to first and next argument */ |
120 |
|
|
121 |
|
struct pslot { |
122 |
< |
int pid; /* process ID (0 if empty) */ |
122 |
> |
RT_PID pid; /* process ID (0 if empty) */ |
123 |
|
int fout; /* output frame number */ |
124 |
|
int (*rcvf)(); /* recover function */ |
125 |
|
} *pslot; /* process slots */ |
128 |
|
#define phostname(ps) ((ps)->hostname[0] ? (ps)->hostname : astat.host) |
129 |
|
PSERVER *lastpserver; /* last process server with error */ |
130 |
|
|
131 |
< |
static struct pslot * findpslot(int pid); |
131 |
> |
static struct pslot * findpslot(RT_PID pid); |
132 |
|
static void checkdir(void); |
133 |
|
static VIEW * getview(int n); |
134 |
|
|
135 |
|
static char * dirfile(char *df, register char *path); |
136 |
|
static char * getexp(int n); |
137 |
< |
static int getblur(double *bf); |
137 |
> |
static int getblur(double *mbf, double *dbf); |
138 |
|
static int getastat(void); |
139 |
|
static void getradfile(char *rfargs); |
140 |
|
static void badvalue(int vc); |
142 |
|
static int runcom(char *cs); |
143 |
|
static int pruncom(char *com, char *ppins, int maxcopies); |
144 |
|
static void bwait(int ncoms); |
145 |
< |
static int bruncom(char *com, int fout, int (*rf)()); |
145 |
> |
static RT_PID bruncom(char *com, int fout, int (*rf)()); |
146 |
|
static int serverdown(void); |
147 |
|
static pscompfunc donecom; |
148 |
|
static int countviews(void); |
218 |
|
animate(); |
219 |
|
/* all done */ |
220 |
|
if (vdef(NEXTANIM)) { |
221 |
+ |
char *fullp; |
222 |
|
argv[i] = vval(NEXTANIM); /* just change input file */ |
223 |
|
if (!silent) |
224 |
|
printargs(argc, argv, stdout); |
225 |
< |
if ((argv[0] = getpath(progname,getenv("PATH"),X_OK)) == NULL) |
226 |
< |
fprintf(stderr, "%s: command not found\n", progname); |
225 |
> |
fflush(stdout); |
226 |
> |
if ((fullp = getpath(argv[0],getenv("PATH"),X_OK)) == NULL) |
227 |
> |
fprintf(stderr, "%s: command not found\n", argv[0]); |
228 |
|
else |
229 |
< |
execv(progname, argv); |
229 |
> |
execv(fullp, argv); |
230 |
|
quit(1); |
231 |
|
} |
232 |
|
quit(0); |
233 |
< |
return 0; /* pro forma return */ |
233 |
> |
return(0); /* pro forma return */ |
234 |
|
userr: |
235 |
|
fprintf(stderr, "Usage: %s [-s][-n][-w][-e] anim_file\n", progname); |
236 |
|
quit(1); |
574 |
|
} |
575 |
|
/* figure # frames per batch */ |
576 |
|
d1 = mult*xres*mult*yres*4; /* space for orig. picture */ |
577 |
< |
if ((i=vint(INTERP)) || getblur(NULL) > 1) |
577 |
> |
if ((i=vint(INTERP)) || getblur(NULL, NULL) > 1) |
578 |
|
d1 += mult*xres*mult*yres*sizeof(float); /* Z-buffer */ |
579 |
|
d2 = xres*yres*4; /* space for final picture */ |
580 |
|
frames_batch = (i+1)*(vflt(DISKSPACE)*1048576.-d1)/(d1+i*d2); |
747 |
|
char *vfn |
748 |
|
) |
749 |
|
{ |
750 |
< |
double blurf; |
751 |
< |
int nblur = getblur(&blurf); |
750 |
> |
double mblurf, dblurf; |
751 |
> |
int nblur = getblur(&mblurf, &dblurf); |
752 |
|
char combuf[2048]; |
753 |
|
register char *inspoint; |
754 |
|
register int i; |
766 |
|
inspoint = combuf; |
767 |
|
while (*inspoint) inspoint++; |
768 |
|
if (nblur) { |
769 |
< |
sprintf(inspoint, " -pm %.3f", blurf/nblur); |
769 |
> |
sprintf(inspoint, " -pm %.3f", mblurf/nblur); |
770 |
|
while (*inspoint) inspoint++; |
771 |
+ |
sprintf(inspoint, " -pd %.3f", dblurf/nblur); |
772 |
+ |
while (*inspoint) inspoint++; |
773 |
|
} |
774 |
|
if (nblur > 1 || vint(INTERP)) { |
775 |
|
sprintf(inspoint, " -z %s.zbf", vval(BASENAME)); |
802 |
|
{ |
803 |
|
static int *rfrm; /* list of recovered frames */ |
804 |
|
static int nrfrms = 0; |
805 |
< |
double blurf; |
806 |
< |
int nblur = getblur(&blurf); |
805 |
> |
double mblurf, dblurf; |
806 |
> |
int nblur = getblur(&mblurf, &dblurf); |
807 |
|
char combuf[2048]; |
808 |
|
char fname[128]; |
809 |
|
register char *cp; |
822 |
|
cp = combuf; |
823 |
|
while (*cp) cp++; |
824 |
|
if (nblur) { |
825 |
< |
sprintf(cp, " -pm %.3f", blurf/nblur); |
825 |
> |
sprintf(cp, " -pm %.3f", mblurf/nblur); |
826 |
|
while (*cp) cp++; |
827 |
+ |
sprintf(cp, " -pd %.3f", dblurf/nblur); |
828 |
+ |
while (*cp) cp++; |
829 |
|
} |
830 |
|
if (nblur > 1 || vint(INTERP)) { |
831 |
|
sprintf(cp, " -z %s.zbf", fname); |
913 |
|
) |
914 |
|
{ |
915 |
|
static int iter = 0; |
916 |
< |
double blurf; |
917 |
< |
int nblur = getblur(&blurf); |
916 |
> |
double mblurf, dblurf; |
917 |
> |
int nblur = getblur(&mblurf, &dblurf); |
918 |
|
VIEW *vp = getview(frame); |
919 |
|
char *ep = getexp(frame); |
920 |
|
char fnbefore[128], fnafter[128], *fbase; |
973 |
|
if (usepinterp) { /* using pinterp */ |
974 |
|
if (rvr == 2 && recover(frseq[1])) /* recover after? */ |
975 |
|
return(1); |
976 |
< |
if (nblur > 1) { /* with pmblur */ |
976 |
> |
if (nblur > 1) { /* with pdmblur */ |
977 |
|
sprintf(fname0, "%s/vw0%c", vval(DIRECTORY), |
978 |
|
'a'+(iter%26)); |
979 |
|
sprintf(fname1, "%s/vw1%c", vval(DIRECTORY), |
1000 |
|
putc('\n', fp); fclose(fp); |
1001 |
|
} |
1002 |
|
sprintf(combuf, |
1003 |
< |
"(pmblur %.3f %d %s %s; rm -f %s %s) | pinterp -B -a", |
1004 |
< |
blurf, nblur, |
1003 |
> |
"(pmdblur %.3f %.3f %d %s %s; rm -f %s %s) | pinterp -B -a", |
1004 |
> |
mblurf, dblurf, nblur, |
1005 |
|
fname0, fname1, fname0, fname1); |
1006 |
|
iter++; |
1007 |
|
} else /* no blurring */ |
1195 |
|
|
1196 |
|
|
1197 |
|
static struct pslot * |
1198 |
< |
findpslot(int pid) /* find or allocate a process slot */ |
1198 |
> |
findpslot(RT_PID pid) /* find or allocate a process slot */ |
1199 |
|
{ |
1200 |
|
register struct pslot *psempty = NULL; |
1201 |
|
register int i; |
1269 |
|
} |
1270 |
|
|
1271 |
|
|
1272 |
< |
static int |
1272 |
> |
static RT_PID |
1273 |
|
bruncom( /* run a command in the background */ |
1274 |
|
char *com, |
1275 |
|
int fout, |
1276 |
|
int (*rf)() |
1277 |
|
) |
1278 |
|
{ |
1279 |
< |
int pid; |
1279 |
> |
RT_PID pid; |
1280 |
|
register struct pslot *psl; |
1281 |
|
|
1282 |
|
if (noaction) { |
1289 |
|
bwait(1); |
1290 |
|
if (!silent) { /* echo command */ |
1291 |
|
PSERVER *ps; |
1292 |
< |
int psn = pid; |
1292 |
> |
RT_PID psn = pid; |
1293 |
|
ps = findjob(&psn); |
1294 |
|
printf("\t%s\n", com); |
1295 |
|
printf("\tProcess started on %s\n", phostname(ps)); |
1453 |
|
|
1454 |
|
|
1455 |
|
static int |
1456 |
< |
getblur(double *bf) /* get # blur samples (and fraction) */ |
1456 |
> |
getblur(double *mbf, double *dbf) /* get # blur samples (and fraction) */ |
1457 |
|
{ |
1458 |
< |
double blurf; |
1459 |
< |
int nblur; |
1458 |
> |
double mblurf, dblurf; |
1459 |
> |
int nmblur, ndblur; |
1460 |
|
char *s; |
1461 |
< |
|
1462 |
< |
if (!vdef(MBLUR)) { |
1463 |
< |
if (bf != NULL) |
1464 |
< |
*bf = 0.0; |
1465 |
< |
return(0); |
1466 |
< |
} |
1467 |
< |
blurf = atof(vval(MBLUR)); |
1468 |
< |
if (blurf < 0.0) |
1469 |
< |
blurf = 0.0; |
1470 |
< |
if (bf != NULL) |
1471 |
< |
*bf = blurf; |
1472 |
< |
if (blurf <= FTINY) |
1473 |
< |
return(0); |
1474 |
< |
s = sskip(vval(MBLUR)); |
1475 |
< |
if (!*s) |
1476 |
< |
return(DEF_NBLUR); |
1477 |
< |
nblur = atoi(s); |
1478 |
< |
if (nblur <= 0) |
1461 |
> |
/* get motion blur */ |
1462 |
> |
if (!vdef(MBLUR) || (mblurf = atof(vval(MBLUR))) < 0.0) |
1463 |
> |
mblurf = 0.0; |
1464 |
> |
if (mbf != NULL) |
1465 |
> |
*mbf = mblurf; |
1466 |
> |
if (mblurf <= FTINY) |
1467 |
> |
nmblur = 0; |
1468 |
> |
else if (!*(s = sskip(vval(MBLUR)))) |
1469 |
> |
nmblur = DEF_NBLUR; |
1470 |
> |
else if ((nmblur = atoi(s)) <= 0) |
1471 |
> |
nmblur = 1; |
1472 |
> |
/* get depth-of-field blur */ |
1473 |
> |
if (!vdef(DBLUR) || (dblurf = atof(vval(DBLUR))) < 0.0) |
1474 |
> |
dblurf = 0.0; |
1475 |
> |
if (dbf != NULL) |
1476 |
> |
*dbf = dblurf; |
1477 |
> |
if (dblurf <= FTINY) |
1478 |
> |
ndblur = 0; |
1479 |
> |
else if (!*(s = sskip(vval(DBLUR)))) |
1480 |
> |
ndblur = DEF_NBLUR; |
1481 |
> |
else if ((ndblur = atoi(s)) <= 0) |
1482 |
> |
ndblur = 1; |
1483 |
> |
if ((nmblur == 1) & (ndblur == 1)) |
1484 |
|
return(1); |
1485 |
< |
return(nblur); |
1485 |
> |
/* return combined samples */ |
1486 |
> |
return(nmblur + ndblur); |
1487 |
|
} |