Newsgroups: comp.sources.misc From: Craig Kolb Subject: v23i075: rayshade - A raytracing package for UNIX, Patch01 Message-ID: <1991Oct19.024232.13698@sparky.imd.sterling.com> X-Md4-Signature: 6348dbe45469af21d17e7a255c013923 Date: Sat, 19 Oct 1991 02:42:32 GMT Approved: kent@sparky.imd.sterling.com Submitted-by: Craig Kolb Posting-number: Volume 23, Issue 75 Archive-name: rayshade/patch01 Environment: UNIX Patch-To: rayshade: Volume 21, Issue 3-22 System: rayshade version 4.0 Patch #: 1 Priority: HIGH Description: Added "transform" support. New "window" and "crop" support. Window uses pixel coordinates to define a subwindow, crop uses normalized coordinates and crops the subwindow. Rayview supports spotlights and transparency (given appropriate hardware.) Faster bbox transform, a la Jim Arvo. Fixed view initialization weirdness that lead to bugs when rendering animated stereo pairs. Don't declare free or exit void if stdlib.h is used. Fixed problems with coincident bbox faces. Removed a number of floating point comparisons Corrected help message. Potential roundoff problem in triangle dPdU code. CoordSysTransform did not detect up-Z == -1. Defined MAKE macro in Makefiles for braindamaged machines. Note that "make -n" on such machines will almost certainly do the wrong thing. Fixed various typos. Fix: From rn, say "| patch -p -N -d DIR", where DIR is your rayshade source directory. Outside of rn, say "cd DIR; patch -p -N #define PATCHLEVEL 1 Index: rayview/glmethods.c Prereq: 4.0 *** rayview/glmethods.c.old 1991/07/17 17:38:43 --- rayview/glmethods.c 1991/10/10 22:45:27 *************** *** 14,22 **** * There is no warranty or other guarantee of fitness of this software * for any purpose. It is provided solely "as is". * ! * $Id: glmethods.c,v 4.0 91/07/17 17:38:43 kolb Exp Locker: kolb $ * * $Log: glmethods.c,v $ * Revision 4.0 91/07/17 17:38:43 kolb * Initial version * --- 14,28 ---- * There is no warranty or other guarantee of fitness of this software * for any purpose. It is provided solely "as is". * ! * $Id: glmethods.c,v 4.0.1.2 91/10/10 22:45:27 cek Exp $ * * $Log: glmethods.c,v $ + * Revision 4.0.1.2 91/10/10 22:45:27 cek + * patch1: Added spotlight support. + * + * Revision 4.0.1.1 1991/09/29 15:28:36 cek + * patch1: Added support for transparency. + * * Revision 4.0 91/07/17 17:38:43 kolb * Initial version * *************** *** 117,123 **** PlaneMethodRegister(GLPlaneDraw); PolygonMethodRegister(GLPolygonDraw); SphereMethodRegister(GLSphereDraw); - /* Have to write sphere routine for RS6000... */ /*TorusMethodRegister(GLTorusDraw);*/ TriangleMethodRegister(GLTriangleDraw); --- 123,128 ---- *************** *** 133,138 **** --- 138,152 ---- short val; float tmp; + /* + * We're only sampling the scene once, so we need + * not do lots of work to determine exactly what + * animated transformations are doing... + */ + Options.samples = 1; + SamplingSetOptions(Options.samples, Options.gaussian, + Options.filterwidth); + DrawInit(); qdevice(ESCKEY); qdevice(SPACEKEY); *************** *** 197,203 **** --- 211,219 ---- doublebuffer(); } + gconfig(); + blendfunction(BF_SA, BF_MSA); /* * Initialize viewing matrix. */ *************** *** 329,339 **** DIFFUSE, 0, 0, 0, SPECULAR, 0, 0, 0, SHININESS, 0, LMNULL}; static float *amb = &surfprops[1], *diff = &surfprops[5], *spec = &surfprops[9], ! *shine = &surfprops[13]; static void GLPushSurface(surf) --- 345,357 ---- DIFFUSE, 0, 0, 0, SPECULAR, 0, 0, 0, SHININESS, 0, + ALPHA, 1, LMNULL}; static float *amb = &surfprops[1], *diff = &surfprops[5], *spec = &surfprops[9], ! *shine = &surfprops[13], ! *alpha = &surfprops[15]; static void GLPushSurface(surf) *************** *** 357,363 **** spec[0] = surf->spec.r; spec[1] = surf->spec.g; spec[2] = surf->spec.b; shine[0] = surf->srexp; ! lmdef(DEFMATERIAL, cursurf, 15, surfprops); lastsurf = surf; } lmbind(MATERIAL, cursurf); --- 375,383 ---- spec[0] = surf->spec.r; spec[1] = surf->spec.g; spec[2] = surf->spec.b; shine[0] = surf->srexp; ! *alpha = 1. - surf->transp; ! lmdef(DEFMATERIAL, cursurf, sizeof(surfprops)/sizeof(float), ! surfprops); lastsurf = surf; } lmbind(MATERIAL, cursurf); *************** *** 630,639 **** float lightprops[] = {POSITION, 0., 0., 0., 0., LCOLOR, 0, 0, 0, LMNULL}; float *lpos = &lightprops[1], ! *lcolor = &lightprops[6]; float lmodel[] = {AMBIENT, 1., 1., 1., ATTENUATION, 1., 0., --- 650,664 ---- float lightprops[] = {POSITION, 0., 0., 0., 0., LCOLOR, 0, 0, 0, + SPOTDIRECTION, 0., 0., 0., + SPOTLIGHT, 0., 180., LMNULL}; float *lpos = &lightprops[1], ! *lcolor = &lightprops[6], ! *spotdir = &lightprops[10], ! *spotexp = &lightprops[14], ! *spotspread = &lightprops[15]; float lmodel[] = {AMBIENT, 1., 1., 1., ATTENUATION, 1., 0., *************** *** 676,686 **** lmodel[2] = Options.ambient.g; lmodel[3] = Options.ambient.b; ! #ifdef sgi ! lmdef(DEFLMODEL, 1, 14, lmodel); ! #else ! lmdef(DEFLMODEL, 1, 10, lmodel); ! #endif lmbind(LMODEL, 1); } --- 701,707 ---- lmodel[2] = Options.ambient.g; lmodel[3] = Options.ambient.b; ! lmdef(DEFLMODEL, 1, sizeof(lmodel) / sizeof(float), lmodel); lmbind(LMODEL, 1); } *************** *** 704,710 **** lpos[1] = ext->pos.y; lpos[2] = ext->pos.z; lpos[3] = 1.; ! lmdef(DEFLIGHT, curlight++, 10, lightprops); } --- 725,732 ---- lpos[1] = ext->pos.y; lpos[2] = ext->pos.z; lpos[3] = 1.; ! lmdef(DEFLIGHT, curlight++, sizeof(lightprops)/sizeof(float), ! lightprops); } *************** *** 716,722 **** lpos[1] = inf->dir.y; lpos[2] = inf->dir.z; lpos[3] = 0.; ! lmdef(DEFLIGHT, curlight++, 10, lightprops); } static void --- 738,745 ---- lpos[1] = inf->dir.y; lpos[2] = inf->dir.z; lpos[3] = 0.; ! lmdef(DEFLIGHT, curlight++, sizeof(lightprops)/sizeof(float), ! lightprops); } static void *************** *** 727,733 **** lpos[1] = pt->pos.y; lpos[2] = pt->pos.z; lpos[3] = 1.; ! lmdef(DEFLIGHT, curlight++, 10, lightprops); } static void --- 750,757 ---- lpos[1] = pt->pos.y; lpos[2] = pt->pos.z; lpos[3] = 1.; ! lmdef(DEFLIGHT, curlight++, sizeof(lightprops) / sizeof(float), ! lightprops); } static void *************** *** 734,739 **** --- 758,776 ---- GLSpotLight(spot) Spotlight *spot; { + lpos[0] = spot->pos.x; + lpos[1] = spot->pos.y; + lpos[2] = spot->pos.z; + lpos[3] = 1.; + spotdir[0] = spot->pos.x - spot->dir.x; + spotdir[1] = spot->pos.y - spot->dir.y; + spotdir[2] = spot->pos.z - spot->dir.z; + *spotexp = spot->coef; + *spotspread = spot->falloff; + lmdef(DEFLIGHT, curlight++, sizeof(lightprops) / sizeof(float), + lightprops); + *spotspread = 180.; + *spotexp = 1.; } static float boxfaces[6][4][3] = { Index: etc/rsconvert/yacc.y Prereq: 4.0 *** etc/rsconvert/yacc.y.old 1991/07/17 17:11:26 --- etc/rsconvert/yacc.y 1991/09/28 20:44:09 *************** *** 11,17 **** /* */ /* There is no warranty or other guarantee of fitness of this software */ /* for any purpose. It is provided solely "as is". */ ! /* $Id: yacc.y,v 4.0 91/07/17 17:11:26 kolb Exp Locker: kolb $ */ %{ #include #include "libcommon/common.h" --- 11,17 ---- /* */ /* There is no warranty or other guarantee of fitness of this software */ /* for any purpose. It is provided solely "as is". */ ! /* $Id: yacc.y,v 4.0.1.1 91/09/28 20:44:09 cek Exp Locker: cek $ */ %{ #include #include "libcommon/common.h" *************** *** 399,404 **** --- 399,405 ---- if ($10) { WriteString("\ttranslu"); WriteFloat($10); + WriteString("1 1 1"); WriteFloat($11); } } Index: libshade/yacc.y Prereq: 4.0 *** libshade/yacc.y.old 1991/07/17 17:39:39 --- libshade/yacc.y 1991/10/08 20:40:35 *************** *** 11,17 **** /* */ /* There is no warranty or other guarantee of fitness of this software */ /* for any purpose. It is provided solely "as is". */ ! /* $Id: yacc.y,v 4.0 91/07/17 17:39:39 kolb Exp Locker: kolb $ */ %{ #include "rayshade.h" --- 11,17 ---- /* */ /* There is no warranty or other guarantee of fitness of this software */ /* for any purpose. It is provided solely "as is". */ ! /* $Id: yacc.y,v 4.0.1.2 91/10/08 20:40:35 cek Exp Locker: cek $ */ %{ #include "rayshade.h" *************** *** 72,77 **** --- 72,78 ---- #include "libcommon/rotate.h" #include "libcommon/scale.h" #include "libcommon/translate.h" + #include "libcommon/xform.h" Geom *NewAggregate(); char yyfilename[BUFSIZ]; /* Input filename */ *************** *** 126,132 **** %token tTEXTURE tCHECKER tWOOD tCONTRAST tCUTOFF tCLOUD %token tAMBIENT tDIFFUSE tREFLECT tTRANSP tSPECULAR tSPECPOW %token tINDEX tATMOSPHERE tNOSHADOW tAREA tTRANSLU tTORUS ! %token tEYESEP tSHADOWTRANSP tREPORT tVERBOSE tQUIET tWINDOW tSTRIPE %token tMAP tUV tSPHERICAL tCYLINDRICAL tPLANAR %token tIMAGE tSMOOTH tCOMPONENT tTEXTSURF tRANGE tTILE tSTARTTIME tFRAMELENGTH %token tNAME tFILTER tGAUSS tBODY tSAMPLE tEXTINCT tWINDY tMOUNT --- 127,133 ---- %token tTEXTURE tCHECKER tWOOD tCONTRAST tCUTOFF tCLOUD %token tAMBIENT tDIFFUSE tREFLECT tTRANSP tSPECULAR tSPECPOW %token tINDEX tATMOSPHERE tNOSHADOW tAREA tTRANSLU tTORUS ! %token tEYESEP tSHADOWTRANSP tREPORT tVERBOSE tQUIET tWINDOW tCROP tSTRIPE %token tMAP tUV tSPHERICAL tCYLINDRICAL tPLANAR %token tIMAGE tSMOOTH tCOMPONENT tTEXTSURF tRANGE tTILE tSTARTTIME tFRAMELENGTH %token tNAME tFILTER tGAUSS tBODY tSAMPLE tEXTINCT tWINDY tMOUNT *************** *** 166,171 **** --- 167,173 ---- | Fov | Screen | Window + | Crop | Report | Aperture | Focaldist *************** *** 489,494 **** --- 491,533 ---- TransRotateSetTheta($$, $5); if (!$$->animated) TransPropagate($$); + } + | tTRANSFORM AnimExpr AnimExpr AnimExpr + AnimExpr AnimExpr AnimExpr + AnimExpr AnimExpr AnimExpr + { + $$ = TransXformCreate(); + TransXformSetX0($$, $2); + TransXformSetY0($$, $3); + TransXformSetZ0($$, $4); + TransXformSetX1($$, $5); + TransXformSetY1($$, $6); + TransXformSetZ1($$, $7); + TransXformSetX2($$, $8); + TransXformSetY2($$, $9); + TransXformSetZ2($$, $10); + if (!$$->animated) + TransPropagate($$); + } + | tTRANSFORM AnimExpr AnimExpr AnimExpr + AnimExpr AnimExpr AnimExpr + AnimExpr AnimExpr AnimExpr + AnimExpr AnimExpr AnimExpr + { + TransXformSetX0($$, $2); + TransXformSetY0($$, $3); + TransXformSetZ0($$, $4); + TransXformSetX1($$, $5); + TransXformSetY1($$, $6); + TransXformSetZ1($$, $7); + TransXformSetX2($$, $8); + TransXformSetY2($$, $9); + TransXformSetZ2($$, $10); + TransXformSetXt($$, $11); + TransXformSetYt($$, $12); + TransXformSetZt($$, $13); + if (!$$->animated) + TransPropagate($$); }; Eyep : tEYEP Vector Transforms { *************** *** 602,616 **** } } ; ! Window : tWINDOW Expr Expr Expr Expr { if (!Options.window_set) { ! Options.xmin = $2; ! Options.xmax = $3; ! Options.ymin = $4; ! Options.ymax = $5; } } Report : tREPORT Verbose Quiet IExpr Filename { if (!Options.freq_set) --- 641,666 ---- } } ; ! Window : tWINDOW IExpr IExpr IExpr IExpr { if (!Options.window_set) { ! Options.window[LOW][X] = $2; ! Options.window[HIGH][X] = $3; ! Options.window[LOW][Y] = $4; ! Options.window[HIGH][Y] = $5; } } + ; + Crop : tCROP Expr Expr Expr Expr + { + if (!Options.crop_set) { + Options.crop[LOW][X] = $2; + Options.crop[HIGH][X] = $3; + Options.crop[LOW][Y] = $4; + Options.crop[HIGH][Y] = $5; + } + } + ; Report : tREPORT Verbose Quiet IExpr Filename { if (!Options.freq_set) *************** *** 667,673 **** ; Shadowtransp : tSHADOWTRANSP { ! Options.shadowtransp = TRUE; } ; Light : LightType --- 717,723 ---- ; Shadowtransp : tSHADOWTRANSP { ! Options.shadowtransp = !Options.shadowtransp; } ; Light : LightType Index: libray/libobj/grid.c Prereq: 4.0 *** libray/libobj/grid.c.old 1991/07/17 14:38:02 --- libray/libobj/grid.c 1991/10/04 15:55:37 *************** *** 13,21 **** * There is no warranty or other guarantee of fitness of this software * for any purpose. It is provided solely "as is". * ! * $Id: grid.c,v 4.0 91/07/17 14:38:02 kolb Exp Locker: kolb $ * * $Log: grid.c,v $ * Revision 4.0 91/07/17 14:38:02 kolb * Initial version. * --- 13,24 ---- * There is no warranty or other guarantee of fitness of this software * for any purpose. It is provided solely "as is". * ! * $Id: grid.c,v 4.0.1.1 91/10/04 15:55:37 cek Exp Locker: cek $ * * $Log: grid.c,v $ + * Revision 4.0.1.1 91/10/04 15:55:37 cek + * patch1: Removed straight floating point comparisons. + * * Revision 4.0 91/07/17 14:38:02 kolb * Initial version. * *************** *** 120,132 **** x = x2voxel(grid, curpos.x); if (x == grid->xsize) x--; ! if (ray->dir.x < 0.) { tMaxX = offset + (voxel2x(grid, x) - curpos.x) / ray->dir.x; tDeltaX = grid->voxsize[X] / - ray->dir.x; stepX = outX = -1; raybounds[LOW][X] = &np.x; raybounds[HIGH][X] = &curpos.x; ! } else if (ray->dir.x > 0.) { tMaxX = offset + (voxel2x(grid, x+1) - curpos.x) / ray->dir.x; tDeltaX = grid->voxsize[X] / ray->dir.x; stepX = 1; --- 123,140 ---- x = x2voxel(grid, curpos.x); if (x == grid->xsize) x--; ! if (fabs(ray->dir.x) < EPSILON) { ! tMaxX = FAR_AWAY; ! raybounds[LOW][X] = &curpos.x; ! raybounds[HIGH][X] = &np.x; ! tDeltaX = 0.; ! } else if (ray->dir.x < 0.) { tMaxX = offset + (voxel2x(grid, x) - curpos.x) / ray->dir.x; tDeltaX = grid->voxsize[X] / - ray->dir.x; stepX = outX = -1; raybounds[LOW][X] = &np.x; raybounds[HIGH][X] = &curpos.x; ! } else { tMaxX = offset + (voxel2x(grid, x+1) - curpos.x) / ray->dir.x; tDeltaX = grid->voxsize[X] / ray->dir.x; stepX = 1; *************** *** 133,155 **** outX = grid->xsize; raybounds[LOW][X] = &curpos.x; raybounds[HIGH][X] = &np.x; - } else { - tMaxX = FAR_AWAY; - raybounds[LOW][X] = &curpos.x; - raybounds[HIGH][X] = &np.x; - tDeltaX = 0.; } y = y2voxel(grid, curpos.y); if (y == grid->ysize) y--; ! if (ray->dir.y < 0.) { tMaxY = offset + (voxel2y(grid, y) - curpos.y) / ray->dir.y; tDeltaY = grid->voxsize[Y] / - ray->dir.y; stepY = outY = -1; raybounds[LOW][Y] = &np.y; raybounds[HIGH][Y] = &curpos.y; ! } else if (ray->dir.y > 0.) { tMaxY = offset + (voxel2y(grid, y+1) - curpos.y) / ray->dir.y; tDeltaY = grid->voxsize[Y] / ray->dir.y; stepY = 1; --- 141,164 ---- outX = grid->xsize; raybounds[LOW][X] = &curpos.x; raybounds[HIGH][X] = &np.x; } y = y2voxel(grid, curpos.y); if (y == grid->ysize) y--; ! ! if (fabs(ray->dir.y) < EPSILON) { ! tMaxY = FAR_AWAY; ! raybounds[LOW][Y] = &curpos.y; ! raybounds[HIGH][Y] = &np.y; ! tDeltaY = 0.; ! } else if (ray->dir.y < 0.) { tMaxY = offset + (voxel2y(grid, y) - curpos.y) / ray->dir.y; tDeltaY = grid->voxsize[Y] / - ray->dir.y; stepY = outY = -1; raybounds[LOW][Y] = &np.y; raybounds[HIGH][Y] = &curpos.y; ! } else { tMaxY = offset + (voxel2y(grid, y+1) - curpos.y) / ray->dir.y; tDeltaY = grid->voxsize[Y] / ray->dir.y; stepY = 1; *************** *** 156,178 **** outY = grid->ysize; raybounds[LOW][Y] = &curpos.y; raybounds[HIGH][Y] = &np.y; - } else { - tMaxY = FAR_AWAY; - raybounds[LOW][Y] = &curpos.y; - raybounds[HIGH][Y] = &np.y; - tDeltaY = 0.; } z = z2voxel(grid, curpos.z); if (z == grid->zsize) z--; ! if (ray->dir.z < 0.) { tMaxZ = offset + (voxel2z(grid, z) - curpos.z) / ray->dir.z; tDeltaZ = grid->voxsize[Z] / - ray->dir.z; stepZ = outZ = -1; raybounds[LOW][Z] = &np.z; raybounds[HIGH][Z] = &curpos.z; ! } else if (ray->dir.z > 0.) { tMaxZ = offset + (voxel2z(grid, z+1) - curpos.z) / ray->dir.z; tDeltaZ = grid->voxsize[Z] / ray->dir.z; stepZ = 1; --- 165,187 ---- outY = grid->ysize; raybounds[LOW][Y] = &curpos.y; raybounds[HIGH][Y] = &np.y; } z = z2voxel(grid, curpos.z); if (z == grid->zsize) z--; ! if (fabs(ray->dir.z) < EPSILON) { ! tMaxZ = FAR_AWAY; ! raybounds[LOW][Z] = &curpos.z; ! raybounds[HIGH][Z] = &np.z; ! tDeltaZ = 0.; ! } else if (ray->dir.z < 0.) { tMaxZ = offset + (voxel2z(grid, z) - curpos.z) / ray->dir.z; tDeltaZ = grid->voxsize[Z] / - ray->dir.z; stepZ = outZ = -1; raybounds[LOW][Z] = &np.z; raybounds[HIGH][Z] = &curpos.z; ! } else { tMaxZ = offset + (voxel2z(grid, z+1) - curpos.z) / ray->dir.z; tDeltaZ = grid->voxsize[Z] / ray->dir.z; stepZ = 1; *************** *** 179,189 **** outZ = grid->zsize; raybounds[LOW][Z] = &curpos.z; raybounds[HIGH][Z] = &np.z; - } else { - tMaxZ = FAR_AWAY; - raybounds[LOW][Z] = &curpos.z; - raybounds[HIGH][Z] = &np.z; - tDeltaZ = 0.; } VecScale(tDeltaX, ray->dir, &pDeltaX); --- 188,193 ---- Index: libshade/viewing.c Prereq: 4.0 *** libshade/viewing.c.old 1991/07/17 14:48:18 --- libshade/viewing.c 1991/09/29 15:53:09 *************** *** 13,21 **** * There is no warranty or other guarantee of fitness of this software * for any purpose. It is provided solely "as is". * ! * $Id: viewing.c,v 4.0 91/07/17 14:48:18 kolb Exp Locker: kolb $ * * $Log: viewing.c,v $ * Revision 4.0 91/07/17 14:48:18 kolb * Initial version. * --- 13,24 ---- * There is no warranty or other guarantee of fitness of this software * for any purpose. It is provided solely "as is". * ! * $Id: viewing.c,v 4.0.1.1 91/09/29 15:53:09 cek Exp Locker: cek $ * * $Log: viewing.c,v $ + * Revision 4.0.1.1 91/09/29 15:53:09 cek + * patch1: Added support for window and crop commands. + * * Revision 4.0 91/07/17 14:48:18 kolb * Initial version. * *************** *** 71,76 **** --- 74,85 ---- VecScale(magnitude, Screen.scrni, &Screen.scrnx); magnitude = 2.*Camera.lookdist * tan(deg2rad(0.5*Camera.vfov)) / Screen.yres; + #ifndef URT + /* + * If using "generic" file format, render top-to-bottom (yick). + */ + magnitude *= -1; + #endif VecScale(magnitude, Screen.scrnj, &Screen.scrny); Screen.firstray.x -= 0.5*Screen.yres*Screen.scrny.x + *************** *** 119,124 **** --- 128,138 ---- void ViewingSetup() { + #define SWAP(a,b) (tmp = (a), (a) = (b), (b) = tmp) + + Float tmp; + int xwidth, ywidth; + if (Options.stereo && Options.eyesep == UNSET) RLerror(RL_PANIC, "No eye separation specified for stereo rendering.\n"); *************** *** 137,147 **** if (Screen.yres == UNSET) Screen.yres = YRESOLUTION; #ifdef URT /* ! * If using the URT, we can use the RLE file header to ! * determine window size. Screen size (Screen.xres, Screen.yres) ! * is determined as usual (from command line or input file). */ if (Options.appending) { /* --- 151,205 ---- if (Screen.yres == UNSET) Screen.yres = YRESOLUTION; + /* + * The window to be rendered is defined by applying + * the crop window to the sub window. The subwindow + * is defined using pixel numbers, and must be within + * [0, xres -1],[0, yres -1]. The default is the entire + * screen. The crop window is specified using normalized + * coordinates. + */ + + if (!Options.window_set) { + /* If no window set, set equal to entire screen. */ + Options.window[LOW][X] = Options.window[LOW][Y] = 0; + Options.window[HIGH][X] = Screen.xres -1; + Options.window[HIGH][Y] = Screen.yres -1; + } + + /* Truncate crop window to legal limits. */ + if (Options.crop[LOW][X] > Options.crop[HIGH][X]) + SWAP(Options.crop[LOW][X], Options.crop[HIGH][X]); + if (Options.crop[LOW][Y] > Options.crop[HIGH][Y]) + SWAP(Options.crop[LOW][Y], Options.crop[HIGH][Y]); + if (Options.crop[LOW][X] < 0.) Options.crop[LOW][X] = 0.; + if (Options.crop[LOW][Y] < 0.) Options.crop[LOW][Y] = 0.; + if (Options.crop[HIGH][X] > 1.) Options.crop[HIGH][X] = 1.; + if (Options.crop[HIGH][Y] > 1.) Options.crop[HIGH][Y] = 1.; + + xwidth = Options.window[HIGH][X] - Options.window[LOW][X]; + ywidth = Options.window[HIGH][Y] - Options.window[LOW][Y]; + + /* Compute x and y extents of window to be renered. */ + Screen.minx = (int)(Options.window[LOW][X] + + Options.crop[LOW][X] * xwidth); + Screen.maxx = (int)(Options.window[LOW][X] + + Options.crop[HIGH][X] * xwidth); + Screen.miny = (int)(Options.window[LOW][Y] + + Options.crop[LOW][Y] * ywidth); + Screen.maxy = (int)(Options.window[LOW][Y] + + Options.crop[HIGH][Y] * ywidth); + #ifdef URT /* ! * If using the URT, we should use the RLE file header to ! * determine cropped window size. Screen size ! * (Screen.xres, Screen.yres) is determined from command ! * line or input file, as usual. ! * ! * If the cropped window computed in PictureSetWindow() ! * is not equal the cropped window computed above, ! * a warning message is issued. */ if (Options.appending) { /* *************** *** 148,165 **** * Read image header to determine window size. */ PictureSetWindow(); - } else { - #endif - if (Options.xmin < 0.) Options.xmin = 0.; - if (Options.ymin < 0.) Options.ymin = 0.; - if (Options.xmax > 1.) Options.xmax = 1.; - if (Options.xmax > 1.) Options.xmax = 1.; - - Screen.minx = (int)(Options.xmin * Screen.xres); - Screen.maxx = (int)(Options.xmax * Screen.xres -1); - Screen.miny = (int)(Options.ymin * Screen.yres); - Screen.maxy = (int)(Options.ymax * Screen.yres -1); - #ifdef URT } #endif --- 206,211 ---- Index: README *** README.old 1991/07/17 14:27:21 --- README 1991/10/10 18:16:26 *************** *** 35,41 **** conversion utility, rsconvert. See Doc/Changes for a list of some of the more important changes. ! Rayshade v4.0 has been tested on several different UNIX-based computers, including: SGI 4D, IBM RS6000, Sun Sparcstation 1, Sun 3, DECstation, Apollo DN10000, NeXT. If your machine has a C compiler, enough memory (at least 2Mb), and runs something resembling UNIX, rayshade should be fairly --- 35,41 ---- conversion utility, rsconvert. See Doc/Changes for a list of some of the more important changes. ! Rayshade v4.0 Beta has been tested on several different UNIX-based computers, including: SGI 4D, IBM RS6000, Sun Sparcstation 1, Sun 3, DECstation, Apollo DN10000, NeXT. If your machine has a C compiler, enough memory (at least 2Mb), and runs something resembling UNIX, rayshade should be fairly *************** *** 90,96 **** Standard Procedural Databases through awk using the etc/nff2shade.awk script, and then feed the results to rayshade. Note that for several of the databases, you will need to tweak the data a bit to achieve ! optimal runtimes. See spd2shade.awk for details. Rayshade was not designed to be, nor is it, the be-all and end-all of ray tracers. It was meant to be reasonably fast, portable, and easy to --- 90,96 ---- Standard Procedural Databases through awk using the etc/nff2shade.awk script, and then feed the results to rayshade. Note that for several of the databases, you will need to tweak the data a bit to achieve ! optimal runtimes. See nff2shade.awk for details. Rayshade was not designed to be, nor is it, the be-all and end-all of ray tracers. It was meant to be reasonably fast, portable, and easy to *************** *** 136,146 **** for the 'net tracer' conversations and for the inspiration to do something to clean up rayshade. ! Thanks to Marc Andreessen, Ray Bellis, Dominique Boisvert, William Bouma, ! Allen Braunsdorf, Jeff Butterworth, Nick Carriero, Nancy Everson, Tom Friedel, ! Robert Funchess, David Gelernter, Mike Gigante, Ed Herderick, John Knuston, ! Raphael Manfredi, Lee Moore, Dietmar Saupe, Brian Wyvill, ! and everybody else for their bugfixes, suggestions, input files, encouragement, and other feedback. Thanks also to Mark Podlipec for providing the blob and torus objects. --- 136,146 ---- for the 'net tracer' conversations and for the inspiration to do something to clean up rayshade. ! Thanks to Marc Andreessen, Tony Apodaca, Ray Bellis, Dominique Boisvert, ! William Bouma, Allen Braunsdorf, Jeff Butterworth, Nick Carriero, ! Nancy Everson, Tom Friedel, Robert Funchess, David Gelernter, Mike Gigante, ! Ed Herderick, John Knuston, Raphael Manfredi, Lee Moore, Dietmar Saupe, ! Brian Wyvill, and everybody else for their bugfixes, suggestions, input files, encouragement, and other feedback. Thanks also to Mark Podlipec for providing the blob and torus objects. *************** *** 156,179 **** particularly braindamaged section of code, please let us know. We can be most easily reached by email. ! Once you start using rayshade, send a message to ! rayshade@weedeater.math.yale.edu and you'll be added to the rayshade ! mailing list. Craig Kolb Rod Bogart ! 17 July 1991 rayshade@weedeater.math.yale.edu Craig Kolb - Department of Mathematics - Yale University - 10 Hillhouse Ave. - Box 2155 Yale Station - New Haven, CT 06520-2155 - (Until September, 1991) - Computer Science Department Princeton University Princeton, NJ 08544 - (September, 1991 onwards) --- 156,172 ---- particularly braindamaged section of code, please let us know. We can be most easily reached by email. ! Once you start using rayshade, and you'd like to be kept abreast of ! changes and extensions, send a message to rayshade-request@cs.princeton.edu, ! and we'll add you to the rayshade mailing list. Craig Kolb Rod Bogart ! 9 October 1991 rayshade@weedeater.math.yale.edu Craig Kolb Computer Science Department Princeton University + 35 Olden St. Princeton, NJ 08544 Index: libshade/options.c Prereq: 4.0 *** libshade/options.c.old 1991/07/17 14:46:47 --- libshade/options.c 1991/10/05 18:23:15 *************** *** 13,21 **** * There is no warranty or other guarantee of fitness of this software * for any purpose. It is provided solely "as is". * ! * $Id: options.c,v 4.0 91/07/17 14:46:47 kolb Exp Locker: kolb $ * * $Log: options.c,v $ * Revision 4.0 91/07/17 14:46:47 kolb * Initial version. * --- 13,25 ---- * There is no warranty or other guarantee of fitness of this software * for any purpose. It is provided solely "as is". * ! * $Id: options.c,v 4.0.1.1 91/10/05 18:23:15 cek Exp Locker: cek $ * * $Log: options.c,v $ + * Revision 4.0.1.1 91/10/05 18:23:15 cek + * patch1: Changes for new window/crop options. + * patch1: Corrected help message. + * * Revision 4.0 91/07/17 14:46:47 kolb * Initial version. * *************** *** 210,239 **** OpenStatsFile(); argv++; argc--; break; - #ifdef URT case 'W': ! Options.xmin = atof(argv[1]); ! Options.xmax = atof(argv[2]); ! Options.ymin = atof(argv[3]); ! Options.ymax = atof(argv[4]); Options.window_set = TRUE; argv += 4; argc -= 4; break; - #endif - #ifdef LINDA case 'X': ! Options.workers = atoi(argv[1]); ! if (Options.workers<0 || Options.workers>17) { ! RLerror(RL_PANIC, "%d workers?\n", ! Options.workers); ! } ! argv++; argc--; ! break; ! case 'w': ! Options.verbose_worker = ! !Options.verbose_worker; break; - #endif default: RLerror(RL_PANIC,"Bad argument: %s\n",argv[0]); } --- 214,235 ---- OpenStatsFile(); argv++; argc--; break; case 'W': ! Options.window[LOW][X] = atoi(argv[1]); ! Options.window[HIGH][X] = atoi(argv[3]); ! Options.window[LOW][Y] = atoi(argv[3]); ! Options.window[HIGH][Y] = atoi(argv[4]); Options.window_set = TRUE; argv += 4; argc -= 4; break; case 'X': ! Options.crop[LOW][X] = atof(argv[1]); ! Options.crop[HIGH][X] = atof(argv[2]); ! Options.crop[LOW][Y] = atof(argv[3]); ! Options.crop[HIGH][Y] = atof(argv[4]); ! Options.crop_set = TRUE; ! argv += 4; argc -= 4; break; default: RLerror(RL_PANIC,"Bad argument: %s\n",argv[0]); } *************** *** 304,312 **** --- 300,314 ---- fprintf(stderr,"\t-e \t\t(Write exponential RLE file.)\n"); #endif fprintf(stderr,"\t-F freq\t\t(Set frequency of status report.)\n"); + fprintf(stderr,"\t-f \t\t(Flip all triangle normals.)\n"); fprintf(stderr,"\t-G gamma\t(Use given gamma correction exponent.)\n"); + fprintf(stderr,"\t-g \t\t(Use Gaussian pixel filter.)\n"); fprintf(stderr,"\t-h \t\t(Print this message.)\n"); + fprintf(stderr,"\t-j \t\t(Toggle jittered sampling.)\n"); fprintf(stderr,"\t-l \t\t(Render image for left eye view.)\n"); + #ifdef URT + fprintf(stderr,"\t-m \t\t(Output sample map in alpha channel.)\n"); + #endif fprintf(stderr,"\t-N number\t(Render given number of frames.)\n"); fprintf(stderr,"\t-n \t\t(Do not render shadows.)\n"); fprintf(stderr,"\t-O outfile \t(Set output file name.)\n"); *************** *** 321,331 **** fprintf(stderr,"\t-T r g b\t(Set contrast threshold (0. - 1.).)\n"); fprintf(stderr,"\t-V filename \t(Write verbose output to filename.)\n"); fprintf(stderr,"\t-v \t\t(Verbose output.)\n"); ! #ifdef URT ! fprintf(stderr,"\t-W x y x y \t(Render subwindow.)\n"); ! #endif ! #ifdef LINDA ! fprintf(stderr,"\t-X workers\t(Number of workers.)\n"); ! fprintf(stderr,"\t-w \t\t(Verbose worker output.)\n"); ! #endif } --- 323,328 ---- fprintf(stderr,"\t-T r g b\t(Set contrast threshold (0. - 1.).)\n"); fprintf(stderr,"\t-V filename \t(Write verbose output to filename.)\n"); fprintf(stderr,"\t-v \t\t(Verbose output.)\n"); ! fprintf(stderr,"\t-W x x y y \t(Render subwindow.)\n"); ! fprintf(stderr,"\t-X l r b t \t(Crop window.)\n"); } Index: libray/libobj/bounds.c Prereq: 4.0 *** libray/libobj/bounds.c.old 1991/07/17 14:36:21 --- libray/libobj/bounds.c 1991/10/05 18:17:29 *************** *** 13,21 **** * There is no warranty or other guarantee of fitness of this software * for any purpose. It is provided solely "as is". * ! * $Id: bounds.c,v 4.0 91/07/17 14:36:21 kolb Exp Locker: kolb $ * * $Log: bounds.c,v $ * Revision 4.0 91/07/17 14:36:21 kolb * Initial version. * --- 13,27 ---- * There is no warranty or other guarantee of fitness of this software * for any purpose. It is provided solely "as is". * ! * $Id: bounds.c,v 4.0.1.2 91/10/05 18:17:29 cek Exp Locker: cek $ * * $Log: bounds.c,v $ + * Revision 4.0.1.2 91/10/05 18:17:29 cek + * patch1: Faster box transform, a la Jim Arvo. + * + * Revision 4.0.1.1 1991/09/29 15:42:05 cek + * patch1: Justified floating point compare... + * * Revision 4.0 91/07/17 14:36:21 kolb * Initial version. * *************** *** 134,139 **** --- 140,149 ---- } else if (pos < bounds[LOW][Z] || pos > bounds[HIGH][Z]) return FALSE; + /* + * If tmin == mindist, then there was no "near" + * intersection farther than EPSILON away. + */ if (tmin == mindist) { if (tmax < *maxdist) { *maxdist = tmax; *************** *** 157,165 **** RSMatrix *trans; Float objbounds[2][3]; { ! Vector tmp; ! Float bounds[2][3]; ! int x, y, z; /* * Can't (and shouldn't) do anything with unbounded objects. --- 167,174 ---- RSMatrix *trans; Float objbounds[2][3]; { ! Float bounds[2][3], a, b; ! int i, j; /* * Can't (and shouldn't) do anything with unbounded objects. *************** *** 166,200 **** */ if (objbounds[LOW][X] > objbounds[HIGH][X]) return; - - BoundsInit(bounds); ! /* ! * Find bounding box of transformed corners of bounding box. ! */ ! for (x = 0 ; x < 2; x++) { ! for (y = 0; y < 2; y++) { ! for (z = 0; z < 2; z++) { ! tmp.x = objbounds[x][X]; ! tmp.y = objbounds[y][Y]; ! tmp.z = objbounds[z][Z]; ! PointTransform(&tmp, trans); ! if (tmp.x < bounds[LOW][X]) ! bounds[LOW][X] = tmp.x; ! if (tmp.x > bounds[HIGH][X]) ! bounds[HIGH][X] = tmp.x; ! if (tmp.y < bounds[LOW][Y]) ! bounds[LOW][Y] = tmp.y; ! if (tmp.y > bounds[HIGH][Y]) ! bounds[HIGH][Y] = tmp.y; ! if (tmp.z < bounds[LOW][Z]) ! bounds[LOW][Z] = tmp.z; ! if (tmp.z > bounds[HIGH][Z]) ! bounds[HIGH][Z] = tmp.z; } } } - BoundsCopy(bounds, objbounds); } --- 175,198 ---- */ if (objbounds[LOW][X] > objbounds[HIGH][X]) return; ! bounds[LOW][X] = bounds[HIGH][X] = trans->translate.x; ! bounds[LOW][Y] = bounds[HIGH][Y] = trans->translate.y; ! bounds[LOW][Z] = bounds[HIGH][Z] = trans->translate.z; ! ! for (i = 0; i < 3; i++) { ! for (j = 0; j < 3; j++) { ! a = trans->matrix[j][i] * objbounds[LOW][j]; ! b = trans->matrix[j][i] * objbounds[HIGH][j]; ! if (a < b) { ! bounds[LOW][i] += a; ! bounds[HIGH][i] += b; ! } else { ! bounds[LOW][i] += b; ! bounds[HIGH][i] += a; } } } BoundsCopy(bounds, objbounds); } Index: Doc/quickref.txt *** Doc/quickref.txt.old 1991/07/17 14:25:15 --- Doc/quickref.txt 1991/10/05 18:00:35 *************** *** 40,46 **** -r Right eye view -S samples Use Samples^2 samples -s Toggle shadow caching -T r g b Contrast threshold -V filename Verbose file output -v Verbose output ! -W lx ly hx hy Render subwindow ------------------------------------------------------------------------------- File: /* Input file consists of...*/ --- 40,46 ---- -r Right eye view -S samples Use Samples^2 samples -s Toggle shadow caching -T r g b Contrast threshold -V filename Verbose file output -v Verbose output ! -W lx hx ly hy Render subwindow -X l r b t Crop window ------------------------------------------------------------------------------- File: /* Input file consists of...*/ *************** *** 70,76 **** shutter Speed /* Shutter speed (0 --> no blur) */ framelength Length /* Length of a singelf frame (1) */ screen Xsize Ysize /* Screen size */ ! window Xmin Ymin Xmax Ymax /* Window (0 0 xsize-1 ysize-1) */ eyesep Separation /* eye separation (0) */ SurfDef: /* Give a name to a set of surface attributes. */ --- 70,77 ---- shutter Speed /* Shutter speed (0 --> no blur) */ framelength Length /* Length of a singelf frame (1) */ screen Xsize Ysize /* Screen size */ ! window Xmin Xmax Ymin Ymax /* Window (0 xsize-1 0 ysize-1) */ ! crop left right bot top /* Crop window (0 1 0 1) */ eyesep Separation /* eye separation (0) */ SurfDef: /* Give a name to a set of surface attributes. */ *************** *** 199,205 **** Mapping: map uv map cylindrical [Xorigin Yorigin Zorigin Xup Yup Zup Xu Yu Zu] ! map linear [Xorigin Yorigin Zorigin Xv Yv Zv Xu Yu Zu] map spherical [Xorigin Yorigin Zorigin Xup Yup Zup Xu Yu Zu] Light: --- 200,206 ---- Mapping: map uv map cylindrical [Xorigin Yorigin Zorigin Xup Yup Zup Xu Yu Zu] ! map planar [Xorigin Yorigin Zorigin Xv Yv Zv Xu Yu Zu] map spherical [Xorigin Yorigin Zorigin Xup Yup Zup Xu Yu Zu] Light: Index: libshade/symtab.c Prereq: 4.0 *** libshade/symtab.c.old 1991/07/17 14:48:02 --- libshade/symtab.c 1991/10/05 18:24:29 *************** *** 13,21 **** * There is no warranty or other guarantee of fitness of this software * for any purpose. It is provided solely "as is". * ! * $Id: symtab.c,v 4.0 91/07/17 14:48:02 kolb Exp Locker: kolb $ * * $Log: symtab.c,v $ * Revision 4.0 91/07/17 14:48:02 kolb * Initial version. * --- 13,24 ---- * There is no warranty or other guarantee of fitness of this software * for any purpose. It is provided solely "as is". * ! * $Id: symtab.c,v 4.0.1.1 91/10/05 18:24:29 cek Exp Locker: cek $ * * $Log: symtab.c,v $ + * Revision 4.0.1.1 91/10/05 18:24:29 cek + * patch1: Added casts for builtin functions. + * * Revision 4.0 91/07/17 14:48:02 kolb * Initial version. * *************** *** 29,42 **** {"pi", 3.141592, NULL, FLOAT_EXPR, FALSE, 0}, {"dtor", 0.017453, NULL, FLOAT_EXPR, FALSE, 0}, {"rtod", 57.29578, NULL, FLOAT_EXPR, FALSE, 0}, ! {"cos", 0.0, cos, BUILTIN_EXPR, FALSE, 1}, ! {"sin", 0.0, sin, BUILTIN_EXPR, FALSE, 1}, ! {"tan", 0.0, tan, BUILTIN_EXPR, FALSE, 1}, ! {"sqrt", 0.0, sqrt, BUILTIN_EXPR, FALSE, 1}, ! {"acos", 0.0, acos, BUILTIN_EXPR, FALSE, 1}, ! {"asin", 0.0, asin, BUILTIN_EXPR, FALSE, 1}, ! {"atan", 0.0, atan, BUILTIN_EXPR, FALSE, 1}, ! {"hypot", 0.0, hypot, BUILTIN_EXPR, FALSE, 2}, {"time", 0.0, NULL, FLOAT_EXPR, TRUE, 0}, {"frame", 0.0, NULL, FLOAT_EXPR, TRUE, 0}, {"linear", 0.0, LinearTime, BUILTIN_EXPR, TRUE, 4}, --- 32,45 ---- {"pi", 3.141592, NULL, FLOAT_EXPR, FALSE, 0}, {"dtor", 0.017453, NULL, FLOAT_EXPR, FALSE, 0}, {"rtod", 57.29578, NULL, FLOAT_EXPR, FALSE, 0}, ! {"cos", 0.0, (Float (*)())cos, BUILTIN_EXPR, FALSE, 1}, ! {"sin", 0.0, (Float (*)())sin, BUILTIN_EXPR, FALSE, 1}, ! {"tan", 0.0, (Float (*)())tan, BUILTIN_EXPR, FALSE, 1}, ! {"sqrt", 0.0, (Float (*)())sqrt, BUILTIN_EXPR, FALSE, 1}, ! {"acos", 0.0, (Float (*)())acos, BUILTIN_EXPR, FALSE, 1}, ! {"asin", 0.0, (Float (*)())asin, BUILTIN_EXPR, FALSE, 1}, ! {"atan", 0.0, (Float (*)())atan, BUILTIN_EXPR, FALSE, 1}, ! {"hypot", 0.0, (Float (*)())hypot, BUILTIN_EXPR, FALSE, 2}, {"time", 0.0, NULL, FLOAT_EXPR, TRUE, 0}, {"frame", 0.0, NULL, FLOAT_EXPR, TRUE, 0}, {"linear", 0.0, LinearTime, BUILTIN_EXPR, TRUE, 4}, Index: Doc/Guide/running.tex *** Doc/Guide/running.tex.old 1991/07/17 15:46:02 --- Doc/Guide/running.tex 1991/10/05 18:02:29 *************** *** 153,171 **** the windows into a final image. \begin{defkey}{window}{{\em minx maxx miny maxy}} ! Render the image in the given screen subwindow, ! specified in normalized units. \end{defkey} The window must be properly contained within the screen, i.e., {\em minx} and {\em miny} must be greater than or equal to zero, while {\em maxx} and ! {\em maxy} must be less than or equal to one. ! The {\em mtv} image file format does not support windows. The ! Utah Raster tool {\em rlecomp\/} is useful for reconstructing the full image from sub-images. By default, the window ! is equal to ($0., 1., 0, 1$), or the entire screen. {\em Gamma correction} may also be applied to the three output color channels. See Appendix A for more details. --- 153,184 ---- the windows into a final image. \begin{defkey}{window}{{\em minx maxx miny maxy}} ! Render the image in the given window. \end{defkey} The window must be properly contained within the screen, i.e., {\em minx} and {\em miny} must be greater than or equal to zero, while {\em maxx} and ! {\em maxy} must be less than {\em xsize} and {\em ysize}, respectively. ! The Utah Raster tool {\em rlecomp\/} is useful for reconstructing the full image from sub-images. By default, the window ! is equivalent to the entire screen. ! ! It is also convenient to be able to render a small portion ! of the window by specifying a subregion using normalized coordinates. ! ! \begin{defkey}{crop}{{\em left right bottom top}} ! Crop the rendering window. ! \end{defkey} ! The rendering window is cropped by rendering the screen ! area that falls within $minx + left(maxx - minx)$ and ! $minx + right(maxx - minx)$ in the $X$ direction, and similarly ! for the $Y$ direction. ! {\em Left} and {\em bottom} must be greater than or equal to zero. ! {\em Right} and {\em top} must be less than or equal to one. ! If {\em left} is greater than {\em right}, the two values are ! swapped, and similarly for {\em bottom} and {\em top}. {\em Gamma correction} may also be applied to the three output color channels. See Appendix A for more details. Index: libray/libcommon/rotate.c Prereq: 4.0 *** libray/libcommon/rotate.c.old 1991/07/17 14:31:18 --- libray/libcommon/rotate.c 1991/09/29 15:35:38 *************** *** 13,21 **** * There is no warranty or other guarantee of fitness of this software * for any purpose. It is provided solely "as is". * ! * $Id: rotate.c,v 4.0 91/07/17 14:31:18 kolb Exp Locker: kolb $ * * $Log: rotate.c,v $ * Revision 4.0 91/07/17 14:31:18 kolb * Initial version. * --- 13,24 ---- * There is no warranty or other guarantee of fitness of this software * for any purpose. It is provided solely "as is". * ! * $Id: rotate.c,v 4.0.1.1 91/09/29 15:35:38 cek Exp Locker: cek $ * * $Log: rotate.c,v $ + * Revision 4.0.1.1 91/09/29 15:35:38 cek + * patch1: Added comments. + * * Revision 4.0 91/07/17 14:31:18 kolb * Initial version. * *************** *** 26,31 **** --- 29,37 ---- TransMethods *iRotateMethods; void RotationMatrix(); + /* + * Create and return reference to Rotate structure. + */ Rotate * RotateCreate() { *************** *** 37,42 **** --- 43,52 ---- return res; } + /* + * Return a pointer to collection of methods for the + * Rotate transformation. + */ TransMethods * RotateMethods() { *************** *** 48,53 **** --- 58,68 ---- return iRotateMethods; } + /* + * Given a Rotate structure and forward and inverse transformations, + * propagate the information in the Rotate structure to the + * transformations. + */ void RotatePropagate(rotate, trans, itrans) Rotate *rotate; *************** *** 62,67 **** --- 77,86 ---- MatrixInvert(trans, itrans); } + /* + * Initialize a rotation matrix given an axis of rotation and an + * angle. Right-handed rotation is applied. + */ void RotationMatrix(x, y, z, theta, trans) Float x, y, z, theta; *** End of Patch 1 *** exit 0 # Just in case... -- Kent Landfield INTERNET: kent@sparky.IMD.Sterling.COM Sterling Software, IMD UUCP: uunet!sparky!kent Phone: (402) 291-8300 FAX: (402) 291-4362 Please send comp.sources.misc-related mail to kent@uunet.uu.net.