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.5 by greg, Tue Jan 23 16:14:28 1996 UTC vs.
Revision 2.10 by greg, Tue Feb 20 16:13:53 1996 UTC

# Line 15 | Line 15 | static char SCCSid[] = "$SunId$ LBL";
15   #include "view.h"
16   #include "vars.h"
17   #include "netproc.h"
18 +                                /* default remote shell */
19 + #ifdef _AUX_SOURCE
20 + #define REMSH           "remsh"
21 + #else
22 + #define REMSH           "rsh"
23 + #endif
24                                  /* input variables */
25   #define HOST            0               /* rendering host machine */
26   #define RENDER          1               /* rendering options */
# Line 38 | Line 44 | static char SCCSid[] = "$SunId$ LBL";
44   #define DISKSPACE       19              /* how much disk space to use */
45   #define RESOLUTION      20              /* desired final resolution */
46   #define EXPOSURE        21              /* how to compute exposure */
47 + #define RSH             22              /* remote shell script or program */
48  
49 < int     NVARS = 22;             /* total number of variables */
49 > int     NVARS = 23;             /* total number of variables */
50  
51   VARIABLE        vv[] = {                /* variable-value pairs */
52          {"host",        4,      0,      NULL,   NULL},
# Line 64 | Line 71 | VARIABLE       vv[] = {                /* variable-value pairs */
71          {"DISKSPACE",   3,      0,      NULL,   fltvalue},
72          {"RESOLUTION",  3,      0,      NULL,   onevalue},
73          {"EXPOSURE",    3,      0,      NULL,   onevalue},
74 +        {"RSH",         3,      0,      NULL,   onevalue},
75   };
76  
77   #define SFNAME  "STATUS"                /* status file name */
# Line 84 | Line 92 | int    nowarn = 0;             /* turn warnings off? */
92   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 */
97   char    rresopt[32];            /* rendering resolution options */
98   char    fresopt[32];            /* filter resolution options */
99   int     pfiltalways;            /* always use pfilt? */
100  
101 + char    arcargs[10240];         /* files to archive */
102 + char    *arcfirst, *arcnext;    /* pointers to first and next argument */
103 +
104   struct pslot {
105          int     pid;                    /* process ID (0 if empty) */
106          int     fout;                   /* output frame number */
# Line 201 | Line 213 | getastat()                     /* check/set animation status */
213                  goto fmterr;
214          fclose(fp);
215          if (astat.pid != 0) {                   /* thinks it's still running */
216 <                gethostname(buf, sizeof(buf));
205 <                if (strcmp(buf, astat.host)) {
216 >                if (strcmp(myhostname(), astat.host)) {
217                          fprintf(stderr,
218                          "%s: process %d may still be running on host %s\n",
219                                          progname, astat.pid, astat.host);
# Line 221 | Line 232 | getastat()                     /* check/set animation status */
232                  return(-1);
233          }
234   setours:                                        /* set our values */
235 <        gethostname(astat.host, sizeof(astat.host));
235 >        strcpy(astat.host, myhostname());
236          astat.pid = getpid();
237          strcpy(astat.cfname, cfname);
238          return(0);
# Line 279 | Line 290 | checkdir()                     /* make sure we have our directory */
290  
291   setdefaults()                   /* set default values */
292   {
293 +        extern char     *atos();
294          char    buf[256];
295  
296          if (vdef(ANIMATE)) {
# Line 344 | Line 356 | setdefaults()                  /* set default values */
356                  vval(DISKSPACE) = "100";
357                  vdef(DISKSPACE)++;
358          }
359 +        if (!vdef(RSH)) {
360 +                vval(RSH) = REMSH;
361 +                vdef(RSH)++;
362 +        }
363 +                                /* locate remote shell program */
364 +        atos(buf, sizeof(buf), vval(RSH));
365 +        if ((remsh = getpath(buf, getenv("PATH"), X_OK)) != NULL)
366 +                remsh = savqstr(remsh);
367 +        else
368 +                remsh = vval(RSH);      /* will generate error if used */
369 +
370                                  /* append rendering options */
371          if (vdef(RENDER))
372                  sprintf(rendopt+strlen(rendopt), " %s", vval(RENDER));
# Line 406 | Line 429 | sethosts()                     /* set up process servers */
429   }
430  
431  
432 < getradfile(rfname)              /* run rad and get needed variables */
433 < char    *rfname;
432 > getradfile(rfargs)              /* run rad and get needed variables */
433 > char    *rfargs;
434   {
435          static short    mvar[] = {OCTREE,PFILT,RESOLUTION,EXPOSURE,-1};
436          char    combuf[256];
# Line 417 | Line 440 | char   *rfname;
440          sprintf(rendopt, " @%s/render.opt", vval(DIRECTORY));
441          sprintf(combuf,
442          "rad -v 0 -s -e -w %s OPTFILE=%s | egrep '^[ \t]*(NOMATCH",
443 <                        rfname, rendopt+2);
443 >                        rfargs, rendopt+2);
444          cp = combuf;
445          while (*cp) cp++;               /* match unset variables */
446          for (i = 0; mvar[i] >= 0; i++)
# Line 429 | Line 452 | char   *rfname;
452          sprintf(cp, ")[ \t]*=' > %s/radset.var", vval(DIRECTORY));
453          cp += 11;                       /* point to file name */
454          if (system(combuf)) {
455 <                fprintf(stderr, "%s: bad rad input file \"%s\"\n",
456 <                                progname, rfname);
455 >                fprintf(stderr, "%s: error executing rad command:\n\t%s\n",
456 >                                progname, combuf);
457                  quit(1);
458          }
459          loadvars(cp);                   /* load variables and remove file */
# Line 487 | Line 510 | animate()                      /* run animation */
510                                  progname);
511                  quit(1);
512          }
513 +                                        /* initialize archive argument list */
514 +        i = 16;
515 +        if (vdef(ARCHIVE) && strlen(vval(ARCHIVE)) > i)
516 +                i = strlen(vval(ARCHIVE));
517 +        arcnext = arcfirst = arcargs + i;
518                                          /* initialize status file */
519          if (astat.rnext == 0)
520                  astat.rnext = astat.fnext = astat.tnext = vint(START);
# Line 581 | Line 609 | filterframes()                         /* catch up with filtering */
609                  dofilt(i, vp, getexp(i), 0);            /* filter frame */
610          }
611          bwait(0);                       /* wait for filter processes */
612 <        archive(astat.fnext, i-1);      /* archive originals */
612 >        archive();                      /* archive originals */
613          astat.fnext = i;                /* update status */
614          putastat();
615   }
# Line 662 | Line 690 | char   *vfn;
690          inspoint = combuf + strlen(combuf);
691          sprintf(inspoint, " %s < %s", vval(OCTREE), vfn);
692                                          /* run in parallel */
693 <        if (pruncom(combuf, inspoint, (last-first+1)/(vint(INTERP)+1))) {
693 >        i = (last-first+1)/(vint(INTERP)+1);
694 >        if (i < 1) i = 1;
695 >        if (pruncom(combuf, inspoint, i)) {
696                  fprintf(stderr, "%s: error rendering frames %d through %d\n",
697                                  progname, first, last);
698                  quit(1);
# Line 740 | Line 770 | int    frame;
770   }
771  
772  
773 < archive(first, last)                    /* archive and remove renderings */
744 < int     first, last;
773 > archive()                       /* archive and remove renderings */
774   {
775   #define RMCOML  (sizeof(rmcom)-1)
776          static char     rmcom[] = "rm -f";
748        int     offset = RMCOML;
749        char    combuf[10240];
750        struct stat     stb;
751        register char   *cp;
777          register int    i;
778  
779 <        if (noaction)
780 <                return;
756 <        if (vdef(ARCHIVE) && strlen(vval(ARCHIVE)) > offset)
757 <                offset = strlen(vval(ARCHIVE));
758 <        cp = combuf + offset;
759 <        *cp++ = ' ';                            /* make argument list */
760 <        for (i = first; i <= last; i++) {
761 <                sprintf(cp, vval(BASENAME), i);
762 <                strcat(cp, ".unf");
763 <                if (stat(cp, &stb) == 0 && stb.st_size > 0) {   /* non-zero? */
764 <                        while (*cp) cp++;
765 <                        *cp++ = ' ';
766 <                        sprintf(cp, vval(BASENAME), i);
767 <                        strcat(cp, ".zbf");
768 <                        if (access(cp, F_OK) == 0) {            /* exists? */
769 <                                while (*cp) cp++;
770 <                                *cp++ = ' ';
771 <                        }
772 <                }
773 <        }
774 <        *--cp = '\0';
775 <        if (cp <= combuf + offset)              /* no files? */
776 <                return;
779 >        if (arcnext == arcfirst)
780 >                return;                         /* nothing to do */
781          if (vdef(ARCHIVE)) {                    /* run archive command */
782                  i = strlen(vval(ARCHIVE));
783 <                strncpy(combuf+offset-i, vval(ARCHIVE), i);
784 <                if (runcom(combuf+offset-i)) {
785 <                        fprintf(stderr,
786 <                "%s: error running archive command on frames %d through %d\n",
783 <                                        progname, first, last);
783 >                strncpy(arcfirst-i, vval(ARCHIVE), i);
784 >                if (runcom(arcfirst-i)) {
785 >                        fprintf(stderr, "%s: error running archive command\n",
786 >                                        progname);
787                          quit(1);
788                  }
789          }
790                                                  /* run remove command */
791 <        strncpy(combuf+offset-RMCOML, rmcom, RMCOML);
792 <        runcom(combuf+offset-RMCOML);
791 >        strncpy(arcfirst-RMCOML, rmcom, RMCOML);
792 >        runcom(arcfirst-RMCOML);
793 >        arcnext = arcfirst;                     /* reset argument list */
794   #undef RMCOML
795   }
796  
# Line 799 | Line 803 | char   *ep;
803   int     rvr;
804   {
805          extern int      frecover();
806 +        static int      iter = 0;
807          char    fnbefore[128], fnafter[128];
808 <        char    combuf[1024], fname[128];
809 <        int     usepinterp, usepfilt;
808 >        char    combuf[1024], fname0[128], fname1[128];
809 >        int     usepinterp, usepfilt, nora_rgbe;
810          int     frseq[2];
811                                                  /* check what is needed */
812          usepinterp = atoi(vval(MBLUR));
813          usepfilt = pfiltalways | ep==NULL;
814 +        if (ep != NULL && !strcmp(ep, "1"))
815 +                ep = "+0";
816 +        nora_rgbe = strcmp(vval(OVERSAMP),"1") || ep==NULL ||
817 +                        *ep != '+' || *ep != '-' || !isint(ep);
818                                                  /* compute rendered views */
819          frseq[0] = frame - ((frame-1) % (vint(INTERP)+1));
820          frseq[1] = frseq[0] + vint(INTERP) + 1;
# Line 814 | Line 823 | int    rvr;
823          if (frseq[1] == frame) {                        /* pfilt only */
824                  frseq[0] = frseq[1];
825                  usepinterp = 0;                 /* update what's needed */
826 <                usepfilt |= vflt(OVERSAMP)>1.01 || strcmp(ep,"1");
827 <        } else if (frseq[0] == frame) {         /* no interpolation */
828 <                                                /* update what's needed */
829 <                if (!usepinterp)
830 <                        usepfilt |= vflt(OVERSAMP)>1.01 || strcmp(ep,"1");
826 >                usepfilt |= nora_rgbe;
827 >        } else if (frseq[0] == frame) {         /* no interpolation needed */
828 >                if (!rvr && frame > 1+vint(INTERP)) {   /* archive previous */
829 >                        *arcnext++ = ' ';
830 >                        sprintf(arcnext, vval(BASENAME), frame-vint(INTERP)-1);
831 >                        while (*arcnext) arcnext++;
832 >                        strcpy(arcnext, ".unf");
833 >                        arcnext += 4;
834 >                        if (usepinterp || vint(INTERP)) {       /* and z-buf */
835 >                                *arcnext++ = ' ';
836 >                                sprintf(arcnext, vval(BASENAME),
837 >                                                frame-vint(INTERP)-1);
838 >                                while (*arcnext) arcnext++;
839 >                                strcpy(arcnext, ".zbf");
840 >                                arcnext += 4;
841 >                        }
842 >                }
843 >                if (!usepinterp)                /* update what's needed */
844 >                        usepfilt |= nora_rgbe;
845          } else                                  /* interpolation needed */
846                  usepinterp++;
847          if (frseq[1] >= astat.rnext)            /* next batch unavailable */
# Line 833 | Line 856 | int    rvr;
856                          return(1);
857                  if (atoi(vval(MBLUR))) {
858                          FILE    *fp;            /* motion blurring */
859 <                        sprintf(fname, "%s/vw0", vval(DIRECTORY));
860 <                        if (access(fname, F_OK) == 0)
861 <                                sleep(10);
862 <                        if ((fp = fopen(fname, "w")) == NULL) {
840 <                                perror(fname); quit(1);
859 >                        sprintf(fname0, "%s/vw0%c", vval(DIRECTORY),
860 >                                        'a'+(iter%26));
861 >                        if ((fp = fopen(fname0, "w")) == NULL) {
862 >                                perror(fname0); quit(1);
863                          }
864                          fputs(VIEWSTR, fp);
865                          fprintview(vp, fp);
# Line 848 | Line 870 | int    rvr;
870                                                  progname, frame+1);
871                                  quit(1);
872                          }
873 <                        sprintf(fname, "%s/vw1", vval(DIRECTORY));
874 <                        if ((fp = fopen(fname, "w")) == NULL) {
875 <                                perror(fname); quit(1);
873 >                        sprintf(fname1, "%s/vw1%c", vval(DIRECTORY),
874 >                                        'a'+(iter%26));
875 >                        if ((fp = fopen(fname1, "w")) == NULL) {
876 >                                perror(fname1); quit(1);
877                          }
878                          fputs(VIEWSTR, fp);
879                          fprintview(vp, fp);
880                          putc('\n', fp); fclose(fp);
881                          sprintf(combuf,
882 <        "(pmblur %s %d %s/vw0 %s/vw1; rm -f %s/vw0 %s/vw1) | pinterp -B",
882 >                        "(pmblur %s %d %s %s; rm -f %s %s) | pinterp -B",
883                          *sskip(vval(MBLUR)) ? sskip2(vval(MBLUR),1) : "1",
884 <                                        atoi(vval(MBLUR)), vval(DIRECTORY),
885 <                                        vval(DIRECTORY), vval(DIRECTORY),
886 <                                        vval(DIRECTORY), vval(DIRECTORY));
884 >                                        atoi(vval(MBLUR)),
885 >                                        fname0, fname1, fname0, fname1);
886 >                        iter++;
887                  } else                          /* no blurring */
888                          strcpy(combuf, "pinterp");
889                  strcat(combuf, viewopt(vp));
# Line 907 | Line 930 | int    rvr;
930          } else {                                /* else just check it */
931                  if (rvr == 2)
932                          return(1);
933 <                sprintf(combuf, "ra_rgbe -r %s.unf", fnbefore);
933 >                sprintf(combuf, "ra_rgbe -e %s -r %s.unf", ep, fnbefore);
934          }
935                                                  /* output file name */
936 <        sprintf(fname, vval(BASENAME), frame);
937 <        sprintf(combuf+strlen(combuf), " > %s.pic", fname);
936 >        sprintf(fname0, vval(BASENAME), frame);
937 >        sprintf(combuf+strlen(combuf), " > %s.pic", fname0);
938          if (rvr)                                /* in recovery */
939                  return(runcom(combuf));
940          bruncom(combuf, frame, frecover);       /* else run in background */
# Line 943 | Line 966 | int    n;
966                          quit(1);
967                  }
968          } else if (n < viewnum) {       /* rewind file */
969 +                if (viewnum == 1 && feof(viewfp))
970 +                        return(&curview);               /* just one view */
971                  if (fseek(viewfp, 0L, 0) == EOF) {
972                          perror(vval(VIEWFILE));
973                          quit(1);
# Line 952 | Line 977 | int    n;
977          }
978          while (n > viewnum) {           /* scan to desired view */
979                  if (fgets(linebuf, sizeof(linebuf), viewfp) == NULL)
980 <                        return(NULL);
980 >                        return(viewnum==1 ? &curview : NULL);
981                  if (isview(linebuf) && sscanview(&curview, linebuf) > 0)
982                          viewnum++;
983          }
# Line 1166 | Line 1191 | int    maxcopies;
1191          register PSERVER        *ps;
1192  
1193          if (!silent)
1194 <                printf("\t%s &\n", com);        /* echo command */
1194 >                printf("\t%s\n", com);  /* echo command */
1195          if (noaction)
1196                  return(0);
1197          fflush(stdout);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines