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.39 by schorsch, Mon Jun 30 14:59:13 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 < #include "standard.h"
16 > #include "copyright.h"
17 >
18   #include <ctype.h>
13 #include <sys/types.h>
19   #include <sys/stat.h>
20 +
21 + #include "standard.h"
22 + #include "paths.h"
23   #include "view.h"
24   #include "vars.h"
25   #include "netproc.h"
26 +                                /* default blur samples */
27 + #ifndef DEF_NBLUR
28 + #define DEF_NBLUR       5
29 + #endif
30                                  /* default remote shell */
31   #ifdef _AUX_SOURCE
32   #define REMSH           "remsh"
# Line 31 | Line 43 | static char SCCSid[] = "$SunId$ SGI";
43   #define EXPOSURE        6               /* how to compute exposure */
44   #define HOST            7               /* rendering host machine */
45   #define INTERP          8               /* # frames to interpolate */
46 < #define MBLUR           9               /* samples for motion blur */
46 > #define MBLUR           9               /* motion blur parameters */
47   #define NEXTANIM        10              /* next animation file */
48   #define OCTREE          11              /* octree file name */
49   #define OVERSAMP        12              /* # times to oversample image */
# Line 116 | Line 128 | PSERVER        *lastpserver;           /* last process server with err
128  
129   VIEW    *getview();
130   char    *getexp(), *dirfile();
131 + int     getblur();
132  
133 < extern time_t   fdate(), time();
133 > extern time_t   time();
134  
135  
136   main(argc, argv)
# Line 469 | Line 482 | char   *rfargs;
482                          pippt = NULL;
483                  }
484          if (pippt != NULL)
485 <                strcpy(pippt, "> /dev/null");   /* nothing to match */
485 >                strcpy(pippt, "> " NULL_DEVICE);        /* nothing to match */
486          else {
487                  sprintf(cp, ")[ \t]*=' > %s/radset.var", vval(DIRECTORY));
488                  cp += 11;               /* point to file name */
# Line 512 | Line 525 | animate()                      /* run animation */
525                                                  progname, vnam(INTERP));
526                          vval(INTERP) = "0";
527                  }
528 <                if (atoi(vval(MBLUR))) {        /* can't handle this yet */
528 >                if (strcmp(vval(MBLUR),"0")) {  /* can't handle this */
529                          if (!nowarn)
530                                  fprintf(stderr,
531                                          "%s: resetting %s=0 for animation\n",
# Line 522 | Line 535 | animate()                      /* run animation */
535          }
536                                          /* figure # frames per batch */
537          d1 = mult*xres*mult*yres*4;             /* space for orig. picture */
538 <        if ((i=vint(INTERP)) || atoi(vval(MBLUR)))
538 >        if ((i=vint(INTERP)) || getblur(NULL) > 1)
539                  d1 += mult*xres*mult*yres*sizeof(float);        /* Z-buffer */
540          d2 = xres*yres*4;                       /* space for final picture */
541          frames_batch = (i+1)*(vflt(DISKSPACE)*1048576.-d1)/(d1+i*d2);
# Line 618 | Line 631 | filterframes()                         /* catch up with filtering */
631          if (astat.tnext < astat.fnext)  /* other work to do first */
632                  return;
633                                          /* filter each view */
634 <        for (i = astat.fnext; i < astat.rnext; i++) {
635 <                if ((vp = getview(i)) == NULL) {        /* get view i */
636 <                        fprintf(stderr,
624 <                        "%s: unexpected error reading view for frame %d\n",
625 <                                        progname, i);
626 <                        quit(1);
627 <                }
628 <                dofilt(i, vp, getexp(i), 0);            /* filter frame */
629 <        }
634 >        for (i = astat.fnext; i < astat.rnext; i++)
635 >                dofilt(i, 0);
636 >
637          bwait(0);                       /* wait for filter processes */
638          archive();                      /* archive originals */
639          astat.fnext = i;                /* update status */
# Line 696 | Line 703 | walkwait(first, last, vfn)             /* walk-through frames */
703   int     first, last;
704   char    *vfn;
705   {
706 +        double  blurf;
707 +        int     nblur = getblur(&blurf);
708          char    combuf[2048];
709 <        char    *inspoint;
709 >        register char   *inspoint;
710          register int    i;
711  
712          if (!noaction && vint(INTERP))          /* create dummy frames */
# Line 710 | Line 719 | char   *vfn;
719                                          /* create command */
720          sprintf(combuf, "rpict%s%s -w0", rendopt,
721                          viewopt(getview(first>1 ? first-1 : 1)));
722 <        if (vint(INTERP) || atoi(vval(MBLUR)))
723 <                sprintf(combuf+strlen(combuf), " -z %s.zbf", vval(BASENAME));
724 <        sprintf(combuf+strlen(combuf), " -o %s.unf %s -S %d",
722 >        inspoint = combuf;
723 >        while (*inspoint) inspoint++;
724 >        if (nblur) {
725 >                sprintf(inspoint, " -pm %.3f", blurf/nblur);
726 >                while (*inspoint) inspoint++;
727 >        }
728 >        if (nblur > 1 || vint(INTERP)) {
729 >                sprintf(inspoint, " -z %s.zbf", vval(BASENAME));
730 >                while (*inspoint) inspoint++;
731 >        }
732 >        sprintf(inspoint, " -o %s.unf %s -S %d",
733                          vval(BASENAME), rresopt, first);
734 <        inspoint = combuf + strlen(combuf);
734 >        while (*inspoint) inspoint++;
735          sprintf(inspoint, " %s < %s", vval(OCTREE), vfn);
736                                          /* run in parallel */
737          i = (last-first+1)/(vint(INTERP)+1);
# Line 740 | Line 757 | int    frame;
757   {
758          static int      *rfrm;          /* list of recovered frames */
759          static int      nrfrms = 0;
760 +        double  blurf;
761 +        int     nblur = getblur(&blurf);
762          char    combuf[2048];
763          char    fname[128];
764          register char   *cp;
# Line 755 | Line 774 | int    frame;
774                                  vval(ANIMATE), frame, rendopt);
775          else
776                  sprintf(combuf, "rpict%s -w0", rendopt);
777 <        cp = combuf + strlen(combuf);
778 <        if (vint(INTERP) || atoi(vval(MBLUR))) {
777 >        cp = combuf;
778 >        while (*cp) cp++;
779 >        if (nblur) {
780 >                sprintf(cp, " -pm %.3f", blurf/nblur);
781 >                while (*cp) cp++;
782 >        }
783 >        if (nblur > 1 || vint(INTERP)) {
784                  sprintf(cp, " -z %s.zbf", fname);
785                  while (*cp) cp++;
786          }
# Line 770 | Line 794 | int    frame;
794                  return(1);
795                                          /* add frame to recovered list */
796          if (nrfrms)
797 <                rfrm = (int *)realloc((char *)rfrm, (nrfrms+1)*sizeof(int));
797 >                rfrm = (int *)realloc((void *)rfrm, (nrfrms+1)*sizeof(int));
798          else
799                  rfrm = (int *)malloc(sizeof(int));
800          if (rfrm == NULL) {
# Line 786 | Line 810 | int
810   frecover(frame)                         /* recover filtered frame */
811   int     frame;
812   {
813 <        VIEW    *vp;
790 <        char    *ex;
791 <
792 <        vp = getview(frame);
793 <        ex = getexp(frame);
794 <        if (dofilt(frame, vp, ex, 2) && dofilt(frame, vp, ex, 1))
813 >        if (dofilt(frame, 2) && dofilt(frame, 1))
814                  return(1);
815          return(0);
816   }
# Line 841 | Line 860 | archive()                      /* archive and remove renderings */
860  
861  
862   int
863 < dofilt(frame, vp, ep, rvr)                      /* filter frame */
863 > dofilt(frame, rvr)                              /* filter frame */
864   int     frame;
846 VIEW    *vp;
847 char    *ep;
865   int     rvr;
866   {
867          extern int      frecover();
868          static int      iter = 0;
869 +        double  blurf;
870 +        int     nblur = getblur(&blurf);
871 +        VIEW    *vp = getview(frame);
872 +        char    *ep = getexp(frame);
873          char    fnbefore[128], fnafter[128], *fbase;
874          char    combuf[1024], fname0[128], fname1[128];
875          int     usepinterp, usepfilt, nora_rgbe;
876          int     frseq[2];
877                                                  /* check what is needed */
878 <        usepinterp = atoi(vval(MBLUR));
878 >        if (vp == NULL) {
879 >                 fprintf(stderr,
880 >                        "%s: unexpected error reading view for frame %d\n",
881 >                                          progname, frame);
882 >                quit(1);
883 >        }
884 >        if (ep == NULL) {
885 >                 fprintf(stderr,
886 >                        "%s: unexpected error reading exposure for frame %d\n",
887 >                                          progname, frame);
888 >                quit(1);
889 >        }
890 >        usepinterp = (nblur > 1);
891          usepfilt = pfiltalways | ep==NULL;
892          if (ep != NULL && !strcmp(ep, "1"))
893                  ep = "+0";
# Line 899 | Line 932 | int    rvr;
932          if (usepinterp) {                       /* using pinterp */
933                  if (rvr == 2 && recover(frseq[1]))      /* recover after? */
934                          return(1);
935 <                if (atoi(vval(MBLUR))) {
935 >                if (nblur > 1) {                /* with pmblur */
936                          sprintf(fname0, "%s/vw0%c", vval(DIRECTORY),
937                                          'a'+(iter%26));
938                          sprintf(fname1, "%s/vw1%c", vval(DIRECTORY),
# Line 926 | Line 959 | int    rvr;
959                                  putc('\n', fp); fclose(fp);
960                          }
961                          sprintf(combuf,
962 <                        "(pmblur %s %d %s %s; rm -f %s %s) | pinterp -B",
963 <                        *sskip(vval(MBLUR)) ? sskip2(vval(MBLUR),1) : "1",
931 <                                        atoi(vval(MBLUR)),
962 >                        "(pmblur %.3f %d %s %s; rm -f %s %s) | pinterp -B -a",
963 >                                        blurf, nblur,
964                                          fname0, fname1, fname0, fname1);
965                          iter++;
966                  } else                          /* no blurring */
# Line 942 | Line 974 | int    rvr;
974                  if (usepfilt)
975                          sprintf(combuf+strlen(combuf), " %s", rresopt);
976                  else
977 <                        sprintf(combuf+strlen(combuf), " %s -e %s",
977 >                        sprintf(combuf+strlen(combuf), " -a %s -e %s",
978                                          fresopt, ep);
979                  sprintf(combuf+strlen(combuf), " %s.unf %s.zbf",
980                                  fnbefore, fnbefore);
# Line 1066 | Line 1098 | int    n;
1098          if (n == 0) {                           /* signal to close file */
1099                  if (expfp != NULL) {
1100                          fclose(expfp);
1101 <                        free((char *)exppos);
1101 >                        free((void *)exppos);
1102                          expfp = NULL;
1103                  }
1104                  return(NULL);
# Line 1271 | Line 1303 | int    maxcopies;
1303                          strcpy(com1=buf, com);  /* build -PP command */
1304                          sprintf(com1+(ppins-com), " -PP %s/%s.persist",
1305                                          vval(DIRECTORY), phostname(ps));
1306 +                        unlink(com1+(ppins-com)+5);
1307                          strcat(com1, ppins);
1308                  } else
1309                          com1 = com;
# Line 1331 | Line 1364 | rmfile(fn)                     /* remove a file */
1364   char    *fn;
1365   {
1366          if (!silent)
1367 < #ifdef MSDOS
1367 > #ifdef _WIN32
1368                  printf("\tdel %s\n", fn);
1369   #else
1370                  printf("\trm -f %s\n", fn);
# Line 1372 | Line 1405 | register char  *path;
1405                  } else
1406                          df[0] = '\0';
1407          return(path+psep+1);
1408 + }
1409 +
1410 +
1411 + int
1412 + getblur(double *bf)             /* get # blur samples (and fraction) */
1413 + {
1414 +        double  blurf;
1415 +        int     nblur;
1416 +        char    *s;
1417 +
1418 +        if (!vdef(MBLUR)) {
1419 +                if (bf != NULL)
1420 +                        *bf = 0.0;
1421 +                return(0);
1422 +        }
1423 +        blurf = atof(vval(MBLUR));
1424 +        if (blurf < 0.0)
1425 +                blurf = 0.0;
1426 +        if (bf != NULL)
1427 +                *bf = blurf;
1428 +        if (blurf <= FTINY)
1429 +                return(0);
1430 +        s = sskip(vval(MBLUR));
1431 +        if (!*s)
1432 +                return(DEF_NBLUR);
1433 +        nblur = atoi(s);
1434 +        if (nblur <= 0)
1435 +                return(1);
1436 +        return(nblur);
1437   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines