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.26 by gwlarson, Tue Mar 3 19:36:43 1998 UTC vs.
Revision 2.34 by greg, Tue May 27 15:30:04 2003 UTC

# Line 1 | Line 1
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"
31   #else
32   #define REMSH           "rsh"
33   #endif
34 <                                /* input variables */
35 < #define HOST            0               /* rendering host machine */
36 < #define RENDER          1               /* rendering options */
37 < #define PFILT           2               /* pfilt options */
38 < #define PINTERP         3               /* pinterp options */
39 < #define OCTREE          4               /* octree file name */
40 < #define DIRECTORY       5               /* working (sub)directory */
41 < #define BASENAME        6               /* output image base name */
42 < #define VIEWFILE        7               /* animation frame views */
43 < #define START           8               /* starting frame number */
44 < #define END             9               /* ending frame number */
45 < #define RIF             10              /* rad input file */
46 < #define NEXTANIM        11              /* next animation file */
47 < #define ANIMATE         12              /* animation command */
48 < #define TRANSFER        13              /* frame transfer command */
49 < #define ARCHIVE         14              /* archiving command */
50 < #define INTERP          15              /* # frames to interpolate */
51 < #define OVERSAMP        16              /* # times to oversample image */
52 < #define MBLUR           17              /* samples for motion blur */
53 < #define RTRACE          18              /* use rtrace with pinterp? */
54 < #define DISKSPACE       19              /* how much disk space to use */
55 < #define RESOLUTION      20              /* desired final resolution */
56 < #define EXPOSURE        21              /* how to compute exposure */
57 < #define RSH             22              /* remote shell script or program */
34 >                                /* input variables (alphabetical by name) */
35 > #define ANIMATE         0               /* animation command */
36 > #define ARCHIVE         1               /* archiving command */
37 > #define BASENAME        2               /* output image base name */
38 > #define DIRECTORY       3               /* working (sub)directory */
39 > #define DISKSPACE       4               /* how much disk space to use */
40 > #define END             5               /* ending frame number */
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               /* 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 */
48 > #define PFILT           13              /* pfilt options */
49 > #define PINTERP         14              /* pinterp options */
50 > #define RENDER          15              /* rendering options */
51 > #define RESOLUTION      16              /* desired final resolution */
52 > #define RIF             17              /* rad input file */
53 > #define RSH             18              /* remote shell script or program */
54 > #define RTRACE          19              /* use rtrace with pinterp? */
55 > #define START           20              /* starting frame number */
56 > #define TRANSFER        21              /* frame transfer command */
57 > #define VIEWFILE        22              /* animation frame views */
58  
59   int     NVARS = 23;             /* total number of variables */
60  
61   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},
62          {"ANIMATE",     2,      0,      NULL,   onevalue},
65        {"TRANSFER",    2,      0,      NULL,   onevalue},
63          {"ARCHIVE",     2,      0,      NULL,   onevalue},
64 +        {"BASENAME",    3,      0,      NULL,   onevalue},
65 +        {"DIRECTORY",   3,      0,      NULL,   onevalue},
66 +        {"DISKSPACE",   3,      0,      NULL,   fltvalue},
67 +        {"END",         2,      0,      NULL,   intvalue},
68 +        {"EXPOSURE",    3,      0,      NULL,   onevalue},
69 +        {"host",        4,      0,      NULL,   NULL},
70          {"INTERPOLATE", 3,      0,      NULL,   intvalue},
68        {"OVERSAMPLE",  2,      0,      NULL,   fltvalue},
71          {"MBLUR",       2,      0,      NULL,   onevalue},
72 <        {"RTRACE",      2,      0,      NULL,   boolvalue},
73 <        {"DISKSPACE",   3,      0,      NULL,   fltvalue},
72 >        {"NEXTANIM",    3,      0,      NULL,   onevalue},
73 >        {"OCTREE",      3,      0,      NULL,   onevalue},
74 >        {"OVERSAMPLE",  2,      0,      NULL,   fltvalue},
75 >        {"pfilt",       2,      0,      NULL,   catvalues},
76 >        {"pinterp",     2,      0,      NULL,   catvalues},
77 >        {"render",      3,      0,      NULL,   catvalues},
78          {"RESOLUTION",  3,      0,      NULL,   onevalue},
79 <        {"EXPOSURE",    3,      0,      NULL,   onevalue},
79 >        {"RIF",         3,      0,      NULL,   onevalue},
80          {"RSH",         3,      0,      NULL,   onevalue},
81 +        {"RTRACE",      2,      0,      NULL,   boolvalue},
82 +        {"START",       2,      0,      NULL,   intvalue},
83 +        {"TRANSFER",    2,      0,      NULL,   onevalue},
84 +        {"VIEWFILE",    2,      0,      NULL,   onevalue},
85   };
86  
87   #define SFNAME  "STATUS"                /* status file name */
# Line 116 | Line 126 | PSERVER        *lastpserver;           /* last process server with err
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)
# Line 474 | Line 485 | char   *rfargs;
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);
# Line 516 | Line 523 | animate()                      /* run animation */
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",
# Line 526 | Line 533 | animate()                      /* run animation */
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);
# Line 700 | Line 707 | walkwait(first, last, vfn)             /* walk-through frames */
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 */
# Line 712 | Line 721 | char   *vfn;
721                                  close(open(combuf, O_RDONLY|O_CREAT, 0666));
722                          }
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",
724 >        sprintf(combuf, "rpict%s -w0", rendopt);
725 >        inspoint = combuf;
726 >        while (*inspoint) inspoint++;
727 >        if (nblur) {
728 >                sprintf(inspoint, " -pm %.3f", blurf/nblur);
729 >                while (*inspoint) inspoint++;
730 >        }
731 >        if (nblur > 1 || vint(INTERP)) {
732 >                sprintf(inspoint, " -z %s.zbf", vval(BASENAME));
733 >                while (*inspoint) inspoint++;
734 >        }
735 >        sprintf(inspoint, " -o %s.unf %s -S %d",
736                          vval(BASENAME), rresopt, first);
737 <        inspoint = combuf + strlen(combuf);
737 >        while (*inspoint) inspoint++;
738          sprintf(inspoint, " %s < %s", vval(OCTREE), vfn);
739                                          /* run in parallel */
740          i = (last-first+1)/(vint(INTERP)+1);
# Line 744 | Line 760 | int    frame;
760   {
761          static int      *rfrm;          /* list of recovered frames */
762          static int      nrfrms = 0;
763 +        double  blurf;
764 +        int     nblur = getblur(&blurf);
765          char    combuf[2048];
766          char    fname[128];
767          register char   *cp;
# Line 759 | Line 777 | int    frame;
777                                  vval(ANIMATE), frame, rendopt);
778          else
779                  sprintf(combuf, "rpict%s -w0", rendopt);
780 <        cp = combuf + strlen(combuf);
781 <        if (vint(INTERP) || atoi(vval(MBLUR))) {
780 >        cp = combuf;
781 >        while (*cp) cp++;
782 >        if (nblur) {
783 >                sprintf(cp, " -pm %.3f", blurf/nblur);
784 >                while (*cp) cp++;
785 >        }
786 >        if (nblur > 1 || vint(INTERP)) {
787                  sprintf(cp, " -z %s.zbf", fname);
788                  while (*cp) cp++;
789          }
# Line 774 | Line 797 | int    frame;
797                  return(1);
798                                          /* add frame to recovered list */
799          if (nrfrms)
800 <                rfrm = (int *)realloc((char *)rfrm, (nrfrms+1)*sizeof(int));
800 >                rfrm = (int *)realloc((void *)rfrm, (nrfrms+1)*sizeof(int));
801          else
802                  rfrm = (int *)malloc(sizeof(int));
803          if (rfrm == NULL) {
# Line 853 | Line 876 | int    rvr;
876   {
877          extern int      frecover();
878          static int      iter = 0;
879 +        double  blurf;
880 +        int     nblur = getblur(&blurf);
881          char    fnbefore[128], fnafter[128], *fbase;
882          char    combuf[1024], fname0[128], fname1[128];
883          int     usepinterp, usepfilt, nora_rgbe;
884          int     frseq[2];
885                                                  /* check what is needed */
886 <        usepinterp = atoi(vval(MBLUR));
886 >        usepinterp = (nblur > 1);
887          usepfilt = pfiltalways | ep==NULL;
888          if (ep != NULL && !strcmp(ep, "1"))
889                  ep = "+0";
# Line 903 | Line 928 | int    rvr;
928          if (usepinterp) {                       /* using pinterp */
929                  if (rvr == 2 && recover(frseq[1]))      /* recover after? */
930                          return(1);
931 <                if (atoi(vval(MBLUR))) {
931 >                if (nblur > 1) {                /* with pmblur */
932                          sprintf(fname0, "%s/vw0%c", vval(DIRECTORY),
933                                          'a'+(iter%26));
934                          sprintf(fname1, "%s/vw1%c", vval(DIRECTORY),
# Line 930 | Line 955 | int    rvr;
955                                  putc('\n', fp); fclose(fp);
956                          }
957                          sprintf(combuf,
958 <                        "(pmblur %s %d %s %s; rm -f %s %s) | pinterp -B",
959 <                        *sskip(vval(MBLUR)) ? sskip2(vval(MBLUR),1) : "1",
935 <                                        atoi(vval(MBLUR)),
958 >                        "(pmblur %.3f %d %s %s; rm -f %s %s) | pinterp -B -a",
959 >                                        blurf, nblur,
960                                          fname0, fname1, fname0, fname1);
961                          iter++;
962                  } else                          /* no blurring */
# Line 946 | Line 970 | int    rvr;
970                  if (usepfilt)
971                          sprintf(combuf+strlen(combuf), " %s", rresopt);
972                  else
973 <                        sprintf(combuf+strlen(combuf), " %s -e %s",
973 >                        sprintf(combuf+strlen(combuf), " -a %s -e %s",
974                                          fresopt, ep);
975                  sprintf(combuf+strlen(combuf), " %s.unf %s.zbf",
976                                  fnbefore, fnbefore);
# Line 1070 | Line 1094 | int    n;
1094          if (n == 0) {                           /* signal to close file */
1095                  if (expfp != NULL) {
1096                          fclose(expfp);
1097 <                        free((char *)exppos);
1097 >                        free((void *)exppos);
1098                          expfp = NULL;
1099                  }
1100                  return(NULL);
# Line 1376 | Line 1400 | register char  *path;
1400                  } else
1401                          df[0] = '\0';
1402          return(path+psep+1);
1403 + }
1404 +
1405 +
1406 + int
1407 + getblur(double *bf)             /* get # blur samples (and fraction) */
1408 + {
1409 +        double  blurf;
1410 +        int     nblur;
1411 +        char    *s;
1412 +
1413 +        if (!vdef(MBLUR)) {
1414 +                if (bf != NULL)
1415 +                        *bf = 0.0;
1416 +                return(0);
1417 +        }
1418 +        blurf = atof(vval(MBLUR));
1419 +        if (blurf < 0.0)
1420 +                blurf = 0.0;
1421 +        if (bf != NULL)
1422 +                *bf = blurf;
1423 +        if (blurf <= FTINY)
1424 +                return(0);
1425 +        s = sskip(vval(MBLUR));
1426 +        if (!*s)
1427 +                return(DEF_NBLUR);
1428 +        nblur = atoi(s);
1429 +        if (nblur <= 0)
1430 +                return(1);
1431 +        return(nblur);
1432   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines