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

Comparing ray/src/gen/mkillum.c (file contents):
Revision 1.3 by greg, Tue Jul 23 17:18:21 1991 UTC vs.
Revision 1.4 by greg, Wed Jul 24 12:22:03 1991 UTC

# Line 25 | Line 25 | static char SCCSid[] = "$SunId$ LBL";
25   #define  S_ALL          3               /* select all */
26  
27                                  /* rtrace command and defaults */
28 < char  *rtargv[64] = { "rtrace", "-dj", ".25", "-dr", "3", "-ab", "2",
29 <                "-ad", "256", "-as", "128", "-aa", ".15" };
30 < int  rtargc = 13;
28 > char  *rtargv[64] = { "rtrace", "-dj", ".25", "-dr", "3", "-di+",
29 >                "-ab", "2", "-ad", "256", "-as", "128", "-aa", ".15", };
30 > int  rtargc = 14;
31                                  /* overriding rtrace options */
32 < char  *myrtopts[] = { "-I-", "-i-", "-di+", "-ov", "-h-", "-fff", NULL };
32 > char  *myrtopts[] = { "-I-", "-i-", "-ov", "-h-", "-fff", NULL };
33  
34   struct rtproc   rt;             /* our rtrace process */
35  
# Line 135 | Line 135 | int  status;
135  
136   init()                          /* start rtrace and set up buffers */
137   {
138 <        extern int  o_face(), o_ring();
138 >        extern int  o_face(), o_sphere(), o_ring();
139          int     maxbytes;
140                                          /* set up object functions */
141          ofun[OBJ_FACE].funp = o_face;
142 +        ofun[OBJ_SPHERE].funp = o_sphere;
143          ofun[OBJ_RING].funp = o_ring;
144                                          /* set up signal handling */
145          signal(SIGPIPE, quit);
# Line 152 | Line 153 | init()                         /* start rtrace and set up buffers */
153          if (maxbytes < 0)
154                  error(SYSTEM, "cannot start rtrace process");
155          rt.bsiz = maxbytes/(6*sizeof(float));
156 <        rt.buf = (float *)malloc(rt.bsiz*(6*sizeof(float)));
157 <        if (rt.buf == NULL)
156 >        rt.buf = (float *)malloc(6*sizeof(float)*rt.bsiz--);
157 >        rt.dest = (float **)malloc(sizeof(float *)*rt.bsiz);
158 >        if (rt.buf == NULL || rt.dest == NULL)
159                  error(SYSTEM, "out of memory in init");
158        rt.bsiz--;                      /* allow for flush ray */
160          rt.nrays = 0;
161   }
162  
# Line 313 | Line 314 | char   *nm;
314                          cp = sskip(cp);
315                          continue;
316                  case 'l':                       /* light sources */
317 <                        if (*++cp != '+' && *cp != '-')
318 <                                break;
318 <                        if (*cp++ == '+')
317 >                        cp++;
318 >                        if (*cp == '+')
319                                  thisillum.flags |= IL_LIGHT;
320 <                        else
320 >                        else if (*cp == '-')
321                                  thisillum.flags &= ~IL_LIGHT;
322 +                        else
323 +                                break;
324 +                        cp++;
325                          continue;
326                  case 'o':                       /* output file */
327                          if (*++cp != '=')
# Line 351 | Line 354 | char   *nm;
354                                  progname, nerrs);
355          }
356                                                  /* print pure comment */
357 <        putchar('#'); putchar(' '); fputs(s+2, stdout);
357 >        printf("# %s", s+2);
358   }
359  
360  
# Line 387 | Line 390 | char  *nm;
390                  printf("\n%s %s %s", thisillum.altmat, ALIASID, str);
391                  if (fgetword(str, MAXSTR, fp) == NULL)
392                          goto readerr;
393 <                printf(" %s\n", str);
393 >                printf("\t%s\n", str);
394                  return;
395          }
396 <        thisobj.omod = OVOID;
396 >        thisobj.omod = OVOID;           /* unused field */
397          if ((thisobj.otype = otype(str)) < 0) {
398                  sprintf(errmsg, "(%s): unknown type \"%s\"", nm, str);
399                  error(USER, errmsg);
# Line 407 | Line 410 | char  *nm;
410                  doit = 0;
411                  break;
412          case S_ALL:
413 <                doit = issurface(thisobj.otype);
413 >                doit = 1;
414                  break;
415          case S_ELEM:
416                  doit = !strcmp(thisillum.altmat, matcheck);
# Line 416 | Line 419 | char  *nm;
419                  doit = strcmp(thisillum.altmat, matcheck);
420                  break;
421          }
422 <        if (doit && ofun[thisobj.otype].funp == o_default) {
420 <                sprintf(errmsg, "(%s): cannot make illum for %s \"%s\"",
421 <                                nm, ofun[thisobj.otype].funame, thisobj.oname);
422 <                error(WARNING, errmsg);
423 <                doit = 0;
424 <        }
422 >        doit = doit && issurface(thisobj.otype);
423                                                  /* print header? */
424          checkhead();
425                                                  /* process object */
426          if (doit)
427 <                (*ofun[thisobj.otype].funp)(&thisobj, &thisillum, &rt);
427 >                (*ofun[thisobj.otype].funp)(&thisobj, &thisillum, &rt, nm);
428          else
429                  printobj(thisillum.altmat, &thisobj);
430                                                  /* free arguments */
# Line 436 | Line 434 | readerr:
434          sprintf(errmsg, "(%s): error reading scene", nm);
435          error(USER, errmsg);
436   }
439
440
441 int
442 otype(ofname)                   /* get object function number from its name */
443 char  *ofname;
444 {
445        register int  i;
446
447        for (i = 0; i < NUMOTYPE; i++)
448                if (!strcmp(ofun[i].funame, ofname))
449                        return(i);
450
451        return(-1);             /* not found */
452 }
453
454
455 o_default() {}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines