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

Comparing ray/src/util/rad.c (file contents):
Revision 2.43 by greg, Thu Jul 6 12:15:40 1995 UTC vs.
Revision 2.47 by greg, Fri Dec 8 19:55:50 1995 UTC

# Line 1 | Line 1
1 < /* Copyright (c) 1994 Regents of the University of California */
1 > /* Copyright (c) 1995 Regents of the University of California */
2  
3   #ifndef lint
4   static char SCCSid[] = "$SunId$ LBL";
# Line 38 | Line 38 | int    onevalue(), catvalues(), boolvalue(),
38   #define ZONE            9               /* simulation zone */
39   #define QUALITY         10              /* desired rendering quality */
40   #define OCTREE          11              /* octree file name */
41 < #define PICTURE         12              /* picture file name */
41 > #define PICTURE         12              /* picture file root name */
42   #define AMBFILE         13              /* ambient file name */
43   #define OPTFILE         14              /* rendering options file */
44   #define EXPOSURE        15              /* picture exposure setting */
# Line 49 | Line 49 | int    onevalue(), catvalues(), boolvalue(),
49   #define PENUMBRAS       20              /* shadow penumbras are desired */
50   #define VARIABILITY     21              /* level of light variability */
51   #define REPORT          22              /* report frequency and errfile */
52 < #define RAWSAVE         23              /* save raw picture file */
52 > #define RAWFILE         23              /* raw picture file root name */
53 > #define ZFILE           24              /* distance file root name */
54                                  /* total number of variables */
55 < #define NVARS           24
55 > #define NVARS           25
56  
57   VARIABLE        vv[NVARS] = {           /* variable-value pairs */
58          {"objects",     3,      0,      NULL,   catvalues},
# Line 77 | Line 78 | VARIABLE       vv[NVARS] = {           /* variable-value pairs */
78          {"PENUMBRAS",   3,      0,      NULL,   boolvalue},
79          {"VARIABILITY", 3,      0,      NULL,   qualvalue},
80          {"REPORT",      3,      0,      NULL,   onevalue},
81 <        {"RAWSAVE",     3,      0,      NULL,   boolvalue},
81 >        {"RAWFILE",     3,      0,      NULL,   onevalue},
82 >        {"ZFILE",       2,      0,      NULL,   onevalue},
83   };
84  
85   VARIABLE        *matchvar();
# Line 99 | Line 101 | char   *nvalue();
101  
102                                  /* overture calculation file */
103   #ifdef NIX
104 < char    overfile[] = "overture.raw";
104 > char    overfile[] = "overture.unf";
105   #else
106   char    overfile[] = "/dev/null";
107   #endif
# Line 561 | Line 563 | double org[3], *sizp;
563          extern FILE     *popen();
564          static double   oorg[3], osiz = 0.;
565          double  min[3], max[3];
566 <        char    buf[512];
566 >        char    buf[1024];
567          FILE    *fp;
568          register int    i;
569  
# Line 649 | Line 651 | setdefaults()                  /* set default values for unassigned v
651                  vval(VARIABILITY) = "L";
652                  vdef(VARIABILITY)++;
653          }
652        if (!vdef(RAWSAVE)) {
653                vval(RAWSAVE) = "F";
654                vdef(RAWSAVE)++;
655        }
654   }
655  
656  
# Line 691 | Line 689 | printvals()                    /* print variable values */
689   oconv()                         /* run oconv and mkillum if necessary */
690   {
691          static char     illumtmp[] = "ilXXXXXX";
692 <        char    combuf[512], ocopts[64], mkopts[64];
692 >        char    combuf[1024], ocopts[64], mkopts[64];
693  
694          oconvopts(ocopts);              /* get options */
695          if (octreedate < scenedate) {   /* check date on original octree */
# Line 779 | Line 777 | oconv()                                /* run oconv and mkillum if necessary */
777                                  "%s: error generating octree\n\t%s removed\n",
778                                          progname, oct1name);
779                          unlink(oct1name);
780 +                        unlink(illumtmp);
781                          exit(1);
782                  }
783                  rmfile(illumtmp);
# Line 943 | Line 942 | medqopts(op, po)                       /* medium quality rendering options
942   register char   *op;
943   char    *po;
944   {
945 <        double  d, org[3], siz[3];
945 >        double  d, org[3], siz[3], asz;
946  
947          *op = '\0';
948          *po = '\0';
# Line 954 | Line 953 | char   *po;
953          if (siz[0] <= FTINY | siz[1] <= FTINY | siz[2] <= FTINY)
954                  badvalue(ZONE);
955          getoctcube(org, &d);
956 <        d *= 3./(siz[0]+siz[1]+siz[2]);
956 >        asz = (siz[0]+siz[1]+siz[2])/3.;
957 >        d /= asz;
958          switch (vscale(DETAIL)) {
959          case LOW:
960                  po = addarg(po, vbool(PENUMBRAS) ? "-ps 4" : "-ps 8");
961                  op = addarg(op, "-dp 256");
962                  sprintf(op, " -ar %d", (int)(8*d));
963                  op += strlen(op);
964 +                sprintf(op, " -ms %.2g", asz/20.);
965 +                op += strlen(op);
966                  break;
967          case MEDIUM:
968                  po = addarg(po, vbool(PENUMBRAS) ? "-ps 3" : "-ps 6");
969                  op = addarg(op, "-dp 512");
970                  sprintf(op, " -ar %d", (int)(16*d));
971                  op += strlen(op);
972 +                sprintf(op, " -ms %.2g", asz/40.);
973 +                op += strlen(op);
974                  break;
975          case HIGH:
976                  po = addarg(po, vbool(PENUMBRAS) ? "-ps 2" : "-ps 4");
977                  op = addarg(op, "-dp 1024");
978                  sprintf(op, " -ar %d", (int)(32*d));
979                  op += strlen(op);
980 +                sprintf(op, " -ms %.2g", asz/80.);
981 +                op += strlen(op);
982                  break;
983          }
984          po = addarg(po, "-pt .08");
# Line 1014 | Line 1020 | hiqopts(op, po)                                /* high quality rendering options *
1020   register char   *op;
1021   char    *po;
1022   {
1023 <        double  d, org[3], siz[3];
1023 >        double  d, org[3], siz[3], asz;
1024  
1025          *op = '\0';
1026          *po = '\0';
# Line 1025 | Line 1031 | char   *po;
1031          if (siz[0] <= FTINY | siz[1] <= FTINY | siz[2] <= FTINY)
1032                  badvalue(ZONE);
1033          getoctcube(org, &d);
1034 <        d *= 3./(siz[0]+siz[1]+siz[2]);
1034 >        asz = (siz[0]+siz[1]+siz[2])/3.;
1035 >        d /= asz;
1036          switch (vscale(DETAIL)) {
1037          case LOW:
1038                  po = addarg(po, vbool(PENUMBRAS) ? "-ps 1" : "-ps 8");
1039                  op = addarg(op, "-dp 1024");
1040                  sprintf(op, " -ar %d", (int)(16*d));
1041                  op += strlen(op);
1042 +                sprintf(op, " -ms %.2g", asz/40.);
1043 +                op += strlen(op);
1044                  break;
1045          case MEDIUM:
1046                  po = addarg(po, vbool(PENUMBRAS) ? "-ps 1" : "-ps 5");
1047                  op = addarg(op, "-dp 2048");
1048                  sprintf(op, " -ar %d", (int)(32*d));
1049                  op += strlen(op);
1050 +                sprintf(op, " -ms %.2g", asz/80.);
1051 +                op += strlen(op);
1052                  break;
1053          case HIGH:
1054                  po = addarg(po, vbool(PENUMBRAS) ? "-ps 1" : "-ps 3");
1055                  op = addarg(op, "-dp 4096");
1056                  sprintf(op, " -ar %d", (int)(64*d));
1057                  op += strlen(op);
1058 +                sprintf(op, " -ms %.2g", asz/160.);
1059 +                op += strlen(op);
1060                  break;
1061          }
1062          po = addarg(po, "-pt .04");
# Line 1185 | Line 1198 | register char  *vs;
1198                  zpos = -1; vs++;
1199          }
1200          viewtype = 'v';
1201 <        if (*vs == 'v' | *vs == 'l' | *vs == 'a' | *vs == 'h')
1201 >        if (*vs == 'v' | *vs == 'l' | *vs == 'a' | *vs == 'h' | *vs == 'c')
1202                  viewtype = *vs++;
1203          cp = viewopts;
1204          if ((!*vs || isspace(*vs)) && (xpos|ypos|zpos)) {       /* got one! */
# Line 1240 | Line 1253 | register char  *vs;
1253                  case 'h':
1254                          cp = addarg(cp, "-vh 180 -vv 180");
1255                          break;
1256 +                case 'c':
1257 +                        cp = addarg(cp, "-vh 180 -vv 90");
1258 +                        break;
1259                  }
1260          } else {
1261                  while (!isspace(*vs))           /* else skip id */
# Line 1388 | Line 1404 | rpict(opts, po)                                /* run rpict and pfilt for each vie
1404   char    *opts, *po;
1405   {
1406          char    combuf[1024];
1407 <        char    rawfile[MAXPATH], picfile[MAXPATH], rep[MAXPATH+16], res[32];
1407 >        char    rawfile[MAXPATH], picfile[MAXPATH];
1408 >        char    zopt[MAXPATH+4], rep[MAXPATH+16], res[32];
1409          char    pfopts[128];
1410          char    vs[32], *vw;
1411          int     vn, mult;
# Line 1441 | Line 1458 | char   *opts, *po;
1458                  if (!vs[0])
1459                          sprintf(vs, "%d", vn);
1460                  sprintf(picfile, "%s_%s.pic", vval(PICTURE), vs);
1461 +                if (vdef(ZFILE))
1462 +                        sprintf(zopt, " -z %s_%s.zbf", vval(ZFILE), vs);
1463 +                else
1464 +                        zopt[0] = '\0';
1465                                                  /* check date on picture */
1466                  pfdt = fdate(picfile);
1467                  if (pfdt >= oct1date)
1468                          continue;
1469                                                  /* get raw file name */
1470 <                sprintf(rawfile, "%s_%s.raw", vval(PICTURE), vs);
1470 >                sprintf(rawfile, "%s_%s.unf",
1471 >                        vdef(RAWFILE) ? vval(RAWFILE) : vval(PICTURE), vs);
1472                  rfdt = fdate(rawfile);
1473                  if (touchonly) {                /* update times only */
1474                          if (rfdt) {
# Line 1458 | Line 1480 | char   *opts, *po;
1480                  }
1481                                                  /* build rpict command */
1482                  if (rfdt >= oct1date)           /* recover */
1483 <                        sprintf(combuf, "rpict%s%s%s -ro %s %s",
1484 <                                        rep, po, opts, rawfile, oct1name);
1483 >                        sprintf(combuf, "rpict%s%s%s%s -ro %s %s",
1484 >                                rep, po, opts, zopt, rawfile, oct1name);
1485                  else {
1486                          if (overture) {         /* run overture calculation */
1487                                  sprintf(combuf,
# Line 1476 | Line 1498 | char   *opts, *po;
1498                                  rmfile(overfile);
1499   #endif
1500                          }
1501 <                        sprintf(combuf, "rpict%s %s %s%s%s %s > %s",
1502 <                                        rep, vw, res, po, opts,
1503 <                                oct1name, rawfile);
1501 >                        sprintf(combuf, "rpict%s %s %s%s%s%s %s > %s",
1502 >                                        rep, vw, res, po, opts, zopt,
1503 >                                        oct1name, rawfile);
1504                  }
1505                  if (runcom(combuf)) {           /* run rpict */
1506                          fprintf(stderr, "%s: error rendering view %s\n",
1507                                          progname, vs);
1508                          exit(1);
1509                  }
1510 +                if (!vdef(RAWFILE) || strcmp(vval(RAWFILE),vval(PICTURE))) {
1511                                                  /* build pfilt command */
1512 <                if (mult > 1)
1513 <                        sprintf(combuf, "pfilt%s -x /%d -y /%d %s > %s",
1512 >                        if (mult > 1)
1513 >                                sprintf(combuf, "pfilt%s -x /%d -y /%d %s > %s",
1514                                          pfopts, mult, mult, rawfile, picfile);
1515 <                else
1516 <                        sprintf(combuf, "pfilt%s %s > %s", pfopts,
1517 <                                        rawfile, picfile);
1518 <                if (runcom(combuf)) {           /* run pfilt */
1519 <                        fprintf(stderr,
1520 <                        "%s: error filtering view %s\n\t%s removed\n",
1521 <                                        progname, vs, picfile);
1522 <                        unlink(picfile);
1523 <                        exit(1);
1515 >                        else
1516 >                                sprintf(combuf, "pfilt%s %s > %s", pfopts,
1517 >                                                rawfile, picfile);
1518 >                        if (runcom(combuf)) {           /* run pfilt */
1519 >                                fprintf(stderr,
1520 >                                "%s: error filtering view %s\n\t%s removed\n",
1521 >                                                progname, vs, picfile);
1522 >                                unlink(picfile);
1523 >                                exit(1);
1524 >                        }
1525                  }
1526                                                  /* remove/rename raw file */
1527 <                if (vbool(RAWSAVE)) {
1528 <                        sprintf(combuf, "%s_%s.rwp", vval(PICTURE), vs);
1527 >                if (vdef(RAWFILE)) {
1528 >                        sprintf(combuf, "%s_%s.pic", vval(RAWFILE), vs);
1529                          mvfile(rawfile, combuf);
1530                  } else
1531                          rmfile(rawfile);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines