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.19 by greg, Wed Jul 10 15:14:59 1996 UTC vs.
Revision 2.25 by gwlarson, Tue Mar 3 11:44:46 1998 UTC

# Line 93 | Line 93 | int    silent = 0;             /* silent mode? */
93   int     noaction = 0;           /* take no action? */
94  
95   char    *remsh;                 /* remote shell program/script */
96 < char    rendopt[2048] = "";     /* rendering options */
96 > char    rendopt[2048];          /* rendering options */
97   char    rresopt[32];            /* rendering resolution options */
98   char    fresopt[32];            /* filter resolution options */
99   int     pfiltalways;            /* always use pfilt? */
# Line 115 | Line 115 | struct pslot   *findpslot();
115   PSERVER *lastpserver;           /* last process server with error */
116  
117   VIEW    *getview();
118 < char    *getexp();
118 > char    *getexp(), *dirfile();
119  
120   extern time_t   fdate(), time();
121  
# Line 150 | Line 150 | char   *argv[];
150          cfname = argv[i];
151                                                  /* load variables */
152          loadvars(cfname);
153 +                                                /* check variables */
154 +        checkvalues();
155                                                  /* did we get DIRECTORY? */
156          checkdir();
157                                                  /* check status */
# Line 230 | Line 232 | getastat()                     /* check/set animation status */
232                  }
233                  /* assume it is dead */
234          }
235 <        if (strcmp(cfname, astat.cfname) && astat.tnext != 0) { /* other's */
235 >        if (strcmp(cfname, astat.cfname) && astat.pid != 0) {   /* other's */
236                  fprintf(stderr, "%s: unfinished job \"%s\"\n",
237                                  progname, astat.cfname);
238                  return(-1);
# Line 448 | Line 450 | char   *rfargs;
450          char    combuf[256];
451          register int    i;
452          register char   *cp;
453 +        char    *pippt;
454                                          /* create rad command */
455          sprintf(rendopt, " @%s/render.opt", vval(DIRECTORY));
456          sprintf(combuf,
457          "rad -v 0 -s -e -w %s OPTFILE=%s | egrep '^[ \t]*(NOMATCH",
458                          rfargs, rendopt+2);
459          cp = combuf;
460 <        while (*cp) cp++;               /* match unset variables */
460 >        while (*cp) {
461 >                if (*cp == '|') pippt = cp;
462 >                cp++;
463 >        }                               /* match unset variables */
464          for (i = 0; mvar[i] >= 0; i++)
465                  if (!vdef(mvar[i])) {
466                          *cp++ = '|';
467                          strcpy(cp, vnam(mvar[i]));
468                          while (*cp) cp++;
469 +                        pippt = NULL;
470                  }
471 <        sprintf(cp, ")[ \t]*=' > %s/radset.var", vval(DIRECTORY));
472 <        cp += 11;                       /* point to file name */
471 >        if (pippt != NULL)
472 >                strcpy(pippt, "> /dev/null");   /* nothing to match */
473 >        else {
474 >                sprintf(cp, ")[ \t]*=' > %s/radset.var", vval(DIRECTORY));
475 >                cp += 11;               /* point to file name */
476 >        }
477          if (system(combuf)) {
478                  fprintf(stderr, "%s: error executing rad command:\n\t%s\n",
479                                  progname, combuf);
480                  quit(1);
481          }
482 <        loadvars(cp);                   /* load variables and remove file */
483 <        unlink(cp);
482 >        if (pippt == NULL) {            /* load variables and remove file */
483 >                loadvars(cp);
484 >                unlink(cp);
485 >        }
486   }
487  
488  
# Line 523 | Line 536 | animate()                      /* run animation */
536                  quit(1);
537          }
538                                          /* initialize archive argument list */
539 <        i = 16;
527 <        if (vdef(ARCHIVE) && strlen(vval(ARCHIVE)) > i)
528 <                i = strlen(vval(ARCHIVE));
539 >        i = vdef(ARCHIVE) ? strlen(vval(ARCHIVE))+132 : 132;
540          arcnext = arcfirst = arcargs + i;
541                                          /* initialize status file */
542          if (astat.rnext == 0)
# Line 629 | Line 640 | filterframes()                         /* catch up with filtering */
640  
641   transferframes()                        /* catch up with picture transfers */
642   {
643 <        char    combuf[10240];
643 >        char    combuf[10240], *fbase;
644          register char   *cp;
645          register int    i;
646  
# Line 640 | Line 651 | transferframes()                       /* catch up with picture transfers
651                  putastat();             /* update status */
652                  return;
653          }
654 <        strcpy(combuf, vval(TRANSFER)); /* start transfer command */
655 <        cp = combuf + strlen(combuf);
654 >        strcpy(combuf, "cd ");          /* start transfer command */
655 >        fbase = dirfile(cp = combuf+3, vval(BASENAME));
656 >        if (*cp) {
657 >                while (*++cp) ;
658 >                *cp++ = ';'; *cp++ = ' ';
659 >        } else
660 >                cp = combuf;
661 >        strcpy(cp, vval(TRANSFER));
662 >        while (*cp) cp++;
663                                          /* make argument list */
664          for (i = astat.tnext; i < astat.fnext; i++) {
665                  *cp++ = ' ';
666 <                sprintf(cp, vval(BASENAME), i);
666 >                sprintf(cp, fbase, i);
667                  while (*cp) cp++;
668                  strcpy(cp, ".pic");
669                  cp += 4;
# Line 786 | Line 804 | archive()                      /* archive and remove renderings */
804   {
805   #define RMCOML  (sizeof(rmcom)-1)
806          static char     rmcom[] = "rm -f";
807 <        register int    i;
807 >        char    basedir[128];
808 >        int     dlen, alen;
809 >        register int    j;
810  
811          if (arcnext == arcfirst)
812                  return;                         /* nothing to do */
813 +        dirfile(basedir, vval(BASENAME));
814 +        dlen = strlen(basedir);
815          if (vdef(ARCHIVE)) {                    /* run archive command */
816 <                i = strlen(vval(ARCHIVE));
817 <                strncpy(arcfirst-i, vval(ARCHIVE), i);
818 <                if (runcom(arcfirst-i)) {
816 >                alen = strlen(vval(ARCHIVE));
817 >                if (dlen) {
818 >                        j = alen + dlen + 5;
819 >                        strncpy(arcfirst-j, "cd ", 3);
820 >                        strncpy(arcfirst-j+3, basedir, dlen);
821 >                        (arcfirst-j)[dlen+3] = ';'; (arcfirst-j)[dlen+4] = ' ';
822 >                } else
823 >                        j = alen;
824 >                strncpy(arcfirst-alen, vval(ARCHIVE), alen);
825 >                if (runcom(arcfirst-j)) {
826                          fprintf(stderr, "%s: error running archive command\n",
827                                          progname);
828                          quit(1);
829                  }
830          }
831 +        if (dlen) {
832 +                j = RMCOML + dlen + 5;
833 +                strncpy(arcfirst-j, "cd ", 3);
834 +                strncpy(arcfirst-j+3, basedir, dlen);
835 +                (arcfirst-j)[dlen+3] = ';'; (arcfirst-j)[dlen+4] = ' ';
836 +        } else
837 +                j = RMCOML;
838                                                  /* run remove command */
839          strncpy(arcfirst-RMCOML, rmcom, RMCOML);
840 <        runcom(arcfirst-RMCOML);
840 >        runcom(arcfirst-j);
841          arcnext = arcfirst;                     /* reset argument list */
842   #undef RMCOML
843   }
# Line 816 | Line 852 | int    rvr;
852   {
853          extern int      frecover();
854          static int      iter = 0;
855 <        char    fnbefore[128], fnafter[128];
855 >        char    fnbefore[128], fnafter[128], *fbase;
856          char    combuf[1024], fname0[128], fname1[128];
857          int     usepinterp, usepfilt, nora_rgbe;
858          int     frseq[2];
# Line 830 | Line 866 | int    rvr;
866                                                  /* compute rendered views */
867          frseq[0] = frame - ((frame-1) % (vint(INTERP)+1));
868          frseq[1] = frseq[0] + vint(INTERP) + 1;
869 +        fbase = dirfile(NULL, vval(BASENAME));
870          if (frseq[1] > vint(END))
871                  frseq[1] = vint(END);
872          if (frseq[1] == frame) {                        /* pfilt only */
# Line 839 | Line 876 | int    rvr;
876          } else if (frseq[0] == frame) {         /* no interpolation needed */
877                  if (!rvr && frame > 1+vint(INTERP)) {   /* archive previous */
878                          *arcnext++ = ' ';
879 <                        sprintf(arcnext, vval(BASENAME), frame-vint(INTERP)-1);
879 >                        sprintf(arcnext, fbase, frame-vint(INTERP)-1);
880                          while (*arcnext) arcnext++;
881                          strcpy(arcnext, ".unf");
882                          arcnext += 4;
883                          if (usepinterp || vint(INTERP)) {       /* and Z-buf */
884                                  *arcnext++ = ' ';
885 <                                sprintf(arcnext, vval(BASENAME),
849 <                                                frame-vint(INTERP)-1);
885 >                                sprintf(arcnext, fbase, frame-vint(INTERP)-1);
886                                  while (*arcnext) arcnext++;
887                                  strcpy(arcnext, ".zbf");
888                                  arcnext += 4;
# Line 867 | Line 903 | int    rvr;
903                  if (rvr == 2 && recover(frseq[1]))      /* recover after? */
904                          return(1);
905                  if (atoi(vval(MBLUR))) {
870                        FILE    *fp;            /* motion blurring */
906                          sprintf(fname0, "%s/vw0%c", vval(DIRECTORY),
907                                          'a'+(iter%26));
873                        if ((fp = fopen(fname0, "w")) == NULL) {
874                                perror(fname0); quit(1);
875                        }
876                        fputs(VIEWSTR, fp);
877                        fprintview(vp, fp);
878                        putc('\n', fp); fclose(fp);
879                        if ((vp = getview(frame+1)) == NULL) {
880                                fprintf(stderr,
881                        "%s: unexpected error reading view for frame %d\n",
882                                                progname, frame+1);
883                                quit(1);
884                        }
908                          sprintf(fname1, "%s/vw1%c", vval(DIRECTORY),
909                                          'a'+(iter%26));
910 <                        if ((fp = fopen(fname1, "w")) == NULL) {
911 <                                perror(fname1); quit(1);
910 >                        if (!noaction) {
911 >                                FILE    *fp;            /* motion blurring */
912 >                                if ((fp = fopen(fname0, "w")) == NULL) {
913 >                                        perror(fname0); quit(1);
914 >                                }
915 >                                fputs(VIEWSTR, fp);
916 >                                fprintview(vp, fp);
917 >                                putc('\n', fp); fclose(fp);
918 >                                if ((vp = getview(frame+1)) == NULL) {
919 >                                        fprintf(stderr,
920 >                        "%s: unexpected error reading view for frame %d\n",
921 >                                                        progname, frame+1);
922 >                                        quit(1);
923 >                                }
924 >                                if ((fp = fopen(fname1, "w")) == NULL) {
925 >                                        perror(fname1); quit(1);
926 >                                }
927 >                                fputs(VIEWSTR, fp);
928 >                                fprintview(vp, fp);
929 >                                putc('\n', fp); fclose(fp);
930                          }
890                        fputs(VIEWSTR, fp);
891                        fprintview(vp, fp);
892                        putc('\n', fp); fclose(fp);
931                          sprintf(combuf,
932                          "(pmblur %s %d %s %s; rm -f %s %s) | pinterp -B",
933                          *sskip(vval(MBLUR)) ? sskip2(vval(MBLUR),1) : "1",
# Line 901 | Line 939 | int    rvr;
939                  strcat(combuf, viewopt(vp));
940                  if (vbool(RTRACE))
941                          sprintf(combuf+strlen(combuf), " -ff -fr '%s -w0 %s'",
942 <                                        rendopt, vval(OCTREE));
942 >                                        rendopt+1, vval(OCTREE));
943                  if (vdef(PINTERP))
944                          sprintf(combuf+strlen(combuf), " %s", vval(PINTERP));
945                  if (usepfilt)
# Line 972 | Line 1010 | int    n;
1010                  }
1011                  return(NULL);
1012          }
1013 <        if (viewfp == NULL) {           /* open file */
1013 >        if (viewfp == NULL) {                   /* open file */
1014                  if ((viewfp = fopen(vval(VIEWFILE), "r")) == NULL) {
1015                          perror(vval(VIEWFILE));
1016                          quit(1);
1017                  }
1018 <        } else if (n < viewnum) {       /* rewind file */
1018 >        } else if (n > 0 && n < viewnum) {      /* rewind file */
1019                  if (viewnum == 1 && feof(viewfp))
1020                          return(&curview);               /* just one view */
1021                  if (fseek(viewfp, 0L, 0) == EOF) {
# Line 987 | Line 1025 | int    n;
1025                  copystruct(&curview, &stdview);
1026                  viewnum = 0;
1027          }
1028 +        if (n < 0) {                            /* get next view */
1029 +                register int    c = getc(viewfp);
1030 +                if (c == EOF)
1031 +                        return((VIEW *)NULL);           /* that's it */
1032 +                ungetc(c, viewfp);
1033 +                n = viewnum + 1;
1034 +        }
1035          while (n > viewnum) {           /* scan to desired view */
1036                  if (fgets(linebuf, sizeof(linebuf), viewfp) == NULL)
1037                          return(viewnum==1 ? &curview : (VIEW *)NULL);
# Line 1000 | Line 1045 | int    n;
1045   int
1046   countviews()                    /* count views in view file */
1047   {
1048 <        register int    n = 0;
1048 >        int     n;
1049  
1050 <        while (getview(n+1) != NULL)
1050 >        if (getview(n=1) == NULL)
1051 >                return(0);
1052 >        while (getview(-1) != NULL)
1053                  n++;
1054          return(n);
1055   }
# Line 1304 | Line 1351 | int    vc;
1351          fprintf(stderr, "%s: bad value for variable '%s'\n",
1352                          progname, vnam(vc));
1353          quit(1);
1354 + }
1355 +
1356 +
1357 + char *
1358 + dirfile(df, path)               /* separate path into directory and file */
1359 + char    *df;
1360 + register char   *path;
1361 + {
1362 +        register int    i;
1363 +        int     psep;
1364 +
1365 +        for (i = 0, psep = -1; path[i]; i++)
1366 +                if (path[i] == '/')
1367 +                        psep = i;
1368 +        if (df != NULL)
1369 +                if (psep == 0) {
1370 +                        df[0] = '/';
1371 +                        df[1] = '\0';
1372 +                } else if (psep > 0) {
1373 +                        strncpy(df, path, psep);
1374 +                        df[psep] = '\0';
1375 +                } else
1376 +                        df[0] = '\0';
1377 +        return(path+psep+1);
1378   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines