1 |
– |
/* Copyright (c) 1998 Silicon Graphics, Inc. */ |
2 |
– |
|
1 |
|
#ifndef lint |
2 |
< |
static char SCCSid[] = "$SunId$ SGI"; |
2 |
> |
static const char RCSid[] = "$Id$"; |
3 |
|
#endif |
6 |
– |
|
4 |
|
/* |
5 |
|
* Radiance animation control program |
6 |
+ |
* |
7 |
+ |
* The main difference between this program and ranimove is that |
8 |
+ |
* we have many optimizations here for camera motion in static |
9 |
+ |
* environments, calling rpict and pinterp on multiple processors, |
10 |
+ |
* where ranimove puts its emphasis on object motion, and does |
11 |
+ |
* not use any external programs for image generation. |
12 |
+ |
* |
13 |
+ |
* See the ranimate(1) man page for further details. |
14 |
|
*/ |
15 |
|
|
16 |
+ |
#include "copyright.h" |
17 |
+ |
|
18 |
|
#include "standard.h" |
19 |
|
#include <ctype.h> |
13 |
– |
#include <sys/types.h> |
20 |
|
#include <sys/stat.h> |
21 |
|
#include "view.h" |
22 |
|
#include "vars.h" |
23 |
|
#include "netproc.h" |
24 |
+ |
/* default blur samples */ |
25 |
+ |
#ifndef DEF_NBLUR |
26 |
+ |
#define DEF_NBLUR 5 |
27 |
+ |
#endif |
28 |
|
/* default remote shell */ |
29 |
|
#ifdef _AUX_SOURCE |
30 |
|
#define REMSH "remsh" |
41 |
|
#define EXPOSURE 6 /* how to compute exposure */ |
42 |
|
#define HOST 7 /* rendering host machine */ |
43 |
|
#define INTERP 8 /* # frames to interpolate */ |
44 |
< |
#define MBLUR 9 /* samples for motion blur */ |
44 |
> |
#define MBLUR 9 /* motion blur parameters */ |
45 |
|
#define NEXTANIM 10 /* next animation file */ |
46 |
|
#define OCTREE 11 /* octree file name */ |
47 |
|
#define OVERSAMP 12 /* # times to oversample image */ |
126 |
|
|
127 |
|
VIEW *getview(); |
128 |
|
char *getexp(), *dirfile(); |
129 |
+ |
int getblur(); |
130 |
|
|
131 |
< |
extern time_t fdate(), time(); |
131 |
> |
extern time_t time(); |
132 |
|
|
133 |
|
|
134 |
|
main(argc, argv) |
523 |
|
progname, vnam(INTERP)); |
524 |
|
vval(INTERP) = "0"; |
525 |
|
} |
526 |
< |
if (atoi(vval(MBLUR))) { /* can't handle this yet */ |
526 |
> |
if (strcmp(vval(MBLUR),"0")) { /* can't handle this */ |
527 |
|
if (!nowarn) |
528 |
|
fprintf(stderr, |
529 |
|
"%s: resetting %s=0 for animation\n", |
533 |
|
} |
534 |
|
/* figure # frames per batch */ |
535 |
|
d1 = mult*xres*mult*yres*4; /* space for orig. picture */ |
536 |
< |
if ((i=vint(INTERP)) || atoi(vval(MBLUR))) |
536 |
> |
if ((i=vint(INTERP)) || getblur(NULL) > 1) |
537 |
|
d1 += mult*xres*mult*yres*sizeof(float); /* Z-buffer */ |
538 |
|
d2 = xres*yres*4; /* space for final picture */ |
539 |
|
frames_batch = (i+1)*(vflt(DISKSPACE)*1048576.-d1)/(d1+i*d2); |
629 |
|
if (astat.tnext < astat.fnext) /* other work to do first */ |
630 |
|
return; |
631 |
|
/* filter each view */ |
632 |
< |
for (i = astat.fnext; i < astat.rnext; i++) { |
633 |
< |
if ((vp = getview(i)) == NULL) { /* get view i */ |
634 |
< |
fprintf(stderr, |
624 |
< |
"%s: unexpected error reading view for frame %d\n", |
625 |
< |
progname, i); |
626 |
< |
quit(1); |
627 |
< |
} |
628 |
< |
dofilt(i, vp, getexp(i), 0); /* filter frame */ |
629 |
< |
} |
632 |
> |
for (i = astat.fnext; i < astat.rnext; i++) |
633 |
> |
dofilt(i, 0); |
634 |
> |
|
635 |
|
bwait(0); /* wait for filter processes */ |
636 |
|
archive(); /* archive originals */ |
637 |
|
astat.fnext = i; /* update status */ |
701 |
|
int first, last; |
702 |
|
char *vfn; |
703 |
|
{ |
704 |
+ |
double blurf; |
705 |
+ |
int nblur = getblur(&blurf); |
706 |
|
char combuf[2048]; |
707 |
< |
char *inspoint; |
707 |
> |
register char *inspoint; |
708 |
|
register int i; |
709 |
|
|
710 |
|
if (!noaction && vint(INTERP)) /* create dummy frames */ |
717 |
|
/* create command */ |
718 |
|
sprintf(combuf, "rpict%s%s -w0", rendopt, |
719 |
|
viewopt(getview(first>1 ? first-1 : 1))); |
720 |
< |
if (vint(INTERP) || atoi(vval(MBLUR))) |
721 |
< |
sprintf(combuf+strlen(combuf), " -z %s.zbf", vval(BASENAME)); |
722 |
< |
sprintf(combuf+strlen(combuf), " -o %s.unf %s -S %d", |
720 |
> |
inspoint = combuf; |
721 |
> |
while (*inspoint) inspoint++; |
722 |
> |
if (nblur) { |
723 |
> |
sprintf(inspoint, " -pm %.3f", blurf/nblur); |
724 |
> |
while (*inspoint) inspoint++; |
725 |
> |
} |
726 |
> |
if (nblur > 1 || vint(INTERP)) { |
727 |
> |
sprintf(inspoint, " -z %s.zbf", vval(BASENAME)); |
728 |
> |
while (*inspoint) inspoint++; |
729 |
> |
} |
730 |
> |
sprintf(inspoint, " -o %s.unf %s -S %d", |
731 |
|
vval(BASENAME), rresopt, first); |
732 |
< |
inspoint = combuf + strlen(combuf); |
732 |
> |
while (*inspoint) inspoint++; |
733 |
|
sprintf(inspoint, " %s < %s", vval(OCTREE), vfn); |
734 |
|
/* run in parallel */ |
735 |
|
i = (last-first+1)/(vint(INTERP)+1); |
755 |
|
{ |
756 |
|
static int *rfrm; /* list of recovered frames */ |
757 |
|
static int nrfrms = 0; |
758 |
+ |
double blurf; |
759 |
+ |
int nblur = getblur(&blurf); |
760 |
|
char combuf[2048]; |
761 |
|
char fname[128]; |
762 |
|
register char *cp; |
772 |
|
vval(ANIMATE), frame, rendopt); |
773 |
|
else |
774 |
|
sprintf(combuf, "rpict%s -w0", rendopt); |
775 |
< |
cp = combuf + strlen(combuf); |
776 |
< |
if (vint(INTERP) || atoi(vval(MBLUR))) { |
775 |
> |
cp = combuf; |
776 |
> |
while (*cp) cp++; |
777 |
> |
if (nblur) { |
778 |
> |
sprintf(cp, " -pm %.3f", blurf/nblur); |
779 |
> |
while (*cp) cp++; |
780 |
> |
} |
781 |
> |
if (nblur > 1 || vint(INTERP)) { |
782 |
|
sprintf(cp, " -z %s.zbf", fname); |
783 |
|
while (*cp) cp++; |
784 |
|
} |
792 |
|
return(1); |
793 |
|
/* add frame to recovered list */ |
794 |
|
if (nrfrms) |
795 |
< |
rfrm = (int *)realloc((char *)rfrm, (nrfrms+1)*sizeof(int)); |
795 |
> |
rfrm = (int *)realloc((void *)rfrm, (nrfrms+1)*sizeof(int)); |
796 |
|
else |
797 |
|
rfrm = (int *)malloc(sizeof(int)); |
798 |
|
if (rfrm == NULL) { |
808 |
|
frecover(frame) /* recover filtered frame */ |
809 |
|
int frame; |
810 |
|
{ |
811 |
< |
VIEW *vp; |
790 |
< |
char *ex; |
791 |
< |
|
792 |
< |
vp = getview(frame); |
793 |
< |
ex = getexp(frame); |
794 |
< |
if (dofilt(frame, vp, ex, 2) && dofilt(frame, vp, ex, 1)) |
811 |
> |
if (dofilt(frame, 2) && dofilt(frame, 1)) |
812 |
|
return(1); |
813 |
|
return(0); |
814 |
|
} |
858 |
|
|
859 |
|
|
860 |
|
int |
861 |
< |
dofilt(frame, vp, ep, rvr) /* filter frame */ |
861 |
> |
dofilt(frame, rvr) /* filter frame */ |
862 |
|
int frame; |
846 |
– |
VIEW *vp; |
847 |
– |
char *ep; |
863 |
|
int rvr; |
864 |
|
{ |
865 |
|
extern int frecover(); |
866 |
|
static int iter = 0; |
867 |
+ |
double blurf; |
868 |
+ |
int nblur = getblur(&blurf); |
869 |
+ |
VIEW *vp = getview(frame); |
870 |
+ |
char *ep = getexp(frame); |
871 |
|
char fnbefore[128], fnafter[128], *fbase; |
872 |
|
char combuf[1024], fname0[128], fname1[128]; |
873 |
|
int usepinterp, usepfilt, nora_rgbe; |
874 |
|
int frseq[2]; |
875 |
|
/* check what is needed */ |
876 |
< |
usepinterp = atoi(vval(MBLUR)); |
876 |
> |
if (vp == NULL) { |
877 |
> |
fprintf(stderr, |
878 |
> |
"%s: unexpected error reading view for frame %d\n", |
879 |
> |
progname, frame); |
880 |
> |
quit(1); |
881 |
> |
} |
882 |
> |
if (ep == NULL) { |
883 |
> |
fprintf(stderr, |
884 |
> |
"%s: unexpected error reading exposure for frame %d\n", |
885 |
> |
progname, frame); |
886 |
> |
quit(1); |
887 |
> |
} |
888 |
> |
usepinterp = (nblur > 1); |
889 |
|
usepfilt = pfiltalways | ep==NULL; |
890 |
|
if (ep != NULL && !strcmp(ep, "1")) |
891 |
|
ep = "+0"; |
930 |
|
if (usepinterp) { /* using pinterp */ |
931 |
|
if (rvr == 2 && recover(frseq[1])) /* recover after? */ |
932 |
|
return(1); |
933 |
< |
if (atoi(vval(MBLUR))) { |
933 |
> |
if (nblur > 1) { /* with pmblur */ |
934 |
|
sprintf(fname0, "%s/vw0%c", vval(DIRECTORY), |
935 |
|
'a'+(iter%26)); |
936 |
|
sprintf(fname1, "%s/vw1%c", vval(DIRECTORY), |
957 |
|
putc('\n', fp); fclose(fp); |
958 |
|
} |
959 |
|
sprintf(combuf, |
960 |
< |
"(pmblur %s %d %s %s; rm -f %s %s) | pinterp -B", |
961 |
< |
*sskip(vval(MBLUR)) ? sskip2(vval(MBLUR),1) : "1", |
931 |
< |
atoi(vval(MBLUR)), |
960 |
> |
"(pmblur %.3f %d %s %s; rm -f %s %s) | pinterp -B -a", |
961 |
> |
blurf, nblur, |
962 |
|
fname0, fname1, fname0, fname1); |
963 |
|
iter++; |
964 |
|
} else /* no blurring */ |
972 |
|
if (usepfilt) |
973 |
|
sprintf(combuf+strlen(combuf), " %s", rresopt); |
974 |
|
else |
975 |
< |
sprintf(combuf+strlen(combuf), " %s -e %s", |
975 |
> |
sprintf(combuf+strlen(combuf), " -a %s -e %s", |
976 |
|
fresopt, ep); |
977 |
|
sprintf(combuf+strlen(combuf), " %s.unf %s.zbf", |
978 |
|
fnbefore, fnbefore); |
1096 |
|
if (n == 0) { /* signal to close file */ |
1097 |
|
if (expfp != NULL) { |
1098 |
|
fclose(expfp); |
1099 |
< |
free((char *)exppos); |
1099 |
> |
free((void *)exppos); |
1100 |
|
expfp = NULL; |
1101 |
|
} |
1102 |
|
return(NULL); |
1301 |
|
strcpy(com1=buf, com); /* build -PP command */ |
1302 |
|
sprintf(com1+(ppins-com), " -PP %s/%s.persist", |
1303 |
|
vval(DIRECTORY), phostname(ps)); |
1304 |
+ |
unlink(com1+(ppins-com)+5); |
1305 |
|
strcat(com1, ppins); |
1306 |
|
} else |
1307 |
|
com1 = com; |
1362 |
|
char *fn; |
1363 |
|
{ |
1364 |
|
if (!silent) |
1365 |
< |
#ifdef MSDOS |
1365 |
> |
#ifdef _WIN32 |
1366 |
|
printf("\tdel %s\n", fn); |
1367 |
|
#else |
1368 |
|
printf("\trm -f %s\n", fn); |
1403 |
|
} else |
1404 |
|
df[0] = '\0'; |
1405 |
|
return(path+psep+1); |
1406 |
+ |
} |
1407 |
+ |
|
1408 |
+ |
|
1409 |
+ |
int |
1410 |
+ |
getblur(double *bf) /* get # blur samples (and fraction) */ |
1411 |
+ |
{ |
1412 |
+ |
double blurf; |
1413 |
+ |
int nblur; |
1414 |
+ |
char *s; |
1415 |
+ |
|
1416 |
+ |
if (!vdef(MBLUR)) { |
1417 |
+ |
if (bf != NULL) |
1418 |
+ |
*bf = 0.0; |
1419 |
+ |
return(0); |
1420 |
+ |
} |
1421 |
+ |
blurf = atof(vval(MBLUR)); |
1422 |
+ |
if (blurf < 0.0) |
1423 |
+ |
blurf = 0.0; |
1424 |
+ |
if (bf != NULL) |
1425 |
+ |
*bf = blurf; |
1426 |
+ |
if (blurf <= FTINY) |
1427 |
+ |
return(0); |
1428 |
+ |
s = sskip(vval(MBLUR)); |
1429 |
+ |
if (!*s) |
1430 |
+ |
return(DEF_NBLUR); |
1431 |
+ |
nblur = atoi(s); |
1432 |
+ |
if (nblur <= 0) |
1433 |
+ |
return(1); |
1434 |
+ |
return(nblur); |
1435 |
|
} |