--- ray/src/util/ranimate.c 1998/03/03 19:36:43 2.26
+++ ray/src/util/ranimate.c 2003/02/24 16:44:40 2.30
@@ -1,77 +1,142 @@
-/* Copyright (c) 1996 Regents of the University of California */
-
#ifndef lint
-static char SCCSid[] = "$SunId$ LBL";
+static const char RCSid[] = "$Id: ranimate.c,v 2.30 2003/02/24 16:44:40 greg Exp $";
#endif
-
/*
* Radiance animation control program
+ *
+ * The main difference between this program and ranimove is that
+ * we have many optimizations here for camera motion in static
+ * environments, calling rpict and pinterp on multiple processors,
+ * where ranimove puts its emphasis on object motion, and does
+ * not use any external programs for image generation.
+ *
+ * See the ranimate(1) man page for further details.
*/
+/* ====================================================================
+ * The Radiance Software License, Version 1.0
+ *
+ * Copyright (c) 1990 - 2002 The Regents of the University of California,
+ * through Lawrence Berkeley National Laboratory. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes Radiance software
+ * (http://radsite.lbl.gov/)
+ * developed by the Lawrence Berkeley National Laboratory
+ * (http://www.lbl.gov/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Radiance," "Lawrence Berkeley National Laboratory"
+ * and "The Regents of the University of California" must
+ * not be used to endorse or promote products derived from this
+ * software without prior written permission. For written
+ * permission, please contact radiance@radsite.lbl.gov.
+ *
+ * 5. Products derived from this software may not be called "Radiance",
+ * nor may "Radiance" appear in their name, without prior written
+ * permission of Lawrence Berkeley National Laboratory.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL Lawrence Berkeley National Laboratory OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of Lawrence Berkeley National Laboratory. For more
+ * information on Lawrence Berkeley National Laboratory, please see
+ * .
+ */
+
#include "standard.h"
#include
-#include
#include
#include "view.h"
#include "vars.h"
#include "netproc.h"
+ /* default blur samples */
+#ifndef DEF_NBLUR
+#define DEF_NBLUR 5
+#endif
/* default remote shell */
#ifdef _AUX_SOURCE
#define REMSH "remsh"
#else
#define REMSH "rsh"
#endif
- /* input variables */
-#define HOST 0 /* rendering host machine */
-#define RENDER 1 /* rendering options */
-#define PFILT 2 /* pfilt options */
-#define PINTERP 3 /* pinterp options */
-#define OCTREE 4 /* octree file name */
-#define DIRECTORY 5 /* working (sub)directory */
-#define BASENAME 6 /* output image base name */
-#define VIEWFILE 7 /* animation frame views */
-#define START 8 /* starting frame number */
-#define END 9 /* ending frame number */
-#define RIF 10 /* rad input file */
-#define NEXTANIM 11 /* next animation file */
-#define ANIMATE 12 /* animation command */
-#define TRANSFER 13 /* frame transfer command */
-#define ARCHIVE 14 /* archiving command */
-#define INTERP 15 /* # frames to interpolate */
-#define OVERSAMP 16 /* # times to oversample image */
-#define MBLUR 17 /* samples for motion blur */
-#define RTRACE 18 /* use rtrace with pinterp? */
-#define DISKSPACE 19 /* how much disk space to use */
-#define RESOLUTION 20 /* desired final resolution */
-#define EXPOSURE 21 /* how to compute exposure */
-#define RSH 22 /* remote shell script or program */
+ /* input variables (alphabetical by name) */
+#define ANIMATE 0 /* animation command */
+#define ARCHIVE 1 /* archiving command */
+#define BASENAME 2 /* output image base name */
+#define DIRECTORY 3 /* working (sub)directory */
+#define DISKSPACE 4 /* how much disk space to use */
+#define END 5 /* ending frame number */
+#define EXPOSURE 6 /* how to compute exposure */
+#define HOST 7 /* rendering host machine */
+#define INTERP 8 /* # frames to interpolate */
+#define MBLUR 9 /* motion blur parameters */
+#define NEXTANIM 10 /* next animation file */
+#define OCTREE 11 /* octree file name */
+#define OVERSAMP 12 /* # times to oversample image */
+#define PFILT 13 /* pfilt options */
+#define PINTERP 14 /* pinterp options */
+#define RENDER 15 /* rendering options */
+#define RESOLUTION 16 /* desired final resolution */
+#define RIF 17 /* rad input file */
+#define RSH 18 /* remote shell script or program */
+#define RTRACE 19 /* use rtrace with pinterp? */
+#define START 20 /* starting frame number */
+#define TRANSFER 21 /* frame transfer command */
+#define VIEWFILE 22 /* animation frame views */
int NVARS = 23; /* total number of variables */
VARIABLE vv[] = { /* variable-value pairs */
- {"host", 4, 0, NULL, NULL},
- {"render", 3, 0, NULL, catvalues},
- {"pfilt", 2, 0, NULL, catvalues},
- {"pinterp", 2, 0, NULL, catvalues},
- {"OCTREE", 3, 0, NULL, onevalue},
- {"DIRECTORY", 3, 0, NULL, onevalue},
- {"BASENAME", 3, 0, NULL, onevalue},
- {"VIEWFILE", 2, 0, NULL, onevalue},
- {"START", 2, 0, NULL, intvalue},
- {"END", 2, 0, NULL, intvalue},
- {"RIF", 3, 0, NULL, onevalue},
- {"NEXTANIM", 3, 0, NULL, onevalue},
{"ANIMATE", 2, 0, NULL, onevalue},
- {"TRANSFER", 2, 0, NULL, onevalue},
{"ARCHIVE", 2, 0, NULL, onevalue},
+ {"BASENAME", 3, 0, NULL, onevalue},
+ {"DIRECTORY", 3, 0, NULL, onevalue},
+ {"DISKSPACE", 3, 0, NULL, fltvalue},
+ {"END", 2, 0, NULL, intvalue},
+ {"EXPOSURE", 3, 0, NULL, onevalue},
+ {"host", 4, 0, NULL, NULL},
{"INTERPOLATE", 3, 0, NULL, intvalue},
- {"OVERSAMPLE", 2, 0, NULL, fltvalue},
{"MBLUR", 2, 0, NULL, onevalue},
- {"RTRACE", 2, 0, NULL, boolvalue},
- {"DISKSPACE", 3, 0, NULL, fltvalue},
+ {"NEXTANIM", 3, 0, NULL, onevalue},
+ {"OCTREE", 3, 0, NULL, onevalue},
+ {"OVERSAMPLE", 2, 0, NULL, fltvalue},
+ {"pfilt", 2, 0, NULL, catvalues},
+ {"pinterp", 2, 0, NULL, catvalues},
+ {"render", 3, 0, NULL, catvalues},
{"RESOLUTION", 3, 0, NULL, onevalue},
- {"EXPOSURE", 3, 0, NULL, onevalue},
+ {"RIF", 3, 0, NULL, onevalue},
{"RSH", 3, 0, NULL, onevalue},
+ {"RTRACE", 2, 0, NULL, boolvalue},
+ {"START", 2, 0, NULL, intvalue},
+ {"TRANSFER", 2, 0, NULL, onevalue},
+ {"VIEWFILE", 2, 0, NULL, onevalue},
};
#define SFNAME "STATUS" /* status file name */
@@ -116,8 +181,9 @@ PSERVER *lastpserver; /* last process server with err
VIEW *getview();
char *getexp(), *dirfile();
+int getblur();
-extern time_t fdate(), time();
+extern time_t time();
main(argc, argv)
@@ -474,11 +540,7 @@ char *rfargs;
sprintf(cp, ")[ \t]*=' > %s/radset.var", vval(DIRECTORY));
cp += 11; /* point to file name */
}
- if (system(combuf)) {
- fprintf(stderr, "%s: error executing rad command:\n\t%s\n",
- progname, combuf);
- quit(1);
- }
+ system(combuf); /* ignore exit code */
if (pippt == NULL) { /* load variables and remove file */
loadvars(cp);
unlink(cp);
@@ -516,7 +578,7 @@ animate() /* run animation */
progname, vnam(INTERP));
vval(INTERP) = "0";
}
- if (atoi(vval(MBLUR))) { /* can't handle this yet */
+ if (strcmp(vval(MBLUR),"0")) { /* can't handle this */
if (!nowarn)
fprintf(stderr,
"%s: resetting %s=0 for animation\n",
@@ -526,7 +588,7 @@ animate() /* run animation */
}
/* figure # frames per batch */
d1 = mult*xres*mult*yres*4; /* space for orig. picture */
- if ((i=vint(INTERP)) || atoi(vval(MBLUR)))
+ if ((i=vint(INTERP)) || getblur(NULL) > 1)
d1 += mult*xres*mult*yres*sizeof(float); /* Z-buffer */
d2 = xres*yres*4; /* space for final picture */
frames_batch = (i+1)*(vflt(DISKSPACE)*1048576.-d1)/(d1+i*d2);
@@ -700,8 +762,10 @@ walkwait(first, last, vfn) /* walk-through frames */
int first, last;
char *vfn;
{
+ double blurf;
+ int nblur = getblur(&blurf);
char combuf[2048];
- char *inspoint;
+ register char *inspoint;
register int i;
if (!noaction && vint(INTERP)) /* create dummy frames */
@@ -714,11 +778,19 @@ char *vfn;
/* create command */
sprintf(combuf, "rpict%s%s -w0", rendopt,
viewopt(getview(first>1 ? first-1 : 1)));
- if (vint(INTERP) || atoi(vval(MBLUR)))
- sprintf(combuf+strlen(combuf), " -z %s.zbf", vval(BASENAME));
- sprintf(combuf+strlen(combuf), " -o %s.unf %s -S %d",
+ inspoint = combuf;
+ while (*inspoint) inspoint++;
+ if (nblur) {
+ sprintf(inspoint, " -pm %.3f", blurf/nblur);
+ while (*inspoint) inspoint++;
+ }
+ if (nblur > 1 || vint(INTERP)) {
+ sprintf(inspoint, " -z %s.zbf", vval(BASENAME));
+ while (*inspoint) inspoint++;
+ }
+ sprintf(inspoint, " -o %s.unf %s -S %d",
vval(BASENAME), rresopt, first);
- inspoint = combuf + strlen(combuf);
+ while (*inspoint) inspoint++;
sprintf(inspoint, " %s < %s", vval(OCTREE), vfn);
/* run in parallel */
i = (last-first+1)/(vint(INTERP)+1);
@@ -744,6 +816,8 @@ int frame;
{
static int *rfrm; /* list of recovered frames */
static int nrfrms = 0;
+ double blurf;
+ int nblur = getblur(&blurf);
char combuf[2048];
char fname[128];
register char *cp;
@@ -759,8 +833,13 @@ int frame;
vval(ANIMATE), frame, rendopt);
else
sprintf(combuf, "rpict%s -w0", rendopt);
- cp = combuf + strlen(combuf);
- if (vint(INTERP) || atoi(vval(MBLUR))) {
+ cp = combuf;
+ while (*cp) cp++;
+ if (nblur) {
+ sprintf(cp, " -pm %.3f", blurf/nblur);
+ while (*cp) cp++;
+ }
+ if (nblur > 1 || vint(INTERP)) {
sprintf(cp, " -z %s.zbf", fname);
while (*cp) cp++;
}
@@ -853,12 +932,14 @@ int rvr;
{
extern int frecover();
static int iter = 0;
+ double blurf;
+ int nblur = getblur(&blurf);
char fnbefore[128], fnafter[128], *fbase;
char combuf[1024], fname0[128], fname1[128];
int usepinterp, usepfilt, nora_rgbe;
int frseq[2];
/* check what is needed */
- usepinterp = atoi(vval(MBLUR));
+ usepinterp = (nblur > 1);
usepfilt = pfiltalways | ep==NULL;
if (ep != NULL && !strcmp(ep, "1"))
ep = "+0";
@@ -903,7 +984,7 @@ int rvr;
if (usepinterp) { /* using pinterp */
if (rvr == 2 && recover(frseq[1])) /* recover after? */
return(1);
- if (atoi(vval(MBLUR))) {
+ if (nblur > 1) { /* with pmblur */
sprintf(fname0, "%s/vw0%c", vval(DIRECTORY),
'a'+(iter%26));
sprintf(fname1, "%s/vw1%c", vval(DIRECTORY),
@@ -930,9 +1011,8 @@ int rvr;
putc('\n', fp); fclose(fp);
}
sprintf(combuf,
- "(pmblur %s %d %s %s; rm -f %s %s) | pinterp -B",
- *sskip(vval(MBLUR)) ? sskip2(vval(MBLUR),1) : "1",
- atoi(vval(MBLUR)),
+ "(pmblur %.3f %d %s %s; rm -f %s %s) | pinterp -B -a",
+ blurf, nblur,
fname0, fname1, fname0, fname1);
iter++;
} else /* no blurring */
@@ -946,7 +1026,7 @@ int rvr;
if (usepfilt)
sprintf(combuf+strlen(combuf), " %s", rresopt);
else
- sprintf(combuf+strlen(combuf), " %s -e %s",
+ sprintf(combuf+strlen(combuf), "-a %s -e %s",
fresopt, ep);
sprintf(combuf+strlen(combuf), " %s.unf %s.zbf",
fnbefore, fnbefore);
@@ -1070,7 +1150,7 @@ int n;
if (n == 0) { /* signal to close file */
if (expfp != NULL) {
fclose(expfp);
- free((char *)exppos);
+ free((void *)exppos);
expfp = NULL;
}
return(NULL);
@@ -1376,4 +1456,33 @@ register char *path;
} else
df[0] = '\0';
return(path+psep+1);
+}
+
+
+int
+getblur(double *bf) /* get # blur samples (and fraction) */
+{
+ double blurf;
+ int nblur;
+ char *s;
+
+ if (!vdef(MBLUR)) {
+ if (bf != NULL)
+ *bf = 0.0;
+ return(0);
+ }
+ blurf = atof(vval(MBLUR));
+ if (blurf < 0.0)
+ blurf = 0.0;
+ if (bf != NULL)
+ *bf = blurf;
+ if (blurf <= FTINY)
+ return(0);
+ s = sskip(vval(MBLUR));
+ if (!*s)
+ return(DEF_NBLUR);
+ nblur = atoi(s);
+ if (nblur <= 0)
+ return(1);
+ return(nblur);
}