ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/util/ranimate.c
(Generate patch)

Comparing ray/src/util/ranimate.c (file contents):
Revision 2.28 by gwlarson, Mon Jul 6 18:17:39 1998 UTC vs.
Revision 2.29 by greg, Sat Feb 22 02:07:30 2003 UTC

# Line 1 | Line 1
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 + /* ====================================================================
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"
# Line 31 | Line 96 | static char SCCSid[] = "$SunId$ SGI";
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               /* samples for motion blur */
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 */
# Line 116 | Line 181 | PSERVER        *lastpserver;           /* last process server with err
181  
182   VIEW    *getview();
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)
# Line 512 | Line 578 | animate()                      /* run animation */
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",
# Line 522 | Line 588 | animate()                      /* run animation */
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);
# Line 696 | Line 762 | walkwait(first, last, vfn)             /* walk-through frames */
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 */
# Line 710 | Line 778 | char   *vfn;
778                                          /* create command */
779          sprintf(combuf, "rpict%s%s -w0", rendopt,
780                          viewopt(getview(first>1 ? first-1 : 1)));
781 <        if (vint(INTERP) || atoi(vval(MBLUR)))
782 <                sprintf(combuf+strlen(combuf), " -z %s.zbf", vval(BASENAME));
783 <        sprintf(combuf+strlen(combuf), " -o %s.unf %s -S %d",
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);
# Line 740 | Line 816 | int    frame;
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;
# Line 755 | Line 833 | int    frame;
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          }
# Line 849 | Line 932 | int    rvr;
932   {
933          extern int      frecover();
934          static int      iter = 0;
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";
# Line 899 | Line 984 | int    rvr;
984          if (usepinterp) {                       /* using pinterp */
985                  if (rvr == 2 && recover(frseq[1]))      /* recover after? */
986                          return(1);
987 <                if (atoi(vval(MBLUR))) {
987 >                if (nblur > 1) {                /* with pmblur */
988                          sprintf(fname0, "%s/vw0%c", vval(DIRECTORY),
989                                          'a'+(iter%26));
990                          sprintf(fname1, "%s/vw1%c", vval(DIRECTORY),
# Line 926 | Line 1011 | int    rvr;
1011                                  putc('\n', fp); fclose(fp);
1012                          }
1013                          sprintf(combuf,
1014 <                        "(pmblur %s %d %s %s; rm -f %s %s) | pinterp -B",
1015 <                        *sskip(vval(MBLUR)) ? sskip2(vval(MBLUR),1) : "1",
931 <                                        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 */
# Line 1066 | Line 1150 | int    n;
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);
# Line 1372 | Line 1456 | register char  *path;
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   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines