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 |
+ |
/* ==================================================================== |
17 |
+ |
* The Radiance Software License, Version 1.0 |
18 |
+ |
* |
19 |
+ |
* Copyright (c) 1990 - 2002 The Regents of the University of California, |
20 |
+ |
* through Lawrence Berkeley National Laboratory. All rights reserved. |
21 |
+ |
* |
22 |
+ |
* Redistribution and use in source and binary forms, with or without |
23 |
+ |
* modification, are permitted provided that the following conditions |
24 |
+ |
* are met: |
25 |
+ |
* |
26 |
+ |
* 1. Redistributions of source code must retain the above copyright |
27 |
+ |
* notice, this list of conditions and the following disclaimer. |
28 |
+ |
* |
29 |
+ |
* 2. Redistributions in binary form must reproduce the above copyright |
30 |
+ |
* notice, this list of conditions and the following disclaimer in |
31 |
+ |
* the documentation and/or other materials provided with the |
32 |
+ |
* distribution. |
33 |
+ |
* |
34 |
+ |
* 3. The end-user documentation included with the redistribution, |
35 |
+ |
* if any, must include the following acknowledgment: |
36 |
+ |
* "This product includes Radiance software |
37 |
+ |
* (http://radsite.lbl.gov/) |
38 |
+ |
* developed by the Lawrence Berkeley National Laboratory |
39 |
+ |
* (http://www.lbl.gov/)." |
40 |
+ |
* Alternately, this acknowledgment may appear in the software itself, |
41 |
+ |
* if and wherever such third-party acknowledgments normally appear. |
42 |
+ |
* |
43 |
+ |
* 4. The names "Radiance," "Lawrence Berkeley National Laboratory" |
44 |
+ |
* and "The Regents of the University of California" must |
45 |
+ |
* not be used to endorse or promote products derived from this |
46 |
+ |
* software without prior written permission. For written |
47 |
+ |
* permission, please contact [email protected]. |
48 |
+ |
* |
49 |
+ |
* 5. Products derived from this software may not be called "Radiance", |
50 |
+ |
* nor may "Radiance" appear in their name, without prior written |
51 |
+ |
* permission of Lawrence Berkeley National Laboratory. |
52 |
+ |
* |
53 |
+ |
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED |
54 |
+ |
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
55 |
+ |
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
56 |
+ |
* DISCLAIMED. IN NO EVENT SHALL Lawrence Berkeley National Laboratory OR |
57 |
+ |
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
58 |
+ |
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
59 |
+ |
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF |
60 |
+ |
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
61 |
+ |
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
62 |
+ |
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT |
63 |
+ |
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
64 |
+ |
* SUCH DAMAGE. |
65 |
+ |
* ==================================================================== |
66 |
+ |
* |
67 |
+ |
* This software consists of voluntary contributions made by many |
68 |
+ |
* individuals on behalf of Lawrence Berkeley National Laboratory. For more |
69 |
+ |
* information on Lawrence Berkeley National Laboratory, please see |
70 |
+ |
* <http://www.lbl.gov/>. |
71 |
+ |
*/ |
72 |
+ |
|
73 |
|
#include "standard.h" |
74 |
|
#include <ctype.h> |
13 |
– |
#include <sys/types.h> |
75 |
|
#include <sys/stat.h> |
76 |
|
#include "view.h" |
77 |
|
#include "vars.h" |
78 |
|
#include "netproc.h" |
79 |
+ |
/* default blur samples */ |
80 |
+ |
#ifndef DEF_NBLUR |
81 |
+ |
#define DEF_NBLUR 5 |
82 |
+ |
#endif |
83 |
|
/* default remote shell */ |
84 |
|
#ifdef _AUX_SOURCE |
85 |
|
#define REMSH "remsh" |
86 |
|
#else |
87 |
|
#define REMSH "rsh" |
88 |
|
#endif |
89 |
< |
/* input variables */ |
90 |
< |
#define HOST 0 /* rendering host machine */ |
91 |
< |
#define RENDER 1 /* rendering options */ |
92 |
< |
#define PFILT 2 /* pfilt options */ |
93 |
< |
#define PINTERP 3 /* pinterp options */ |
94 |
< |
#define OCTREE 4 /* octree file name */ |
95 |
< |
#define DIRECTORY 5 /* working (sub)directory */ |
96 |
< |
#define BASENAME 6 /* output image base name */ |
97 |
< |
#define VIEWFILE 7 /* animation frame views */ |
98 |
< |
#define START 8 /* starting frame number */ |
99 |
< |
#define END 9 /* ending frame number */ |
100 |
< |
#define RIF 10 /* rad input file */ |
101 |
< |
#define NEXTANIM 11 /* next animation file */ |
102 |
< |
#define ANIMATE 12 /* animation command */ |
103 |
< |
#define TRANSFER 13 /* frame transfer command */ |
104 |
< |
#define ARCHIVE 14 /* archiving command */ |
105 |
< |
#define INTERP 15 /* # frames to interpolate */ |
106 |
< |
#define OVERSAMP 16 /* # times to oversample image */ |
107 |
< |
#define MBLUR 17 /* samples for motion blur */ |
108 |
< |
#define RTRACE 18 /* use rtrace with pinterp? */ |
109 |
< |
#define DISKSPACE 19 /* how much disk space to use */ |
110 |
< |
#define RESOLUTION 20 /* desired final resolution */ |
111 |
< |
#define EXPOSURE 21 /* how to compute exposure */ |
112 |
< |
#define RSH 22 /* remote shell script or program */ |
89 |
> |
/* input variables (alphabetical by name) */ |
90 |
> |
#define ANIMATE 0 /* animation command */ |
91 |
> |
#define ARCHIVE 1 /* archiving command */ |
92 |
> |
#define BASENAME 2 /* output image base name */ |
93 |
> |
#define DIRECTORY 3 /* working (sub)directory */ |
94 |
> |
#define DISKSPACE 4 /* how much disk space to use */ |
95 |
> |
#define END 5 /* ending frame number */ |
96 |
> |
#define EXPOSURE 6 /* how to compute exposure */ |
97 |
> |
#define HOST 7 /* rendering host machine */ |
98 |
> |
#define INTERP 8 /* # frames to interpolate */ |
99 |
> |
#define MBLUR 9 /* motion blur parameters */ |
100 |
> |
#define NEXTANIM 10 /* next animation file */ |
101 |
> |
#define OCTREE 11 /* octree file name */ |
102 |
> |
#define OVERSAMP 12 /* # times to oversample image */ |
103 |
> |
#define PFILT 13 /* pfilt options */ |
104 |
> |
#define PINTERP 14 /* pinterp options */ |
105 |
> |
#define RENDER 15 /* rendering options */ |
106 |
> |
#define RESOLUTION 16 /* desired final resolution */ |
107 |
> |
#define RIF 17 /* rad input file */ |
108 |
> |
#define RSH 18 /* remote shell script or program */ |
109 |
> |
#define RTRACE 19 /* use rtrace with pinterp? */ |
110 |
> |
#define START 20 /* starting frame number */ |
111 |
> |
#define TRANSFER 21 /* frame transfer command */ |
112 |
> |
#define VIEWFILE 22 /* animation frame views */ |
113 |
|
|
114 |
|
int NVARS = 23; /* total number of variables */ |
115 |
|
|
116 |
|
VARIABLE vv[] = { /* variable-value pairs */ |
52 |
– |
{"host", 4, 0, NULL, NULL}, |
53 |
– |
{"render", 3, 0, NULL, catvalues}, |
54 |
– |
{"pfilt", 2, 0, NULL, catvalues}, |
55 |
– |
{"pinterp", 2, 0, NULL, catvalues}, |
56 |
– |
{"OCTREE", 3, 0, NULL, onevalue}, |
57 |
– |
{"DIRECTORY", 3, 0, NULL, onevalue}, |
58 |
– |
{"BASENAME", 3, 0, NULL, onevalue}, |
59 |
– |
{"VIEWFILE", 2, 0, NULL, onevalue}, |
60 |
– |
{"START", 2, 0, NULL, intvalue}, |
61 |
– |
{"END", 2, 0, NULL, intvalue}, |
62 |
– |
{"RIF", 3, 0, NULL, onevalue}, |
63 |
– |
{"NEXTANIM", 3, 0, NULL, onevalue}, |
117 |
|
{"ANIMATE", 2, 0, NULL, onevalue}, |
65 |
– |
{"TRANSFER", 2, 0, NULL, onevalue}, |
118 |
|
{"ARCHIVE", 2, 0, NULL, onevalue}, |
119 |
+ |
{"BASENAME", 3, 0, NULL, onevalue}, |
120 |
+ |
{"DIRECTORY", 3, 0, NULL, onevalue}, |
121 |
+ |
{"DISKSPACE", 3, 0, NULL, fltvalue}, |
122 |
+ |
{"END", 2, 0, NULL, intvalue}, |
123 |
+ |
{"EXPOSURE", 3, 0, NULL, onevalue}, |
124 |
+ |
{"host", 4, 0, NULL, NULL}, |
125 |
|
{"INTERPOLATE", 3, 0, NULL, intvalue}, |
68 |
– |
{"OVERSAMPLE", 2, 0, NULL, fltvalue}, |
126 |
|
{"MBLUR", 2, 0, NULL, onevalue}, |
127 |
< |
{"RTRACE", 2, 0, NULL, boolvalue}, |
128 |
< |
{"DISKSPACE", 3, 0, NULL, fltvalue}, |
127 |
> |
{"NEXTANIM", 3, 0, NULL, onevalue}, |
128 |
> |
{"OCTREE", 3, 0, NULL, onevalue}, |
129 |
> |
{"OVERSAMPLE", 2, 0, NULL, fltvalue}, |
130 |
> |
{"pfilt", 2, 0, NULL, catvalues}, |
131 |
> |
{"pinterp", 2, 0, NULL, catvalues}, |
132 |
> |
{"render", 3, 0, NULL, catvalues}, |
133 |
|
{"RESOLUTION", 3, 0, NULL, onevalue}, |
134 |
< |
{"EXPOSURE", 3, 0, NULL, onevalue}, |
134 |
> |
{"RIF", 3, 0, NULL, onevalue}, |
135 |
|
{"RSH", 3, 0, NULL, onevalue}, |
136 |
+ |
{"RTRACE", 2, 0, NULL, boolvalue}, |
137 |
+ |
{"START", 2, 0, NULL, intvalue}, |
138 |
+ |
{"TRANSFER", 2, 0, NULL, onevalue}, |
139 |
+ |
{"VIEWFILE", 2, 0, NULL, onevalue}, |
140 |
|
}; |
141 |
|
|
142 |
|
#define SFNAME "STATUS" /* status file name */ |
158 |
|
int noaction = 0; /* take no action? */ |
159 |
|
|
160 |
|
char *remsh; /* remote shell program/script */ |
161 |
< |
char rendopt[2048] = ""; /* rendering options */ |
161 |
> |
char rendopt[2048]; /* rendering options */ |
162 |
|
char rresopt[32]; /* rendering resolution options */ |
163 |
|
char fresopt[32]; /* filter resolution options */ |
164 |
|
int pfiltalways; /* always use pfilt? */ |
180 |
|
PSERVER *lastpserver; /* last process server with error */ |
181 |
|
|
182 |
|
VIEW *getview(); |
183 |
< |
char *getexp(); |
183 |
> |
char *getexp(), *dirfile(); |
184 |
> |
int getblur(); |
185 |
|
|
186 |
< |
extern time_t fdate(), time(); |
186 |
> |
extern time_t time(); |
187 |
|
|
188 |
|
|
189 |
|
main(argc, argv) |
216 |
|
cfname = argv[i]; |
217 |
|
/* load variables */ |
218 |
|
loadvars(cfname); |
219 |
+ |
/* check variables */ |
220 |
+ |
checkvalues(); |
221 |
|
/* did we get DIRECTORY? */ |
222 |
|
checkdir(); |
223 |
|
/* check status */ |
298 |
|
} |
299 |
|
/* assume it is dead */ |
300 |
|
} |
301 |
< |
if (strcmp(cfname, astat.cfname) && astat.tnext != 0) { /* other's */ |
301 |
> |
if (strcmp(cfname, astat.cfname) && astat.pid != 0) { /* other's */ |
302 |
|
fprintf(stderr, "%s: unfinished job \"%s\"\n", |
303 |
|
progname, astat.cfname); |
304 |
|
return(-1); |
368 |
|
setdefaults() /* set default values */ |
369 |
|
{ |
370 |
|
extern char *atos(); |
371 |
+ |
int decades; |
372 |
|
char buf[256]; |
373 |
|
|
374 |
|
if (vdef(ANIMATE)) { |
402 |
|
quit(1); |
403 |
|
} |
404 |
|
if (!vdef(BASENAME)) { |
405 |
< |
sprintf(buf, "%s/frame%%03d", vval(DIRECTORY)); |
405 |
> |
decades = (int)log10((double)vint(END)) + 1; |
406 |
> |
if (decades < 3) decades = 3; |
407 |
> |
sprintf(buf, "%s/frame%%0%dd", vval(DIRECTORY), decades); |
408 |
|
vval(BASENAME) = savqstr(buf); |
409 |
|
vdef(BASENAME)++; |
410 |
|
} |
516 |
|
char combuf[256]; |
517 |
|
register int i; |
518 |
|
register char *cp; |
519 |
+ |
char *pippt; |
520 |
|
/* create rad command */ |
521 |
|
sprintf(rendopt, " @%s/render.opt", vval(DIRECTORY)); |
522 |
|
sprintf(combuf, |
523 |
|
"rad -v 0 -s -e -w %s OPTFILE=%s | egrep '^[ \t]*(NOMATCH", |
524 |
|
rfargs, rendopt+2); |
525 |
|
cp = combuf; |
526 |
< |
while (*cp) cp++; /* match unset variables */ |
526 |
> |
while (*cp) { |
527 |
> |
if (*cp == '|') pippt = cp; |
528 |
> |
cp++; |
529 |
> |
} /* match unset variables */ |
530 |
|
for (i = 0; mvar[i] >= 0; i++) |
531 |
|
if (!vdef(mvar[i])) { |
532 |
|
*cp++ = '|'; |
533 |
|
strcpy(cp, vnam(mvar[i])); |
534 |
|
while (*cp) cp++; |
535 |
+ |
pippt = NULL; |
536 |
|
} |
537 |
< |
sprintf(cp, ")[ \t]*=' > %s/radset.var", vval(DIRECTORY)); |
538 |
< |
cp += 11; /* point to file name */ |
539 |
< |
if (system(combuf)) { |
540 |
< |
fprintf(stderr, "%s: error executing rad command:\n\t%s\n", |
541 |
< |
progname, combuf); |
466 |
< |
quit(1); |
537 |
> |
if (pippt != NULL) |
538 |
> |
strcpy(pippt, "> /dev/null"); /* nothing to match */ |
539 |
> |
else { |
540 |
> |
sprintf(cp, ")[ \t]*=' > %s/radset.var", vval(DIRECTORY)); |
541 |
> |
cp += 11; /* point to file name */ |
542 |
|
} |
543 |
< |
loadvars(cp); /* load variables and remove file */ |
544 |
< |
unlink(cp); |
543 |
> |
system(combuf); /* ignore exit code */ |
544 |
> |
if (pippt == NULL) { /* load variables and remove file */ |
545 |
> |
loadvars(cp); |
546 |
> |
unlink(cp); |
547 |
> |
} |
548 |
|
} |
549 |
|
|
550 |
|
|
578 |
|
progname, vnam(INTERP)); |
579 |
|
vval(INTERP) = "0"; |
580 |
|
} |
581 |
< |
if (atoi(vval(MBLUR))) { /* can't handle this yet */ |
581 |
> |
if (strcmp(vval(MBLUR),"0")) { /* can't handle this */ |
582 |
|
if (!nowarn) |
583 |
|
fprintf(stderr, |
584 |
|
"%s: resetting %s=0 for animation\n", |
588 |
|
} |
589 |
|
/* figure # frames per batch */ |
590 |
|
d1 = mult*xres*mult*yres*4; /* space for orig. picture */ |
591 |
< |
if ((i=vint(INTERP)) || atoi(vval(MBLUR))) |
591 |
> |
if ((i=vint(INTERP)) || getblur(NULL) > 1) |
592 |
|
d1 += mult*xres*mult*yres*sizeof(float); /* Z-buffer */ |
593 |
|
d2 = xres*yres*4; /* space for final picture */ |
594 |
|
frames_batch = (i+1)*(vflt(DISKSPACE)*1048576.-d1)/(d1+i*d2); |
598 |
|
quit(1); |
599 |
|
} |
600 |
|
/* initialize archive argument list */ |
601 |
< |
i = 16; |
524 |
< |
if (vdef(ARCHIVE) && strlen(vval(ARCHIVE)) > i) |
525 |
< |
i = strlen(vval(ARCHIVE)); |
601 |
> |
i = vdef(ARCHIVE) ? strlen(vval(ARCHIVE))+132 : 132; |
602 |
|
arcnext = arcfirst = arcargs + i; |
603 |
|
/* initialize status file */ |
604 |
|
if (astat.rnext == 0) |
702 |
|
|
703 |
|
transferframes() /* catch up with picture transfers */ |
704 |
|
{ |
705 |
< |
char combuf[10240]; |
705 |
> |
char combuf[10240], *fbase; |
706 |
|
register char *cp; |
707 |
|
register int i; |
708 |
|
|
713 |
|
putastat(); /* update status */ |
714 |
|
return; |
715 |
|
} |
716 |
< |
strcpy(combuf, vval(TRANSFER)); /* start transfer command */ |
717 |
< |
cp = combuf + strlen(combuf); |
716 |
> |
strcpy(combuf, "cd "); /* start transfer command */ |
717 |
> |
fbase = dirfile(cp = combuf+3, vval(BASENAME)); |
718 |
> |
if (*cp) { |
719 |
> |
while (*++cp) ; |
720 |
> |
*cp++ = ';'; *cp++ = ' '; |
721 |
> |
} else |
722 |
> |
cp = combuf; |
723 |
> |
strcpy(cp, vval(TRANSFER)); |
724 |
> |
while (*cp) cp++; |
725 |
|
/* make argument list */ |
726 |
|
for (i = astat.tnext; i < astat.fnext; i++) { |
727 |
|
*cp++ = ' '; |
728 |
< |
sprintf(cp, vval(BASENAME), i); |
728 |
> |
sprintf(cp, fbase, i); |
729 |
|
while (*cp) cp++; |
730 |
|
strcpy(cp, ".pic"); |
731 |
|
cp += 4; |
762 |
|
int first, last; |
763 |
|
char *vfn; |
764 |
|
{ |
765 |
+ |
double blurf; |
766 |
+ |
int nblur = getblur(&blurf); |
767 |
|
char combuf[2048]; |
768 |
< |
char *inspoint; |
768 |
> |
register char *inspoint; |
769 |
|
register int i; |
770 |
|
|
771 |
|
if (!noaction && vint(INTERP)) /* create dummy frames */ |
776 |
|
close(open(combuf, O_RDONLY|O_CREAT, 0666)); |
777 |
|
} |
778 |
|
/* create command */ |
779 |
< |
sprintf(combuf, "rpict%s -w0", rendopt); |
780 |
< |
if (vint(INTERP) || atoi(vval(MBLUR))) |
781 |
< |
sprintf(combuf+strlen(combuf), " -z %s.zbf", vval(BASENAME)); |
782 |
< |
sprintf(combuf+strlen(combuf), " -o %s.unf %s -S %d", |
779 |
> |
sprintf(combuf, "rpict%s%s -w0", rendopt, |
780 |
> |
viewopt(getview(first>1 ? first-1 : 1))); |
781 |
> |
inspoint = combuf; |
782 |
> |
while (*inspoint) inspoint++; |
783 |
> |
if (nblur) { |
784 |
> |
sprintf(inspoint, " -pm %.3f", blurf/nblur); |
785 |
> |
while (*inspoint) inspoint++; |
786 |
> |
} |
787 |
> |
if (nblur > 1 || vint(INTERP)) { |
788 |
> |
sprintf(inspoint, " -z %s.zbf", vval(BASENAME)); |
789 |
> |
while (*inspoint) inspoint++; |
790 |
> |
} |
791 |
> |
sprintf(inspoint, " -o %s.unf %s -S %d", |
792 |
|
vval(BASENAME), rresopt, first); |
793 |
< |
inspoint = combuf + strlen(combuf); |
793 |
> |
while (*inspoint) inspoint++; |
794 |
|
sprintf(inspoint, " %s < %s", vval(OCTREE), vfn); |
795 |
|
/* run in parallel */ |
796 |
|
i = (last-first+1)/(vint(INTERP)+1); |
816 |
|
{ |
817 |
|
static int *rfrm; /* list of recovered frames */ |
818 |
|
static int nrfrms = 0; |
819 |
+ |
double blurf; |
820 |
+ |
int nblur = getblur(&blurf); |
821 |
|
char combuf[2048]; |
822 |
|
char fname[128]; |
823 |
|
register char *cp; |
833 |
|
vval(ANIMATE), frame, rendopt); |
834 |
|
else |
835 |
|
sprintf(combuf, "rpict%s -w0", rendopt); |
836 |
< |
cp = combuf + strlen(combuf); |
837 |
< |
if (vint(INTERP) || atoi(vval(MBLUR))) { |
836 |
> |
cp = combuf; |
837 |
> |
while (*cp) cp++; |
838 |
> |
if (nblur) { |
839 |
> |
sprintf(cp, " -pm %.3f", blurf/nblur); |
840 |
> |
while (*cp) cp++; |
841 |
> |
} |
842 |
> |
if (nblur > 1 || vint(INTERP)) { |
843 |
|
sprintf(cp, " -z %s.zbf", fname); |
844 |
|
while (*cp) cp++; |
845 |
|
} |
884 |
|
{ |
885 |
|
#define RMCOML (sizeof(rmcom)-1) |
886 |
|
static char rmcom[] = "rm -f"; |
887 |
< |
register int i; |
887 |
> |
char basedir[128]; |
888 |
> |
int dlen, alen; |
889 |
> |
register int j; |
890 |
|
|
891 |
|
if (arcnext == arcfirst) |
892 |
|
return; /* nothing to do */ |
893 |
+ |
dirfile(basedir, vval(BASENAME)); |
894 |
+ |
dlen = strlen(basedir); |
895 |
|
if (vdef(ARCHIVE)) { /* run archive command */ |
896 |
< |
i = strlen(vval(ARCHIVE)); |
897 |
< |
strncpy(arcfirst-i, vval(ARCHIVE), i); |
898 |
< |
if (runcom(arcfirst-i)) { |
896 |
> |
alen = strlen(vval(ARCHIVE)); |
897 |
> |
if (dlen) { |
898 |
> |
j = alen + dlen + 5; |
899 |
> |
strncpy(arcfirst-j, "cd ", 3); |
900 |
> |
strncpy(arcfirst-j+3, basedir, dlen); |
901 |
> |
(arcfirst-j)[dlen+3] = ';'; (arcfirst-j)[dlen+4] = ' '; |
902 |
> |
} else |
903 |
> |
j = alen; |
904 |
> |
strncpy(arcfirst-alen, vval(ARCHIVE), alen); |
905 |
> |
if (runcom(arcfirst-j)) { |
906 |
|
fprintf(stderr, "%s: error running archive command\n", |
907 |
|
progname); |
908 |
|
quit(1); |
909 |
|
} |
910 |
|
} |
911 |
+ |
if (dlen) { |
912 |
+ |
j = RMCOML + dlen + 5; |
913 |
+ |
strncpy(arcfirst-j, "cd ", 3); |
914 |
+ |
strncpy(arcfirst-j+3, basedir, dlen); |
915 |
+ |
(arcfirst-j)[dlen+3] = ';'; (arcfirst-j)[dlen+4] = ' '; |
916 |
+ |
} else |
917 |
+ |
j = RMCOML; |
918 |
|
/* run remove command */ |
919 |
|
strncpy(arcfirst-RMCOML, rmcom, RMCOML); |
920 |
< |
runcom(arcfirst-RMCOML); |
920 |
> |
runcom(arcfirst-j); |
921 |
|
arcnext = arcfirst; /* reset argument list */ |
922 |
|
#undef RMCOML |
923 |
|
} |
932 |
|
{ |
933 |
|
extern int frecover(); |
934 |
|
static int iter = 0; |
935 |
< |
char fnbefore[128], fnafter[128]; |
935 |
> |
double blurf; |
936 |
> |
int nblur = getblur(&blurf); |
937 |
> |
char fnbefore[128], fnafter[128], *fbase; |
938 |
|
char combuf[1024], fname0[128], fname1[128]; |
939 |
|
int usepinterp, usepfilt, nora_rgbe; |
940 |
|
int frseq[2]; |
941 |
|
/* check what is needed */ |
942 |
< |
usepinterp = atoi(vval(MBLUR)); |
942 |
> |
usepinterp = (nblur > 1); |
943 |
|
usepfilt = pfiltalways | ep==NULL; |
944 |
|
if (ep != NULL && !strcmp(ep, "1")) |
945 |
|
ep = "+0"; |
948 |
|
/* compute rendered views */ |
949 |
|
frseq[0] = frame - ((frame-1) % (vint(INTERP)+1)); |
950 |
|
frseq[1] = frseq[0] + vint(INTERP) + 1; |
951 |
+ |
fbase = dirfile(NULL, vval(BASENAME)); |
952 |
|
if (frseq[1] > vint(END)) |
953 |
|
frseq[1] = vint(END); |
954 |
|
if (frseq[1] == frame) { /* pfilt only */ |
958 |
|
} else if (frseq[0] == frame) { /* no interpolation needed */ |
959 |
|
if (!rvr && frame > 1+vint(INTERP)) { /* archive previous */ |
960 |
|
*arcnext++ = ' '; |
961 |
< |
sprintf(arcnext, vval(BASENAME), frame-vint(INTERP)-1); |
961 |
> |
sprintf(arcnext, fbase, frame-vint(INTERP)-1); |
962 |
|
while (*arcnext) arcnext++; |
963 |
|
strcpy(arcnext, ".unf"); |
964 |
|
arcnext += 4; |
965 |
|
if (usepinterp || vint(INTERP)) { /* and Z-buf */ |
966 |
|
*arcnext++ = ' '; |
967 |
< |
sprintf(arcnext, vval(BASENAME), |
846 |
< |
frame-vint(INTERP)-1); |
967 |
> |
sprintf(arcnext, fbase, frame-vint(INTERP)-1); |
968 |
|
while (*arcnext) arcnext++; |
969 |
|
strcpy(arcnext, ".zbf"); |
970 |
|
arcnext += 4; |
984 |
|
if (usepinterp) { /* using pinterp */ |
985 |
|
if (rvr == 2 && recover(frseq[1])) /* recover after? */ |
986 |
|
return(1); |
987 |
< |
if (atoi(vval(MBLUR))) { |
867 |
< |
FILE *fp; /* motion blurring */ |
987 |
> |
if (nblur > 1) { /* with pmblur */ |
988 |
|
sprintf(fname0, "%s/vw0%c", vval(DIRECTORY), |
989 |
|
'a'+(iter%26)); |
870 |
– |
if ((fp = fopen(fname0, "w")) == NULL) { |
871 |
– |
perror(fname0); quit(1); |
872 |
– |
} |
873 |
– |
fputs(VIEWSTR, fp); |
874 |
– |
fprintview(vp, fp); |
875 |
– |
putc('\n', fp); fclose(fp); |
876 |
– |
if ((vp = getview(frame+1)) == NULL) { |
877 |
– |
fprintf(stderr, |
878 |
– |
"%s: unexpected error reading view for frame %d\n", |
879 |
– |
progname, frame+1); |
880 |
– |
quit(1); |
881 |
– |
} |
990 |
|
sprintf(fname1, "%s/vw1%c", vval(DIRECTORY), |
991 |
|
'a'+(iter%26)); |
992 |
< |
if ((fp = fopen(fname1, "w")) == NULL) { |
993 |
< |
perror(fname1); quit(1); |
992 |
> |
if (!noaction) { |
993 |
> |
FILE *fp; /* motion blurring */ |
994 |
> |
if ((fp = fopen(fname0, "w")) == NULL) { |
995 |
> |
perror(fname0); quit(1); |
996 |
> |
} |
997 |
> |
fputs(VIEWSTR, fp); |
998 |
> |
fprintview(vp, fp); |
999 |
> |
putc('\n', fp); fclose(fp); |
1000 |
> |
if ((vp = getview(frame+1)) == NULL) { |
1001 |
> |
fprintf(stderr, |
1002 |
> |
"%s: unexpected error reading view for frame %d\n", |
1003 |
> |
progname, frame+1); |
1004 |
> |
quit(1); |
1005 |
> |
} |
1006 |
> |
if ((fp = fopen(fname1, "w")) == NULL) { |
1007 |
> |
perror(fname1); quit(1); |
1008 |
> |
} |
1009 |
> |
fputs(VIEWSTR, fp); |
1010 |
> |
fprintview(vp, fp); |
1011 |
> |
putc('\n', fp); fclose(fp); |
1012 |
|
} |
887 |
– |
fputs(VIEWSTR, fp); |
888 |
– |
fprintview(vp, fp); |
889 |
– |
putc('\n', fp); fclose(fp); |
1013 |
|
sprintf(combuf, |
1014 |
< |
"(pmblur %s %d %s %s; rm -f %s %s) | pinterp -B", |
1015 |
< |
*sskip(vval(MBLUR)) ? sskip2(vval(MBLUR),1) : "1", |
893 |
< |
atoi(vval(MBLUR)), |
1014 |
> |
"(pmblur %.3f %d %s %s; rm -f %s %s) | pinterp -B", |
1015 |
> |
blurf, nblur, |
1016 |
|
fname0, fname1, fname0, fname1); |
1017 |
|
iter++; |
1018 |
|
} else /* no blurring */ |
1020 |
|
strcat(combuf, viewopt(vp)); |
1021 |
|
if (vbool(RTRACE)) |
1022 |
|
sprintf(combuf+strlen(combuf), " -ff -fr '%s -w0 %s'", |
1023 |
< |
rendopt, vval(OCTREE)); |
1023 |
> |
rendopt+1, vval(OCTREE)); |
1024 |
|
if (vdef(PINTERP)) |
1025 |
|
sprintf(combuf+strlen(combuf), " %s", vval(PINTERP)); |
1026 |
|
if (usepfilt) |
1091 |
|
} |
1092 |
|
return(NULL); |
1093 |
|
} |
1094 |
< |
if (viewfp == NULL) { /* open file */ |
1094 |
> |
if (viewfp == NULL) { /* open file */ |
1095 |
|
if ((viewfp = fopen(vval(VIEWFILE), "r")) == NULL) { |
1096 |
|
perror(vval(VIEWFILE)); |
1097 |
|
quit(1); |
1098 |
|
} |
1099 |
< |
} else if (n < viewnum) { /* rewind file */ |
1099 |
> |
} else if (n > 0 && n < viewnum) { /* rewind file */ |
1100 |
|
if (viewnum == 1 && feof(viewfp)) |
1101 |
|
return(&curview); /* just one view */ |
1102 |
|
if (fseek(viewfp, 0L, 0) == EOF) { |
1106 |
|
copystruct(&curview, &stdview); |
1107 |
|
viewnum = 0; |
1108 |
|
} |
1109 |
+ |
if (n < 0) { /* get next view */ |
1110 |
+ |
register int c = getc(viewfp); |
1111 |
+ |
if (c == EOF) |
1112 |
+ |
return((VIEW *)NULL); /* that's it */ |
1113 |
+ |
ungetc(c, viewfp); |
1114 |
+ |
n = viewnum + 1; |
1115 |
+ |
} |
1116 |
|
while (n > viewnum) { /* scan to desired view */ |
1117 |
|
if (fgets(linebuf, sizeof(linebuf), viewfp) == NULL) |
1118 |
|
return(viewnum==1 ? &curview : (VIEW *)NULL); |
1126 |
|
int |
1127 |
|
countviews() /* count views in view file */ |
1128 |
|
{ |
1129 |
< |
register int n = 0; |
1129 |
> |
int n; |
1130 |
|
|
1131 |
< |
while (getview(n+1) != NULL) |
1131 |
> |
if (getview(n=1) == NULL) |
1132 |
> |
return(0); |
1133 |
> |
while (getview(-1) != NULL) |
1134 |
|
n++; |
1135 |
|
return(n); |
1136 |
|
} |
1150 |
|
if (n == 0) { /* signal to close file */ |
1151 |
|
if (expfp != NULL) { |
1152 |
|
fclose(expfp); |
1153 |
< |
free((char *)exppos); |
1153 |
> |
free((void *)exppos); |
1154 |
|
expfp = NULL; |
1155 |
|
} |
1156 |
|
return(NULL); |
1432 |
|
fprintf(stderr, "%s: bad value for variable '%s'\n", |
1433 |
|
progname, vnam(vc)); |
1434 |
|
quit(1); |
1435 |
+ |
} |
1436 |
+ |
|
1437 |
+ |
|
1438 |
+ |
char * |
1439 |
+ |
dirfile(df, path) /* separate path into directory and file */ |
1440 |
+ |
char *df; |
1441 |
+ |
register char *path; |
1442 |
+ |
{ |
1443 |
+ |
register int i; |
1444 |
+ |
int psep; |
1445 |
+ |
|
1446 |
+ |
for (i = 0, psep = -1; path[i]; i++) |
1447 |
+ |
if (path[i] == '/') |
1448 |
+ |
psep = i; |
1449 |
+ |
if (df != NULL) |
1450 |
+ |
if (psep == 0) { |
1451 |
+ |
df[0] = '/'; |
1452 |
+ |
df[1] = '\0'; |
1453 |
+ |
} else if (psep > 0) { |
1454 |
+ |
strncpy(df, path, psep); |
1455 |
+ |
df[psep] = '\0'; |
1456 |
+ |
} else |
1457 |
+ |
df[0] = '\0'; |
1458 |
+ |
return(path+psep+1); |
1459 |
+ |
} |
1460 |
+ |
|
1461 |
+ |
|
1462 |
+ |
int |
1463 |
+ |
getblur(double *bf) /* get # blur samples (and fraction) */ |
1464 |
+ |
{ |
1465 |
+ |
double blurf; |
1466 |
+ |
int nblur; |
1467 |
+ |
char *s; |
1468 |
+ |
|
1469 |
+ |
if (!vdef(MBLUR)) { |
1470 |
+ |
if (bf != NULL) |
1471 |
+ |
*bf = 0.0; |
1472 |
+ |
return(0); |
1473 |
+ |
} |
1474 |
+ |
blurf = atof(vval(MBLUR)); |
1475 |
+ |
if (blurf < 0.0) |
1476 |
+ |
blurf = 0.0; |
1477 |
+ |
if (bf != NULL) |
1478 |
+ |
*bf = blurf; |
1479 |
+ |
if (blurf <= FTINY) |
1480 |
+ |
return(0); |
1481 |
+ |
s = sskip(vval(MBLUR)); |
1482 |
+ |
if (!*s) |
1483 |
+ |
return(DEF_NBLUR); |
1484 |
+ |
nblur = atoi(s); |
1485 |
+ |
if (nblur <= 0) |
1486 |
+ |
return(1); |
1487 |
+ |
return(nblur); |
1488 |
|
} |