home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume23 / rayshade / patch01 next >
Text File  |  1991-10-19  |  44KB  |  1,467 lines

  1. Newsgroups: comp.sources.misc
  2. From: Craig Kolb <rayshade-request@cs.princeton.edu>
  3. Subject:  v23i075:  rayshade - A raytracing package for UNIX, Patch01
  4. Message-ID: <1991Oct19.024232.13698@sparky.imd.sterling.com>
  5. X-Md4-Signature: 6348dbe45469af21d17e7a255c013923
  6. Date: Sat, 19 Oct 1991 02:42:32 GMT
  7. Approved: kent@sparky.imd.sterling.com
  8.  
  9. Submitted-by: Craig Kolb <rayshade-request@cs.princeton.edu>
  10. Posting-number: Volume 23, Issue 75
  11. Archive-name: rayshade/patch01
  12. Environment: UNIX
  13. Patch-To: rayshade: Volume 21, Issue 3-22
  14.  
  15. System: rayshade version 4.0
  16. Patch #: 1
  17. Priority: HIGH
  18.  
  19. Description:
  20.  
  21.     Added "transform" support.
  22.  
  23.     New "window" and "crop" support.  Window uses pixel coordinates
  24.     to define a subwindow, crop uses normalized coordinates and
  25.     crops the subwindow.
  26.  
  27.     Rayview supports spotlights and transparency (given appropriate
  28.     hardware.)
  29.  
  30.     Faster bbox transform, a la Jim Arvo.
  31.  
  32.     Fixed view initialization weirdness that lead to bugs
  33.     when rendering animated stereo pairs.
  34.  
  35.     Don't declare free or exit void if stdlib.h is used.
  36.  
  37.     Fixed problems with coincident bbox faces.
  38.  
  39.     Removed a number of floating point comparisons
  40.  
  41.     Corrected help message.
  42.  
  43.     Potential roundoff problem in triangle dPdU code.
  44.  
  45.     CoordSysTransform did not detect up-Z == -1.
  46.  
  47.     Defined MAKE macro in Makefiles for braindamaged machines.
  48.     Note that "make -n" on such machines will almost certainly do
  49.     the wrong thing.
  50.  
  51.     Fixed various typos.
  52.  
  53.  
  54. Fix:    From rn, say "| patch -p -N -d DIR", where DIR is your rayshade source
  55.     directory.  Outside of rn, say "cd DIR; patch -p -N <thisarticle".
  56.     If you don't have the patch program, apply the following by hand,
  57.     or get patch (version 2.0, latest patchlevel).
  58.  
  59.     After patching:
  60.  
  61.         *** DO NOTHING--INSTALL PATCH #2 FIRST ***
  62.  
  63.     If patch indicates that patchlevel is the wrong version, you may need
  64.     to apply one or more previous patches, or the patch may already
  65.     have been applied.  See the patchlevel.h file to find out what has or
  66.     has not been applied.  In any event, don't continue with the patch.
  67.  
  68.     If you are missing previous patches (hah!), they can be obtained
  69.     through anonymous ftp from weedeater.math.yale.edu.  Questions
  70.     and problems should be addressed to:
  71.  
  72.         rayshade-request@cs.princeton.edu
  73.  
  74.  
  75. Index: patchlevel.h
  76. Prereq: 0
  77. 1c1
  78. < #define PATCHLEVEL 0
  79. ---
  80. > #define PATCHLEVEL 1
  81.  
  82. Index: rayview/glmethods.c
  83. Prereq: 4.0
  84. *** rayview/glmethods.c.old    1991/07/17 17:38:43
  85. --- rayview/glmethods.c    1991/10/10 22:45:27
  86. ***************
  87. *** 14,22 ****
  88.    * There is no warranty or other guarantee of fitness of this software
  89.    * for any purpose.  It is provided solely "as is".
  90.    *
  91. !  * $Id: glmethods.c,v 4.0 91/07/17 17:38:43 kolb Exp Locker: kolb $
  92.    *
  93.    * $Log:    glmethods.c,v $
  94.    * Revision 4.0  91/07/17  17:38:43  kolb
  95.    * Initial version
  96.    * 
  97. --- 14,28 ----
  98.    * There is no warranty or other guarantee of fitness of this software
  99.    * for any purpose.  It is provided solely "as is".
  100.    *
  101. !  * $Id: glmethods.c,v 4.0.1.2 91/10/10 22:45:27 cek Exp $
  102.    *
  103.    * $Log:    glmethods.c,v $
  104. +  * Revision 4.0.1.2  91/10/10  22:45:27  cek
  105. +  * patch1: Added spotlight support.
  106. +  * 
  107. +  * Revision 4.0.1.1  1991/09/29  15:28:36  cek
  108. +  * patch1: Added support for transparency.
  109. +  *
  110.    * Revision 4.0  91/07/17  17:38:43  kolb
  111.    * Initial version
  112.    * 
  113. ***************
  114. *** 117,123 ****
  115.       PlaneMethodRegister(GLPlaneDraw);
  116.       PolygonMethodRegister(GLPolygonDraw);
  117.       SphereMethodRegister(GLSphereDraw);
  118. -     /* Have to write sphere routine for RS6000... */
  119.       /*TorusMethodRegister(GLTorusDraw);*/
  120.       TriangleMethodRegister(GLTriangleDraw);
  121.   
  122. --- 123,128 ----
  123. ***************
  124. *** 133,138 ****
  125. --- 138,152 ----
  126.       short val;
  127.       float tmp;
  128.   
  129. +     /*
  130. +      * We're only sampling the scene once, so we need
  131. +      * not do lots of work to determine exactly what
  132. +      * animated transformations are doing...
  133. +      */
  134. +     Options.samples = 1;
  135. +     SamplingSetOptions(Options.samples, Options.gaussian,
  136. +                Options.filterwidth);
  137.       DrawInit();
  138.       qdevice(ESCKEY);
  139.       qdevice(SPACEKEY);
  140. ***************
  141. *** 197,203 ****
  142. --- 211,219 ----
  143.           doublebuffer();
  144.       }
  145.   
  146.       gconfig();
  147. +     blendfunction(BF_SA, BF_MSA);
  148.       /*
  149.        * Initialize viewing matrix.
  150.        */
  151. ***************
  152. *** 329,339 ****
  153.                    DIFFUSE, 0, 0, 0,
  154.                    SPECULAR, 0, 0, 0,
  155.                    SHININESS, 0,
  156.                    LMNULL};
  157.   static float    *amb = &surfprops[1],
  158.           *diff = &surfprops[5],
  159.           *spec = &surfprops[9],
  160. !         *shine = &surfprops[13];
  161.   
  162.   static void
  163.   GLPushSurface(surf)
  164. --- 345,357 ----
  165.                    DIFFUSE, 0, 0, 0,
  166.                    SPECULAR, 0, 0, 0,
  167.                    SHININESS, 0,
  168. +                  ALPHA, 1,
  169.                    LMNULL};
  170.   static float    *amb = &surfprops[1],
  171.           *diff = &surfprops[5],
  172.           *spec = &surfprops[9],
  173. !         *shine = &surfprops[13],
  174. !         *alpha = &surfprops[15];
  175.   
  176.   static void
  177.   GLPushSurface(surf)
  178. ***************
  179. *** 357,363 ****
  180.           spec[0] = surf->spec.r; spec[1] = surf->spec.g;
  181.               spec[2] = surf->spec.b;
  182.           shine[0] = surf->srexp;
  183. !         lmdef(DEFMATERIAL, cursurf, 15, surfprops);
  184.           lastsurf = surf;
  185.       }
  186.       lmbind(MATERIAL, cursurf);
  187. --- 375,383 ----
  188.           spec[0] = surf->spec.r; spec[1] = surf->spec.g;
  189.               spec[2] = surf->spec.b;
  190.           shine[0] = surf->srexp;
  191. !         *alpha = 1. - surf->transp;
  192. !         lmdef(DEFMATERIAL, cursurf, sizeof(surfprops)/sizeof(float),
  193. !             surfprops);
  194.           lastsurf = surf;
  195.       }
  196.       lmbind(MATERIAL, cursurf);
  197. ***************
  198. *** 630,639 ****
  199.   
  200.   float lightprops[] =    {POSITION, 0., 0., 0., 0.,
  201.                LCOLOR, 0, 0, 0,
  202.                LMNULL};
  203.   
  204.   float     *lpos = &lightprops[1],
  205. !     *lcolor = &lightprops[6];
  206.   
  207.   float lmodel[] =    {AMBIENT, 1., 1., 1.,
  208.                ATTENUATION, 1., 0.,
  209. --- 650,664 ----
  210.   
  211.   float lightprops[] =    {POSITION, 0., 0., 0., 0.,
  212.                LCOLOR, 0, 0, 0,
  213. +              SPOTDIRECTION, 0., 0., 0.,
  214. +              SPOTLIGHT, 0., 180.,
  215.                LMNULL};
  216.   
  217.   float     *lpos = &lightprops[1],
  218. !     *lcolor = &lightprops[6],
  219. !     *spotdir = &lightprops[10],
  220. !     *spotexp = &lightprops[14],
  221. !     *spotspread = &lightprops[15];
  222.   
  223.   float lmodel[] =    {AMBIENT, 1., 1., 1.,
  224.                ATTENUATION, 1., 0.,
  225. ***************
  226. *** 676,686 ****
  227.       lmodel[2] = Options.ambient.g;
  228.       lmodel[3] = Options.ambient.b;
  229.   
  230. ! #ifdef sgi
  231. !     lmdef(DEFLMODEL, 1, 14, lmodel);
  232. ! #else
  233. !     lmdef(DEFLMODEL, 1, 10, lmodel);
  234. ! #endif
  235.       lmbind(LMODEL, 1);
  236.   }
  237.   
  238. --- 701,707 ----
  239.       lmodel[2] = Options.ambient.g;
  240.       lmodel[3] = Options.ambient.b;
  241.   
  242. !     lmdef(DEFLMODEL, 1, sizeof(lmodel) / sizeof(float), lmodel);
  243.       lmbind(LMODEL, 1);
  244.   }
  245.   
  246. ***************
  247. *** 704,710 ****
  248.       lpos[1] = ext->pos.y;
  249.       lpos[2] = ext->pos.z;
  250.       lpos[3] = 1.;
  251. !     lmdef(DEFLIGHT, curlight++, 10, lightprops);
  252.   }
  253.   
  254.   
  255. --- 725,732 ----
  256.       lpos[1] = ext->pos.y;
  257.       lpos[2] = ext->pos.z;
  258.       lpos[3] = 1.;
  259. !     lmdef(DEFLIGHT, curlight++, sizeof(lightprops)/sizeof(float),
  260. !         lightprops);
  261.   }
  262.   
  263.   
  264. ***************
  265. *** 716,722 ****
  266.       lpos[1] = inf->dir.y;
  267.       lpos[2] = inf->dir.z;
  268.       lpos[3] = 0.;
  269. !     lmdef(DEFLIGHT, curlight++, 10, lightprops);
  270.   }
  271.   
  272.   static void
  273. --- 738,745 ----
  274.       lpos[1] = inf->dir.y;
  275.       lpos[2] = inf->dir.z;
  276.       lpos[3] = 0.;
  277. !     lmdef(DEFLIGHT, curlight++, sizeof(lightprops)/sizeof(float),
  278. !         lightprops);
  279.   }
  280.   
  281.   static void
  282. ***************
  283. *** 727,733 ****
  284.       lpos[1] = pt->pos.y;
  285.       lpos[2] = pt->pos.z;
  286.       lpos[3] = 1.;
  287. !     lmdef(DEFLIGHT, curlight++, 10, lightprops);
  288.   }
  289.   
  290.   static void
  291. --- 750,757 ----
  292.       lpos[1] = pt->pos.y;
  293.       lpos[2] = pt->pos.z;
  294.       lpos[3] = 1.;
  295. !     lmdef(DEFLIGHT, curlight++, sizeof(lightprops) / sizeof(float),
  296. !             lightprops);
  297.   }
  298.   
  299.   static void
  300. ***************
  301. *** 734,739 ****
  302. --- 758,776 ----
  303.   GLSpotLight(spot)
  304.   Spotlight *spot;
  305.   {
  306. +     lpos[0] = spot->pos.x;
  307. +     lpos[1] = spot->pos.y;
  308. +     lpos[2] = spot->pos.z;
  309. +     lpos[3] = 1.;
  310. +     spotdir[0] = spot->pos.x - spot->dir.x;
  311. +     spotdir[1] = spot->pos.y - spot->dir.y;
  312. +     spotdir[2] = spot->pos.z - spot->dir.z;
  313. +     *spotexp = spot->coef;
  314. +     *spotspread = spot->falloff;
  315. +     lmdef(DEFLIGHT, curlight++, sizeof(lightprops) / sizeof(float),
  316. +             lightprops);
  317. +     *spotspread = 180.;
  318. +     *spotexp = 1.;
  319.   }
  320.   
  321.   static float boxfaces[6][4][3] = {
  322.  
  323. Index: etc/rsconvert/yacc.y
  324. Prereq: 4.0
  325. *** etc/rsconvert/yacc.y.old    1991/07/17 17:11:26
  326. --- etc/rsconvert/yacc.y    1991/09/28 20:44:09
  327. ***************
  328. *** 11,17 ****
  329.   /*                                        */
  330.   /* There is no warranty or other guarantee of fitness of this software       */
  331.   /* for any purpose.  It is provided solely "as is".               */
  332. ! /* $Id: yacc.y,v 4.0 91/07/17 17:11:26 kolb Exp Locker: kolb $ */
  333.   %{
  334.   #include <stdio.h>
  335.   #include "libcommon/common.h"
  336. --- 11,17 ----
  337.   /*                                        */
  338.   /* There is no warranty or other guarantee of fitness of this software       */
  339.   /* for any purpose.  It is provided solely "as is".               */
  340. ! /* $Id: yacc.y,v 4.0.1.1 91/09/28 20:44:09 cek Exp Locker: cek $ */
  341.   %{
  342.   #include <stdio.h>
  343.   #include "libcommon/common.h"
  344. ***************
  345. *** 399,404 ****
  346. --- 399,405 ----
  347.               if ($10) {
  348.                   WriteString("\ttranslu");
  349.                   WriteFloat($10);
  350. +                 WriteString("1 1 1");
  351.                   WriteFloat($11);
  352.               }
  353.           }
  354.  
  355. Index: libshade/yacc.y
  356. Prereq: 4.0
  357. *** libshade/yacc.y.old    1991/07/17 17:39:39
  358. --- libshade/yacc.y    1991/10/08 20:40:35
  359. ***************
  360. *** 11,17 ****
  361.   /*                                        */
  362.   /* There is no warranty or other guarantee of fitness of this software       */
  363.   /* for any purpose.  It is provided solely "as is".               */
  364. ! /* $Id: yacc.y,v 4.0 91/07/17 17:39:39 kolb Exp Locker: kolb $ */
  365.   %{
  366.   #include "rayshade.h"
  367.   
  368. --- 11,17 ----
  369.   /*                                        */
  370.   /* There is no warranty or other guarantee of fitness of this software       */
  371.   /* for any purpose.  It is provided solely "as is".               */
  372. ! /* $Id: yacc.y,v 4.0.1.2 91/10/08 20:40:35 cek Exp Locker: cek $ */
  373.   %{
  374.   #include "rayshade.h"
  375.   
  376. ***************
  377. *** 72,77 ****
  378. --- 72,78 ----
  379.   #include "libcommon/rotate.h"
  380.   #include "libcommon/scale.h"
  381.   #include "libcommon/translate.h"
  382. + #include "libcommon/xform.h"
  383.   
  384.   Geom *NewAggregate();
  385.   char yyfilename[BUFSIZ];            /* Input filename */
  386. ***************
  387. *** 126,132 ****
  388.   %token tTEXTURE tCHECKER tWOOD tCONTRAST tCUTOFF tCLOUD
  389.   %token tAMBIENT tDIFFUSE tREFLECT tTRANSP tSPECULAR tSPECPOW
  390.   %token tINDEX tATMOSPHERE tNOSHADOW tAREA tTRANSLU tTORUS
  391. ! %token tEYESEP tSHADOWTRANSP tREPORT tVERBOSE tQUIET tWINDOW tSTRIPE
  392.   %token tMAP tUV tSPHERICAL tCYLINDRICAL tPLANAR
  393.   %token tIMAGE tSMOOTH tCOMPONENT tTEXTSURF tRANGE tTILE tSTARTTIME tFRAMELENGTH
  394.   %token tNAME tFILTER tGAUSS tBODY tSAMPLE tEXTINCT tWINDY tMOUNT
  395. --- 127,133 ----
  396.   %token tTEXTURE tCHECKER tWOOD tCONTRAST tCUTOFF tCLOUD
  397.   %token tAMBIENT tDIFFUSE tREFLECT tTRANSP tSPECULAR tSPECPOW
  398.   %token tINDEX tATMOSPHERE tNOSHADOW tAREA tTRANSLU tTORUS
  399. ! %token tEYESEP tSHADOWTRANSP tREPORT tVERBOSE tQUIET tWINDOW tCROP tSTRIPE
  400.   %token tMAP tUV tSPHERICAL tCYLINDRICAL tPLANAR
  401.   %token tIMAGE tSMOOTH tCOMPONENT tTEXTSURF tRANGE tTILE tSTARTTIME tFRAMELENGTH
  402.   %token tNAME tFILTER tGAUSS tBODY tSAMPLE tEXTINCT tWINDY tMOUNT
  403. ***************
  404. *** 166,171 ****
  405. --- 167,173 ----
  406.           | Fov
  407.           | Screen
  408.           | Window
  409. +         | Crop
  410.           | Report
  411.           | Aperture
  412.           | Focaldist
  413. ***************
  414. *** 489,494 ****
  415. --- 491,533 ----
  416.               TransRotateSetTheta($$, $5);
  417.               if (!$$->animated)
  418.                   TransPropagate($$);
  419. +         }
  420. +         | tTRANSFORM    AnimExpr AnimExpr AnimExpr
  421. +                 AnimExpr AnimExpr AnimExpr
  422. +                 AnimExpr AnimExpr AnimExpr
  423. +         {
  424. +             $$ = TransXformCreate();
  425. +             TransXformSetX0($$, $2);
  426. +             TransXformSetY0($$, $3);
  427. +             TransXformSetZ0($$, $4);
  428. +             TransXformSetX1($$, $5);
  429. +             TransXformSetY1($$, $6);
  430. +             TransXformSetZ1($$, $7);
  431. +             TransXformSetX2($$, $8);
  432. +             TransXformSetY2($$, $9);
  433. +             TransXformSetZ2($$, $10);
  434. +             if (!$$->animated)
  435. +                 TransPropagate($$);
  436. +         }
  437. +         | tTRANSFORM    AnimExpr AnimExpr AnimExpr
  438. +                 AnimExpr AnimExpr AnimExpr
  439. +                 AnimExpr AnimExpr AnimExpr
  440. +                 AnimExpr AnimExpr AnimExpr
  441. +         {
  442. +             TransXformSetX0($$, $2);
  443. +             TransXformSetY0($$, $3);
  444. +             TransXformSetZ0($$, $4);
  445. +             TransXformSetX1($$, $5);
  446. +             TransXformSetY1($$, $6);
  447. +             TransXformSetZ1($$, $7);
  448. +             TransXformSetX2($$, $8);
  449. +             TransXformSetY2($$, $9);
  450. +             TransXformSetZ2($$, $10);
  451. +             TransXformSetXt($$, $11);
  452. +             TransXformSetYt($$, $12);
  453. +             TransXformSetZt($$, $13);
  454. +             if (!$$->animated)
  455. +                 TransPropagate($$);
  456.           };
  457.   Eyep        : tEYEP Vector Transforms
  458.           {
  459. ***************
  460. *** 602,616 ****
  461.               }
  462.           }
  463.           ;
  464. ! Window        : tWINDOW Expr Expr Expr Expr
  465.           {
  466.               if (!Options.window_set) {
  467. !                 Options.xmin = $2;
  468. !                 Options.xmax = $3;
  469. !                 Options.ymin = $4;
  470. !                 Options.ymax = $5;
  471.               }
  472.           }
  473.   Report        : tREPORT Verbose Quiet IExpr Filename
  474.           {
  475.               if (!Options.freq_set)
  476. --- 641,666 ----
  477.               }
  478.           }
  479.           ;
  480. ! Window        : tWINDOW IExpr IExpr IExpr IExpr
  481.           {
  482.               if (!Options.window_set) {
  483. !                 Options.window[LOW][X] = $2;
  484. !                 Options.window[HIGH][X] = $3;
  485. !                 Options.window[LOW][Y] = $4;
  486. !                 Options.window[HIGH][Y] = $5;
  487.               }
  488.           }
  489. +         ;
  490. + Crop        : tCROP Expr Expr Expr Expr
  491. +         {
  492. +             if (!Options.crop_set) {
  493. +                 Options.crop[LOW][X] = $2;
  494. +                 Options.crop[HIGH][X] = $3;
  495. +                 Options.crop[LOW][Y] = $4;
  496. +                 Options.crop[HIGH][Y] = $5;
  497. +             }
  498. +         }
  499. +         ;
  500.   Report        : tREPORT Verbose Quiet IExpr Filename
  501.           {
  502.               if (!Options.freq_set)
  503. ***************
  504. *** 667,673 ****
  505.           ;
  506.   Shadowtransp    : tSHADOWTRANSP
  507.           {
  508. !             Options.shadowtransp = TRUE;
  509.           }
  510.           ;
  511.   Light        : LightType
  512. --- 717,723 ----
  513.           ;
  514.   Shadowtransp    : tSHADOWTRANSP
  515.           {
  516. !             Options.shadowtransp = !Options.shadowtransp;
  517.           }
  518.           ;
  519.   Light        : LightType
  520.  
  521. Index: libray/libobj/grid.c
  522. Prereq: 4.0
  523. *** libray/libobj/grid.c.old    1991/07/17 14:38:02
  524. --- libray/libobj/grid.c    1991/10/04 15:55:37
  525. ***************
  526. *** 13,21 ****
  527.    * There is no warranty or other guarantee of fitness of this software
  528.    * for any purpose.  It is provided solely "as is".
  529.    *
  530. !  * $Id: grid.c,v 4.0 91/07/17 14:38:02 kolb Exp Locker: kolb $
  531.    *
  532.    * $Log:    grid.c,v $
  533.    * Revision 4.0  91/07/17  14:38:02  kolb
  534.    * Initial version.
  535.    * 
  536. --- 13,24 ----
  537.    * There is no warranty or other guarantee of fitness of this software
  538.    * for any purpose.  It is provided solely "as is".
  539.    *
  540. !  * $Id: grid.c,v 4.0.1.1 91/10/04 15:55:37 cek Exp Locker: cek $
  541.    *
  542.    * $Log:    grid.c,v $
  543. +  * Revision 4.0.1.1  91/10/04  15:55:37  cek
  544. +  * patch1: Removed straight floating point comparisons.
  545. +  * 
  546.    * Revision 4.0  91/07/17  14:38:02  kolb
  547.    * Initial version.
  548.    * 
  549. ***************
  550. *** 120,132 ****
  551.       x = x2voxel(grid, curpos.x);
  552.       if (x == grid->xsize)
  553.           x--;
  554. !     if (ray->dir.x < 0.) {
  555.           tMaxX = offset + (voxel2x(grid, x) - curpos.x) / ray->dir.x;
  556.           tDeltaX = grid->voxsize[X] / - ray->dir.x;
  557.           stepX = outX = -1;
  558.           raybounds[LOW][X] = &np.x;
  559.           raybounds[HIGH][X] = &curpos.x;
  560. !     } else if (ray->dir.x > 0.) {
  561.           tMaxX = offset + (voxel2x(grid, x+1) - curpos.x) / ray->dir.x;
  562.           tDeltaX = grid->voxsize[X] / ray->dir.x;
  563.           stepX = 1;
  564. --- 123,140 ----
  565.       x = x2voxel(grid, curpos.x);
  566.       if (x == grid->xsize)
  567.           x--;
  568. !     if (fabs(ray->dir.x) < EPSILON) {
  569. !         tMaxX = FAR_AWAY;
  570. !         raybounds[LOW][X] = &curpos.x;
  571. !         raybounds[HIGH][X] = &np.x;
  572. !         tDeltaX = 0.;
  573. !     } else if (ray->dir.x < 0.) {
  574.           tMaxX = offset + (voxel2x(grid, x) - curpos.x) / ray->dir.x;
  575.           tDeltaX = grid->voxsize[X] / - ray->dir.x;
  576.           stepX = outX = -1;
  577.           raybounds[LOW][X] = &np.x;
  578.           raybounds[HIGH][X] = &curpos.x;
  579. !     } else {
  580.           tMaxX = offset + (voxel2x(grid, x+1) - curpos.x) / ray->dir.x;
  581.           tDeltaX = grid->voxsize[X] / ray->dir.x;
  582.           stepX = 1;
  583. ***************
  584. *** 133,155 ****
  585.           outX = grid->xsize;
  586.           raybounds[LOW][X] = &curpos.x;
  587.           raybounds[HIGH][X] = &np.x;
  588. -     } else {
  589. -         tMaxX = FAR_AWAY;
  590. -         raybounds[LOW][X] = &curpos.x;
  591. -         raybounds[HIGH][X] = &np.x;
  592. -         tDeltaX = 0.;
  593.       }
  594.   
  595.       y = y2voxel(grid, curpos.y);
  596.       if (y == grid->ysize)
  597.           y--;
  598. !     if (ray->dir.y < 0.) {
  599.           tMaxY = offset + (voxel2y(grid, y) - curpos.y) / ray->dir.y;
  600.           tDeltaY = grid->voxsize[Y] / - ray->dir.y;
  601.           stepY = outY = -1;
  602.           raybounds[LOW][Y] = &np.y;
  603.           raybounds[HIGH][Y] = &curpos.y;
  604. !     } else if (ray->dir.y > 0.) {
  605.           tMaxY = offset + (voxel2y(grid, y+1) - curpos.y) / ray->dir.y;
  606.           tDeltaY = grid->voxsize[Y] / ray->dir.y;
  607.           stepY = 1;
  608. --- 141,164 ----
  609.           outX = grid->xsize;
  610.           raybounds[LOW][X] = &curpos.x;
  611.           raybounds[HIGH][X] = &np.x;
  612.       }
  613.   
  614.       y = y2voxel(grid, curpos.y);
  615.       if (y == grid->ysize)
  616.           y--;
  617. !     if (fabs(ray->dir.y) < EPSILON) {
  618. !         tMaxY = FAR_AWAY;
  619. !         raybounds[LOW][Y] = &curpos.y;
  620. !         raybounds[HIGH][Y] = &np.y;
  621. !         tDeltaY = 0.;
  622. !     } else if (ray->dir.y < 0.) {
  623.           tMaxY = offset + (voxel2y(grid, y) - curpos.y) / ray->dir.y;
  624.           tDeltaY = grid->voxsize[Y] / - ray->dir.y;
  625.           stepY = outY = -1;
  626.           raybounds[LOW][Y] = &np.y;
  627.           raybounds[HIGH][Y] = &curpos.y;
  628. !     } else {
  629.           tMaxY = offset + (voxel2y(grid, y+1) - curpos.y) / ray->dir.y;
  630.           tDeltaY = grid->voxsize[Y] / ray->dir.y;
  631.           stepY = 1;
  632. ***************
  633. *** 156,178 ****
  634.           outY = grid->ysize;
  635.           raybounds[LOW][Y] = &curpos.y;
  636.           raybounds[HIGH][Y] = &np.y;
  637. -     } else {
  638. -         tMaxY = FAR_AWAY;
  639. -         raybounds[LOW][Y] = &curpos.y;
  640. -         raybounds[HIGH][Y] = &np.y;
  641. -         tDeltaY = 0.;
  642.       }
  643.   
  644.       z = z2voxel(grid, curpos.z);
  645.       if (z == grid->zsize)
  646.           z--;
  647. !     if (ray->dir.z < 0.) {
  648.           tMaxZ = offset + (voxel2z(grid, z) - curpos.z) / ray->dir.z;
  649.           tDeltaZ = grid->voxsize[Z] / - ray->dir.z;
  650.           stepZ = outZ = -1;
  651.           raybounds[LOW][Z] = &np.z;
  652.           raybounds[HIGH][Z] = &curpos.z;
  653. !     } else if (ray->dir.z > 0.) {
  654.           tMaxZ = offset + (voxel2z(grid, z+1) - curpos.z) / ray->dir.z;
  655.           tDeltaZ = grid->voxsize[Z] / ray->dir.z;
  656.           stepZ = 1;
  657. --- 165,187 ----
  658.           outY = grid->ysize;
  659.           raybounds[LOW][Y] = &curpos.y;
  660.           raybounds[HIGH][Y] = &np.y;
  661.       }
  662.   
  663.       z = z2voxel(grid, curpos.z);
  664.       if (z == grid->zsize)
  665.           z--;
  666. !     if (fabs(ray->dir.z) < EPSILON) {
  667. !         tMaxZ = FAR_AWAY;
  668. !         raybounds[LOW][Z] = &curpos.z;
  669. !         raybounds[HIGH][Z] = &np.z;
  670. !         tDeltaZ = 0.;
  671. !     } else if (ray->dir.z < 0.) {
  672.           tMaxZ = offset + (voxel2z(grid, z) - curpos.z) / ray->dir.z;
  673.           tDeltaZ = grid->voxsize[Z] / - ray->dir.z;
  674.           stepZ = outZ = -1;
  675.           raybounds[LOW][Z] = &np.z;
  676.           raybounds[HIGH][Z] = &curpos.z;
  677. !     } else {
  678.           tMaxZ = offset + (voxel2z(grid, z+1) - curpos.z) / ray->dir.z;
  679.           tDeltaZ = grid->voxsize[Z] / ray->dir.z;
  680.           stepZ = 1;
  681. ***************
  682. *** 179,189 ****
  683.           outZ = grid->zsize;
  684.           raybounds[LOW][Z] = &curpos.z;
  685.           raybounds[HIGH][Z] = &np.z;
  686. -     } else {
  687. -         tMaxZ = FAR_AWAY;
  688. -         raybounds[LOW][Z] = &curpos.z;
  689. -         raybounds[HIGH][Z] = &np.z;
  690. -         tDeltaZ = 0.;
  691.       }
  692.   
  693.       VecScale(tDeltaX, ray->dir, &pDeltaX);
  694. --- 188,193 ----
  695.  
  696. Index: libshade/viewing.c
  697. Prereq: 4.0
  698. *** libshade/viewing.c.old    1991/07/17 14:48:18
  699. --- libshade/viewing.c    1991/09/29 15:53:09
  700. ***************
  701. *** 13,21 ****
  702.    * There is no warranty or other guarantee of fitness of this software
  703.    * for any purpose.  It is provided solely "as is".
  704.    *
  705. !  * $Id: viewing.c,v 4.0 91/07/17 14:48:18 kolb Exp Locker: kolb $
  706.    *
  707.    * $Log:    viewing.c,v $
  708.    * Revision 4.0  91/07/17  14:48:18  kolb
  709.    * Initial version.
  710.    * 
  711. --- 13,24 ----
  712.    * There is no warranty or other guarantee of fitness of this software
  713.    * for any purpose.  It is provided solely "as is".
  714.    *
  715. !  * $Id: viewing.c,v 4.0.1.1 91/09/29 15:53:09 cek Exp Locker: cek $
  716.    *
  717.    * $Log:    viewing.c,v $
  718. +  * Revision 4.0.1.1  91/09/29  15:53:09  cek
  719. +  * patch1: Added support for window and crop commands.
  720. +  * 
  721.    * Revision 4.0  91/07/17  14:48:18  kolb
  722.    * Initial version.
  723.    * 
  724. ***************
  725. *** 71,76 ****
  726. --- 74,85 ----
  727.       VecScale(magnitude, Screen.scrni, &Screen.scrnx);
  728.       magnitude = 2.*Camera.lookdist * tan(deg2rad(0.5*Camera.vfov)) /
  729.                   Screen.yres;
  730. + #ifndef URT
  731. +     /*
  732. +      * If using "generic" file format, render top-to-bottom (yick).
  733. +      */
  734. +     magnitude *= -1;
  735. + #endif
  736.       VecScale(magnitude, Screen.scrnj, &Screen.scrny);
  737.   
  738.       Screen.firstray.x -= 0.5*Screen.yres*Screen.scrny.x +
  739. ***************
  740. *** 119,124 ****
  741. --- 128,138 ----
  742.   void
  743.   ViewingSetup()
  744.   {
  745. + #define SWAP(a,b)    (tmp = (a), (a) = (b), (b) = tmp)
  746. +     Float tmp;
  747. +     int xwidth, ywidth;
  748.       if (Options.stereo && Options.eyesep == UNSET)
  749.           RLerror(RL_PANIC,
  750.               "No eye separation specified for stereo rendering.\n");
  751. ***************
  752. *** 137,147 ****
  753.       if (Screen.yres == UNSET)
  754.           Screen.yres = YRESOLUTION;
  755.   
  756.   #ifdef URT
  757.       /*
  758. !      * If using the URT, we can use the RLE file header to
  759. !      * determine window size.  Screen size (Screen.xres, Screen.yres)
  760. !      * is determined as usual (from command line or input file).
  761.        */
  762.       if (Options.appending) {
  763.           /*
  764. --- 151,205 ----
  765.       if (Screen.yres == UNSET)
  766.           Screen.yres = YRESOLUTION;
  767.   
  768. +     /*
  769. +      * The window to be rendered is defined by applying
  770. +      * the crop window to the sub window.  The subwindow
  771. +      * is defined using pixel numbers, and must be within
  772. +      * [0, xres -1],[0, yres -1].  The default is the entire
  773. +      * screen.  The crop window is specified using normalized
  774. +      * coordinates.
  775. +      */
  776. +     if (!Options.window_set) {
  777. +         /* If no window set, set equal to entire screen. */    
  778. +         Options.window[LOW][X] = Options.window[LOW][Y] = 0;
  779. +         Options.window[HIGH][X] = Screen.xres -1;
  780. +         Options.window[HIGH][Y] = Screen.yres -1;
  781. +     }
  782. +     /* Truncate crop window to legal limits. */
  783. +     if (Options.crop[LOW][X] > Options.crop[HIGH][X])
  784. +         SWAP(Options.crop[LOW][X], Options.crop[HIGH][X]);
  785. +     if (Options.crop[LOW][Y] > Options.crop[HIGH][Y])
  786. +         SWAP(Options.crop[LOW][Y], Options.crop[HIGH][Y]);
  787. +     if (Options.crop[LOW][X] < 0.) Options.crop[LOW][X] = 0.;
  788. +     if (Options.crop[LOW][Y] < 0.) Options.crop[LOW][Y] = 0.;
  789. +     if (Options.crop[HIGH][X] > 1.) Options.crop[HIGH][X] = 1.;
  790. +     if (Options.crop[HIGH][Y] > 1.) Options.crop[HIGH][Y] = 1.;
  791. +     xwidth = Options.window[HIGH][X] - Options.window[LOW][X];
  792. +     ywidth = Options.window[HIGH][Y] - Options.window[LOW][Y];
  793. +     /* Compute x and y extents of window to be renered. */
  794. +     Screen.minx = (int)(Options.window[LOW][X] +
  795. +             Options.crop[LOW][X] * xwidth);
  796. +     Screen.maxx = (int)(Options.window[LOW][X] +
  797. +             Options.crop[HIGH][X] * xwidth);
  798. +     Screen.miny = (int)(Options.window[LOW][Y] +
  799. +             Options.crop[LOW][Y] * ywidth);
  800. +     Screen.maxy = (int)(Options.window[LOW][Y] +
  801. +             Options.crop[HIGH][Y] * ywidth);
  802.   #ifdef URT
  803.       /*
  804. !      * If using the URT, we should use the RLE file header to
  805. !      * determine cropped window size.  Screen size
  806. !      * (Screen.xres, Screen.yres) is determined from command
  807. !      * line or input file, as usual.
  808. !      *
  809. !      * If the cropped window computed in PictureSetWindow()
  810. !      * is not equal the cropped window computed above,
  811. !      * a warning message is issued.
  812.        */
  813.       if (Options.appending) {
  814.           /*
  815. ***************
  816. *** 148,165 ****
  817.            * Read image header to determine window size.
  818.            */
  819.           PictureSetWindow();
  820. -     } else {
  821. - #endif
  822. -     if (Options.xmin < 0.) Options.xmin = 0.;
  823. -     if (Options.ymin < 0.) Options.ymin = 0.;
  824. -     if (Options.xmax > 1.) Options.xmax = 1.;
  825. -     if (Options.xmax > 1.) Options.xmax = 1.;
  826. -     Screen.minx = (int)(Options.xmin * Screen.xres);
  827. -     Screen.maxx = (int)(Options.xmax * Screen.xres -1);
  828. -     Screen.miny = (int)(Options.ymin * Screen.yres);
  829. -     Screen.maxy = (int)(Options.ymax * Screen.yres -1);
  830. - #ifdef URT
  831.       }
  832.   #endif
  833.   
  834. --- 206,211 ----
  835.  
  836. Index: README
  837. *** README.old    1991/07/17 14:27:21
  838. --- README    1991/10/10 18:16:26
  839. ***************
  840. *** 35,41 ****
  841.   conversion utility, rsconvert.  See Doc/Changes for a list of some of
  842.   the more important changes.
  843.   
  844. ! Rayshade v4.0 has been tested on several different UNIX-based computers,
  845.   including: SGI 4D, IBM RS6000, Sun Sparcstation 1, Sun 3, DECstation,
  846.   Apollo DN10000, NeXT.  If your machine has a C compiler, enough memory
  847.   (at least 2Mb), and runs something resembling UNIX, rayshade should be fairly
  848. --- 35,41 ----
  849.   conversion utility, rsconvert.  See Doc/Changes for a list of some of
  850.   the more important changes.
  851.   
  852. ! Rayshade v4.0 Beta has been tested on several different UNIX-based computers,
  853.   including: SGI 4D, IBM RS6000, Sun Sparcstation 1, Sun 3, DECstation,
  854.   Apollo DN10000, NeXT.  If your machine has a C compiler, enough memory
  855.   (at least 2Mb), and runs something resembling UNIX, rayshade should be fairly
  856. ***************
  857. *** 90,96 ****
  858.   Standard Procedural Databases through awk using the etc/nff2shade.awk
  859.   script, and then feed the results to rayshade.  Note that for several
  860.   of the databases, you will need to tweak the data a bit to achieve
  861. ! optimal runtimes.  See spd2shade.awk for details.
  862.   
  863.   Rayshade was not designed to be, nor is it, the be-all and end-all of
  864.   ray tracers.  It was meant to be reasonably fast, portable, and easy to
  865. --- 90,96 ----
  866.   Standard Procedural Databases through awk using the etc/nff2shade.awk
  867.   script, and then feed the results to rayshade.  Note that for several
  868.   of the databases, you will need to tweak the data a bit to achieve
  869. ! optimal runtimes.  See nff2shade.awk for details.
  870.   
  871.   Rayshade was not designed to be, nor is it, the be-all and end-all of
  872.   ray tracers.  It was meant to be reasonably fast, portable, and easy to
  873. ***************
  874. *** 136,146 ****
  875.   for the 'net tracer' conversations and for the inspiration to do something
  876.   to clean up rayshade.
  877.   
  878. ! Thanks to Marc Andreessen, Ray Bellis, Dominique Boisvert, William Bouma,
  879. ! Allen Braunsdorf, Jeff Butterworth, Nick Carriero, Nancy Everson, Tom Friedel,
  880. ! Robert Funchess, David Gelernter, Mike Gigante, Ed Herderick, John Knuston,
  881. ! Raphael Manfredi, Lee Moore, Dietmar Saupe, Brian Wyvill,
  882. ! and everybody else for their bugfixes, suggestions, input files,
  883.   encouragement, and other feedback.
  884.   
  885.   Thanks also to Mark Podlipec for providing the blob and torus objects.
  886. --- 136,146 ----
  887.   for the 'net tracer' conversations and for the inspiration to do something
  888.   to clean up rayshade.
  889.   
  890. ! Thanks to Marc Andreessen, Tony Apodaca, Ray Bellis, Dominique Boisvert,
  891. ! William Bouma, Allen Braunsdorf, Jeff Butterworth, Nick Carriero,
  892. ! Nancy Everson, Tom Friedel, Robert Funchess, David Gelernter, Mike Gigante,
  893. ! Ed Herderick, John Knuston, Raphael Manfredi, Lee Moore, Dietmar Saupe,
  894. ! Brian Wyvill, and everybody else for their bugfixes, suggestions, input files,
  895.   encouragement, and other feedback.
  896.   
  897.   Thanks also to Mark Podlipec for providing the blob and torus objects.
  898. ***************
  899. *** 156,179 ****
  900.   particularly braindamaged section of code, please let us know.  We can be
  901.   most easily reached by email.
  902.   
  903. ! Once you start using rayshade, send a message to
  904. ! rayshade@weedeater.math.yale.edu and you'll be added to the rayshade
  905. ! mailing list.
  906.   
  907.   Craig Kolb
  908.   Rod Bogart
  909. ! 17 July 1991
  910.   rayshade@weedeater.math.yale.edu
  911.   
  912.   Craig Kolb 
  913. - Department of Mathematics
  914. - Yale University
  915. - 10 Hillhouse Ave.
  916. - Box 2155 Yale Station
  917. - New Haven, CT  06520-2155
  918. - (Until September, 1991)
  919.   Computer Science Department
  920.   Princeton University
  921.   Princeton, NJ 08544
  922. - (September, 1991 onwards)
  923. --- 156,172 ----
  924.   particularly braindamaged section of code, please let us know.  We can be
  925.   most easily reached by email.
  926.   
  927. ! Once you start using rayshade, and you'd like to be kept abreast of
  928. ! changes and extensions, send a message to rayshade-request@cs.princeton.edu,
  929. ! and we'll add you to the rayshade mailing list.
  930.   
  931.   Craig Kolb
  932.   Rod Bogart
  933. ! 9 October 1991
  934.   rayshade@weedeater.math.yale.edu
  935.   
  936.   Craig Kolb 
  937.   Computer Science Department
  938.   Princeton University
  939. + 35 Olden St.
  940.   Princeton, NJ 08544
  941.  
  942. Index: libshade/options.c
  943. Prereq: 4.0
  944. *** libshade/options.c.old    1991/07/17 14:46:47
  945. --- libshade/options.c    1991/10/05 18:23:15
  946. ***************
  947. *** 13,21 ****
  948.    * There is no warranty or other guarantee of fitness of this software
  949.    * for any purpose.  It is provided solely "as is".
  950.    *
  951. !  * $Id: options.c,v 4.0 91/07/17 14:46:47 kolb Exp Locker: kolb $
  952.    *
  953.    * $Log:    options.c,v $
  954.    * Revision 4.0  91/07/17  14:46:47  kolb
  955.    * Initial version.
  956.    * 
  957. --- 13,25 ----
  958.    * There is no warranty or other guarantee of fitness of this software
  959.    * for any purpose.  It is provided solely "as is".
  960.    *
  961. !  * $Id: options.c,v 4.0.1.1 91/10/05 18:23:15 cek Exp Locker: cek $
  962.    *
  963.    * $Log:    options.c,v $
  964. +  * Revision 4.0.1.1  91/10/05  18:23:15  cek
  965. +  * patch1: Changes for new window/crop options.
  966. +  * patch1: Corrected help message.
  967. +  * 
  968.    * Revision 4.0  91/07/17  14:46:47  kolb
  969.    * Initial version.
  970.    * 
  971. ***************
  972. *** 210,239 ****
  973.                   OpenStatsFile();
  974.                   argv++; argc--;
  975.                   break;
  976. - #ifdef URT
  977.               case 'W':
  978. !                 Options.xmin = atof(argv[1]);
  979. !                 Options.xmax = atof(argv[2]);
  980. !                 Options.ymin = atof(argv[3]);
  981. !                 Options.ymax = atof(argv[4]);
  982.                   Options.window_set = TRUE;
  983.                   argv += 4; argc -= 4;
  984.                   break;
  985. - #endif
  986. - #ifdef LINDA
  987.               case 'X':
  988. !                 Options.workers = atoi(argv[1]);
  989. !                 if (Options.workers<0 || Options.workers>17) {
  990. !                     RLerror(RL_PANIC, "%d workers?\n",
  991. !                             Options.workers);
  992. !                 }
  993. !                 argv++; argc--;
  994. !                 break;
  995. !             case 'w':
  996. !                 Options.verbose_worker =
  997. !                     !Options.verbose_worker;
  998.                   break;
  999. - #endif
  1000.               default:
  1001.                   RLerror(RL_PANIC,"Bad argument: %s\n",argv[0]);
  1002.           }
  1003. --- 214,235 ----
  1004.                   OpenStatsFile();
  1005.                   argv++; argc--;
  1006.                   break;
  1007.               case 'W':
  1008. !                 Options.window[LOW][X] = atoi(argv[1]);
  1009. !                 Options.window[HIGH][X] = atoi(argv[3]);
  1010. !                 Options.window[LOW][Y] = atoi(argv[3]);
  1011. !                 Options.window[HIGH][Y] = atoi(argv[4]);
  1012.                   Options.window_set = TRUE;
  1013.                   argv += 4; argc -= 4;
  1014.                   break;
  1015.               case 'X':
  1016. !                 Options.crop[LOW][X] = atof(argv[1]);
  1017. !                 Options.crop[HIGH][X] = atof(argv[2]);
  1018. !                 Options.crop[LOW][Y] = atof(argv[3]);
  1019. !                 Options.crop[HIGH][Y] = atof(argv[4]);
  1020. !                 Options.crop_set = TRUE;
  1021. !                 argv += 4; argc -= 4;
  1022.                   break;
  1023.               default:
  1024.                   RLerror(RL_PANIC,"Bad argument: %s\n",argv[0]);
  1025.           }
  1026. ***************
  1027. *** 304,312 ****
  1028. --- 300,314 ----
  1029.       fprintf(stderr,"\t-e \t\t(Write exponential RLE file.)\n");
  1030.   #endif
  1031.       fprintf(stderr,"\t-F freq\t\t(Set frequency of status report.)\n");
  1032. +     fprintf(stderr,"\t-f \t\t(Flip all triangle normals.)\n");
  1033.       fprintf(stderr,"\t-G gamma\t(Use given gamma correction exponent.)\n");
  1034. +     fprintf(stderr,"\t-g \t\t(Use Gaussian pixel filter.)\n");
  1035.       fprintf(stderr,"\t-h \t\t(Print this message.)\n");
  1036. +     fprintf(stderr,"\t-j \t\t(Toggle jittered sampling.)\n");
  1037.       fprintf(stderr,"\t-l \t\t(Render image for left eye view.)\n");
  1038. + #ifdef URT
  1039. +     fprintf(stderr,"\t-m \t\t(Output sample map in alpha channel.)\n");
  1040. + #endif
  1041.       fprintf(stderr,"\t-N number\t(Render given number of frames.)\n");
  1042.       fprintf(stderr,"\t-n \t\t(Do not render shadows.)\n");
  1043.       fprintf(stderr,"\t-O outfile \t(Set output file name.)\n");
  1044. ***************
  1045. *** 321,331 ****
  1046.       fprintf(stderr,"\t-T r g b\t(Set contrast threshold (0. - 1.).)\n");
  1047.       fprintf(stderr,"\t-V filename \t(Write verbose output to filename.)\n");
  1048.       fprintf(stderr,"\t-v \t\t(Verbose output.)\n");
  1049. ! #ifdef URT
  1050. !     fprintf(stderr,"\t-W x y x y \t(Render subwindow.)\n");
  1051. ! #endif
  1052. ! #ifdef LINDA
  1053. !     fprintf(stderr,"\t-X workers\t(Number of workers.)\n");
  1054. !     fprintf(stderr,"\t-w \t\t(Verbose worker output.)\n");
  1055. ! #endif
  1056.   }
  1057. --- 323,328 ----
  1058.       fprintf(stderr,"\t-T r g b\t(Set contrast threshold (0. - 1.).)\n");
  1059.       fprintf(stderr,"\t-V filename \t(Write verbose output to filename.)\n");
  1060.       fprintf(stderr,"\t-v \t\t(Verbose output.)\n");
  1061. !     fprintf(stderr,"\t-W x x y y \t(Render subwindow.)\n");
  1062. !     fprintf(stderr,"\t-X l r b t \t(Crop window.)\n");
  1063.   }
  1064.  
  1065. Index: libray/libobj/bounds.c
  1066. Prereq: 4.0
  1067. *** libray/libobj/bounds.c.old    1991/07/17 14:36:21
  1068. --- libray/libobj/bounds.c    1991/10/05 18:17:29
  1069. ***************
  1070. *** 13,21 ****
  1071.    * There is no warranty or other guarantee of fitness of this software
  1072.    * for any purpose.  It is provided solely "as is".
  1073.    *
  1074. !  * $Id: bounds.c,v 4.0 91/07/17 14:36:21 kolb Exp Locker: kolb $
  1075.    *
  1076.    * $Log:    bounds.c,v $
  1077.    * Revision 4.0  91/07/17  14:36:21  kolb
  1078.    * Initial version.
  1079.    * 
  1080. --- 13,27 ----
  1081.    * There is no warranty or other guarantee of fitness of this software
  1082.    * for any purpose.  It is provided solely "as is".
  1083.    *
  1084. !  * $Id: bounds.c,v 4.0.1.2 91/10/05 18:17:29 cek Exp Locker: cek $
  1085.    *
  1086.    * $Log:    bounds.c,v $
  1087. +  * Revision 4.0.1.2  91/10/05  18:17:29  cek
  1088. +  * patch1: Faster box transform, a la Jim Arvo.
  1089. +  * 
  1090. +  * Revision 4.0.1.1  1991/09/29  15:42:05  cek
  1091. +  * patch1: Justified floating point compare...
  1092. +  *
  1093.    * Revision 4.0  91/07/17  14:36:21  kolb
  1094.    * Initial version.
  1095.    * 
  1096. ***************
  1097. *** 134,139 ****
  1098. --- 140,149 ----
  1099.       } else if (pos < bounds[LOW][Z] || pos > bounds[HIGH][Z])
  1100.           return FALSE;
  1101.   
  1102. +     /*
  1103. +      * If tmin == mindist, then there was no "near"
  1104. +      * intersection farther than EPSILON away.
  1105. +      */
  1106.       if (tmin == mindist) {
  1107.           if (tmax < *maxdist) {
  1108.               *maxdist = tmax;
  1109. ***************
  1110. *** 157,165 ****
  1111.   RSMatrix *trans;
  1112.   Float objbounds[2][3];
  1113.   {
  1114. !     Vector tmp;
  1115. !     Float bounds[2][3];
  1116. !     int x, y, z;
  1117.   
  1118.       /*
  1119.        * Can't (and shouldn't) do anything with unbounded objects.
  1120. --- 167,174 ----
  1121.   RSMatrix *trans;
  1122.   Float objbounds[2][3];
  1123.   {
  1124. !     Float bounds[2][3], a, b;
  1125. !     int i, j;
  1126.   
  1127.       /*
  1128.        * Can't (and shouldn't) do anything with unbounded objects.
  1129. ***************
  1130. *** 166,200 ****
  1131.        */
  1132.       if (objbounds[LOW][X] > objbounds[HIGH][X])
  1133.           return;
  1134. -         
  1135. -     BoundsInit(bounds);
  1136.   
  1137. !     /*
  1138. !      * Find bounding box of transformed corners of bounding box.
  1139. !      */
  1140. !     for (x = 0 ; x < 2; x++) {
  1141. !         for (y = 0; y < 2; y++) {
  1142. !             for (z = 0; z < 2; z++) {
  1143. !                 tmp.x = objbounds[x][X];
  1144. !                 tmp.y = objbounds[y][Y];
  1145. !                 tmp.z = objbounds[z][Z];
  1146. !                 PointTransform(&tmp, trans);
  1147. !                 if (tmp.x < bounds[LOW][X])
  1148. !                     bounds[LOW][X] = tmp.x;
  1149. !                 if (tmp.x > bounds[HIGH][X])
  1150. !                     bounds[HIGH][X] = tmp.x;
  1151. !                 if (tmp.y < bounds[LOW][Y])
  1152. !                     bounds[LOW][Y] = tmp.y;
  1153. !                 if (tmp.y > bounds[HIGH][Y])
  1154. !                     bounds[HIGH][Y] = tmp.y;
  1155. !                 if (tmp.z < bounds[LOW][Z])
  1156. !                     bounds[LOW][Z] = tmp.z;
  1157. !                 if (tmp.z > bounds[HIGH][Z])
  1158. !                     bounds[HIGH][Z] = tmp.z;
  1159.               }
  1160.           }
  1161.       }
  1162.       BoundsCopy(bounds, objbounds);
  1163.   }
  1164.   
  1165. --- 175,198 ----
  1166.        */
  1167.       if (objbounds[LOW][X] > objbounds[HIGH][X])
  1168.           return;
  1169.   
  1170. !     bounds[LOW][X] = bounds[HIGH][X] = trans->translate.x;
  1171. !     bounds[LOW][Y] = bounds[HIGH][Y] = trans->translate.y;
  1172. !     bounds[LOW][Z] = bounds[HIGH][Z] = trans->translate.z;
  1173. !     for (i = 0; i < 3; i++) {
  1174. !         for (j = 0; j < 3; j++) {
  1175. !             a = trans->matrix[j][i] * objbounds[LOW][j];
  1176. !             b = trans->matrix[j][i] * objbounds[HIGH][j];
  1177. !             if (a < b) {
  1178. !                 bounds[LOW][i] += a;
  1179. !                 bounds[HIGH][i] += b;
  1180. !             } else {
  1181. !                 bounds[LOW][i] += b;
  1182. !                 bounds[HIGH][i] += a;
  1183.               }
  1184.           }
  1185.       }
  1186.       BoundsCopy(bounds, objbounds);
  1187.   }
  1188.   
  1189.  
  1190. Index: Doc/quickref.txt
  1191. *** Doc/quickref.txt.old    1991/07/17 14:25:15
  1192. --- Doc/quickref.txt    1991/10/05 18:00:35
  1193. ***************
  1194. *** 40,46 ****
  1195.   -r             Right eye view         -S samples     Use Samples^2 samples
  1196.   -s             Toggle shadow caching  -T r g b       Contrast threshold
  1197.   -V filename    Verbose file output    -v             Verbose output
  1198. ! -W lx ly hx hy Render subwindow
  1199.   -------------------------------------------------------------------------------
  1200.   
  1201.   File: /* Input file consists of...*/
  1202. --- 40,46 ----
  1203.   -r             Right eye view         -S samples     Use Samples^2 samples
  1204.   -s             Toggle shadow caching  -T r g b       Contrast threshold
  1205.   -V filename    Verbose file output    -v             Verbose output
  1206. ! -W lx hx ly hy Render subwindow       -X l r b t     Crop window
  1207.   -------------------------------------------------------------------------------
  1208.   
  1209.   File: /* Input file consists of...*/
  1210. ***************
  1211. *** 70,76 ****
  1212.           shutter Speed           /* Shutter speed (0 --> no blur) */
  1213.           framelength Length      /* Length of a singelf frame (1) */
  1214.           screen Xsize Ysize      /* Screen size */
  1215. !         window Xmin Ymin Xmax Ymax /* Window (0 0 xsize-1 ysize-1) */
  1216.           eyesep Separation       /* eye separation (0) */
  1217.   
  1218.   SurfDef: /* Give a name to a set of surface attributes. */
  1219. --- 70,77 ----
  1220.           shutter Speed           /* Shutter speed (0 --> no blur) */
  1221.           framelength Length      /* Length of a singelf frame (1) */
  1222.           screen Xsize Ysize      /* Screen size */
  1223. !         window Xmin Xmax Ymin Ymax /* Window (0 xsize-1 0 ysize-1) */
  1224. !         crop left right bot top /* Crop window (0 1 0 1) */
  1225.           eyesep Separation       /* eye separation (0) */
  1226.   
  1227.   SurfDef: /* Give a name to a set of surface attributes. */
  1228. ***************
  1229. *** 199,205 ****
  1230.   Mapping:
  1231.           map uv
  1232.           map cylindrical [Xorigin Yorigin Zorigin Xup Yup Zup Xu Yu Zu] 
  1233. !         map linear      [Xorigin Yorigin Zorigin Xv  Yv  Zv  Xu Yu Zu]
  1234.           map spherical   [Xorigin Yorigin Zorigin Xup Yup Zup Xu Yu Zu]
  1235.   
  1236.   Light:
  1237. --- 200,206 ----
  1238.   Mapping:
  1239.           map uv
  1240.           map cylindrical [Xorigin Yorigin Zorigin Xup Yup Zup Xu Yu Zu] 
  1241. !         map planar      [Xorigin Yorigin Zorigin Xv  Yv  Zv  Xu Yu Zu]
  1242.           map spherical   [Xorigin Yorigin Zorigin Xup Yup Zup Xu Yu Zu]
  1243.   
  1244.   Light:
  1245.  
  1246. Index: libshade/symtab.c
  1247. Prereq: 4.0
  1248. *** libshade/symtab.c.old    1991/07/17 14:48:02
  1249. --- libshade/symtab.c    1991/10/05 18:24:29
  1250. ***************
  1251. *** 13,21 ****
  1252.    * There is no warranty or other guarantee of fitness of this software
  1253.    * for any purpose.  It is provided solely "as is".
  1254.    *
  1255. !  * $Id: symtab.c,v 4.0 91/07/17 14:48:02 kolb Exp Locker: kolb $
  1256.    *
  1257.    * $Log:    symtab.c,v $
  1258.    * Revision 4.0  91/07/17  14:48:02  kolb
  1259.    * Initial version.
  1260.    * 
  1261. --- 13,24 ----
  1262.    * There is no warranty or other guarantee of fitness of this software
  1263.    * for any purpose.  It is provided solely "as is".
  1264.    *
  1265. !  * $Id: symtab.c,v 4.0.1.1 91/10/05 18:24:29 cek Exp Locker: cek $
  1266.    *
  1267.    * $Log:    symtab.c,v $
  1268. +  * Revision 4.0.1.1  91/10/05  18:24:29  cek
  1269. +  * patch1: Added casts for builtin functions.
  1270. +  * 
  1271.    * Revision 4.0  91/07/17  14:48:02  kolb
  1272.    * Initial version.
  1273.    * 
  1274. ***************
  1275. *** 29,42 ****
  1276.       {"pi", 3.141592, NULL, FLOAT_EXPR, FALSE, 0},
  1277.       {"dtor", 0.017453, NULL, FLOAT_EXPR, FALSE, 0},
  1278.       {"rtod", 57.29578, NULL, FLOAT_EXPR, FALSE, 0},
  1279. !     {"cos", 0.0, cos, BUILTIN_EXPR, FALSE, 1},
  1280. !     {"sin", 0.0, sin, BUILTIN_EXPR, FALSE, 1},
  1281. !     {"tan", 0.0, tan, BUILTIN_EXPR, FALSE, 1},
  1282. !     {"sqrt", 0.0, sqrt, BUILTIN_EXPR, FALSE, 1},
  1283. !     {"acos", 0.0, acos, BUILTIN_EXPR, FALSE, 1},
  1284. !     {"asin", 0.0, asin, BUILTIN_EXPR, FALSE, 1},
  1285. !     {"atan", 0.0, atan, BUILTIN_EXPR, FALSE, 1},
  1286. !     {"hypot", 0.0, hypot, BUILTIN_EXPR, FALSE, 2},
  1287.       {"time", 0.0, NULL, FLOAT_EXPR, TRUE, 0},
  1288.       {"frame", 0.0, NULL, FLOAT_EXPR, TRUE, 0},
  1289.       {"linear", 0.0, LinearTime, BUILTIN_EXPR, TRUE, 4},
  1290. --- 32,45 ----
  1291.       {"pi", 3.141592, NULL, FLOAT_EXPR, FALSE, 0},
  1292.       {"dtor", 0.017453, NULL, FLOAT_EXPR, FALSE, 0},
  1293.       {"rtod", 57.29578, NULL, FLOAT_EXPR, FALSE, 0},
  1294. !     {"cos", 0.0, (Float (*)())cos, BUILTIN_EXPR, FALSE, 1},
  1295. !     {"sin", 0.0, (Float (*)())sin, BUILTIN_EXPR, FALSE, 1},
  1296. !     {"tan", 0.0, (Float (*)())tan, BUILTIN_EXPR, FALSE, 1},
  1297. !     {"sqrt", 0.0, (Float (*)())sqrt, BUILTIN_EXPR, FALSE, 1},
  1298. !     {"acos", 0.0, (Float (*)())acos, BUILTIN_EXPR, FALSE, 1},
  1299. !     {"asin", 0.0, (Float (*)())asin, BUILTIN_EXPR, FALSE, 1},
  1300. !     {"atan", 0.0, (Float (*)())atan, BUILTIN_EXPR, FALSE, 1},
  1301. !     {"hypot", 0.0, (Float (*)())hypot, BUILTIN_EXPR, FALSE, 2},
  1302.       {"time", 0.0, NULL, FLOAT_EXPR, TRUE, 0},
  1303.       {"frame", 0.0, NULL, FLOAT_EXPR, TRUE, 0},
  1304.       {"linear", 0.0, LinearTime, BUILTIN_EXPR, TRUE, 4},
  1305.  
  1306. Index: Doc/Guide/running.tex
  1307. *** Doc/Guide/running.tex.old    1991/07/17 15:46:02
  1308. --- Doc/Guide/running.tex    1991/10/05 18:02:29
  1309. ***************
  1310. *** 153,171 ****
  1311.   the windows into a final image.
  1312.   
  1313.   \begin{defkey}{window}{{\em minx maxx miny maxy}}
  1314. !     Render the image in the given screen subwindow,
  1315. !     specified in normalized units.
  1316.   \end{defkey}
  1317.   The window must be properly
  1318.   contained within the screen, i.e., {\em minx} and {\em miny} must
  1319.   be greater than or equal to zero, while {\em maxx} and
  1320. ! {\em maxy} must be less than or equal to one.
  1321. ! The {\em mtv} image file format does not support windows.  The
  1322. ! Utah Raster tool
  1323.   {\em rlecomp\/} is useful for reconstructing the full image from
  1324.   sub-images.
  1325.   By default, the window
  1326. ! is equal to ($0., 1., 0, 1$), or the entire screen.
  1327.   
  1328.   {\em Gamma correction} may also be applied to the three output color
  1329.   channels.  See Appendix A for more details.
  1330. --- 153,184 ----
  1331.   the windows into a final image.
  1332.   
  1333.   \begin{defkey}{window}{{\em minx maxx miny maxy}}
  1334. !     Render the image in the given window.
  1335.   \end{defkey}
  1336.   The window must be properly
  1337.   contained within the screen, i.e., {\em minx} and {\em miny} must
  1338.   be greater than or equal to zero, while {\em maxx} and
  1339. ! {\em maxy} must be less than {\em xsize} and {\em ysize}, respectively.
  1340. ! The Utah Raster tool
  1341.   {\em rlecomp\/} is useful for reconstructing the full image from
  1342.   sub-images.
  1343.   By default, the window
  1344. ! is equivalent to the entire screen.
  1345. ! It is also convenient to be able to render a small portion
  1346. ! of the window by specifying a subregion using normalized coordinates.
  1347. ! \begin{defkey}{crop}{{\em left right bottom top}}
  1348. !     Crop the rendering window.
  1349. ! \end{defkey}
  1350. ! The rendering window is cropped by rendering the screen
  1351. ! area that falls within $minx + left(maxx - minx)$ and
  1352. ! $minx + right(maxx - minx)$ in the $X$ direction, and similarly
  1353. ! for the $Y$ direction.
  1354. ! {\em Left} and {\em bottom} must be greater than or equal to zero.
  1355. ! {\em Right} and {\em top} must be less than or equal to one.
  1356. ! If {\em left} is greater than {\em right}, the two values are
  1357. ! swapped, and similarly for {\em bottom} and {\em top}.
  1358.   
  1359.   {\em Gamma correction} may also be applied to the three output color
  1360.   channels.  See Appendix A for more details.
  1361.  
  1362. Index: libray/libcommon/rotate.c
  1363. Prereq: 4.0
  1364. *** libray/libcommon/rotate.c.old    1991/07/17 14:31:18
  1365. --- libray/libcommon/rotate.c    1991/09/29 15:35:38
  1366. ***************
  1367. *** 13,21 ****
  1368.    * There is no warranty or other guarantee of fitness of this software
  1369.    * for any purpose.  It is provided solely "as is".
  1370.    *
  1371. !  * $Id: rotate.c,v 4.0 91/07/17 14:31:18 kolb Exp Locker: kolb $
  1372.    *
  1373.    * $Log:    rotate.c,v $
  1374.    * Revision 4.0  91/07/17  14:31:18  kolb
  1375.    * Initial version.
  1376.    * 
  1377. --- 13,24 ----
  1378.    * There is no warranty or other guarantee of fitness of this software
  1379.    * for any purpose.  It is provided solely "as is".
  1380.    *
  1381. !  * $Id: rotate.c,v 4.0.1.1 91/09/29 15:35:38 cek Exp Locker: cek $
  1382.    *
  1383.    * $Log:    rotate.c,v $
  1384. +  * Revision 4.0.1.1  91/09/29  15:35:38  cek
  1385. +  * patch1: Added comments.
  1386. +  * 
  1387.    * Revision 4.0  91/07/17  14:31:18  kolb
  1388.    * Initial version.
  1389.    * 
  1390. ***************
  1391. *** 26,31 ****
  1392. --- 29,37 ----
  1393.   TransMethods *iRotateMethods;
  1394.   void RotationMatrix();
  1395.   
  1396. + /*
  1397. +  * Create and return reference to Rotate structure.
  1398. +  */
  1399.   Rotate *
  1400.   RotateCreate()
  1401.   {
  1402. ***************
  1403. *** 37,42 ****
  1404. --- 43,52 ----
  1405.       return res;
  1406.   }
  1407.   
  1408. + /*
  1409. +  * Return a pointer to collection of methods for the
  1410. +  * Rotate transformation.
  1411. +  */
  1412.   TransMethods *
  1413.   RotateMethods()
  1414.   {
  1415. ***************
  1416. *** 48,53 ****
  1417. --- 58,68 ----
  1418.       return iRotateMethods;    
  1419.   }
  1420.   
  1421. + /*
  1422. +  * Given a Rotate structure and forward and inverse transformations,
  1423. +  * propagate the information in the Rotate structure to the
  1424. +  * transformations.
  1425. +  */
  1426.   void
  1427.   RotatePropagate(rotate, trans, itrans)
  1428.   Rotate *rotate;
  1429. ***************
  1430. *** 62,67 ****
  1431. --- 77,86 ----
  1432.       MatrixInvert(trans, itrans);
  1433.   }
  1434.   
  1435. + /*
  1436. +  * Initialize a rotation matrix given an axis of rotation and an
  1437. +  * angle.  Right-handed rotation is applied.
  1438. +  */
  1439.   void
  1440.   RotationMatrix(x, y, z, theta, trans)
  1441.   Float x, y, z, theta;
  1442.  
  1443. *** End of Patch 1 ***
  1444.  
  1445. exit 0 # Just in case...
  1446. -- 
  1447. Kent Landfield                   INTERNET: kent@sparky.IMD.Sterling.COM
  1448. Sterling Software, IMD           UUCP:     uunet!sparky!kent
  1449. Phone:    (402) 291-8300         FAX:      (402) 291-4362
  1450. Please send comp.sources.misc-related mail to kent@uunet.uu.net.
  1451.