#! /bin/sh # This is a shell archive. Remove anything before this line, then unpack # it by saving it into a file and typing "sh file". To overwrite existing # files, type "sh file -c". You can also feed this as standard input via # unshar, or by typing "sh 'Doc/Guide/intro.tex' <<'END_OF_FILE' X\chapter{Introduction} X\pagenumbering{arabic} X XThis document describes {\rayshade} in enough detail to enable Xthe technical-minded to Xsit down and render some images. In its current form, Xit is truly a draft, and even then Xmore of a reference manual than a proper user's guide. X XThis document does not provide any kind of thorough introduction Xto the basics of computer graphics or ray tracing. XThere are many other excellent sources for this kind of information. XThe technical and coding details of {\rayshade} and Xits libraries will be documented elsewhere. X X\section{Getting Started} X XThe best way to learn how to use {\rayshade} is to dive right in and Xstart making pictures. Study the example Xinput files that are packaged with {\rayshade}. Run them through X{\rayshade} to see what the images they produce look like. XChange the input files; move the camera, Xchange the field of view, modify surface properties, and see what differences Xyour changes make, all the while referring to the appropriate portions Xof this document. Browse through the individual chapters Xto see what {\rayshade} can and cannot do. The {\rayshade} quick reference Xguide may also help you sort out syntactical nasties. X XThroughout this text, the {\tt typewriter} type style is used to indicate Xkeywords and other items that should be passed Xdirectly to {\rayshade}. Where appropriate, Xitems in an {\em italic\/} style indicate Xplaces where you should provide an appropriate number or string. X XVectors, which consist of three numerical values, are indicated by Xan arrow over a name written in italic type style, e.g., \evec{vector}. XItems enclosed between {\tt [} and {\tt ]} characters indicate Xthat specifying those items is optional. XComplex constructions that are Xdescribed elsewhere in the text, such as surface or object specification, Xare denoted by enclosing descriptive text between X{\tt $<$} and {\tt $>$} characters. X X\section{A Simple Example} X XBecause {\rayshade} provides a default camera description, surface properties, Xand a default light Xsource, it is easy to construct short input files that allow you to Xexperiment with objects, textures, and transformations. XIf you haven't already run {\rayshade} on one of the example input files, Xyou might want to try producing an image using the following input: X X\begin{verbatim} X sphere 2 0 0 0 X\end{verbatim} X XIf you are running {\rayshade} on a UNIX\footnote{UNIX is a trademark Xof AT\&T Bell Laboratories}-like machine, the command: X\begin{verbatim} X echo "sphere 2 0 0 0" | rayshade > sphere.rle X\end{verbatim} Xshould produce an image of a sphere. END_OF_FILE if test 2601 -ne `wc -c <'Doc/Guide/intro.tex'`; then echo shar: \"'Doc/Guide/intro.tex'\" unpacked with wrong size! fi # end of 'Doc/Guide/intro.tex' fi if test -f 'Examples/planet.map' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'Examples/planet.map'\" else echo shar: Extracting \"'Examples/planet.map'\" \(2551 characters\) sed "s/^X//" >'Examples/planet.map' <<'END_OF_FILE' X40 128 200 X40 128 200 X41 129 201 X42 130 202 X43 131 202 X44 132 203 X45 133 204 X46 134 204 X47 135 205 X48 136 206 X48 136 206 X49 137 207 X50 138 208 X51 139 209 X52 140 209 X53 141 210 X54 142 211 X55 143 211 X56 144 212 X57 145 213 X57 145 213 X58 146 214 X59 147 215 X60 148 216 X61 149 216 X62 150 217 X63 151 218 X64 152 218 X65 153 219 X66 154 220 X66 154 220 X67 155 221 X68 156 222 X69 157 222 X70 158 223 X71 159 224 X72 160 225 X73 161 225 X74 162 226 X75 163 227 X75 163 227 X76 164 228 X77 165 229 X78 166 229 X79 167 230 X80 168 231 X81 169 232 X82 170 232 X83 171 233 X84 172 234 X84 172 234 X85 173 235 X86 174 236 X87 175 236 X88 176 237 X89 177 238 X90 178 238 X91 179 239 X92 180 240 X93 181 241 X93 181 241 X94 182 242 X95 183 243 X96 184 243 X97 185 244 X98 186 245 X99 187 245 X100 188 246 X101 189 247 X102 190 248 X102 190 248 X103 191 249 X104 192 250 X105 193 250 X106 194 251 X107 195 252 X108 196 252 X109 197 253 X110 198 254 X111 199 255 X244 211 1 X240 211 1 X237 211 1 X234 211 1 X231 211 1 X228 211 1 X224 211 1 X221 211 1 X218 211 1 X215 211 1 X212 211 1 X209 211 1 X205 211 1 X202 211 1 X199 211 1 X196 211 1 X193 211 1 X190 211 1 X186 211 1 X183 211 1 X180 211 1 X177 211 1 X174 211 1 X171 211 1 X132 208 1 X129 206 1 X125 204 1 X122 201 1 X119 199 1 X115 197 1 X112 194 1 X108 192 1 X105 190 1 X102 187 1 X98 185 1 X95 183 1 X91 180 1 X88 178 1 X84 176 1 X81 173 1 X78 171 1 X74 169 1 X71 166 1 X67 164 1 X64 162 1 X61 159 1 X57 157 1 X54 155 1 X50 152 1 X47 150 1 X44 148 1 X40 145 1 X37 143 1 X33 141 1 X30 138 1 X27 136 1 X23 134 1 X20 131 1 X16 129 1 X13 127 1 X10 124 1 X6 122 1 X3 120 1 X0 118 1 X3 116 1 X6 115 1 X9 113 1 X12 112 1 X15 110 1 X18 109 1 X21 107 1 X25 106 1 X28 104 1 X31 103 1 X34 101 1 X37 100 1 X40 98 1 X43 97 1 X46 96 1 X50 94 1 X53 93 1 X56 91 1 X59 90 1 X62 88 1 X65 87 1 X68 85 1 X71 84 1 X75 82 1 X78 81 1 X81 79 1 X84 78 1 X87 77 1 X90 75 1 X93 74 1 X96 72 1 X100 71 1 X103 69 1 X106 68 1 X109 66 1 X112 65 1 X115 63 1 X118 62 1 X122 61 1 X121 61 1 X120 61 1 X118 60 1 X117 60 1 X115 59 1 X114 59 1 X113 59 1 X111 58 1 X110 58 1 X109 58 1 X111 59 1 X114 60 1 X116 62 1 X119 63 1 X121 65 1 X124 66 1 X126 68 1 X129 69 1 X131 71 1 X134 72 1 X136 74 1 X139 75 1 X141 77 1 X144 78 1 X147 80 1 X149 81 1 X152 83 1 X154 84 1 X157 86 1 X159 87 1 X162 89 1 X164 90 1 X167 92 1 X169 93 1 X172 95 1 X174 96 1 X177 98 1 X180 99 1 X182 101 1 X185 102 1 X187 104 1 X190 105 1 X192 107 1 X195 108 1 X197 110 1 X200 111 1 X202 113 1 X205 114 1 X207 116 1 X210 117 1 X213 119 2 X210 120 9 X208 122 16 X205 124 23 X203 126 30 X200 128 37 X198 129 44 X195 131 51 X193 133 59 X190 135 66 X188 137 73 X186 138 80 X183 140 87 X181 142 94 X178 144 101 X176 146 109 X173 148 116 X254 255 255 X254 255 254 X254 255 254 X254 255 253 X254 255 253 X254 255 253 END_OF_FILE if test 2551 -ne `wc -c <'Examples/planet.map'`; then echo shar: \"'Examples/planet.map'\" unpacked with wrong size! fi # end of 'Examples/planet.map' fi if test -f 'libray/libcommon/rotate.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'libray/libcommon/rotate.c'\" else echo shar: Extracting \"'libray/libcommon/rotate.c'\" \(2915 characters\) sed "s/^X//" >'libray/libcommon/rotate.c' <<'END_OF_FILE' X/* X * rotate.c X * X * Copyright (C) 1989, 1991, Craig E. Kolb X * All rights reserved. X * X * This software may be freely copied, modified, and redistributed X * provided that this copyright notice is preserved on all copies. X * X * You may not distribute this software, in whole or in part, as part of X * any commercial product without the express consent of the authors. X * X * There is no warranty or other guarantee of fitness of this software X * for any purpose. It is provided solely "as is". X * X * $Id: rotate.c,v 4.0.1.1 91/09/29 15:35:38 cek Exp Locker: cek $ X * X * $Log: rotate.c,v $ X * Revision 4.0.1.1 91/09/29 15:35:38 cek X * patch1: Added comments. X * X * Revision 4.0 91/07/17 14:31:18 kolb X * Initial version. X * X */ X#include "common.h" X#include "rotate.h" X XTransMethods *iRotateMethods; Xvoid RotationMatrix(); X X/* X * Create and return reference to Rotate structure. X */ XRotate * XRotateCreate() X{ X Rotate *res; X X res = (Rotate *)Malloc(sizeof(Rotate)); X res->x = res->y = res->theta = 0.; X res->z = 1.; X return res; X} X X/* X * Return a pointer to collection of methods for the X * Rotate transformation. X */ XTransMethods * XRotateMethods() X{ X if (iRotateMethods == (TransMethods *)NULL) { X iRotateMethods = (TransMethods *)Malloc(sizeof(TransMethods)); X iRotateMethods->create = (TransCreateFunc *)RotateCreate; X iRotateMethods->propagate = RotatePropagate; X } X return iRotateMethods; X} X X/* X * Given a Rotate structure and forward and inverse transformations, X * propagate the information in the Rotate structure to the X * transformations. X */ Xvoid XRotatePropagate(rotate, trans, itrans) XRotate *rotate; XRSMatrix *trans, *itrans; X{ X Vector axis; X X RotationMatrix(rotate->x, rotate->y, rotate->z, deg2rad(rotate->theta), trans); X /* X * Build the inverse... X */ X MatrixInvert(trans, itrans); X} X X/* X * Initialize a rotation matrix given an axis of rotation and an X * angle. Right-handed rotation is applied. X */ Xvoid XRotationMatrix(x, y, z, theta, trans) XFloat x, y, z, theta; XRSMatrix *trans; X{ X Float n1, n2, n3, sintheta, costheta; X Vector vector; X X MatrixInit(trans); X vector.x = x; X vector.y = y; X vector.z = z; X X if (VecNormalize(&vector) == 0.) X RLerror(RL_WARN, "Degenerate rotation axis.\n"); X X sintheta = sin(theta); X costheta = cos(theta); X X n1 = vector.x; n2 = vector.y; n3 = vector.z; X trans->matrix[0][0] = (Float)(n1*n1 + (1. - n1*n1)*costheta); X trans->matrix[0][1] = (Float)(n1*n2*(1 - costheta) + n3*sintheta); X trans->matrix[0][2] = (Float)(n1*n3*(1 - costheta) - n2*sintheta); X trans->matrix[1][0] = (Float)(n1*n2*(1 - costheta) - n3*sintheta); X trans->matrix[1][1] = (Float)(n2*n2 + (1 - n2*n2)*costheta); X trans->matrix[1][2] = (Float)(n2*n3*(1 - costheta) + n1*sintheta); X trans->matrix[2][0] = (Float)(n1*n3*(1 - costheta) + n2*sintheta); X trans->matrix[2][1] = (Float)(n2*n3*(1 - costheta) - n1*sintheta); X trans->matrix[2][2] = (Float)(n3*n3 + (1 - n3*n3)*costheta); X} END_OF_FILE if test 2915 -ne `wc -c <'libray/libcommon/rotate.c'`; then echo shar: \"'libray/libcommon/rotate.c'\" unpacked with wrong size! fi # end of 'libray/libcommon/rotate.c' fi if test -f 'libray/liblight/extended.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'libray/liblight/extended.c'\" else echo shar: Extracting \"'libray/liblight/extended.c'\" \(2819 characters\) sed "s/^X//" >'libray/liblight/extended.c' <<'END_OF_FILE' X/* X * extended.c X * X * Copyright (C) 1989, 1991, Craig E. Kolb X * All rights reserved. X * X * This software may be freely copied, modified, and redistributed X * provided that this copyright notice is preserved on all copies. X * X * You may not distribute this software, in whole or in part, as part of X * any commercial product without the express consent of the authors. X * X * There is no warranty or other guarantee of fitness of this software X * for any purpose. It is provided solely "as is". X * X * $Id: extended.c,v 4.0 91/07/17 14:34:03 kolb Exp Locker: kolb $ X * X * $Log: extended.c,v $ X * Revision 4.0 91/07/17 14:34:03 kolb X * Initial version. X * X */ X#include "light.h" X#include "libcommon/sampling.h" X#include "extended.h" X Xstatic LightMethods *iExtendedMethods = NULL; X XExtended * XExtendedCreate(r, pos) XFloat r; XVector *pos; X{ X Extended *e; X X e = (Extended *)share_malloc(sizeof(Extended)); X e->pos = *pos; X e->radius = r; X X return e; X} X XLightMethods * XExtendedMethods() X{ X if (iExtendedMethods == (LightMethods *)NULL) { X iExtendedMethods = LightMethodsCreate(); X iExtendedMethods->intens = ExtendedIntens; X iExtendedMethods->dir = ExtendedDirection; X } X return iExtendedMethods; X} X X/* X * Compute intensity ('color') of extended light source 'lp' from 'pos'. X */ Xstatic int XExtendedIntens(lp, lcolor, cache, ray, dist, noshadow, color) XExtended *lp; XColor *lcolor, *color; XShadowCache *cache; XRay *ray; XFloat dist; Xint noshadow; X{ X int uSample, vSample, islit; X Float jit, vbase, ubase, vpos, upos, lightdist; X Color newcol; X Ray newray; X Vector Uaxis, Vaxis, ldir; X X if (noshadow) { X *color = *lcolor; X return TRUE; X } X X newray = *ray; X /* X * Determinte two orthoganal vectors that lay in the plane X * whose normal is defined by the vector from the center X * of the light source to the point of intersection and X * passes through the center of the light source. X */ X VecSub(lp->pos, ray->pos, &ldir); X VecCoordSys(&ldir, &Uaxis, &Vaxis); X X jit = 2. * lp->radius * Sampling.spacing; X X /* X * Sample a single point, determined by SampleNumber, X * on the extended source. X */ X vpos = -lp->radius + (ray->sample % Sampling.sidesamples)*jit; X upos = -lp->radius + (ray->sample / Sampling.sidesamples)*jit; X vpos += nrand() * jit; X upos += nrand() * jit; X VecComb(upos, Uaxis, vpos, Vaxis, &newray.dir); X VecAdd(ldir, newray.dir, &newray.dir); X lightdist = VecNormalize(&newray.dir); X X return !Shadowed(color, lcolor, cache, &newray, X lightdist, noshadow); X} X Xvoid XExtendedDirection(lp, pos, dir, dist) XExtended *lp; XVector *pos, *dir; XFloat *dist; X{ X /* X * Calculate dir from position to center of X * light source. X */ X VecSub(lp->pos, *pos, dir); X *dist = VecNormalize(dir); X} X XExtendedMethodRegister(meth) XUserMethodType meth; X{ X if (iExtendedMethods) X iExtendedMethods->user = meth; X} END_OF_FILE if test 2819 -ne `wc -c <'libray/liblight/extended.c'`; then echo shar: \"'libray/liblight/extended.c'\" unpacked with wrong size! fi # end of 'libray/liblight/extended.c' fi if test -f 'libray/libobj/hf.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'libray/libobj/hf.h'\" else echo shar: Extracting \"'libray/libobj/hf.h'\" \(2626 characters\) sed "s/^X//" >'libray/libobj/hf.h' <<'END_OF_FILE' X/* X * hf.h X * X * Copyright (C) 1989, 1991, Craig E. Kolb X * All rights reserved. X * X * This software may be freely copied, modified, and redistributed X * provided that this copyright notice is preserved on all copies. X * X * You may not distribute this software, in whole or in part, as part of X * any commercial product without the express consent of the authors. X * X * There is no warranty or other guarantee of fitness of this software X * for any purpose. It is provided solely "as is". X * X * $Id: hf.h,v 4.0 91/07/17 14:38:19 kolb Exp Locker: kolb $ X * X * $Log: hf.h,v $ X * Revision 4.0 91/07/17 14:38:19 kolb X * Initial version. X * X */ X#ifndef HF_H X#define HF_H X X#define GeomHfCreate(f) GeomCreate((GeomRef)HfCreate(f), HfMethods()) X X/* X * Any height values <= Hf_UNSET is not considered to be part of the X * height field. Any trianges containing such a vertex will not be X * rendered. This allows one to render non-square height fields. X */ X#define HF_UNSET (-1000.) X/* X * Number of datapoints in a single cell. If you've got loads of memory, X * decrease this number. The 'optimal' number is quite system-dependent, X * but something around 20 seems to work well. For systems without much X * memory, this constant should be greater than or equal to the largest X * height field which will be rendered, thus making the algorithm X * non-hierarchical. X */ X#define BESTSIZE 16 X/* X * Size of triangle cache. X */ X#define CACHESIZE 6 X/* X * Used to differentiate between the two triangles used to represent a cell: X * a------d X * |\ | X * | \TRI2| TRI2 == c-->d-->a-->c X * | \ | X * | \ | X * | \ | X * |TRI1 \| TRI1 == c-->a-->b-->c X * b------c X */ X#define TRI1 1 X#define TRI2 2 X Xtypedef struct hfTri { X Vector v1, v2, v3, norm; X Float d; X char type; X struct hfTri *next, *prev; X} hfTri; X Xtypedef struct { X int len; X hfTri *head, *tail; X} TriQueue; X Xtypedef struct { X float **data; /* Altitude points */ X float minz, maxz; X int size, *lsize; /* # of points/side */ X int BestSize; /* "best" division size */ X float iBestSize; /* inverse of above (for faster computation) */ X int levels; /* log base BestSize of size */ X float ***boundsmax; /* high data values at various resolutions. */ X float ***boundsmin; X float *spacing; X hfTri hittri, **q; /* hit triangle and triangle cache */ X int qtail, qsize; /* end and length of cache */ X Float boundbox[2][3]; /* bounding box of Hf */ X} Hf; X Xextern Hf *HfCreate(); Xextern int HfIntersect(), HfEnter(), HfNormal(); Xextern void HfBounds(), HfUV(), HfStats(); Xextern char *HfName(); Xextern Methods *HfMethods(); X X#endif /* HF_H */ END_OF_FILE if test 2626 -ne `wc -c <'libray/libobj/hf.h'`; then echo shar: \"'libray/libobj/hf.h'\" unpacked with wrong size! fi # end of 'libray/libobj/hf.h' fi if test -f 'libray/libobj/instance.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'libray/libobj/instance.c'\" else echo shar: Extracting \"'libray/libobj/instance.c'\" \(2473 characters\) sed "s/^X//" >'libray/libobj/instance.c' <<'END_OF_FILE' X/* X * instance.c X * X * Copyright (C) 1989, 1991, Craig E. Kolb X * All rights reserved. X * X * This software may be freely copied, modified, and redistributed X * provided that this copyright notice is preserved on all copies. X * X * You may not distribute this software, in whole or in part, as part of X * any commercial product without the express consent of the authors. X * X * There is no warranty or other guarantee of fitness of this software X * for any purpose. It is provided solely "as is". X * X * $Id: instance.c,v 4.0 91/07/17 14:38:26 kolb Exp Locker: kolb $ X * X * $Log: instance.c,v $ X * Revision 4.0 91/07/17 14:38:26 kolb X * Initial version. X * X */ X#include "geom.h" X#include "instance.h" X Xstatic Methods *iInstanceMethods = NULL; Xstatic char instanceName[] = "instance"; X XInstance * XInstanceCreate(obj) XGeom *obj; X{ X Instance *inst; X X if (obj == (Geom *)NULL) { X RLerror(RL_WARN, "Instance of NULL?\n"); X return (Instance *)NULL; X } X inst = (Instance *)share_malloc(sizeof(Instance)); X inst->obj = obj; X BoundsCopy(obj->bounds, inst->bounds); X return inst; X} X Xchar * XInstanceName() X{ X return instanceName; X} X X X/* X * Intersect ray & an instance by calling intersect. X */ Xint XInstanceIntersect(inst, ray, hitlist, mindist, maxdist) XInstance *inst; XRay *ray; XHitList *hitlist; XFloat mindist, *maxdist; X{ X return intersect(inst->obj, ray, hitlist, mindist, maxdist); X} X XMethods * XInstanceMethods() X{ X /* X * Instances are special in that there is no X * "convert" method -- when created, they are passed X * a pointer to the object being instantiated. X * This means that you will need to set an instance's X * 'prims' field by hand (e.g., inst->prims = object->prims). X */ X if (iInstanceMethods == (Methods *)NULL) { X iInstanceMethods = MethodsCreate(); X iInstanceMethods->methods = InstanceMethods; X iInstanceMethods->create = (GeomCreateFunc *)InstanceCreate; X iInstanceMethods->name = InstanceName; X iInstanceMethods->intersect = InstanceIntersect; X iInstanceMethods->bounds = InstanceBounds; X iInstanceMethods->convert = (voidstar)NULL; X iInstanceMethods->checkbounds = FALSE; X iInstanceMethods->closed = TRUE; X } X return iInstanceMethods; X} X Xvoid XInstanceBounds(inst, bounds) XInstance *inst; XFloat bounds[2][3]; X{ X GeomComputeBounds(inst->obj); X BoundsCopy(inst->obj->bounds, inst->bounds); X BoundsCopy(inst->bounds, bounds); X} X Xvoid XInstanceMethodRegister(meth) XUserMethodType meth; X{ X if (iInstanceMethods) X iInstanceMethods->user = meth; X} END_OF_FILE if test 2473 -ne `wc -c <'libray/libobj/instance.c'`; then echo shar: \"'libray/libobj/instance.c'\" unpacked with wrong size! fi # end of 'libray/libobj/instance.c' fi if test -f 'libray/libsurf/fogdeck.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'libray/libsurf/fogdeck.c'\" else echo shar: Extracting \"'libray/libsurf/fogdeck.c'\" \(2785 characters\) sed "s/^X//" >'libray/libsurf/fogdeck.c' <<'END_OF_FILE' X/* X * fogdeck.c X * X * Copyright (C) 1989, 1991, Craig E. Kolb X * All rights reserved. X * X * This software may be freely copied, modified, and redistributed X * provided that this copyright notice is preserved on all copies. X * X * You may not distribute this software, in whole or in part, as part of X * any commercial product without the express consent of the authors. X * X * There is no warranty or other guarantee of fitness of this software X * for any purpose. It is provided solely "as is". X * X * $Id: fogdeck.c,v 4.0 91/07/17 14:40:28 kolb Exp Locker: kolb $ X * X * $Log: fogdeck.c,v $ X * Revision 4.0 91/07/17 14:40:28 kolb X * Initial version. X * X */ X#include "atmosphere.h" X#include "fogdeck.h" X XFogdeck * XFogdeckCreate(alt, offset, scale, chaoscale, octaves, color, trans) XFloat alt, offset, chaoscale; XVector *scale; Xint octaves; XColor *color, *trans; X{ X Fogdeck *fogdeck; X static void ComputeFogdeck(); X X fogdeck = (Fogdeck *)Malloc(sizeof(Fogdeck)); X X fogdeck->alt = alt; X fogdeck->octaves = octaves; X fogdeck->scale = *scale; X fogdeck->chaoscale = chaoscale; X fogdeck->offset = offset; X X if (color == (Color *)NULL) X fogdeck->color.r = fogdeck->color.g = fogdeck->color.b = 0.; X else X fogdeck->color = *color; X if (trans == (Color *)NULL) X fogdeck->trans.r = fogdeck->trans.g = fogdeck->trans.b = X FAR_AWAY; X else { X fogdeck->trans = *trans; X } X return fogdeck; X} X X/* X * Add fogdeck to the given color. X */ Xvoid XFogdeckApply(fogdeck, ray, pos, dist, color) XFogdeck *fogdeck; XRay *ray; XVector *pos; XFloat dist; XColor *color; X{ X Float atten, hitdist, density; X Color trans; X Vector endp; X extern Float ExpAtten(), PAChaos(); X X /* X * Find distance from origin at which ray strikes X * z = fogdeck->alt plane X */ X if (abs(ray->dir.z) < EPSILON) X return; X hitdist = (fogdeck->alt - ray->pos.z) / ray->dir.z; X if (hitdist < EPSILON || hitdist > dist) X return; X /* X * Compute ray endpoint X */ X VecAddScaled(ray->pos, hitdist, ray->dir, &endp); X X /* X * Modify transmissivity based on point of X * intersection. X */ X endp.x *= fogdeck->scale.x; X endp.y *= fogdeck->scale.y; X endp.z *= fogdeck->scale.z; X X density = fogdeck->offset + X fogdeck->chaoscale * PAChaos(&endp, fogdeck->octaves); X if (density < EPSILON) X density = HUGE; X else X density = 1. / density; X X trans = fogdeck->trans; X ColorScale(density, trans, &trans); X X dist -= hitdist; X X atten = ExpAtten(dist, trans.r); X X if (trans.r == trans.g && X trans.r == trans.b) { X ColorBlend(color, &fogdeck->color, atten, 1. - atten); X return; X } X color->r = atten*color->r + (1. - atten) * fogdeck->color.r; X X atten = ExpAtten(dist, trans.g); X color->g = atten*color->g + (1. - atten) * fogdeck->color.g; X atten = ExpAtten(dist, trans.b); X color->b = atten*color->b + (1. - atten) * fogdeck->color.b; X} END_OF_FILE if test 2785 -ne `wc -c <'libray/libsurf/fogdeck.c'`; then echo shar: \"'libray/libsurf/fogdeck.c'\" unpacked with wrong size! fi # end of 'libray/libsurf/fogdeck.c' fi if test -f 'libray/libtext/cloud.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'libray/libtext/cloud.c'\" else echo shar: Extracting \"'libray/libtext/cloud.c'\" \(2607 characters\) sed "s/^X//" >'libray/libtext/cloud.c' <<'END_OF_FILE' X/* X * cloud.c X * X * Copyright (C) 1989, 1991, Craig E. Kolb X * All rights reserved. X * X * This software may be freely copied, modified, and redistributed X * provided that this copyright notice is preserved on all copies. X * X * You may not distribute this software, in whole or in part, as part of X * any commercial product without the express consent of the authors. X * X * There is no warranty or other guarantee of fitness of this software X * for any purpose. It is provided solely "as is". X * X * $Id: cloud.c,v 4.0 91/07/17 14:41:57 kolb Exp Locker: kolb $ X * X * $Log: cloud.c,v $ X * Revision 4.0 91/07/17 14:41:57 kolb X * Initial version. X * X */ X#include "texture.h" X#include "cloud.h" X X/* X * Gardner-style textured ellipsoid. Designed to be used on unit spheres X * centered at the origin. (Of course, the spheres may be transformed X * into ellipsoids, translated, etc.) X */ XCloudText * XCloudTextCreate(scale, h, lambda, octaves, cthresh, lthresh, transcale) XFloat scale, h, lambda, cthresh, lthresh, transcale; Xint octaves; X{ X CloudText *cloud; X X cloud = (CloudText *)Malloc(sizeof(CloudText)); X cloud->beta = 1. + 2 * h; X cloud->omega = pow(lambda, -0.5 * cloud->beta); X cloud->lambda = lambda; X cloud->scale = scale; X cloud->cthresh = cthresh; X cloud->range = lthresh - cthresh; X cloud->transcale = transcale; X cloud->maxval = 1. / (1. - cloud->beta); X cloud->octaves = octaves; X return cloud; X} X Xvoid XCloudTextApply(cloud, prim, ray, pos, norm, gnorm, surf) XCloudText *cloud; XGeom *prim; XRay *ray; XVector *pos, *norm, *gnorm; XSurface *surf; X{ X Ray pray; X Float alpha, beta, It, dsquared, d, limb; X X /* X * Transform ray to prim. space. X */ X pray = *ray; X (void)TextRayToPrim(&pray); X dsquared = dotp(&pray.pos, &pray.pos); X if (fabs(dsquared) < 1. + EPSILON) { X surf->transp = 1.; X surf->amb.r = surf->amb.g = surf->amb.b = 0.; X surf->diff.r = surf->diff.g = surf->diff.b = 0.; X return; X } X It = fBm(pos,cloud->omega,cloud->lambda,cloud->octaves); X It = (cloud->maxval + It) * 0.5/cloud->maxval; X if (It < 0.) X It = 0; X else if (It > 1.) X It = 1; X d = sqrt(dsquared); X beta = sqrt(dsquared - 1) / d; X alpha = -dotp(&pray.pos, &pray.dir) / d; X limb = (alpha - beta) / (1 - beta); X /* X * limb is 0 on the limb, 1 at the center, < 1 outside. X */ X surf->transp = 1. - (It-cloud->cthresh-cloud->range*(1.-limb))/ X cloud->transcale; X X if (surf->transp > 1) X surf->transp = 1.; X if (surf->transp < 0) X surf->transp = 0.; X X ColorScale((1. - surf->transp) * X (1. - cloud->scale + cloud->scale*It), X surf->diff, &surf->diff); X ColorScale(1. - surf->transp, surf->amb, &surf->amb); X} END_OF_FILE if test 2607 -ne `wc -c <'libray/libtext/cloud.c'`; then echo shar: \"'libray/libtext/cloud.c'\" unpacked with wrong size! fi # end of 'libray/libtext/cloud.c' fi if test -f 'libray/libtext/stripe.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'libray/libtext/stripe.c'\" else echo shar: Extracting \"'libray/libtext/stripe.c'\" \(2911 characters\) sed "s/^X//" >'libray/libtext/stripe.c' <<'END_OF_FILE' X/* X * stripe.c X * X * Copyright (C) 1989, 1991, Craig E. Kolb X * All rights reserved. X * X * This software may be freely copied, modified, and redistributed X * provided that this copyright notice is preserved on all copies. X * X * You may not distribute this software, in whole or in part, as part of X * any commercial product without the express consent of the authors. X * X * There is no warranty or other guarantee of fitness of this software X * for any purpose. It is provided solely "as is". X * X * $Id: stripe.c,v 4.0 91/07/17 14:43:52 kolb Exp Locker: kolb $ X * X * $Log: stripe.c,v $ X * Revision 4.0 91/07/17 14:43:52 kolb X * Initial version. X * X */ X#include "texture.h" X#include "stripe.h" X XStripe * XStripeCreate(surf, width, bump, mapping) XSurface *surf; XFloat width, bump; XMapping *mapping; X{ X Stripe *stripe; X X stripe = (Stripe *)Malloc(sizeof(Stripe)); X stripe->surf = surf; X stripe->mapping = mapping; X stripe->width = width; X stripe->bump = bump; X return stripe; X} X Xvoid XStripeApply(stripe, prim, ray, pos, norm, gnorm, surf) XStripe *stripe; XGeom *prim; XVector *ray, *pos, *norm, *gnorm; XSurface *surf; X{ X Vector dpdu, dpdv; X Float fu, fv, u, v; X X TextToUV(stripe->mapping, prim, pos, gnorm, &u, &v, &dpdu, &dpdv); X X u -= floor(u); X v -= floor(v); X X /* X * s s s X * | | | | | X * 1 +-+------------+ X * |X|\^^^^^^^^^^/| } s X * |X|<+--------+>| X * |X|<| |>| X * |X|<| |>| X * |X|<| |>| X * v |X|<| |>| X * |X|<| |>| X * |X|<| |>| X * |X|<+--------+>| X * |X|/vvvvvvvvvv\| } s X * |X+------------+ X * |XXXXXXXXXXXXXX| } s X * 0 +--------------+ X * 0 1 X * u X * X * where ^ == positive fv, 0 fu, original surf. X * v == negative fv, 0 fu, original surf. X * > == positive fu, 0 fv, original surf. X * < == negative fu, 0 fv, original surf. X * blank == 0 fu, 0 fv, original surf. X * X == 0 fu, 0 fv, alternate surf. X * for stripe->bump > 0. For stripe->bump < 0., change signs. X */ X X if (u > 2*stripe->width && v > 2*stripe->width && X u <= 1. - stripe->width && v <= 1. - stripe->width) X /* flat surface */ X return; X else if (u < stripe->width || v < stripe->width) { X /* on the bottom of the bump. */ X *surf = *stripe->surf; X return; X } X X /* X * Lower u & v edges are the 'flat' part of the bump -- X * make our lives simpler below by 'removing' this area X * from u & v. X */ X u = (u - stripe->width) / (1. - stripe->width); X v = (v - stripe->width) / (1. - stripe->width); X /* X * Now the hard part -- where's the bump? X */ X if (v < u) { X if (v < 1. - u) { X /* bottom */ X fu = 0.; X fv = -stripe->bump; X } else { X /* right */ X fu = stripe->bump; X fv = 0.; X } X } else { X if (v < 1. - u) { X /* left */ X fu = -stripe->bump; X fv = 0.; X } else { X /* top */ X fu = 0.; X fv = stripe->bump; X } X } X X MakeBump(norm, &dpdu, &dpdv, fu, fv); X} END_OF_FILE if test 2911 -ne `wc -c <'libray/libtext/stripe.c'`; then echo shar: \"'libray/libtext/stripe.c'\" unpacked with wrong size! fi # end of 'libray/libtext/stripe.c' fi if test -f 'libshade/Makefile.SH' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'libshade/Makefile.SH'\" else echo shar: Extracting \"'libshade/Makefile.SH'\" \(2825 characters\) sed "s/^X//" >'libshade/Makefile.SH' <<'END_OF_FILE' Xcase $CONFIG in X'') X if test ! -f config.sh; then X ln ../config.sh . || \ X ln ../../config.sh . || \ X ln ../../../config.sh . || \ X (echo "Can't find config.sh."; exit 1) X fi X . config.sh X ;; Xesac X: This forces SH files to create target in same directory as SH file. X: This is so that make depend always knows where to find SH derivatives. Xcase "$0" in X*/*) cd `expr X$0 : 'X\(.*\)/'` ;; Xesac Xecho "Extracting Makefile (with variable substitutions)" X: This section of the file will have variable substitutions done on it. X: Move anything that needs config subs from !NO!SUBS! section to !GROK!THIS!. X: Protect any dollar signs and backticks that you do not want interpreted X: by putting a backslash in front. You may delete these comments. X$spitshell >Makefile <>Makefile <<'!NO!SUBS!' XLIBRAYDIR = ../libray XINCLUDE = -I.. -I$(LIBRAYDIR) XYFLAGS = -d X XCFLAGS = $(CCFLAGS) $(URTINC) $(INCLUDE) $(OPTIMIZE) XSHELL = /bin/sh X XLIB = libshade.a X XSUPPORT_C = builtin.c symtab.c misc.c lightdef.c objdef.c options.c \ X stats.c surfdef.c X XSUPPORT_H = ../config.h datatypes.h funcdefs.h \ X ../patchlevel.h rayshade.h X XPARSE_C = yacc.c lex.c X XDRIVE_C = setup.c viewing.c shade.c picture.c X XDRIVE_H = y.tab.h defaults.h viewing.h raytrace.h picture.h X XSUPPORT_O = $(SUPPORT_C:.c=.o) X XPARSE_O = $(PARSE_C:.c=.o) X XDRIVE_O = $(DRIVE_C:.c=.o) X XHFILES = $(DRIVE_H) $(SUPPORT_H) X XCFILES = $(DRIVE_C) $(PARSE_C) $(SUPPORT_C) X XSHFILES = Makefile.SH X XOFILES = $(DRIVE_O) $(PARSE_O) $(SUPPORT_O) X XDEPENDSRC = $(DRIVE_C) lex.l yacc.y $(SUPPORT_C) X X$(LIB): $(OFILES) X ar cur $(LIB) $(OFILES) X $(RANLIB) $(LIB) X X# X# Uncomment the following rule if using Linda. X# X#raytrace.lo: raytrace.cl X# $(LCC) $(CFLAGS) -c raytrace.cl X X# X# End of configuration section X# Xinstall: rayshade X mv rayshade $(BINDIR)/rayshade X Xclean: X rm -f $(OFILES) core libshade.a X Xrealclean: X rm -f $(OFILES) core libshade.a y.tab.h X rm -f *.orig Makefile X Xlint: X lint $(CFLAGS) -x $(CFILES) -lm X Xtags: X ctags -t $(CFILES) X Xdepend: X (sed '/^# DO NOT DELETE THIS LINE/q' Makefile && \ X $(MKDEP) $(DEPENDSRC) | sed 's/: \.\//: /; /\/usr\/include/d' \ X ) >Makefile.new X cp Makefile Makefile.bak X cp Makefile.new Makefile X rm -f Makefile.new X X X# DO NOT DELETE THIS LINE X!NO!SUBS! Xchmod 755 Makefile X$eunicefix Makefile END_OF_FILE if test 2825 -ne `wc -c <'libshade/Makefile.SH'`; then echo shar: \"'libshade/Makefile.SH'\" unpacked with wrong size! fi chmod +x 'libshade/Makefile.SH' # end of 'libshade/Makefile.SH' fi if test -f 'libshade/surfdef.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'libshade/surfdef.c'\" else echo shar: Extracting \"'libshade/surfdef.c'\" \(2988 characters\) sed "s/^X//" >'libshade/surfdef.c' <<'END_OF_FILE' X/* X * surfdef.c X * X * Copyright (C) 1989, 1991, Craig E. Kolb X * All rights reserved. X * X * This software may be freely copied, modified, and redistributed X * provided that this copyright notice is preserved on all copies. X * X * You may not distribute this software, in whole or in part, as part of X * any commercial product without the express consent of the authors. X * X * There is no warranty or other guarantee of fitness of this software X * for any purpose. It is provided solely "as is". X * X * $Id: surfdef.c,v 4.0 91/07/17 14:47:53 kolb Exp Locker: kolb $ X * X * $Log: surfdef.c,v $ X * Revision 4.0 91/07/17 14:47:53 kolb X * Initial version. X * X */ X#include "rayshade.h" X#include "libsurf/surface.h" X Xstatic Surface *Surfaces; /* Named surfaces */ X XSurface DefaultSurface = { X "DeFault", /* name */ X {0.1, 0.1, 0.1}, /* ambient */ X {0.6, 0.6, 0.6}, /* diffuse */ X {0.5, 0.5, 0.5}, /* specular */ X {0.0, 0.0, 0.0}, /* Diffuse transmission 'curve' */ X {1.0, 1.0, 1.0}, /* Specular transmission 'curve' */ X 12., /* reflected Phong coef */ X 12., /* transmitted Phong coef */ X 1., /* spec. transmitted attenuation */ X DEFAULT_INDEX, /* index of refr */ X 0., /* reflectivity */ X 0., /* transparency */ X 0., /* translucency */ X FALSE, /* noshadow */ X NULL, /* next */ X}; X XSurface *SurfaceGetNamed(), *SurfaceFetchNamed(); X X/* X * Add surf to the list of defined surfaces. X */ Xvoid XSurfaceAddToDefined(surf) XSurface *surf; X{ X /* X * Make sure index of refraction isn't bogus. X */ X if (surf->transp > EPSILON && surf->index <= 0.) X RLerror(RL_PANIC, X "Index of refraction must be positive.\n"); X X if (surf->name == (char *)NULL || *surf->name == (char)NULL) X RLerror(RL_PANIC, "Surface with NULL name defined.\n"); X X if (SurfaceFetchNamed(surf->name) != (Surface *)NULL) X RLerror(RL_WARN, X "Redefinition of \"%s\" surface.", surf->name); X X surf->next = Surfaces; X Surfaces = surf; X} X X/* X * Search for surface with given name. If not found, complain and exit. X */ XSurface * XSurfaceGetNamed(name) Xchar *name; X{ X Surface *stmp; X X stmp = SurfaceFetchNamed(name); X if (stmp == (Surface *)NULL) X RLerror(RL_PANIC, "Undefined surface \"%s\".", name); X X return stmp; X} X X/* X * Return pointer to surface with given name, NULL if no such surface. X */ XSurface * XSurfaceFetchNamed(name) Xchar *name; X{ X Surface *stmp; X X for (stmp = Surfaces; stmp ; stmp = stmp->next) X if(strcmp(name, stmp->name) == 0) X return stmp; X /* X * No surface named "name". X */ X return (Surface *)NULL; X} X X/* X * Traverse the given hitlist to find the "bottom-most" surface. X * If no surface is found, use the default. X */ XSurface * XGetShadingSurf(hitlist) XHitList *hitlist; X{ X int i; X X /* X * -1 here because the World always has a NULL surface X * (DefaultSurf is used instead) X */ X for (i = 0; i < hitlist->nodes -1; i++) { X if (hitlist->data[i].obj->surf) X return hitlist->data[i].obj->surf; X } X /* X * No suface found -- use the default. X */ X return &DefaultSurface; X} END_OF_FILE if test 2988 -ne `wc -c <'libshade/surfdef.c'`; then echo shar: \"'libshade/surfdef.c'\" unpacked with wrong size! fi # end of 'libshade/surfdef.c' fi if test -f 'raypaint/Makefile.SH' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'raypaint/Makefile.SH'\" else echo shar: Extracting \"'raypaint/Makefile.SH'\" \(2800 characters\) sed "s/^X//" >'raypaint/Makefile.SH' <<'END_OF_FILE' Xcase $CONFIG in X'') X if test ! -f config.sh; then X ln ../config.sh . || \ X ln ../../config.sh . || \ X ln ../../../config.sh . || \ X (echo "Can't find config.sh."; exit 1) X fi X . config.sh X ;; Xesac X: This forces SH files to create target in same directory as SH file. X: This is so that make depend always knows where to find SH derivatives. Xcase "$0" in X*/*) cd `expr X$0 : 'X\(.*\)/'` ;; Xesac Xecho "Extracting Makefile (with variable substitutions)" X: This section of the file will have variable substitutions done on it. X: Move anything that needs config subs from !NO!SUBS! section to !GROK!THIS!. X: Protect any dollar signs and backticks that you do not want interpreted X: by putting a backslash in front. You may delete these comments. X$spitshell >Makefile <>Makefile <<'!NO!SUBS!' XLIBRAYDIR = ../libray XLIBSHADEDIR = ../libshade XINCLUDE = -I$(LIBRAYDIR) -I$(LIBSHADEDIR) -I.. XYFLAGS = -d X X# X# If using X11, use: X#GRAPHICSLIB = -lX11 X X# X# If you are using GL, use: XGRAPHICSLIB = -lgl_s X XLIBRAY = $(LIBRAYDIR)/libray.a XLIBSHADE = $(LIBSHADEDIR)/libshade.a X XCFLAGS = $(CCFLAGS) $(URTINC) $(INCLUDE) $(OPTIMIZE) -DSHARED_EDGES XSHELL = /bin/sh X X# X# If you are using a Multimax, add -lpp X# If you have a fast malloc library, use it (e.g., -lmalloc on MIPS machines) X# XLIBS = $(LIBSHADE) $(LIBRAY) $(URTLIB) X XDRIVE_C = main.c graphics.c render.c version.c X XDRIVE_O = $(DRIVE_C:.c=.o) X XCFILES = $(DRIVE_C) X XSHFILES = Makefile.SH X XOBJ = $(DRIVE_O) X XDEPENDSRC = $(DRIVE_C) X Xraypaint: $(OBJ) $(LIBS) X $(CC) $(OPTIMIZE) -o raypaint $(OBJ) $(LIBS) $(LDFLAGS) $(GRAPHICSLIB) X X# X# Uncomment the following rule if using Linda. X# X#raytrace.lo: raytrace.cl X# $(LCC) $(CFLAGS) -c raytrace.cl X X# X# End of configuration section X# Xinstall: raypaint X mv raypaint $(BINDIR)/raypaint X Xclean: X rm -f $(OBJ) core X Xrealclean: X rm -f $(OBJ) core y.tab.h X rm -f *.orig Makefile X Xlint: X lint $(CFLAGS) -x $(CFILES) -lm X Xtags: X ctags -t $(CFILES) X Xdepend: X (sed '/^# DO NOT DELETE THIS LINE/q' Makefile && \ X $(MKDEP) $(DEPENDSRC) | sed 's/: \.\//: /; /\/usr\/include/d' \ X ) >Makefile.new X cp Makefile Makefile.bak X cp Makefile.new Makefile X rm -f Makefile.new X X X# DO NOT DELETE THIS LINE X!NO!SUBS! Xchmod 755 Makefile X$eunicefix Makefile END_OF_FILE if test 2800 -ne `wc -c <'raypaint/Makefile.SH'`; then echo shar: \"'raypaint/Makefile.SH'\" unpacked with wrong size! fi chmod +x 'raypaint/Makefile.SH' # end of 'raypaint/Makefile.SH' fi if test -f 'raypaint/glgraphics.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'raypaint/glgraphics.c'\" else echo shar: Extracting \"'raypaint/glgraphics.c'\" \(2838 characters\) sed "s/^X//" >'raypaint/glgraphics.c' <<'END_OF_FILE' X/* X * glgraphics.c X * X * Copyright (C) 1989, 1991 Craig E. Kolb X * All rights reserved. X * X * This software may be freely copied, modified, and redistributed X * provided that this copyright notice is preserved on all copies. X * X * You may not distribute this software, in whole or in part, as part of X * any commercial product without the express consent of the authors. X * X * There is no warranty or other guarantee of fitness of this software X * for any purpose. It is provided solely "as is". X * X * $Id: glgraphics.c,v 4.0 91/07/17 17:36:39 kolb Exp Locker: kolb $ X * X * $Log: glgraphics.c,v $ X * Revision 4.0 91/07/17 17:36:39 kolb X * Initial version. X * X * X */ X X#include X#include X X#define CPACK(x) cpack(((((x)[2] << 8) | (x)[1]) << 8) | x[0]) X XGraphicsInit(xsize, ysize, name) Xint xsize, ysize; Xchar *name; X{ X#ifndef _IBMR2 X foreground(); X#endif X prefsize(xsize, ysize); X winopen(name); X ortho2(-0.5, (float)xsize -0.5, -0.5, (float)ysize - 0.5); X viewport(0, xsize -1, 0, ysize -1); X color(BLACK); X clear(); X RGBmode(); X gconfig(); X unqdevice(INPUTCHANGE); X qdevice(LEFTMOUSE); /* Pop a square on request */ X qdevice(MIDDLEMOUSE); X qdevice(RIGHTMOUSE); X qdevice(REDRAW); X} X X/* X * Draw the pixel at (xp, yp) in the color given by the rgb-triple, X * 0 indicating 0 intensity, 255 max intensity. X */ XGraphicsDrawPixel(xp, yp, color) Xint xp, yp; Xunsigned char color[3]; X{ X unsigned long int pix; X X pix = (((color[2] << 8) | color[1]) << 8) | color[0]; X lrectwrite(xp, yp, xp, yp, &pix); X} X X/* X * Draw the rectangle with lower left corner (xp, yp) and upper right X * corner (xp+ys, yp+ys). The colors of the l-l, l-r, u-r, and u-l X * corners are given as arrays of unsigned chars as above. X */ XGraphicsDrawRectangle(xp, yp, xs, ys, ll, lr, ur, ul) Xint xp, yp, xs, ys; Xunsigned char ll[3], lr[3], ur[3], ul[3]; X{ X int p[2]; X X#if defined(_IBMR2) && !defined(SHARED_EDGES) X /* X * RS6000 doesn't seem to draw lower and left edges X * of rectangles correctly. X */ X xp--; yp--; X xs++; ys++; X#endif X bgnpolygon(); X X p[0] = xp; p[1] = yp; X CPACK(ll); X v2i(p); X X p[0] += xs; X CPACK(lr); X v2i(p); X X p[1] += ys; X CPACK(ur); X v2i(p); X X p[0] = xp; X CPACK(ul); X v2i(p); X X endpolygon(); X} X XGraphicsLeftMouseEvent() X{ X /* X * Return TRUE if left mouse button is down. X */ X return getbutton(LEFTMOUSE); X} X XGraphicsMiddleMouseEvent() X{ X return getbutton(MIDDLEMOUSE); X} X XGraphicsRightMouseEvent() X{ X return getbutton(RIGHTMOUSE); X} X X/* X * Return position of mouse in unnormalized screen coordinates. X */ XGraphicsGetMousePos(x, y) Xint *x, *y; X{ X int xo, yo; X X getorigin(&xo, &yo); X *x = getvaluator( MOUSEX ) - xo; X *y = getvaluator( MOUSEY ) - yo; X} X XGraphicsRedraw() X{ X Device dev; X short val; X X while (qtest()) { X dev = qread(&val); X if (dev == REDRAW) { X reshapeviewport(); X return TRUE; X } X } X return FALSE; X} END_OF_FILE if test 2838 -ne `wc -c <'raypaint/glgraphics.c'`; then echo shar: \"'raypaint/glgraphics.c'\" unpacked with wrong size! fi # end of 'raypaint/glgraphics.c' fi if test -f 'raypaint/main.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'raypaint/main.c'\" else echo shar: Extracting \"'raypaint/main.c'\" \(2648 characters\) sed "s/^X//" >'raypaint/main.c' <<'END_OF_FILE' X/* X * main.c X * X * Copyright (C) 1989, 1991, Craig E. Kolb X * All rights reserved. X * X * This software may be freely copied, modified, and redistributed X * provided that this copyright notice is preserved on all copies. X * X * You may not distribute this software, in whole or in part, as part of X * any commercial product without the express consent of the authors. X * X * There is no warranty or other guarantee of fitness of this software X * for any purpose. It is provided solely "as is". X * X * $Id: main.c,v 4.0 91/07/17 17:36:46 kolb Exp Locker: kolb $ X * X * $Log: main.c,v $ X * Revision 4.0 91/07/17 17:36:46 kolb X * Initial version. X * X * X */ X Xchar rcsid[] = "$Id: main.c,v 4.0 91/07/17 17:36:46 kolb Exp Locker: kolb $"; X X#include "rayshade.h" X#include "options.h" X#include "stats.h" X#include "viewing.h" X#include "picture.h" X Xvoid RSInitialize(), RSStartFrame(); X Xint Xmain(argc, argv) Xint argc; Xchar **argv; X{ X Float utime, stime; X X /* X * Initialize variables, etc. X */ X RSInitialize(argc, argv); X RSStartFrame(Options.startframe); X /* X * Print more information than we'll ever need to know... X */ X if (Options.verbose) { X extern Geom *World; X /* World object info. */ X AggregatePrintInfo(World, Stats.fstats); X /* Print info about rendering options and the like. */ X RSOptionsList(); X } X /* X * Print preprocessing time. X */ X RSGetCpuTime(&utime, &stime); X fprintf(Stats.fstats,"Preprocessing time:\t"); X fprintf(Stats.fstats,"%2.2fu %2.2fs\n", utime, stime); X fprintf(Stats.fstats,"Starting trace.\n"); X (void)fflush(Stats.fstats); X /* X * Render the image. X */ X Render(argc, argv); X StatsPrint(); X return 0; X} X Xstatic void XRSStartFrame(frame) Xint frame; X{ X /* X * Set the frame start time X */ X Options.framenum = frame; X Options.framestart = Options.starttime + X Options.framenum*Options.framelength; X SamplingSetTime(Options.framestart, Options.shutterspeed, X Options.framenum); X /* X * Set up viewing parameters. X */ X RSViewing(); X /* X * Initialize world X */ X WorldSetup(); X} X X/* X * Initialize non-time-varying goodies. X */ Xstatic void XRSInitialize(argc, argv) Xint argc; Xchar **argv; X{ X /* X * Initialize variables, etc. X */ X RSSetup(); X /* X * Parse options from command line. X */ X RSOptionsSet(argc, argv); X /* X * Process input file. X */ X if (Options.verbose) { X VersionPrint(); X fprintf(Stats.fstats,"Reading input file...\n"); X (void)fflush(Stats.fstats); X } X RSReadInputFile(); X /* X * Set variables that weren't set on command line X * or in input file. X */ X RSCleanup(); X /* X * Set sampling options. X */ X SamplingSetOptions(Options.samples, Options.gaussian, X Options.filterwidth); X} END_OF_FILE if test 2648 -ne `wc -c <'raypaint/main.c'`; then echo shar: \"'raypaint/main.c'\" unpacked with wrong size! fi # end of 'raypaint/main.c' fi if test -f 'rayshade/Makefile.SH' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'rayshade/Makefile.SH'\" else echo shar: Extracting \"'rayshade/Makefile.SH'\" \(2719 characters\) sed "s/^X//" >'rayshade/Makefile.SH' <<'END_OF_FILE' Xcase $CONFIG in X'') X if test ! -f config.sh; then X ln ../config.sh . || \ X ln ../../config.sh . || \ X ln ../../../config.sh . || \ X (echo "Can't find config.sh."; exit 1) X fi X . config.sh X ;; Xesac X: This forces SH files to create target in same directory as SH file. X: This is so that make depend always knows where to find SH derivatives. Xcase "$0" in X*/*) cd `expr X$0 : 'X\(.*\)/'` ;; Xesac Xecho "Extracting Makefile (with variable substitutions)" X: This section of the file will have variable substitutions done on it. X: Move anything that needs config subs from !NO!SUBS! section to !GROK!THIS!. X: Protect any dollar signs and backticks that you do not want interpreted X: by putting a backslash in front. You may delete these comments. X$spitshell >Makefile <>Makefile <<'!NO!SUBS!' XLIBRAYDIR = ../libray XLIBSHADEDIR = ../libshade XINCLUDE = -I$(LIBRAYDIR) -I$(LIBSHADEDIR) -I.. $(URTINC) XYFLAGS = -d X XLIBRAY = $(LIBRAYDIR)/libray.a XLIBSHADE = $(LIBSHADEDIR)/libshade.a X X# X# If you are using LINDA, add -DLINDA X# If you are running 'tsnet'-style LINDA, add -DTSNET X# If you are running on a Multimax, add -DMULTIMAX -DSHAREDMEM X# X XCFLAGS = $(CCFLAGS) $(INCLUDE) $(OPTIMIZE) X X# X# C-Linda flags, if appropriate X#CLFLAGS = -linda ts 20000 X# X XSHELL = /bin/sh X XLIBS = $(LIBSHADE) $(LIBRAY) $(URTLIB) X XDRIVE_C = main.c raytrace.c version.c X XDRIVE_H = raytrace.h X XDRIVE_O = $(DRIVE_C:.c=.o) X XHFILES = $(DRIVE_H) X XCFILES = $(DRIVE_C) X XSHFILES = Makefile.SH X XOBJ = $(DRIVE_O) X XDEPENDSRC = $(DRIVE_C) X X# X# Change $(CC) below to $(CLC) if using Linda. X# Xrayshade: $(OBJ) $(LIBS) X $(CC) $(OPTIMIZE) -o rayshade $(OBJ) $(LIBS) $(LDFLAGS) X X# X# Uncomment the following rule if using Linda. X# X#raytrace.lo: raytrace.cl X# $(CLC) $(INCLUDE) $(LCFLAGS) -c raytrace.cl X X# X# End of configuration section X# Xinstall: rayshade X mv rayshade $(BINDIR)/rayshade X Xclean: X rm -f $(OBJ) core X Xrealclean: X rm -f $(OBJ) core y.tab.h X rm -f *.orig Makefile X Xlint: X lint $(CFLAGS) -x $(CFILES) -lm X Xtags: X ctags -t $(CFILES) X Xdepend: X (sed '/^# DO NOT DELETE THIS LINE/q' Makefile && \ X $(MKDEP) $(DEPENDSRC) | sed 's/: \.\//: /; /\/usr\/include/d' \ X ) >Makefile.new X cp Makefile Makefile.bak X cp Makefile.new Makefile X rm -f Makefile.new X X X# DO NOT DELETE THIS LINE X!NO!SUBS! Xchmod 755 Makefile X$eunicefix Makefile END_OF_FILE if test 2719 -ne `wc -c <'rayshade/Makefile.SH'`; then echo shar: \"'rayshade/Makefile.SH'\" unpacked with wrong size! fi chmod +x 'rayshade/Makefile.SH' # end of 'rayshade/Makefile.SH' fi if test -f 'rayview/Makefile.SH' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'rayview/Makefile.SH'\" else echo shar: Extracting \"'rayview/Makefile.SH'\" \(2878 characters\) sed "s/^X//" >'rayview/Makefile.SH' <<'END_OF_FILE' Xcase $CONFIG in X'') X if test ! -f config.sh; then X ln ../config.sh . || \ X ln ../../config.sh . || \ X ln ../../../config.sh . || \ X (echo "Can't find config.sh."; exit 1) X fi X . config.sh X ;; Xesac X: This forces SH files to create target in same directory as SH file. X: This is so that make depend always knows where to find SH derivatives. Xcase "$0" in X*/*) cd `expr X$0 : 'X\(.*\)/'` ;; Xesac Xecho "Extracting Makefile (with variable substitutions)" X: This section of the file will have variable substitutions done on it. X: Move anything that needs config subs from !NO!SUBS! section to !GROK!THIS!. X: Protect any dollar signs and backticks that you do not want interpreted X: by putting a backslash in front. You may delete these comments. X$spitshell >Makefile <>Makefile <<'!NO!SUBS!' XLIBRAYDIR = ../libray XLIBSHADEDIR = ../libshade XINCLUDE = -I$(LIBRAYDIR) -I$(LIBSHADEDIR) -I.. XYFLAGS = -d X X# X# If using GL on an SGI machine, use: XGRAPHICSLIBS = -lsphere -lgl_s XSPHERELIB = -DSPHERELIB X X# X# If using GL on an RS6000, use: X#GRAPHICSLIBS = -lgl X#SPHERELIB= X XLIBRAY = $(LIBRAYDIR)/libray.a XLIBSHADE = $(LIBSHADEDIR)/libshade.a X XCFLAGS = $(CCFLAGS) $(SPHERELIB) $(URTINC) $(INCLUDE) $(OPTIMIZE) XSHELL = /bin/sh X X# X# If you have a fast malloc library, use it (e.g., -lmalloc on MIPS machines) X# XLIBS = $(LIBSHADE) $(LIBRAY) $(URTLIB) X XDRIVE_C = main.c glmethods.c spheregen.c version.c X XDRIVE_O = $(DRIVE_C:.c=.o) X XCFILES = $(DRIVE_C) X XSHFILES = Makefile.SH X XOBJ = $(DRIVE_O) X XDEPENDSRC = $(DRIVE_C) X X# X# Change $(CC) below to $(LCC) if using Linda. X# Xrayview: $(OBJ) $(LIBS) X $(CC) $(OPTIMIZE) -o rayview $(OBJ) $(GRAPHICSLIBS) $(LIBS) $(LDFLAGS) X X# X# Uncomment the following rule if using Linda. X# X#raytrace.lo: raytrace.cl X# $(LCC) $(CFLAGS) -c raytrace.cl X X# X# End of configuration section X# Xinstall: rayview X mv rayview $(BINDIR)/rayview X Xclean: X rm -f $(OBJ) core X Xrealclean: X rm -f $(OBJ) core y.tab.h X rm -f *.orig Makefile X Xlint: X lint $(CFLAGS) -x $(CFILES) -lm X Xtags: X ctags -t $(CFILES) X Xdepend: X (sed '/^# DO NOT DELETE THIS LINE/q' Makefile && \ X $(MKDEP) $(DEPENDSRC) | sed 's/: \.\//: /; /\/usr\/include/d' \ X ) >Makefile.new X cp Makefile Makefile.bak X cp Makefile.new Makefile X rm -f Makefile.new X X X# DO NOT DELETE THIS LINE X!NO!SUBS! Xchmod 755 Makefile X$eunicefix Makefile END_OF_FILE if test 2878 -ne `wc -c <'rayview/Makefile.SH'`; then echo shar: \"'rayview/Makefile.SH'\" unpacked with wrong size! fi chmod +x 'rayview/Makefile.SH' # end of 'rayview/Makefile.SH' fi echo shar: End of archive 6 \(of 19\). cp /dev/null ark6isdone MISSING="" for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 ; do if test ! -f ark${I}isdone ; then MISSING="${MISSING} ${I}" fi done if test "${MISSING}" = "" ; then echo You have unpacked all 19 archives. rm -f ark[1-9]isdone ark[1-9][0-9]isdone else echo You still need to unpack the following archives: echo " " ${MISSING} fi ## End of shell archive. exit 0