1 |
– |
/* Copyright (c) 1996 Regents of the University of California */ |
2 |
– |
|
1 |
|
#ifndef lint |
2 |
< |
static char SCCSid[] = "$SunId$ LBL"; |
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) |
485 |
|
sprintf(cp, ")[ \t]*=' > %s/radset.var", vval(DIRECTORY)); |
486 |
|
cp += 11; /* point to file name */ |
487 |
|
} |
488 |
< |
if (system(combuf)) { |
478 |
< |
fprintf(stderr, "%s: error executing rad command:\n\t%s\n", |
479 |
< |
progname, combuf); |
480 |
< |
quit(1); |
481 |
< |
} |
488 |
> |
system(combuf); /* ignore exit code */ |
489 |
|
if (pippt == NULL) { /* load variables and remove file */ |
490 |
|
loadvars(cp); |
491 |
|
unlink(cp); |
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); |
707 |
|
int first, last; |
708 |
|
char *vfn; |
709 |
|
{ |
710 |
+ |
double blurf; |
711 |
+ |
int nblur = getblur(&blurf); |
712 |
|
char combuf[2048]; |
713 |
< |
char *inspoint; |
713 |
> |
register char *inspoint; |
714 |
|
register int i; |
715 |
|
|
716 |
|
if (!noaction && vint(INTERP)) /* create dummy frames */ |
723 |
|
/* create command */ |
724 |
|
sprintf(combuf, "rpict%s%s -w0", rendopt, |
725 |
|
viewopt(getview(first>1 ? first-1 : 1))); |
726 |
< |
if (vint(INTERP) || atoi(vval(MBLUR))) |
727 |
< |
sprintf(combuf+strlen(combuf), " -z %s.zbf", vval(BASENAME)); |
728 |
< |
sprintf(combuf+strlen(combuf), " -o %s.unf %s -S %d", |
726 |
> |
inspoint = combuf; |
727 |
> |
while (*inspoint) inspoint++; |
728 |
> |
if (nblur) { |
729 |
> |
sprintf(inspoint, " -pm %.3f", blurf/nblur); |
730 |
> |
while (*inspoint) inspoint++; |
731 |
> |
} |
732 |
> |
if (nblur > 1 || vint(INTERP)) { |
733 |
> |
sprintf(inspoint, " -z %s.zbf", vval(BASENAME)); |
734 |
> |
while (*inspoint) inspoint++; |
735 |
> |
} |
736 |
> |
sprintf(inspoint, " -o %s.unf %s -S %d", |
737 |
|
vval(BASENAME), rresopt, first); |
738 |
< |
inspoint = combuf + strlen(combuf); |
738 |
> |
while (*inspoint) inspoint++; |
739 |
|
sprintf(inspoint, " %s < %s", vval(OCTREE), vfn); |
740 |
|
/* run in parallel */ |
741 |
|
i = (last-first+1)/(vint(INTERP)+1); |
761 |
|
{ |
762 |
|
static int *rfrm; /* list of recovered frames */ |
763 |
|
static int nrfrms = 0; |
764 |
+ |
double blurf; |
765 |
+ |
int nblur = getblur(&blurf); |
766 |
|
char combuf[2048]; |
767 |
|
char fname[128]; |
768 |
|
register char *cp; |
778 |
|
vval(ANIMATE), frame, rendopt); |
779 |
|
else |
780 |
|
sprintf(combuf, "rpict%s -w0", rendopt); |
781 |
< |
cp = combuf + strlen(combuf); |
782 |
< |
if (vint(INTERP) || atoi(vval(MBLUR))) { |
781 |
> |
cp = combuf; |
782 |
> |
while (*cp) cp++; |
783 |
> |
if (nblur) { |
784 |
> |
sprintf(cp, " -pm %.3f", blurf/nblur); |
785 |
> |
while (*cp) cp++; |
786 |
> |
} |
787 |
> |
if (nblur > 1 || vint(INTERP)) { |
788 |
|
sprintf(cp, " -z %s.zbf", fname); |
789 |
|
while (*cp) cp++; |
790 |
|
} |
798 |
|
return(1); |
799 |
|
/* add frame to recovered list */ |
800 |
|
if (nrfrms) |
801 |
< |
rfrm = (int *)realloc((char *)rfrm, (nrfrms+1)*sizeof(int)); |
801 |
> |
rfrm = (int *)realloc((void *)rfrm, (nrfrms+1)*sizeof(int)); |
802 |
|
else |
803 |
|
rfrm = (int *)malloc(sizeof(int)); |
804 |
|
if (rfrm == NULL) { |
877 |
|
{ |
878 |
|
extern int frecover(); |
879 |
|
static int iter = 0; |
880 |
+ |
double blurf; |
881 |
+ |
int nblur = getblur(&blurf); |
882 |
|
char fnbefore[128], fnafter[128], *fbase; |
883 |
|
char combuf[1024], fname0[128], fname1[128]; |
884 |
|
int usepinterp, usepfilt, nora_rgbe; |
885 |
|
int frseq[2]; |
886 |
|
/* check what is needed */ |
887 |
< |
usepinterp = atoi(vval(MBLUR)); |
887 |
> |
usepinterp = (nblur > 1); |
888 |
|
usepfilt = pfiltalways | ep==NULL; |
889 |
|
if (ep != NULL && !strcmp(ep, "1")) |
890 |
|
ep = "+0"; |
929 |
|
if (usepinterp) { /* using pinterp */ |
930 |
|
if (rvr == 2 && recover(frseq[1])) /* recover after? */ |
931 |
|
return(1); |
932 |
< |
if (atoi(vval(MBLUR))) { |
932 |
> |
if (nblur > 1) { /* with pmblur */ |
933 |
|
sprintf(fname0, "%s/vw0%c", vval(DIRECTORY), |
934 |
|
'a'+(iter%26)); |
935 |
|
sprintf(fname1, "%s/vw1%c", vval(DIRECTORY), |
956 |
|
putc('\n', fp); fclose(fp); |
957 |
|
} |
958 |
|
sprintf(combuf, |
959 |
< |
"(pmblur %s %d %s %s; rm -f %s %s) | pinterp -B", |
960 |
< |
*sskip(vval(MBLUR)) ? sskip2(vval(MBLUR),1) : "1", |
935 |
< |
atoi(vval(MBLUR)), |
959 |
> |
"(pmblur %.3f %d %s %s; rm -f %s %s) | pinterp -B -a", |
960 |
> |
blurf, nblur, |
961 |
|
fname0, fname1, fname0, fname1); |
962 |
|
iter++; |
963 |
|
} else /* no blurring */ |
971 |
|
if (usepfilt) |
972 |
|
sprintf(combuf+strlen(combuf), " %s", rresopt); |
973 |
|
else |
974 |
< |
sprintf(combuf+strlen(combuf), " %s -e %s", |
974 |
> |
sprintf(combuf+strlen(combuf), " -a %s -e %s", |
975 |
|
fresopt, ep); |
976 |
|
sprintf(combuf+strlen(combuf), " %s.unf %s.zbf", |
977 |
|
fnbefore, fnbefore); |
1095 |
|
if (n == 0) { /* signal to close file */ |
1096 |
|
if (expfp != NULL) { |
1097 |
|
fclose(expfp); |
1098 |
< |
free((char *)exppos); |
1098 |
> |
free((void *)exppos); |
1099 |
|
expfp = NULL; |
1100 |
|
} |
1101 |
|
return(NULL); |
1401 |
|
} else |
1402 |
|
df[0] = '\0'; |
1403 |
|
return(path+psep+1); |
1404 |
+ |
} |
1405 |
+ |
|
1406 |
+ |
|
1407 |
+ |
int |
1408 |
+ |
getblur(double *bf) /* get # blur samples (and fraction) */ |
1409 |
+ |
{ |
1410 |
+ |
double blurf; |
1411 |
+ |
int nblur; |
1412 |
+ |
char *s; |
1413 |
+ |
|
1414 |
+ |
if (!vdef(MBLUR)) { |
1415 |
+ |
if (bf != NULL) |
1416 |
+ |
*bf = 0.0; |
1417 |
+ |
return(0); |
1418 |
+ |
} |
1419 |
+ |
blurf = atof(vval(MBLUR)); |
1420 |
+ |
if (blurf < 0.0) |
1421 |
+ |
blurf = 0.0; |
1422 |
+ |
if (bf != NULL) |
1423 |
+ |
*bf = blurf; |
1424 |
+ |
if (blurf <= FTINY) |
1425 |
+ |
return(0); |
1426 |
+ |
s = sskip(vval(MBLUR)); |
1427 |
+ |
if (!*s) |
1428 |
+ |
return(DEF_NBLUR); |
1429 |
+ |
nblur = atoi(s); |
1430 |
+ |
if (nblur <= 0) |
1431 |
+ |
return(1); |
1432 |
+ |
return(nblur); |
1433 |
|
} |