home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume21 / rayshade / patch2 < prev    next >
Encoding:
Internet Message Format  |  1990-03-21  |  54.4 KB

  1. Subject:  v21i017:  A ray tracing program, Patch2
  2. Newsgroups: comp.sources.unix
  3. Sender: sources
  4. Approved: rsalz@uunet.UU.NET
  5.  
  6. Submitted-by: Craig Kolb <craig@weedeater.math.yale.edu>
  7. Posting-number: Volume 21, Issue 17
  8. Archive-name: rayshade/patch2
  9.  
  10. System: rayshade version 3.0
  11. Patch #: 2
  12. Priority: MEDIUM
  13. Subject: New depth of field code.
  14. Subject: Minor changes to texturing functions.
  15. Subject: Changed direction of rendering when NORLE is defined.
  16. Subject: General documentation cleanup.
  17. Subject: New -F option, reporting of total CPU & split times.
  18. Subject: Added handling of cpp-generated '#n "filename"' lines.
  19. Subject: Removed #include handling.
  20. Subject: Suggest using cpp to process input files.
  21. Subject: Improved error/warning message reporting.
  22. Subject: Renamed utime and stime to avoid name clashes.
  23.  
  24. Description:
  25.  
  26.     Cleaned up, improved, and expanded documentation.
  27.     In particular, the height field documentation is a bit more
  28.     complete, the handling of colormaps is more fully explained,
  29.     and low-altitude mist is now documented.
  30.  
  31.     Added new depth of field code, courtesy of Rodney G. Bogart.
  32.     See documentation of the "aperture" and "focaldist" keywords for
  33.     details.
  34.  
  35.     Removed hard coded constants in calculation of ambient
  36.     component in several textures.  In all textures, computed
  37.     color values are now used to scale a surface's ambient and diffuse
  38.     colors.
  39.  
  40.     When NORLE is defined, images will now be rendered top-to-bottom
  41.     to provide complete compatibility with the output of Mark
  42.     VandeWettering's "mtv" ray tracer.
  43.  
  44.     Rayshade no longer processes #include directives.  Instead, you
  45.     are encouraged to make use of cpp (the C pre-processor) to aid
  46.     in the writing of input files.  Rayshade will make use of
  47.     cpp-generated line numbering to perform reasonable error reporting.
  48.     The example input file Examples/planet.ray shows how one might
  49.     use cpp to one's advantage.
  50.  
  51.     A new '-F' option can be used to set the frequency, in lines,
  52.     of status reports.  When in Verbose mode, rayshade will now
  53.     include the total and split CPU times with each status report.
  54.  
  55.     The format of error and warning messages should now be relatively
  56.     standard.
  57.  
  58.     Renamed utime and stime variables to avoid clashing with the
  59.     functions of the same name.
  60.  
  61.     The source comes a bit closer to passing lint.
  62.  
  63. Fix:    From rn, say "| patch -p -N -d DIR", where DIR is your rayshade source
  64.     directory.  Outside of rn, say "cd DIR; patch -p -N <thisarticle".
  65.     If you don't have the patch program, apply the following by hand,
  66.     or get patch (version 2.0, latest patchlevel).
  67.  
  68.     After patching:
  69.         Do *NOT* recompile.  Apply patch #3 immediately.
  70.  
  71.     If patch indicates that patchlevel is the wrong version, you may need
  72.     to apply one or more previous patches, or the patch may already
  73.     have been applied.  See the patchlevel.h file to find out what has or
  74.     has not been applied.  In any event, don't continue with the patch.
  75.  
  76.  
  77. Index: src/patchlevel.h
  78. Prereq: 1
  79. 1c1
  80. < #define PATCHLEVEL 1
  81. ---
  82. > #define PATCHLEVEL 2
  83.  
  84. Index: Changes
  85. *** Changes.old    Thu Dec  7 23:18:29 1989
  86. --- Changes    Thu Dec  7 23:18:29 1989
  87. ***************
  88. *** 1,3 ****
  89. --- 1,34 ----
  90. + Patch #2/3:
  91. + -----------
  92. + Added depth of field code, courtesy of Rodney G. Bogart.
  93. + Added -F option to allow selection of frequency of status reports.
  94. + Added reporting of total and split CPU times during verbose status reports.
  95. + Removed hard-coded constants in several of the textures.
  96. + All textures that use colormaps now use the computed colormap entry
  97. + to scale the ambient and diffuse components of a surface's color.
  98. + Documented low-altitude mist.
  99. + General cleanup of documentation.
  100. + If NORLE is defined, images will be rendered top-to-bottom
  101. + to be compatible with the output of Mark VandeWettering's ray tracer.
  102. + Patch #1:
  103. + ---------
  104. + Corrected computation of field of view when in Stereo mode.
  105. + Atmospheric effects are now applied to background rays.
  106. + Statistics are returned to supervisor and reported when using Linda.
  107. + Created atmosphere.h to facilitate addition of new atmospheric effects.
  108. + Renamed rotate(), translate() and scale() to avoid name clashes when
  109. + linking with external libraries.
  110. + Updated Linda syntax.
  111. + Fixed typos in code comments in hf.c.
  112. + Added -w option.
  113. + ---------
  114. + Version 3.0:
  115.   Bugfixes
  116.   --------
  117.   
  118. ***************
  119. *** 28,34 ****
  120.   Merged int_grid() and DDA().
  121.   Added "samples", "jittered", "cutoff", "contrast" and "adaptive" keywords.
  122.   Flat-shaded triangles now require less storage space.
  123. ! Shadow caching is now the default.
  124.   The number of shadow cache hits are reported.
  125.   Shadow cache hits are counted as "shadow rays".
  126.   Shadow hits are counted as "intersecting rays".
  127. --- 59,65 ----
  128.   Merged int_grid() and DDA().
  129.   Added "samples", "jittered", "cutoff", "contrast" and "adaptive" keywords.
  130.   Flat-shaded triangles now require less storage space.
  131. ! Shadow cacheing is now the default.
  132.   The number of shadow cache hits are reported.
  133.   Shadow cache hits are counted as "shadow rays".
  134.   Shadow hits are counted as "intersecting rays".
  135.  
  136. Index: README
  137. *** README.old    Thu Dec  7 23:18:43 1989
  138. --- README    Thu Dec  7 23:18:45 1989
  139. ***************
  140. *** 1,11 ****
  141. ! This is version 3.0 of rayshade, a raytracing program.  Rayshade reads
  142.   a multi-line ASCII file describing a scene to be rendered and produces
  143. ! a Utah Raster RLE format file of the raytraced image.
  144.   
  145.   Rayshade features:
  146.   
  147. !     Eight types of primitives (box, cone, cylinder, height field,
  148. !     polygon, sphere, superquadric, flat- and Phong-shaded triangle)
  149.   
  150.       Composite objects
  151.   
  152. --- 1,11 ----
  153. ! This is version 3.0 of rayshade, a ray tracing program.  Rayshade reads
  154.   a multi-line ASCII file describing a scene to be rendered and produces
  155. ! a Utah Raster RLE format file of the ray-traced image.
  156.   
  157.   Rayshade features:
  158.   
  159. !     Nine types of primitives (box, cone, cylinder, height field,
  160. !     plane, polygon, sphere, superquadric, flat- and Phong-shaded triangle)
  161.   
  162.       Composite objects
  163.   
  164. ***************
  165. *** 48,56 ****
  166.   formats.
  167.   
  168.   If you do not want to or cannot use the Utah Raster toolkit, compile-time
  169. ! switches are provided to create image files using a generic format very
  170. ! similar to that used by Mark VandeWettering's raytracer.  See the Makefile
  171. ! and src/outputp.c for details.
  172.   
  173.   The directory "src" contains the source to rayshade.  To compile, edit the
  174.   Makefile in that directory and change include file and library paths and set
  175. --- 48,56 ----
  176.   formats.
  177.   
  178.   If you do not want to or cannot use the Utah Raster toolkit, compile-time
  179. ! switches are provided to create image files using a generic format
  180. ! identical to that used by Mark VandeWettering's "mtv" ray tracer.  See the
  181. ! Makefile and src/outputp.c for details.
  182.   
  183.   The directory "src" contains the source to rayshade.  To compile, edit the
  184.   Makefile in that directory and change include file and library paths and set
  185. ***************
  186. *** 58,64 ****
  187.   software configuration.
  188.   
  189.   The file doc/rayshade.1 contains a brief manual page which covers most things
  190. ! a casual user will need to know in order to produce raytraced images.
  191.   A tutorial on adding new textures on rayshade is included in doc/texture.ms.
  192.   A similar document on adding new primitives to rayshade is in
  193.   doc/primitive.ms.  Unfortunately, there is as yet no technical documentation.
  194. --- 58,64 ----
  195.   software configuration.
  196.   
  197.   The file doc/rayshade.1 contains a brief manual page which covers most things
  198. ! a casual user will need to know in order to produce ray-traced images.
  199.   A tutorial on adding new textures on rayshade is included in doc/texture.ms.
  200.   A similar document on adding new primitives to rayshade is in
  201.   doc/primitive.ms.  Unfortunately, there is as yet no technical documentation.
  202. ***************
  203. *** 70,77 ****
  204.   several of the databases, you will need to tweak the data a bit to achieve
  205.   optimal runtimes.  See nff2shade.awk for details.
  206.   
  207.   Rayshade was not designed to be, nor is it, the be-all and end-all of
  208. ! raytracers.  It was meant to be reasonably fast, portable, and easy to 
  209.   modify.  It has some nice features which allow you to produce
  210.   pretty pictures, but there are countless extensions, modifications,
  211.   and improvements which could be made.  There are many routines which may be
  212. --- 70,83 ----
  213.   several of the databases, you will need to tweak the data a bit to achieve
  214.   optimal runtimes.  See nff2shade.awk for details.
  215.   
  216. + As of patch #2, rayshade no longer processes #include directives in the
  217. + input file.  Instead, you are encouraged to make use of cpp in the
  218. + design of your input files.  Rayshade will use cpp-generated lines
  219. + of the form '#n "filename"' to perform meaningful error reporting.
  220. + See Examples/planet.ray for more details.
  221.   Rayshade was not designed to be, nor is it, the be-all and end-all of
  222. ! ray tracers.  It was meant to be reasonably fast, portable, and easy to 
  223.   modify.  It has some nice features which allow you to produce
  224.   pretty pictures, but there are countless extensions, modifications,
  225.   and improvements which could be made.  There are many routines which may be
  226. ***************
  227. *** 79,85 ****
  228.   improvements and projects see "TODO".  You are encouraged to modify the
  229.   source code left and right.
  230.   
  231. ! Rayshade had its start as an "introductory" public domain raytracer written
  232.   by Roman Kuchkuda.  During 1987-88 the first version of rayshade was written
  233.   by Craig Kolb, David P. Dobkin (the original cylinder, cone and extinct torus-
  234.   tracing code), and David C. Hoffman (the original octree code).  Craig Kolb
  235. --- 85,91 ----
  236.   improvements and projects see "TODO".  You are encouraged to modify the
  237.   source code left and right.
  238.   
  239. ! Rayshade had its start as an "introductory" public domain ray tracer written
  240.   by Roman Kuchkuda.  During 1987-88 the first version of rayshade was written
  241.   by Craig Kolb, David P. Dobkin (the original cylinder, cone and extinct torus-
  242.   tracing code), and David C. Hoffman (the original octree code).  Craig Kolb
  243. ***************
  244. *** 93,99 ****
  245.   comments, and willingness to be on the Front Lines.  Thanks also to Roman
  246.   Kuchkuda for providing a base upon which to build.  Special thanks to Robert
  247.   Skinner for providing the Noise(), DNoise(), and other texturing functions
  248. ! and allowing them to be redistributed.
  249.   
  250.   If you find any bugs, make any useful extensions, have a nice input
  251.   file, port rayshade to a new environment, or need assistance understanding a
  252. --- 99,106 ----
  253.   comments, and willingness to be on the Front Lines.  Thanks also to Roman
  254.   Kuchkuda for providing a base upon which to build.  Special thanks to Robert
  255.   Skinner for providing the Noise(), DNoise(), and other texturing functions
  256. ! and allowing them to be redistributed.  Thanks also to Rodney G. Bogart for
  257. ! providing the depth of field code.
  258.   
  259.   If you find any bugs, make any useful extensions, have a nice input
  260.   file, port rayshade to a new environment, or need assistance understanding a
  261. ***************
  262. *** 100,106 ****
  263.   particularly braindamaged section of code, please let me know.  I can be most
  264.   easily reached by email.
  265.   
  266. ! Craig Kolb 10/27/89
  267.   kolb@yale.edu
  268.   
  269.   Yale University Dept. of Mathematics
  270. --- 107,113 ----
  271.   particularly braindamaged section of code, please let me know.  I can be most
  272.   easily reached by email.
  273.   
  274. ! Craig Kolb 7 Dec 89
  275.   kolb@yale.edu
  276.   
  277.   Yale University Dept. of Mathematics
  278.  
  279. Index: src/box.c
  280. *** src/box.c.old    Thu Dec  7 23:19:17 1989
  281. --- src/box.c    Thu Dec  7 23:19:19 1989
  282. ***************
  283. *** 18,26 ****
  284.    * name of the person performing the modification, the date of modification,
  285.    * and the reason for such modification.
  286.    *
  287. !  * $Id: box.c,v 3.0 89/10/27 02:05:47 craig Exp $
  288.    *
  289.    * $Log:    box.c,v $
  290.    * Revision 3.0  89/10/27  02:05:47  craig
  291.    * Baseline for first official release.
  292.    * 
  293. --- 18,29 ----
  294.    * name of the person performing the modification, the date of modification,
  295.    * and the reason for such modification.
  296.    *
  297. !  * $Id: box.c,v 3.0.1.1 89/12/06 16:33:48 craig Exp $
  298.    *
  299.    * $Log:    box.c,v $
  300. +  * Revision 3.0.1.1  89/12/06  16:33:48  craig
  301. +  * patch2: Added calls to new error/warning routines.
  302. +  * 
  303.    * Revision 3.0  89/10/27  02:05:47  craig
  304.    * Baseline for first official release.
  305.    * 
  306. ***************
  307. *** 39,49 ****
  308.       Box          *box;
  309.       Primitive *prim;
  310.       Object *newobj;
  311. -     extern int Quiet, yylineno;
  312.   
  313.       if (xs < EPSILON || ys < EPSILON || zs < EPSILON) {
  314. !         if (!Quiet)
  315. !             fprintf(stderr,"Degenerate box (line %d)\n",yylineno);
  316.           return (Object *)0;
  317.       }
  318.       prim = mallocprim();
  319. --- 42,50 ----
  320.       Box          *box;
  321.       Primitive *prim;
  322.       Object *newobj;
  323.   
  324.       if (xs < EPSILON || ys < EPSILON || zs < EPSILON) {
  325. !         yywarning("Degenerate box.\n");
  326.           return (Object *)0;
  327.       }
  328.       prim = mallocprim();
  329.  
  330. Index: src/cone.c
  331. *** src/cone.c.old    Thu Dec  7 23:19:24 1989
  332. --- src/cone.c    Thu Dec  7 23:19:25 1989
  333. ***************
  334. *** 18,26 ****
  335.    * name of the person performing the modification, the date of modification,
  336.    * and the reason for such modification.
  337.    *
  338. !  * $Id: cone.c,v 3.0.1.1 89/11/18 14:08:09 craig Exp Locker: craig $
  339.    *
  340.    * $Log:    cone.c,v $
  341.    * Revision 3.0.1.1  89/11/18  14:08:09  craig
  342.    * patch1: Changes to reflect new names of transformation routines.
  343.    * 
  344. --- 18,29 ----
  345.    * name of the person performing the modification, the date of modification,
  346.    * and the reason for such modification.
  347.    *
  348. !  * $Id: cone.c,v 3.0.1.2 89/12/06 16:33:44 craig Exp $
  349.    *
  350.    * $Log:    cone.c,v $
  351. +  * Revision 3.0.1.2  89/12/06  16:33:44  craig
  352. +  * patch2: Added calls to new error/warning routines.
  353. +  * 
  354.    * Revision 3.0.1.1  89/11/18  14:08:09  craig
  355.    * patch1: Changes to reflect new names of transformation routines.
  356.    * 
  357. ***************
  358. *** 44,50 ****
  359.       Cone *cone;
  360.       Primitive *prim;
  361.       Object *newobj;
  362. -     extern int yylineno, Quiet;
  363.       double len, dtmp;
  364.       Vector axis, base, tmp;
  365.   
  366. --- 47,52 ----
  367. ***************
  368. *** 96,104 ****
  369.       vecsub(*ax, *cent, &axis);
  370.       len = normalize(&axis);
  371.       if (len < EPSILON) {
  372. !         if (!Quiet)
  373. !             fprintf(stderr,"Degenerate cone (line %d).\n",
  374. !                             yylineno);
  375.           free((char *)cone);
  376.           free((char *)prim);
  377.           free((char *)newobj);
  378. --- 98,104 ----
  379.       vecsub(*ax, *cent, &axis);
  380.       len = normalize(&axis);
  381.       if (len < EPSILON) {
  382. !         yywarning("Degenerate cone.\n");
  383.           free((char *)cone);
  384.           free((char *)prim);
  385.           free((char *)newobj);
  386.  
  387. Index: src/cylinder.c
  388. *** src/cylinder.c.old    Thu Dec  7 23:19:30 1989
  389. --- src/cylinder.c    Thu Dec  7 23:19:32 1989
  390. ***************
  391. *** 18,26 ****
  392.    * name of the person performing the modification, the date of modification,
  393.    * and the reason for such modification.
  394.    *
  395. !  * $Id: cylinder.c,v 3.0.1.1 89/11/18 14:07:52 craig Exp Locker: craig $
  396.    *
  397.    * $Log:    cylinder.c,v $
  398.    * Revision 3.0.1.1  89/11/18  14:07:52  craig
  399.    * patch1: Changes to reflect new names of transformation routines.
  400.    * 
  401. --- 18,29 ----
  402.    * name of the person performing the modification, the date of modification,
  403.    * and the reason for such modification.
  404.    *
  405. !  * $Id: cylinder.c,v 3.0.1.2 89/12/06 16:33:41 craig Exp $
  406.    *
  407.    * $Log:    cylinder.c,v $
  408. +  * Revision 3.0.1.2  89/12/06  16:33:41  craig
  409. +  * patch2: Added calls to new error/warning routines.
  410. +  * 
  411.    * Revision 3.0.1.1  89/11/18  14:07:52  craig
  412.    * patch1: Changes to reflect new names of transformation routines.
  413.    * 
  414. ***************
  415. *** 45,57 ****
  416.       Primitive *prim;
  417.       Object *newobj;
  418.       double len;
  419. -     extern int yylineno, Quiet;
  420.       Vector axis, dir;
  421.   
  422.       if (r <= 0.) {
  423. !         if (!Quiet)
  424. !             fprintf(stderr,"Invalid cylinder radius (line %d)\n",
  425. !                 yylineno);
  426.           return (Object *)0;
  427.       }
  428.   
  429. --- 48,57 ----
  430.       Primitive *prim;
  431.       Object *newobj;
  432.       double len;
  433.       Vector axis, dir;
  434.   
  435.       if (r <= 0.) {
  436. !         yywarning("Invalid cylinder radius.\n");
  437.           return (Object *)0;
  438.       }
  439.   
  440. ***************
  441. *** 68,76 ****
  442.   
  443.       len = normalize(&axis);
  444.       if(len < EPSILON) {
  445. !         if (!Quiet)
  446. !             fprintf(stderr,"Degenerate cylinder (line %d).\n",
  447. !                             yylineno);
  448.           free((char *)cyl);
  449.           free((char *)prim);
  450.           return (Object *)0;
  451. --- 68,74 ----
  452.   
  453.       len = normalize(&axis);
  454.       if(len < EPSILON) {
  455. !         yywarning("Degenerate cylinder.\n");
  456.           free((char *)cyl);
  457.           free((char *)prim);
  458.           return (Object *)0;
  459.  
  460. Index: src/defaults.h
  461. *** src/defaults.h.old    Thu Dec  7 23:19:37 1989
  462. --- src/defaults.h    Thu Dec  7 23:19:38 1989
  463. ***************
  464. *** 18,26 ****
  465.    * name of the person performing the modification, the date of modification,
  466.    * and the reason for such modification.
  467.    *
  468. !  * $Id: defaults.h,v 3.0 89/10/27 02:05:49 craig Exp $
  469.    *
  470.    * $Log:    defaults.h,v $
  471.    * Revision 3.0  89/10/27  02:05:49  craig
  472.    * Baseline for first official release.
  473.    * 
  474. --- 18,29 ----
  475.    * name of the person performing the modification, the date of modification,
  476.    * and the reason for such modification.
  477.    *
  478. !  * $Id: defaults.h,v 3.0.1.1 89/12/02 16:50:42 craig Exp $
  479.    *
  480.    * $Log:    defaults.h,v $
  481. +  * Revision 3.0.1.1  89/12/02  16:50:42  craig
  482. +  * patch2: Added default value for ReportFreq.
  483. +  * 
  484.    * Revision 3.0  89/10/27  02:05:49  craig
  485.    * Baseline for first official release.
  486.    * 
  487. ***************
  488. *** 43,48 ****
  489. --- 46,52 ----
  490.   #define UPX        0        /* Up vector */
  491.   #define UPY        0
  492.   #define UPZ        1
  493. + #define REPORTFREQ    10        /* Frequency of status report */
  494.   
  495.   #define DEFREDCONT    0.25        /* Default contrast threshold values. */
  496.   #define DEFGREENCONT    0.2
  497.  
  498. Index: src/hf.c
  499. *** src/hf.c.old    Thu Dec  7 23:19:44 1989
  500. --- src/hf.c    Thu Dec  7 23:19:45 1989
  501. ***************
  502. *** 18,26 ****
  503.    * name of the person performing the modification, the date of modification,
  504.    * and the reason for such modification.
  505.    *
  506. !  * $Id: hf.c,v 3.0.1.1 89/11/16 20:44:28 craig Exp Locker: craig $
  507.    *
  508.    * $Log:    hf.c,v $
  509.    * Revision 3.0.1.1  89/11/16  20:44:28  craig
  510.    * patch1: Fixed typos in code comments.
  511.    * 
  512. --- 18,29 ----
  513.    * name of the person performing the modification, the date of modification,
  514.    * and the reason for such modification.
  515.    *
  516. !  * $Id: hf.c,v 3.0.1.2 89/12/06 16:33:23 craig Exp $
  517.    *
  518.    * $Log:    hf.c,v $
  519. +  * Revision 3.0.1.2  89/12/06  16:33:23  craig
  520. +  * patch2: Added calls to new error/warning routines.
  521. +  * 
  522.    * Revision 3.0.1.1  89/11/16  20:44:28  craig
  523.    * patch1: Fixed typos in code comments.
  524.    * 
  525. ***************
  526. *** 57,67 ****
  527.    * Used to differentiate between the two triangles used to represent a cell:
  528.    *    a------d
  529.    *      |\     |
  530. !  *      | \TRI1|    TRI1 == c-->d-->a-->c
  531.    *      |  \   |
  532.    *      |   \  |
  533.    *    |    \ |
  534. !  *      |TRI2 \|    TRI2 == c-->a-->b-->c
  535.    *      b------c
  536.    */
  537.   #define TRI1            1
  538. --- 60,70 ----
  539.    * Used to differentiate between the two triangles used to represent a cell:
  540.    *    a------d
  541.    *      |\     |
  542. !  *      | \TRI2|    TRI2 == c-->d-->a-->c
  543.    *      |  \   |
  544.    *      |   \  |
  545.    *    |    \ |
  546. !  *      |TRI1 \|    TRI1 == c-->a-->b-->c
  547.    *      b------c
  548.    */
  549.   #define TRI1            1
  550. ***************
  551. *** 93,99 ****
  552.   
  553.       fp = fopen(filename, "r");
  554.       if (fp == (FILE *)NULL)
  555. !         yyerror("Cannot open heightfield file");
  556.   
  557.       prim = mallocprim();
  558.       newobj = new_object(NULL, HF, (char *)prim, (Trans *)NULL);
  559. --- 96,102 ----
  560.   
  561.       fp = fopen(filename, "r");
  562.       if (fp == (FILE *)NULL)
  563. !         yyerror("Cannot open heightfield file \"%s\".", filename);
  564.   
  565.       prim = mallocprim();
  566.       newobj = new_object(NULL, HF, (char *)prim, (Trans *)NULL);
  567.  
  568. Index: src/input.c
  569. *** src/input.c.old    Thu Dec  7 23:19:52 1989
  570. --- src/input.c    Thu Dec  7 23:19:53 1989
  571. ***************
  572. *** 18,141 ****
  573.    * name of the person performing the modification, the date of modification,
  574.    * and the reason for such modification.
  575.    *
  576. !  * $Id: input.c,v 3.0 89/10/27 02:05:51 craig Exp $
  577.    *
  578.    * $Log:    input.c,v $
  579.    * Revision 3.0  89/10/27  02:05:51  craig
  580.    * Baseline for first official release.
  581.    * 
  582.    */
  583.   #include <stdio.h>
  584. - #ifdef SYSV
  585. - #include <string.h>
  586. - #else
  587. - #ifndef AZTEC_C
  588. - #include <strings.h>
  589. - #else /* AZTEC_C */
  590. - getpid()
  591. - {
  592. -     return 123;
  593. - }
  594. - #endif
  595. - #endif
  596. - #include "constants.h"
  597. - #include "typedefs.h"
  598. - #define INCLUDE_STR    "#include "
  599.   
  600.   char *infilename;    /* Name of input file.  NULL signifies stdin. */
  601. - char tmpname[BUFSIZ];    /* name of temporary file */
  602. - extern FILE *yyin;    /* lex/yacc file pointer */
  603.   
  604.   read_input_file()
  605.   {
  606. !     extern char *infilename;
  607. !     /*
  608. !      * Open temporary file.
  609. !      */
  610. !     sprintf(tmpname,"%s/raytmp.%d",TMPDIR, getpid());
  611. !     yyin = fopen(tmpname, "w");
  612.   
  613. !     if (yyin == (FILE *)NULL) {
  614. !         fprintf(stderr,"Cannot write to temp file %s\n",tmpname);
  615. !         exit(1);
  616.       }
  617. -     if (!process_file(infilename)) {
  618. -         /*
  619. -          * Some kind of error occurred -- unlink
  620. -          * temporary file and exit.
  621. -          */
  622. -         fclose(yyin);
  623. -         unlink(tmpname);
  624. -         exit(1);
  625. -     }
  626. -     /*
  627. -      * File processed okay.  Close the file, open it again for
  628. -      * reading, and call lex/yacc.
  629. -      */
  630. -     fclose(yyin);
  631. -     yyin = fopen(tmpname, "r");
  632.       yyparse();
  633. -     /*
  634. -      * All done -- unlink temporary file.
  635. -      */
  636. -     unlink(tmpname);
  637.   }
  638.   
  639.   /*
  640. !  * Open the named file and copy its contents into the temporary file.
  641. !  * If we run across a #include directive, recurse on the desired
  642. !  * file.  Note that *no checking is performed* -- a file could,
  643. !  * for example, include itself.  Rayshade will happily go on
  644. !  * copying data into the temporary file until it runs out
  645. !  * of file pointers (an fopen will fail), or you run out of disk space...
  646.    */
  647. ! process_file(filename)
  648. ! char *filename;
  649.   {
  650. !     FILE *fp;
  651. !     char buf[BUFSIZ], *name, *np;
  652. !     extern int yylineno;
  653.   
  654. !     if (filename == (char *)NULL)
  655. !         fp = stdin;
  656. !     else {
  657. !         fp = fopen(filename, "r");
  658. !         if (fp == (FILE *)NULL) {
  659. !             fprintf(stderr,"Cannot open %s for reading.\n",filename);
  660. !             return FALSE;
  661. !         }
  662. !     }
  663.   
  664. !     while(fgets(buf, BUFSIZ, fp) != NULL) {
  665. !         if (strncmp(buf, INCLUDE_STR, strlen(INCLUDE_STR)) == 0) {
  666. !             /*
  667. !              * Got an "#include "...
  668. !              */
  669. ! #ifdef SYSV
  670. !             name = strchr(buf, '"');
  671. !             np = strrchr(buf, '"');
  672. ! #else
  673. !             name = index(buf, '"');
  674. !             np = rindex(buf, '"');
  675. ! #endif
  676. !             /*
  677. !              * Get name between quotes.  If no or
  678. !              * one quote, complain.
  679. !              */
  680. !             if (name == (char *)0 || name == np) {
  681. !                 fprintf(stderr,"Invalid include directive (line %d)\n", yylineno);
  682. !                 return FALSE;
  683. !             }
  684. !             name++;
  685. !             *np = (char)NULL;
  686. !             if (process_file(name) == FALSE)
  687. !                 return FALSE;
  688. !         } else
  689. !             fputs(buf, yyin);
  690. !     }
  691. !     return TRUE;
  692.   }
  693. --- 18,96 ----
  694.    * name of the person performing the modification, the date of modification,
  695.    * and the reason for such modification.
  696.    *
  697. !  * $Id: input.c,v 3.0.1.2 89/12/07 22:53:32 craig Exp $
  698.    *
  699.    * $Log:    input.c,v $
  700. +  * Revision 3.0.1.2  89/12/07  22:53:32  craig
  701. +  * patch2: Added comments, lint-related goofiness.
  702. +  * 
  703. +  * Revision 3.0.1.1  89/12/06  16:08:43  craig
  704. +  * patch2: Removed #include handling.  Added RSmessage(), RSwarning(),
  705. +  * patch2: and RSerror().
  706. +  * 
  707.    * Revision 3.0  89/10/27  02:05:51  craig
  708.    * Baseline for first official release.
  709.    * 
  710.    */
  711.   #include <stdio.h>
  712.   
  713.   char *infilename;    /* Name of input file.  NULL signifies stdin. */
  714.   
  715. + /*
  716. +  * Open input file and call yyparse().
  717. +  */
  718.   read_input_file()
  719.   {
  720. !     extern FILE *yyin;    /* lex/yacc file pointer */
  721. !     extern char yyfilename[];
  722.   
  723. !     if (infilename == (char *)NULL) {
  724. !         yyin = stdin;
  725. !         strcpy(yyfilename, "stdin");
  726. !     } else {
  727. !         yyin = fopen(infilename, "r");
  728. !         if (yyin == (FILE *)NULL)
  729. !             RSerror("Cannot open %s.\n",infilename);
  730. !         strcpy(yyfilename, infilename);
  731.       }
  732.       yyparse();
  733.   }
  734.   
  735.   /*
  736. !  * Print message to standard output with format:
  737. !  * program_name: message_type: message
  738.    */
  739. ! /*VARARGS2*/
  740. ! RSmessage(type, str, pat1, pat2, pat3)
  741. ! char *type, *str, *pat1, *pat2, *pat3;
  742.   {
  743. !     extern char *progname;
  744.   
  745. !     fprintf(stderr,"%s: %s: ",progname, type);
  746. !     fprintf(stderr, str, pat1, pat2, pat3);
  747. !     fflush(stderr);
  748. ! }
  749.   
  750. ! /*
  751. !  * Issue warning message if not in Quiet mode.
  752. !  */
  753. ! /*VARARGS1*/
  754. ! RSwarning(str, pat1, pat2, pat3)
  755. ! char *str, *pat1, *pat2, *pat3;
  756. ! {
  757. !     extern int Quiet;
  758. !     if (!Quiet)
  759. !         RSmessage("Warning", str, pat1, pat2, pat3);
  760. ! }
  761. ! /*
  762. !  * Issue error message and exit.
  763. !  */
  764. ! /*VARARGS1*/
  765. ! RSerror(str, pat1, pat2, pat3)
  766. ! char *str, *pat1, *pat2, *pat3;
  767. ! {
  768. !     RSmessage("Error", str, pat1, pat2, pat3);
  769. !     exit(1);
  770.   }
  771.  
  772. Index: src/input_lex.l
  773. *** src/input_lex.l.old    Thu Dec  7 23:20:09 1989
  774. --- src/input_lex.l    Thu Dec  7 23:20:10 1989
  775. ***************
  776. *** 13,19 ****
  777.   /* without supplying the source, or without informing the end-user that the */
  778.   /* source is available for no extra charge.                    */
  779.   /*                                        */
  780. ! /* $Id: input_lex.l,v 3.0 89/10/27 02:05:52 craig Exp $ */
  781.   %{
  782.   #include <stdio.h>
  783.   #ifdef SYSV
  784. --- 13,19 ----
  785.   /* without supplying the source, or without informing the end-user that the */
  786.   /* source is available for no extra charge.                    */
  787.   /*                                        */
  788. ! /* $Id: input_lex.l,v 3.0.1.3 89/12/07 23:00:54 craig Exp $ */
  789.   %{
  790.   #include <stdio.h>
  791.   #ifdef SYSV
  792. ***************
  793. *** 33,43 ****
  794.   string    ({alpha}|"/")({alpha}|{digit}|{special}|"/")*
  795.   %p 3000
  796.   %%
  797. ! " "            ;
  798. ! \t            ;
  799. ! \n            ;
  800.   "/*"            {skipcomments();}
  801.   adaptive        {return(tADAPTIVE);}
  802.   background        {return(tBACKGROUND);}
  803.   blotch            {return(tBLOTCH);}
  804.   box            {return(tBOX);}
  805. --- 33,43 ----
  806.   string    ({alpha}|"/")({alpha}|{digit}|{special}|"/")*
  807.   %p 3000
  808.   %%
  809. ! [ \t\n]            ;
  810. ! ^#            {handlehash();}
  811.   "/*"            {skipcomments();}
  812.   adaptive        {return(tADAPTIVE);}
  813. + aperture        {return(tAPERTURE);}
  814.   background        {return(tBACKGROUND);}
  815.   blotch            {return(tBLOTCH);}
  816.   box            {return(tBOX);}
  817. ***************
  818. *** 55,60 ****
  819. --- 55,61 ----
  820.   eyep            {return(tEYEP);}
  821.   fbm            {return(tFBM);}
  822.   fbmbump            {return(tFBMBUMP);}
  823. + focaldist        {return(tFOCALDIST);}
  824.   fog            {return(tFOG);}
  825.   fov            {return(tFOV);}
  826.   grid            {return(tGRID);}
  827. ***************
  828. *** 111,115 ****
  829. --- 112,159 ----
  830.           if ((c = input()) == '/')
  831.               return;
  832.           unput(c);
  833. +     }
  834. + }
  835. + /*
  836. +  * Deal with ccp-produced lines of the form:
  837. +  * # n "filename"
  838. +  * and
  839. +  * # n
  840. +  * Where filename is the name of the file being processed, and n is
  841. +  * the current line number in that file.
  842. +  */
  843. + handlehash()
  844. + {
  845. +     char buf[BUFSIZ];
  846. +     int i;
  847. +     extern int yylineno;
  848. +     extern char yyfilename[];
  849. +     /*
  850. +      * Read the entire line into buf.
  851. +      */
  852. +     for (i = 0; (buf[i] = input()) != '\n'; i++)
  853. +             ;
  854. +     unput(buf[i]);        /* To make sure consecutive # lines work. */
  855. +     buf[i] = (char)NULL;    /* Replace newline with NULL. */
  856. +     /*
  857. +      * Complain if the line was not of the form #n "filename"
  858. +      */
  859. +     if ((i = sscanf(buf, "%d \"%[^\"]s\"", &yylineno, yyfilename)) == 0) {
  860. +         yyerror("Unknown '#' control.");
  861. +         exit(1);
  862. +     }
  863. +     if (i == 1) {
  864. + #ifdef SYSV
  865. +         if (strchr(buf, '"') != (char *)0) {
  866. + #else
  867. +         if (index(buf, '"') != (char *)0) {
  868. + #endif
  869. +             /*
  870. +              * Filename was "", which means stdin.
  871. +              */
  872. +             strcpy(yyfilename, "stdin");
  873. +         }
  874.       }
  875.   }
  876.  
  877. Index: src/input_yacc.y
  878. *** src/input_yacc.y.old    Thu Dec  7 23:20:17 1989
  879. --- src/input_yacc.y    Thu Dec  7 23:20:19 1989
  880. ***************
  881. *** 17,23 ****
  882.   /* name of the person performing the modification, the date of modification,*/
  883.   /* and the reason for such modification.                    */
  884.   /*                                        */
  885. ! /* $Id: input_yacc.y,v 3.0.1.3 89/11/20 13:05:33 craig Exp Locker: craig $ */
  886.   %{
  887.   #include <stdio.h>
  888.   #include "constants.h"
  889. --- 17,23 ----
  890.   /* name of the person performing the modification, the date of modification,*/
  891.   /* and the reason for such modification.                    */
  892.   /*                                        */
  893. ! /* $Id: input_yacc.y,v 3.0.1.6 89/12/07 22:55:53 craig Exp $ */
  894.   %{
  895.   #include <stdio.h>
  896.   #include "constants.h"
  897. ***************
  898. *** 26,33 ****
  899.   #include "texture.h"
  900.   #include "atmosphere.h"
  901.   
  902.   int Npoints=0, CurXSize, CurYSize, CurZSize;
  903. ! Object *LastObj = (Object *)0;
  904.   ObjList *CurObj, *ListTmp;
  905.   Surface *stmp;
  906.   Texture *CurText;
  907. --- 26,34 ----
  908.   #include "texture.h"
  909.   #include "atmosphere.h"
  910.   
  911. + char yyfilename[BUFSIZ];
  912.   int Npoints=0, CurXSize, CurYSize, CurZSize;
  913. ! Object    *LastObj = (Object *)0;
  914.   ObjList *CurObj, *ListTmp;
  915.   Surface *stmp;
  916.   Texture *CurText;
  917. ***************
  918. *** 40,46 ****
  919.   extern int ResolutionSet, ContrastSet, SamplesSet, CutoffSet;
  920.   extern int AdaptiveSet, JitteredSet;
  921.   extern double hfov, vfov, RedContrast, GreenContrast, BlueContrast;
  922. ! extern double TreeCutoff;
  923.   extern Vector eyep, lookp, up;
  924.   extern char outfilename[];
  925.   extern Color background;
  926. --- 41,47 ----
  927.   extern int ResolutionSet, ContrastSet, SamplesSet, CutoffSet;
  928.   extern int AdaptiveSet, JitteredSet;
  929.   extern double hfov, vfov, RedContrast, GreenContrast, BlueContrast;
  930. ! extern double TreeCutoff, aperture, focaldist;
  931.   extern Vector eyep, lookp, up;
  932.   extern char outfilename[];
  933.   extern Color background;
  934. ***************
  935. *** 60,67 ****
  936.   %token <i> tINT
  937.   %token <d> tFLOAT
  938.   %token <c> tSTRING
  939. ! %token tADAPTIVE tBACKGROUND tBLOTCH tBOX tBUMP tCONE tCYL tDIRECTIONAL
  940. ! %token tENDDEF tEXTENDED tEYEP tFBM tFBMBUMP tFOG tFOV tGRID
  941.   %token tHEIGHTFIELD tJITTERED tLIGHT tLIST tLOOKP tMARBLE tMAXDEPTH tMIST
  942.   %token tOBJECT tOUTFILE
  943.   %token tPLANE tPOINT tPOLY tROTATE tSAMPLES
  944. --- 61,69 ----
  945.   %token <i> tINT
  946.   %token <d> tFLOAT
  947.   %token <c> tSTRING
  948. ! %token tADAPTIVE tAPERTURE 
  949. ! %token tBACKGROUND tBLOTCH tBOX tBUMP tCONE tCYL tDIRECTIONAL
  950. ! %token tENDDEF tEXTENDED tEYEP tFBM tFBMBUMP tFOCALDIST tFOG tFOV tGRID
  951.   %token tHEIGHTFIELD tJITTERED tLIGHT tLIST tLOOKP tMARBLE tMAXDEPTH tMIST
  952.   %token tOBJECT tOUTFILE
  953.   %token tPLANE tPOINT tPOLY tROTATE tSAMPLES
  954. ***************
  955. *** 82,87 ****
  956. --- 84,91 ----
  957.           | Up
  958.           | Fov
  959.           | Screen
  960. +         | Aperture
  961. +         | Focaldist
  962.           | Maxdepth
  963.           | Samples
  964.           | Jittered
  965. ***************
  966. *** 198,205 ****
  967.                */
  968.               LastObj = (Object *)NULL;
  969.               if (CurObj->data->data == (char *)0) {
  970. !                 fprintf(stderr,"Warning: null object defined");
  971. !                 fprintf(stderr," (line %d)\n",yylineno);
  972.               } else {
  973.                   if (CurObj->data->type == GRID) {
  974.                       list2grid(CurObj->data, CurXSize,
  975. --- 202,209 ----
  976.                */
  977.               LastObj = (Object *)NULL;
  978.               if (CurObj->data->data == (char *)0) {
  979. !                 yywarning("Null object \"%s\" defined.\n",
  980. !                     CurObj->data->name);
  981.               } else {
  982.                   if (CurObj->data->type == GRID) {
  983.                       list2grid(CurObj->data, CurXSize,
  984. ***************
  985. *** 471,476 ****
  986. --- 475,490 ----
  987.               }
  988.           }
  989.           ;
  990. + Aperture    : tAPERTURE Fnumber
  991. +         {
  992. +             aperture = $2;
  993. +         }
  994. +         ;
  995. + Focaldist    : tFOCALDIST Fnumber
  996. +         {
  997. +             focaldist = $2;
  998. +         }
  999. +         ;
  1000.   Maxdepth    : tMAXDEPTH tINT
  1001.           {
  1002.               maxlevel = $2;
  1003. ***************
  1004. *** 505,511 ****
  1005.   Lightdef    : tLIGHT Fnumber
  1006.           {
  1007.               if (nlight == LIGHTS)
  1008. !                 yyerror("Too many lights.");
  1009.               light[nlight].color.r = $2;
  1010.               light[nlight].color.g = $2;
  1011.               light[nlight].color.b = $2;
  1012. --- 519,525 ----
  1013.   Lightdef    : tLIGHT Fnumber
  1014.           {
  1015.               if (nlight == LIGHTS)
  1016. !                 yyerror("Too many lights.\n");
  1017.               light[nlight].color.r = $2;
  1018.               light[nlight].color.g = $2;
  1019.               light[nlight].color.b = $2;
  1020. ***************
  1021. *** 626,633 ****
  1022.   Outfile        : tOUTFILE String
  1023.           {
  1024.               if (*outfilename != (char)NULL)
  1025. !                 fprintf(stderr,"Ignoring output name \"%s\"\n",
  1026. !                     $2);
  1027.               else
  1028.                   strcpy(outfilename, $2);
  1029.           }
  1030. --- 640,647 ----
  1031.   Outfile        : tOUTFILE String
  1032.           {
  1033.               if (*outfilename != (char)NULL)
  1034. !                 yywarning("Ignoring output file name \"%s\".\n",
  1035. !                             $2);
  1036.               else
  1037.                   strcpy(outfilename, $2);
  1038.           }
  1039. ***************
  1040. *** 670,682 ****
  1041.   String        : tSTRING
  1042.           { $$ = $1;}
  1043.   %%
  1044. ! yyerror(s)
  1045. ! char *s;
  1046.   {
  1047. !     extern char tmpname[];
  1048. !     fprintf(stderr,"rayshade: line %d: %s\n", yylineno, s);
  1049. !     unlink(tmpname);
  1050. !     exit(2);
  1051.   }
  1052.   
  1053. --- 684,714 ----
  1054.   String        : tSTRING
  1055.           { $$ = $1;}
  1056.   %%
  1057. ! /*
  1058. !  * Issue error message containing filename and line number, and exit.
  1059. !  */
  1060. ! /*VARARGS1*/
  1061. ! yyerror(s, pat1, pat2)
  1062. ! char *s, *pat1, *pat2;
  1063.   {
  1064. !     RSmessage("Error", "%s, line %d: ", yyfilename, yylineno);
  1065. !     fprintf(stderr, s, pat1, pat2);
  1066. !     fprintf(stderr,"\n");    /* yacc doesn't use newlines on syntax errors */
  1067. !     exit(1);
  1068.   }
  1069.   
  1070. + /*
  1071. +  * Issue warning message containing filename and line number if not in
  1072. +  * Quiet mode.
  1073. +  */
  1074. + /*VARARGS1*/
  1075. + yywarning(s, pat1, pat2)
  1076. + char *s, *pat1, *pat2;
  1077. + {
  1078. +     extern int Quiet;
  1079. +     if (!Quiet) {
  1080. +         RSmessage("Warning", "%s, line %d: ",yyfilename, yylineno);
  1081. +         fprintf(stderr, s, pat1, pat2);
  1082. +     }
  1083. + }
  1084.  
  1085. Index: src/main.c
  1086. *** src/main.c.old    Thu Dec  7 23:20:27 1989
  1087. --- src/main.c    Thu Dec  7 23:20:28 1989
  1088. ***************
  1089. *** 1,5 ****
  1090.   char rcsid[] =
  1091. !     "$Id: main.c,v 3.0.1.1 89/11/16 18:28:21 craig Exp Locker: craig $";
  1092.   /*
  1093.    * main.c
  1094.    *
  1095. --- 1,5 ----
  1096.   char rcsid[] =
  1097. !     "$Id: main.c,v 3.0.1.2 89/12/07 22:54:39 craig Exp $";
  1098.   /*
  1099.    * main.c
  1100.    *
  1101. ***************
  1102. *** 21,26 ****
  1103. --- 21,29 ----
  1104.    * and the reason for such modification.
  1105.    *
  1106.    * $Log:    main.c,v $
  1107. +  * Revision 3.0.1.2  89/12/07  22:54:39  craig
  1108. +  * patch2: Renamed utime and stime to avoid name clashes.
  1109. +  * 
  1110.    * Revision 3.0.1.1  89/11/16  18:28:21  craig
  1111.    * patch1: Statistics are now reported in Linda implementation.
  1112.    * 
  1113. ***************
  1114. *** 52,58 ****
  1115.           BVTests,    /* # of bounding volume tests. */
  1116.           SuperSampled;    /* # of supersampled pixels. */
  1117.   double        ftmp;        /* Used by fabs() macro. */
  1118. ! double        utime, stime;    /* user, system CPU time */
  1119.   FILE        *fstats;    /* Statistics file */
  1120.   
  1121.   /*
  1122. --- 55,61 ----
  1123.           BVTests,    /* # of bounding volume tests. */
  1124.           SuperSampled;    /* # of supersampled pixels. */
  1125.   double        ftmp;        /* Used by fabs() macro. */
  1126. ! double        Utime, Stime;    /* user, system CPU time */
  1127.   FILE        *fstats;    /* Statistics file */
  1128.   
  1129.   /*
  1130. ***************
  1131. *** 106,114 ****
  1132.       if (Verbose)
  1133.           fprintf(fstats,"Setting up voxels...\n");
  1134.       SetupWorld();
  1135. !     get_cpu_time(&utime, &stime);
  1136.       fprintf(fstats,"Preprocessing time:\t");
  1137. !     fprintf(fstats,"%2.2lfu  %2.2lfs\n",utime, stime);
  1138.       fprintf(fstats,"Starting trace.\n");
  1139.       fflush(fstats);
  1140.       /*
  1141. --- 109,117 ----
  1142.       if (Verbose)
  1143.           fprintf(fstats,"Setting up voxels...\n");
  1144.       SetupWorld();
  1145. !     get_cpu_time(&Utime, &Stime);
  1146.       fprintf(fstats,"Preprocessing time:\t");
  1147. !     fprintf(fstats,"%2.2lfu  %2.2lfs\n",Utime, Stime);
  1148.       fprintf(fstats,"Starting trace.\n");
  1149.       fflush(fstats);
  1150.       /*
  1151. ***************
  1152. *** 120,126 ****
  1153.        */
  1154.       endpic();
  1155.   #ifndef LINDA
  1156. !     get_cpu_time(&utime, &stime);
  1157.   #endif
  1158.   
  1159.       TotalRays = EyeRays + ShadowRays + ReflectRays + RefractRays;
  1160. --- 123,129 ----
  1161.        */
  1162.       endpic();
  1163.   #ifndef LINDA
  1164. !     get_cpu_time(&Utime, &Stime);
  1165.   #endif
  1166.   
  1167.       TotalRays = EyeRays + ShadowRays + ReflectRays + RefractRays;
  1168. ***************
  1169. *** 153,179 ****
  1170.   #else
  1171.       fprintf(fstats,"Total CPU time (sec):\t\t");
  1172.   #endif
  1173. !     fprintf(fstats,"%2.2lf (%2.2lfu + %2.2lfs)\n",utime+stime, utime, stime);
  1174.       if (TotalRays != 0.)
  1175.           fprintf(fstats,"Seconds / ray:\t\t\t%4.4lf\n",
  1176. !                 (utime + stime) / (double)TotalRays);
  1177.       if (HitRays != 0.)
  1178.           fprintf(fstats, "Seconds / intersecting ray:\t%4.4lf\n",
  1179. !                 (utime + stime) / (double)HitRays);
  1180.       PrintMemoryStats();
  1181.       exit(0);
  1182.   }
  1183.   
  1184.   #ifdef SYSV
  1185. ! get_cpu_time(utime, stime)
  1186. ! double *utime, *stime;
  1187.   {
  1188.       struct tms time;
  1189.       long times();
  1190.   
  1191.       (void)times(&time);
  1192. !     *utime = (double)time.tms_utime / (double)HZ;
  1193. !     *stime = (double)time.tms_stime / (double)HZ;
  1194.   }
  1195.   #else
  1196.   #ifdef AZTEC_C
  1197. --- 156,182 ----
  1198.   #else
  1199.       fprintf(fstats,"Total CPU time (sec):\t\t");
  1200.   #endif
  1201. !     fprintf(fstats,"%2.2lf (%2.2lfu + %2.2lfs)\n",Utime+Stime, Utime, Stime);
  1202.       if (TotalRays != 0.)
  1203.           fprintf(fstats,"Seconds / ray:\t\t\t%4.4lf\n",
  1204. !                 (Utime + Stime) / (double)TotalRays);
  1205.       if (HitRays != 0.)
  1206.           fprintf(fstats, "Seconds / intersecting ray:\t%4.4lf\n",
  1207. !                 (Utime + Stime) / (double)HitRays);
  1208.       PrintMemoryStats();
  1209.       exit(0);
  1210.   }
  1211.   
  1212.   #ifdef SYSV
  1213. ! get_cpu_time(usertime, systime)
  1214. ! double *usertime, *systime;
  1215.   {
  1216.       struct tms time;
  1217.       long times();
  1218.   
  1219.       (void)times(&time);
  1220. !     *usertime = (double)time.tms_utime / (double)HZ;
  1221. !     *systime = (double)time.tms_stime / (double)HZ;
  1222.   }
  1223.   #else
  1224.   #ifdef AZTEC_C
  1225. ***************
  1226. *** 181,196 ****
  1227.   {
  1228.   }
  1229.   #else    /* !SYSV && !AZTEC_C */
  1230. ! get_cpu_time(utime, stime)
  1231. ! double *utime, *stime;
  1232.   {
  1233.       struct rusage usage;
  1234.   
  1235.       getrusage(RUSAGE_SELF, &usage);
  1236.   
  1237. !     *utime = (double)usage.ru_utime.tv_sec +
  1238.               (double)usage.ru_utime.tv_usec / 1000000.;
  1239. !     *stime = (double)usage.ru_stime.tv_sec +
  1240.               (double)usage.ru_stime.tv_usec / 1000000.;
  1241.   }
  1242.   #endif
  1243. --- 184,199 ----
  1244.   {
  1245.   }
  1246.   #else    /* !SYSV && !AZTEC_C */
  1247. ! get_cpu_time(usertime, systime)
  1248. ! double *usertime, *systime;
  1249.   {
  1250.       struct rusage usage;
  1251.   
  1252.       getrusage(RUSAGE_SELF, &usage);
  1253.   
  1254. !     *usertime = (double)usage.ru_utime.tv_sec +
  1255.               (double)usage.ru_utime.tv_usec / 1000000.;
  1256. !     *systime = (double)usage.ru_stime.tv_sec +
  1257.               (double)usage.ru_stime.tv_usec / 1000000.;
  1258.   }
  1259.   #endif
  1260.  
  1261. Index: src/memory.c
  1262. *** src/memory.c.old    Thu Dec  7 23:20:32 1989
  1263. --- src/memory.c    Thu Dec  7 23:20:33 1989
  1264. ***************
  1265. *** 18,26 ****
  1266.    * name of the person performing the modification, the date of modification,
  1267.    * and the reason for such modification.
  1268.    *
  1269. !  * $Id: memory.c,v 3.0 89/10/27 02:05:56 craig Exp $
  1270.    *
  1271.    * $Log:    memory.c,v $
  1272.    * Revision 3.0  89/10/27  02:05:56  craig
  1273.    * Baseline for first official release.
  1274.    * 
  1275. --- 18,29 ----
  1276.    * name of the person performing the modification, the date of modification,
  1277.    * and the reason for such modification.
  1278.    *
  1279. !  * $Id: memory.c,v 3.0.1.1 89/12/06 16:33:59 craig Exp $
  1280.    *
  1281.    * $Log:    memory.c,v $
  1282. +  * Revision 3.0.1.1  89/12/06  16:33:59  craig
  1283. +  * patch2: Added calls to new error/warning routines.
  1284. +  * 
  1285.    * Revision 3.0  89/10/27  02:05:56  craig
  1286.    * Baseline for first official release.
  1287.    * 
  1288. ***************
  1289. *** 40,49 ****
  1290.       TotalAllocated += bytes;
  1291.   
  1292.       res = malloc(bytes);
  1293. !     if (res == (char *)0) {
  1294. !         fprintf(stderr,"Out of memory trying to allocate %d bytes.\n");
  1295. !         exit(0);
  1296. !     }
  1297.       return res;
  1298.   }
  1299.   
  1300. --- 43,50 ----
  1301.       TotalAllocated += bytes;
  1302.   
  1303.       res = malloc(bytes);
  1304. !     if (res == (char *)0)
  1305. !         RSerror("Out of memory trying to allocate %d bytes.\n",bytes);
  1306.       return res;
  1307.   }
  1308.   
  1309.  
  1310. Index: src/object.c
  1311. *** src/object.c.old    Thu Dec  7 23:20:38 1989
  1312. --- src/object.c    Thu Dec  7 23:20:39 1989
  1313. ***************
  1314. *** 18,26 ****
  1315.    * name of the person performing the modification, the date of modification,
  1316.    * and the reason for such modification.
  1317.    *
  1318. !  * $Id: object.c,v 3.0 89/10/27 02:05:58 craig Exp $
  1319.    *
  1320.    * $Log:    object.c,v $
  1321.    * Revision 3.0  89/10/27  02:05:58  craig
  1322.    * Baseline for first official release.
  1323.    * 
  1324. --- 18,29 ----
  1325.    * name of the person performing the modification, the date of modification,
  1326.    * and the reason for such modification.
  1327.    *
  1328. !  * $Id: object.c,v 3.0.1.1 89/12/06 16:33:20 craig Exp $
  1329.    *
  1330.    * $Log:    object.c,v $
  1331. +  * Revision 3.0.1.1  89/12/06  16:33:20  craig
  1332. +  * patch2: Added calls to new error/warning routines.
  1333. +  * 
  1334.    * Revision 3.0  89/10/27  02:05:58  craig
  1335.    * Baseline for first official release.
  1336.    * 
  1337. ***************
  1338. *** 83,92 ****
  1339.       int i;
  1340.   
  1341.       child = get_object_named(name);
  1342. !     if (child == (Object *)0) {
  1343. !         fprintf(stderr,"There is no object named \"%s\".\n",name);
  1344. !         exit(1);
  1345. !     }
  1346.       /*
  1347.        * Create new object that points to child
  1348.        * and add to 'parent' list.
  1349. --- 86,93 ----
  1350.       int i;
  1351.   
  1352.       child = get_object_named(name);
  1353. !     if (child == (Object *)0)
  1354. !         yyerror("There is no object named \"%s\".", name);
  1355.       /*
  1356.        * Create new object that points to child
  1357.        * and add to 'parent' list.
  1358.  
  1359. Index: src/outputp.c
  1360. *** src/outputp.c.old    Thu Dec  7 23:20:43 1989
  1361. --- src/outputp.c    Thu Dec  7 23:20:43 1989
  1362. ***************
  1363. *** 18,26 ****
  1364.    * name of the person performing the modification, the date of modification,
  1365.    * and the reason for such modification.
  1366.    *
  1367. !  * $Id: outputp.c,v 3.0 89/10/27 02:05:58 craig Exp $
  1368.    *
  1369.    * $Log:    outputp.c,v $
  1370.    * Revision 3.0  89/10/27  02:05:58  craig
  1371.    * Baseline for first official release.
  1372.    * 
  1373. --- 18,29 ----
  1374.    * name of the person performing the modification, the date of modification,
  1375.    * and the reason for such modification.
  1376.    *
  1377. !  * $Id: outputp.c,v 3.0.1.1 89/12/06 16:33:17 craig Exp $
  1378.    *
  1379.    * $Log:    outputp.c,v $
  1380. +  * Revision 3.0.1.1  89/12/06  16:33:17  craig
  1381. +  * patch2: Added calls to new error/warning routines.
  1382. +  * 
  1383.    * Revision 3.0  89/10/27  02:05:58  craig
  1384.    * Baseline for first official release.
  1385.    * 
  1386. ***************
  1387. *** 73,83 ****
  1388.               imgfile = fopen(outfilename, "r+");
  1389.           } else
  1390.               imgfile = fopen(outfilename, "w");
  1391. !         if (imgfile == (FILE *)NULL) {
  1392. !             fprintf(stderr,"Cannot open %s for writing.\n",
  1393. !                             outfilename);
  1394. !             exit(2);
  1395. !         }
  1396.       } else
  1397.           imgfile = stdout;
  1398.       sv_globals.svfb_fd = imgfile;
  1399. --- 76,83 ----
  1400.               imgfile = fopen(outfilename, "r+");
  1401.           } else
  1402.               imgfile = fopen(outfilename, "w");
  1403. !         if (imgfile == (FILE *)NULL)
  1404. !             yyerror("Cannot open %s for writing.", outfilename);
  1405.       } else
  1406.           imgfile = stdout;
  1407.       sv_globals.svfb_fd = imgfile;
  1408. ***************
  1409. *** 145,155 ****
  1410.               imgfile = fopen(outfilename, "a");
  1411.           else
  1412.               imgfile = fopen(outfilename, "w");
  1413. !         if (imgfile == (FILE *)NULL) {
  1414. !             fprintf(stderr,"Cannot open %s for writing.\n",
  1415. !                             outfilename);
  1416. !             exit(2);
  1417. !         }
  1418.       } else
  1419.           imgfile = stdout;
  1420.   
  1421. --- 145,152 ----
  1422.               imgfile = fopen(outfilename, "a");
  1423.           else
  1424.               imgfile = fopen(outfilename, "w");
  1425. !         if (imgfile == (FILE *)NULL)
  1426. !             RSerror("Cannot open %s for writing.", outfilename);
  1427.       } else
  1428.           imgfile = stdout;
  1429.   
  1430.  
  1431. Index: src/plane.c
  1432. *** src/plane.c.old    Thu Dec  7 23:20:47 1989
  1433. --- src/plane.c    Thu Dec  7 23:20:48 1989
  1434. ***************
  1435. *** 18,26 ****
  1436.    * name of the person performing the modification, the date of modification,
  1437.    * and the reason for such modification.
  1438.    *
  1439. !  * $Id: plane.c,v 3.0 89/10/27 02:05:59 craig Exp $
  1440.    *
  1441.    * $Log:    plane.c,v $
  1442.    * Revision 3.0  89/10/27  02:05:59  craig
  1443.    * Baseline for first official release.
  1444.    * 
  1445. --- 18,29 ----
  1446.    * name of the person performing the modification, the date of modification,
  1447.    * and the reason for such modification.
  1448.    *
  1449. !  * $Id: plane.c,v 3.0.1.1 89/12/06 16:34:03 craig Exp $
  1450.    *
  1451.    * $Log:    plane.c,v $
  1452. +  * Revision 3.0.1.1  89/12/06  16:34:03  craig
  1453. +  * patch2: Added calls to new error/warning routines.
  1454. +  * 
  1455.    * Revision 3.0  89/10/27  02:05:59  craig
  1456.    * Baseline for first official release.
  1457.    * 
  1458. ***************
  1459. *** 42,54 ****
  1460.       Vector tmpnrm;
  1461.       Object *newobj;
  1462.       Primitive *prim;
  1463. -     extern int Quiet, yylineno;
  1464.   
  1465.       tmpnrm = *norm;
  1466.       if (normalize(&tmpnrm) == 0.) {
  1467. !         if (!Quiet)
  1468. !             fprintf(stderr, "Degenerate plane normal (line %d)\n",
  1469. !                             yylineno);
  1470.           return (Object *)0;
  1471.       }
  1472.       prim = mallocprim();
  1473. --- 45,54 ----
  1474.       Vector tmpnrm;
  1475.       Object *newobj;
  1476.       Primitive *prim;
  1477.   
  1478.       tmpnrm = *norm;
  1479.       if (normalize(&tmpnrm) == 0.) {
  1480. !         yywarning("Degenerate plane normal.");
  1481.           return (Object *)0;
  1482.       }
  1483.       prim = mallocprim();
  1484.  
  1485. Index: Examples/planet.ray
  1486. *** Examples/planet.ray.old    Thu Dec  7 23:18:35 1989
  1487. --- Examples/planet.ray    Thu Dec  7 23:18:36 1989
  1488. ***************
  1489. *** 1,18 ****
  1490.   /*
  1491.    * Example rayshade input file describing a single texture-mapped sphere.
  1492.    *
  1493.    * C. Kolb 9/89
  1494.    */
  1495.   screen 256 256
  1496.   light 1.0 0.9 0.8 directional 1. -1. 1.
  1497.   eyep 0. -4. 0.
  1498. ! surface basesurf .16 .15 .14 .8 .75 .7 0 0 0 0 0 0 0
  1499.   sphere basesurf 1.0 0 0 0
  1500.       texture fbm     0.        /* offset */
  1501.               1.        /* scale */
  1502.               0.3        /* h */
  1503. !             2.0        /* lambda */
  1504. !             6        /* octaves */
  1505.               -.2        /* thresh */
  1506.               planet.map     /* mapname */
  1507. !         scale 0.7 0.7 0.7 
  1508. --- 1,44 ----
  1509.   /*
  1510.    * Example rayshade input file describing a single texture-mapped sphere.
  1511. +  * To use, feed to the C pre-processor, and then to rayshade.  Depending
  1512. +  * on your system type, this probably means doing something like:
  1513.    *
  1514. +  *        cpp thisfile | rayshade <options>
  1515. +  * or
  1516. +  *
  1517. +  *        cc -E thisfile | rayshade <options>
  1518. +  * 
  1519. +  * Note that using cpp means that, in addition to macros, you can use #include,
  1520. +  * #define, #ifdef, etc. in your input files.
  1521. +  *
  1522.    * C. Kolb 9/89
  1523. +  *
  1524. +  * $Id: planet.ray,v 3.0.1.2 89/12/06 17:06:49 craig Exp $
  1525. +  *
  1526. +  * $Log:    planet.ray,v $
  1527. +  * Revision 3.0.1.2  89/12/06  17:06:49  craig
  1528. +  * patch2: Changes to show use of cpp.
  1529. +  * 
  1530. +  * Revision 3.0.1.1  89/11/28  13:57:21  craig
  1531. +  * patch2: Decreased intensity of planet's ambient color.
  1532. +  * 
  1533.    */
  1534. + #define EXPAND(x)    scale x x x
  1535. + #define BLACK        0 0 0
  1536. + #define LACUNARITY    2.
  1537. + #define OCTAVES        6
  1538.   screen 256 256
  1539.   light 1.0 0.9 0.8 directional 1. -1. 1.
  1540.   eyep 0. -4. 0.
  1541. ! surface basesurf .06 .05 .04 .9 .85 .8 BLACK 0 0 0 0
  1542.   sphere basesurf 1.0 0 0 0
  1543.       texture fbm     0.        /* offset */
  1544.               1.        /* scale */
  1545.               0.3        /* h */
  1546. !             LACUNARITY    /* lambda */
  1547. !             OCTAVES        /* octaves */
  1548.               -.2        /* thresh */
  1549.               planet.map     /* mapname */
  1550. !         EXPAND(0.7)
  1551.  
  1552. Index: src/poly.c
  1553. *** src/poly.c.old    Thu Dec  7 23:20:52 1989
  1554. --- src/poly.c    Thu Dec  7 23:20:53 1989
  1555. ***************
  1556. *** 18,26 ****
  1557.    * name of the person performing the modification, the date of modification,
  1558.    * and the reason for such modification.
  1559.    *
  1560. !  * $Id: poly.c,v 3.0 89/10/27 02:05:59 craig Exp $
  1561.    *
  1562.    * $Log:    poly.c,v $
  1563.    * Revision 3.0  89/10/27  02:05:59  craig
  1564.    * Baseline for first official release.
  1565.    * 
  1566. --- 18,29 ----
  1567.    * name of the person performing the modification, the date of modification,
  1568.    * and the reason for such modification.
  1569.    *
  1570. !  * $Id: poly.c,v 3.0.1.1 89/12/06 16:33:38 craig Exp $
  1571.    *
  1572.    * $Log:    poly.c,v $
  1573. +  * Revision 3.0.1.1  89/12/06  16:33:38  craig
  1574. +  * patch2: Added calls to new error/warning routines.
  1575. +  * 
  1576.    * Revision 3.0  89/10/27  02:05:59  craig
  1577.    * Baseline for first official release.
  1578.    * 
  1579. ***************
  1580. *** 48,54 ****
  1581.       Vector edge1, edge2, anorm;
  1582.       PointList *cur;
  1583.       int i;
  1584. !     extern int yylineno, TrashBadPoly, Quiet;
  1585.   
  1586.       prim = mallocprim();
  1587.       prim->type = POLY;
  1588. --- 51,57 ----
  1589.       Vector edge1, edge2, anorm;
  1590.       PointList *cur;
  1591.       int i;
  1592. !     extern int TrashBadPoly;
  1593.   
  1594.       prim = mallocprim();
  1595.       prim->type = POLY;
  1596. ***************
  1597. *** 101,107 ****
  1598.            * then we didn't find a valid normal vector -- we
  1599.            * must have a degenerate polygon of some sort.
  1600.            */
  1601. !         fprintf(stderr,"Degenerate polygon (line %d).\n", yylineno);
  1602.           free((char *)poly->points);
  1603.           free((char *)poly);
  1604.           free((char *)prim);
  1605. --- 104,110 ----
  1606.            * then we didn't find a valid normal vector -- we
  1607.            * must have a degenerate polygon of some sort.
  1608.            */
  1609. !         yywarning("Degenerate polygon.\n");
  1610.           free((char *)poly->points);
  1611.           free((char *)poly);
  1612.           free((char *)prim);
  1613.  
  1614. Index: src/ray_options.c
  1615. *** src/ray_options.c.old    Thu Dec  7 23:20:57 1989
  1616. --- src/ray_options.c    Thu Dec  7 23:20:58 1989
  1617. ***************
  1618. *** 18,26 ****
  1619.    * name of the person performing the modification, the date of modification,
  1620.    * and the reason for such modification.
  1621.    *
  1622. !  * $Id: ray_options.c,v 3.0.1.2 89/11/20 13:02:22 craig Exp Locker: craig $
  1623.    *
  1624.    * $Log:    ray_options.c,v $
  1625.    * Revision 3.0.1.2  89/11/20  13:02:22  craig
  1626.    * patch1: Fixed problems involving overriding values on the command line.
  1627.    * 
  1628. --- 18,32 ----
  1629.    * name of the person performing the modification, the date of modification,
  1630.    * and the reason for such modification.
  1631.    *
  1632. !  * $Id: ray_options.c,v 3.0.1.4 89/12/06 16:33:55 craig Exp $
  1633.    *
  1634.    * $Log:    ray_options.c,v $
  1635. +  * Revision 3.0.1.4  89/12/06  16:33:55  craig
  1636. +  * patch2: Added calls to new error/warning routines.
  1637. +  * 
  1638. +  * Revision 3.0.1.3  89/12/02  16:42:16  craig
  1639. +  * patch2: Added -F option.
  1640. +  * 
  1641.    * Revision 3.0.1.2  89/11/20  13:02:22  craig
  1642.    * patch1: Fixed problems involving overriding values on the command line.
  1643.    * 
  1644. ***************
  1645. *** 63,68 ****
  1646. --- 69,75 ----
  1647.       extern double RedContrast, GreenContrast, BlueContrast, atof();
  1648.       extern int pixel_div, JitSamples, Xres, Yres, Jittered, Cache;
  1649.       extern int Stereo, StartLine, Appending, NoShadows, ClearShadows;
  1650. +     extern int ReportFreq;
  1651.       extern double Separation, TreeCutoff;
  1652.       extern char outfilename[];
  1653.       extern FILE *fstats;
  1654. ***************
  1655. *** 90,95 ****
  1656. --- 97,108 ----
  1657.                   Separation = atof(argv[1]);
  1658.                   argc--; argv++;
  1659.                   break;
  1660. +             case 'F':
  1661. +                 ReportFreq = atoi(argv[1]);
  1662. +                 if (ReportFreq < 1)
  1663. +                     ReportFreq = 1;
  1664. +                 argv++; argc--;
  1665. +                 break;
  1666.               case 'h':
  1667.                   usage();
  1668.                   exit(0);
  1669. ***************
  1670. *** 168,175 ****
  1671.                   }
  1672.                   fstats = fopen(argv[1], "w");
  1673.                   if (fstats == (FILE *)0) {
  1674. !                     fprintf(stderr,"Cannot write to stats file %s\n",argv[0]);
  1675. !                     exit(2);
  1676.                   }
  1677.                   argv++; argc--;
  1678.                   break;
  1679. --- 181,188 ----
  1680.                   }
  1681.                   fstats = fopen(argv[1], "w");
  1682.                   if (fstats == (FILE *)0) {
  1683. !                     RSerror("Cannot open stats file %s.\n",
  1684. !                             argv[0]);
  1685.                   }
  1686.                   argv++; argc--;
  1687.                   break;
  1688. ***************
  1689. *** 177,185 ****
  1690.               case 'W':
  1691.                   Workers = atoi(argv[1]);
  1692.                   if (Workers < 0 || Workers > 17) {
  1693. !                     fprintf(stderr,"%d workers?!?\n",
  1694. !                             Workers);
  1695. !                     exit(3);
  1696.                   }
  1697.                   argv++; argc--;
  1698.                   break;
  1699. --- 190,196 ----
  1700.               case 'W':
  1701.                   Workers = atoi(argv[1]);
  1702.                   if (Workers < 0 || Workers > 17) {
  1703. !                     RSerror("%d workers?\n",workers);
  1704.                   }
  1705.                   argv++; argc--;
  1706.                   break;
  1707. ***************
  1708. *** 188,196 ****
  1709.                   break;
  1710.   #endif
  1711.               default:
  1712. !                 fprintf(stderr,"Bad argument: \"%s\"\n",argv[0]);
  1713. !                 usage();
  1714. !                 exit(1);
  1715.           }
  1716.       }
  1717.   
  1718. --- 199,205 ----
  1719.                   break;
  1720.   #endif
  1721.               default:
  1722. !                 RSerror("Bad argument: %s\n", argv[0]);
  1723.           }
  1724.       }
  1725.   
  1726. ***************
  1727. *** 211,224 ****
  1728.        * entire input file is read).
  1729.        */
  1730.       if (Appending && *outfilename == (char)NULL) {
  1731. !         fprintf(stderr,"The -L option requires the -O option.\n");
  1732. !         exit(4);
  1733.       }
  1734.   
  1735.       if (Stereo && Separation == 0.) {
  1736. !         fprintf(stderr,"You must specify eye separation (-E) in order ");
  1737. !         fprintf(stderr,"to enable Stereo mode.\n");
  1738. !         exit(4);
  1739.       }
  1740.   }
  1741.   
  1742. --- 220,230 ----
  1743.        * entire input file is read).
  1744.        */
  1745.       if (Appending && *outfilename == (char)NULL) {
  1746. !         RSerror("The -L option requires the -O option.\n");
  1747.       }
  1748.   
  1749.       if (Stereo && Separation == 0.) {
  1750. !         RSerror("Stereo mode requires use of -E option.\n");
  1751.       }
  1752.   }
  1753.   
  1754. ***************
  1755. *** 229,234 ****
  1756. --- 235,241 ----
  1757.       fprintf(stderr,"\t-C r g b\t(Set contrast threshold (0. - 1.).)\n");
  1758.       fprintf(stderr,"\t-c \t\t(Trace shadow rays through clear objects.)\n");
  1759.       fprintf(stderr,"\t-E eye_sep\t(Set eye separation.)\n");
  1760. +     fprintf(stderr,"\t-F freq\t\t(Frequency, in lines, of status report.)\n");
  1761.       fprintf(stderr,"\t-h \t\t(Print this message.)\n");
  1762.       fprintf(stderr,"\t-j \t\t(Antialias using jittered sampling.)\n");
  1763.       fprintf(stderr,"\t-L line#\t(Begin rendering at specified line.)\n");
  1764. ***************
  1765. *** 247,251 ****
  1766. --- 254,259 ----
  1767.       fprintf(stderr,"\t-v \t\t(Verbose output.)\n");
  1768.   #ifdef LINDA
  1769.       fprintf(stderr,"\t-W workers (Specify number of worker processes.)\n");
  1770. +     fprintf(stderr,"\t-w \t\t(Verbose worker output.)\n");
  1771.   #endif
  1772.   }
  1773.  
  1774. Index: src/triangle.c
  1775. *** src/triangle.c.old    Thu Dec  7 23:21:47 1989
  1776. --- src/triangle.c    Thu Dec  7 23:21:48 1989
  1777. ***************
  1778. *** 18,26 ****
  1779.    * name of the person performing the modification, the date of modification,
  1780.    * and the reason for such modification.
  1781.    *
  1782. !  * $Id: triangle.c,v 3.0 89/10/27 02:06:07 craig Exp $
  1783.    *
  1784.    * $Log:    triangle.c,v $
  1785.    * Revision 3.0  89/10/27  02:06:07  craig
  1786.    * Baseline for first official release.
  1787.    * 
  1788. --- 18,29 ----
  1789.    * name of the person performing the modification, the date of modification,
  1790.    * and the reason for such modification.
  1791.    *
  1792. !  * $Id: triangle.c,v 3.0.1.1 89/12/06 16:33:32 craig Exp $
  1793.    *
  1794.    * $Log:    triangle.c,v $
  1795. +  * Revision 3.0.1.1  89/12/06  16:33:32  craig
  1796. +  * patch2: Added calls to new error/warning routines.
  1797. +  * 
  1798.    * Revision 3.0  89/10/27  02:06:07  craig
  1799.    * Baseline for first official release.
  1800.    * 
  1801. ***************
  1802. *** 47,53 ****
  1803.       Vector vc1, vc2, vc3, ptmp, anorm;
  1804.       Object *newobj;
  1805.       double indexval;
  1806. -     extern int yylineno, Quiet;
  1807.   
  1808.       prim = mallocprim();
  1809.       triangle = (Triangle *)Malloc(sizeof(Triangle));
  1810. --- 50,55 ----
  1811. ***************
  1812. *** 77,85 ****
  1813.       rawcrossp(&triangle->nrm, &vc1, &vc2);
  1814.       ptmp = triangle->nrm;
  1815.       if (normalize(&ptmp) == 0.) {
  1816. !         if (!Quiet)
  1817. !             fprintf(stderr,"Degenerate triangle (line %d).\n",
  1818. !                             yylineno);
  1819.           free((char *)prim);
  1820.           free((char *)triangle);
  1821.           free((char *)newobj);
  1822. --- 79,85 ----
  1823.       rawcrossp(&triangle->nrm, &vc1, &vc2);
  1824.       ptmp = triangle->nrm;
  1825.       if (normalize(&ptmp) == 0.) {
  1826. !         yywarning("Degenerate triangle.\n");
  1827.           free((char *)prim);
  1828.           free((char *)triangle);
  1829.           free((char *)newobj);
  1830.  
  1831. Index: doc/texture.ms
  1832. *** doc/texture.ms.old    Thu Dec  7 23:19:09 1989
  1833. --- doc/texture.ms    Thu Dec  7 23:19:09 1989
  1834. ***************
  1835. *** 2,10 ****
  1836.   .\" Brief tutorial on adding textures to rayshade.
  1837.   .\" Craig Kolb 10/89
  1838.   .\"
  1839. ! .\" $Id: texture.ms,v 3.0 89/10/23 16:42:57 craig Exp $
  1840.   .\"
  1841.   .\" $Log:    texture.ms,v $
  1842.   .\" Revision 3.0  89/10/23  16:42:57  craig
  1843.   .\" Baseline for first official release.
  1844.   .\" 
  1845. --- 2,14 ----
  1846.   .\" Brief tutorial on adding textures to rayshade.
  1847.   .\" Craig Kolb 10/89
  1848.   .\"
  1849. ! .\" $Id: texture.ms,v 3.0.1.1 89/11/27 18:49:26 craig Exp $
  1850.   .\"
  1851.   .\" $Log:    texture.ms,v $
  1852. + .\" Revision 3.0.1.1  89/11/27  18:49:26  craig
  1853. + .\" patch2: Example texture now uses colormap to scale ambient & diffuse
  1854. + .\" patch2: components of surface color.
  1855. + .\" 
  1856.   .\" Revision 3.0  89/10/23  16:42:57  craig
  1857.   .\" Baseline for first official release.
  1858.   .\" 
  1859. ***************
  1860. *** 99,107 ****
  1861.   texture will modify the diffuse component of a surface as a function of the
  1862.   Z component of the point of intersection.  If the name of a colormap
  1863.   is given, an index into
  1864. ! the colormap is used to a color to be used as the diffuse component the
  1865. ! surface.
  1866. ! Otherwise, the diffuse component of the surface is simply scaled.
  1867. ! To avoid strictly horizontal boundries
  1868.   between colors when using a colormap, we add a bit of "noise" to the
  1869.   Z component of the point of intersection.  The magnitude and nature of the
  1870. --- 103,111 ----
  1871.   texture will modify the diffuse component of a surface as a function of the
  1872.   Z component of the point of intersection.  If the name of a colormap
  1873.   is given, an index into
  1874. ! the colormap is computed and the corresponding color is used to scale
  1875. ! the ambient and diffuse components of the surface.
  1876. ! Otherwise, the ambient and diffuse components of the surface are simply scaled.
  1877. ! To avoid strictly horizontal boundaries
  1878.   between colors when using a colormap, we add a bit of "noise" to the
  1879.   Z component of the point of intersection.  The magnitude and nature of the
  1880. ***************
  1881. *** 317,329 ****
  1882.                           index = 255;
  1883.                   if (index < 0)
  1884.                           index = 0;
  1885. !                 surf->diff = text->colormap[index];
  1886.           } else {
  1887.                   /*
  1888.                    * If there's no colormap, simply scale the diffuse
  1889.                    * component. 
  1890.                    */
  1891. !                 surf->diff = ScaleColor(val, surf->diff);
  1892.           }
  1893.   }
  1894.   .D)
  1895. --- 321,339 ----
  1896.                           index = 255;
  1897.                   if (index < 0)
  1898.                           index = 0;
  1899. !                 surf->diff.r *= text->colormap[index].r;
  1900. !                 surf->diff.g *= text->colormap[index].g;
  1901. !                 surf->diff.b *= text->colormap[index].b;
  1902. !                 surf->amb.r *= text->colormap[index].r;
  1903. !                 surf->amb.g *= text->colormap[index].g;
  1904. !                 surf->amb.b *= text->colormap[index].b;
  1905.           } else {
  1906.                   /*
  1907.                    * If there's no colormap, simply scale the diffuse
  1908.                    * component. 
  1909.                    */
  1910. !                 ScaleColor(val, surf->diff, &surf->diff);
  1911. !         ScaleColor(val, surf->amb, &surf->amb);
  1912.           }
  1913.   }
  1914.   .D)
  1915.  
  1916.  
  1917.  
  1918.