v21i017: A ray tracing program, Patch2
Rich Salz
rsalz at uunet.uu.net
Thu Feb 8 07:53:46 AEST 1990
Submitted-by: Craig Kolb <craig at weedeater.math.yale.edu>
Posting-number: Volume 21, Issue 17
Archive-name: rayshade/patch2
System: rayshade version 3.0
Patch #: 2
Priority: MEDIUM
Subject: New depth of field code.
Subject: Minor changes to texturing functions.
Subject: Changed direction of rendering when NORLE is defined.
Subject: General documentation cleanup.
Subject: New -F option, reporting of total CPU & split times.
Subject: Added handling of cpp-generated '#n "filename"' lines.
Subject: Removed #include handling.
Subject: Suggest using cpp to process input files.
Subject: Improved error/warning message reporting.
Subject: Renamed utime and stime to avoid name clashes.
Description:
Cleaned up, improved, and expanded documentation.
In particular, the height field documentation is a bit more
complete, the handling of colormaps is more fully explained,
and low-altitude mist is now documented.
Added new depth of field code, courtesy of Rodney G. Bogart.
See documentation of the "aperture" and "focaldist" keywords for
details.
Removed hard coded constants in calculation of ambient
component in several textures. In all textures, computed
color values are now used to scale a surface's ambient and diffuse
colors.
When NORLE is defined, images will now be rendered top-to-bottom
to provide complete compatibility with the output of Mark
VandeWettering's "mtv" ray tracer.
Rayshade no longer processes #include directives. Instead, you
are encouraged to make use of cpp (the C pre-processor) to aid
in the writing of input files. Rayshade will make use of
cpp-generated line numbering to perform reasonable error reporting.
The example input file Examples/planet.ray shows how one might
use cpp to one's advantage.
A new '-F' option can be used to set the frequency, in lines,
of status reports. When in Verbose mode, rayshade will now
include the total and split CPU times with each status report.
The format of error and warning messages should now be relatively
standard.
Renamed utime and stime variables to avoid clashing with the
functions of the same name.
The source comes a bit closer to passing lint.
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 <thisarticle".
If you don't have the patch program, apply the following by hand,
or get patch (version 2.0, latest patchlevel).
After patching:
Do *NOT* recompile. Apply patch #3 immediately.
If patch indicates that patchlevel is the wrong version, you may need
to apply one or more previous patches, or the patch may already
have been applied. See the patchlevel.h file to find out what has or
has not been applied. In any event, don't continue with the patch.
Index: src/patchlevel.h
Prereq: 1
1c1
< #define PATCHLEVEL 1
---
> #define PATCHLEVEL 2
Index: Changes
*** Changes.old Thu Dec 7 23:18:29 1989
--- Changes Thu Dec 7 23:18:29 1989
***************
*** 1,3 ****
--- 1,34 ----
+ Patch #2/3:
+ -----------
+
+ Added depth of field code, courtesy of Rodney G. Bogart.
+ Added -F option to allow selection of frequency of status reports.
+ Added reporting of total and split CPU times during verbose status reports.
+ Removed hard-coded constants in several of the textures.
+ All textures that use colormaps now use the computed colormap entry
+ to scale the ambient and diffuse components of a surface's color.
+ Documented low-altitude mist.
+ General cleanup of documentation.
+ If NORLE is defined, images will be rendered top-to-bottom
+ to be compatible with the output of Mark VandeWettering's ray tracer.
+
+ Patch #1:
+ ---------
+
+ Corrected computation of field of view when in Stereo mode.
+ Atmospheric effects are now applied to background rays.
+ Statistics are returned to supervisor and reported when using Linda.
+ Created atmosphere.h to facilitate addition of new atmospheric effects.
+ Renamed rotate(), translate() and scale() to avoid name clashes when
+ linking with external libraries.
+ Updated Linda syntax.
+ Fixed typos in code comments in hf.c.
+ Added -w option.
+
+ ---------
+
+ Version 3.0:
+
Bugfixes
--------
***************
*** 28,34 ****
Merged int_grid() and DDA().
Added "samples", "jittered", "cutoff", "contrast" and "adaptive" keywords.
Flat-shaded triangles now require less storage space.
! Shadow caching is now the default.
The number of shadow cache hits are reported.
Shadow cache hits are counted as "shadow rays".
Shadow hits are counted as "intersecting rays".
--- 59,65 ----
Merged int_grid() and DDA().
Added "samples", "jittered", "cutoff", "contrast" and "adaptive" keywords.
Flat-shaded triangles now require less storage space.
! Shadow cacheing is now the default.
The number of shadow cache hits are reported.
Shadow cache hits are counted as "shadow rays".
Shadow hits are counted as "intersecting rays".
Index: README
*** README.old Thu Dec 7 23:18:43 1989
--- README Thu Dec 7 23:18:45 1989
***************
*** 1,11 ****
! This is version 3.0 of rayshade, a raytracing program. Rayshade reads
a multi-line ASCII file describing a scene to be rendered and produces
! a Utah Raster RLE format file of the raytraced image.
Rayshade features:
! Eight types of primitives (box, cone, cylinder, height field,
! polygon, sphere, superquadric, flat- and Phong-shaded triangle)
Composite objects
--- 1,11 ----
! This is version 3.0 of rayshade, a ray tracing program. Rayshade reads
a multi-line ASCII file describing a scene to be rendered and produces
! a Utah Raster RLE format file of the ray-traced image.
Rayshade features:
! Nine types of primitives (box, cone, cylinder, height field,
! plane, polygon, sphere, superquadric, flat- and Phong-shaded triangle)
Composite objects
***************
*** 48,56 ****
formats.
If you do not want to or cannot use the Utah Raster toolkit, compile-time
! switches are provided to create image files using a generic format very
! similar to that used by Mark VandeWettering's raytracer. See the Makefile
! and src/outputp.c for details.
The directory "src" contains the source to rayshade. To compile, edit the
Makefile in that directory and change include file and library paths and set
--- 48,56 ----
formats.
If you do not want to or cannot use the Utah Raster toolkit, compile-time
! switches are provided to create image files using a generic format
! identical to that used by Mark VandeWettering's "mtv" ray tracer. See the
! Makefile and src/outputp.c for details.
The directory "src" contains the source to rayshade. To compile, edit the
Makefile in that directory and change include file and library paths and set
***************
*** 58,64 ****
software configuration.
The file doc/rayshade.1 contains a brief manual page which covers most things
! a casual user will need to know in order to produce raytraced images.
A tutorial on adding new textures on rayshade is included in doc/texture.ms.
A similar document on adding new primitives to rayshade is in
doc/primitive.ms. Unfortunately, there is as yet no technical documentation.
--- 58,64 ----
software configuration.
The file doc/rayshade.1 contains a brief manual page which covers most things
! a casual user will need to know in order to produce ray-traced images.
A tutorial on adding new textures on rayshade is included in doc/texture.ms.
A similar document on adding new primitives to rayshade is in
doc/primitive.ms. Unfortunately, there is as yet no technical documentation.
***************
*** 70,77 ****
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
! raytracers. It was meant to be reasonably fast, portable, and easy to
modify. It has some nice features which allow you to produce
pretty pictures, but there are countless extensions, modifications,
and improvements which could be made. There are many routines which may be
--- 70,83 ----
several of the databases, you will need to tweak the data a bit to achieve
optimal runtimes. See nff2shade.awk for details.
+ As of patch #2, rayshade no longer processes #include directives in the
+ input file. Instead, you are encouraged to make use of cpp in the
+ design of your input files. Rayshade will use cpp-generated lines
+ of the form '#n "filename"' to perform meaningful error reporting.
+ See Examples/planet.ray for more 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
modify. It has some nice features which allow you to produce
pretty pictures, but there are countless extensions, modifications,
and improvements which could be made. There are many routines which may be
***************
*** 79,85 ****
improvements and projects see "TODO". You are encouraged to modify the
source code left and right.
! Rayshade had its start as an "introductory" public domain raytracer written
by Roman Kuchkuda. During 1987-88 the first version of rayshade was written
by Craig Kolb, David P. Dobkin (the original cylinder, cone and extinct torus-
tracing code), and David C. Hoffman (the original octree code). Craig Kolb
--- 85,91 ----
improvements and projects see "TODO". You are encouraged to modify the
source code left and right.
! Rayshade had its start as an "introductory" public domain ray tracer written
by Roman Kuchkuda. During 1987-88 the first version of rayshade was written
by Craig Kolb, David P. Dobkin (the original cylinder, cone and extinct torus-
tracing code), and David C. Hoffman (the original octree code). Craig Kolb
***************
*** 93,99 ****
comments, and willingness to be on the Front Lines. Thanks also to Roman
Kuchkuda for providing a base upon which to build. Special thanks to Robert
Skinner for providing the Noise(), DNoise(), and other texturing functions
! and allowing them to be redistributed.
If you find any bugs, make any useful extensions, have a nice input
file, port rayshade to a new environment, or need assistance understanding a
--- 99,106 ----
comments, and willingness to be on the Front Lines. Thanks also to Roman
Kuchkuda for providing a base upon which to build. Special thanks to Robert
Skinner for providing the Noise(), DNoise(), and other texturing functions
! and allowing them to be redistributed. Thanks also to Rodney G. Bogart for
! providing the depth of field code.
If you find any bugs, make any useful extensions, have a nice input
file, port rayshade to a new environment, or need assistance understanding a
***************
*** 100,106 ****
particularly braindamaged section of code, please let me know. I can be most
easily reached by email.
! Craig Kolb 10/27/89
kolb at yale.edu
Yale University Dept. of Mathematics
--- 107,113 ----
particularly braindamaged section of code, please let me know. I can be most
easily reached by email.
! Craig Kolb 7 Dec 89
kolb at yale.edu
Yale University Dept. of Mathematics
Index: src/box.c
*** src/box.c.old Thu Dec 7 23:19:17 1989
--- src/box.c Thu Dec 7 23:19:19 1989
***************
*** 18,26 ****
* name of the person performing the modification, the date of modification,
* and the reason for such modification.
*
! * $Id: box.c,v 3.0 89/10/27 02:05:47 craig Exp $
*
* $Log: box.c,v $
* Revision 3.0 89/10/27 02:05:47 craig
* Baseline for first official release.
*
--- 18,29 ----
* name of the person performing the modification, the date of modification,
* and the reason for such modification.
*
! * $Id: box.c,v 3.0.1.1 89/12/06 16:33:48 craig Exp $
*
* $Log: box.c,v $
+ * Revision 3.0.1.1 89/12/06 16:33:48 craig
+ * patch2: Added calls to new error/warning routines.
+ *
* Revision 3.0 89/10/27 02:05:47 craig
* Baseline for first official release.
*
***************
*** 39,49 ****
Box *box;
Primitive *prim;
Object *newobj;
- extern int Quiet, yylineno;
if (xs < EPSILON || ys < EPSILON || zs < EPSILON) {
! if (!Quiet)
! fprintf(stderr,"Degenerate box (line %d)\n",yylineno);
return (Object *)0;
}
prim = mallocprim();
--- 42,50 ----
Box *box;
Primitive *prim;
Object *newobj;
if (xs < EPSILON || ys < EPSILON || zs < EPSILON) {
! yywarning("Degenerate box.\n");
return (Object *)0;
}
prim = mallocprim();
Index: src/cone.c
*** src/cone.c.old Thu Dec 7 23:19:24 1989
--- src/cone.c Thu Dec 7 23:19:25 1989
***************
*** 18,26 ****
* name of the person performing the modification, the date of modification,
* and the reason for such modification.
*
! * $Id: cone.c,v 3.0.1.1 89/11/18 14:08:09 craig Exp Locker: craig $
*
* $Log: cone.c,v $
* Revision 3.0.1.1 89/11/18 14:08:09 craig
* patch1: Changes to reflect new names of transformation routines.
*
--- 18,29 ----
* name of the person performing the modification, the date of modification,
* and the reason for such modification.
*
! * $Id: cone.c,v 3.0.1.2 89/12/06 16:33:44 craig Exp $
*
* $Log: cone.c,v $
+ * Revision 3.0.1.2 89/12/06 16:33:44 craig
+ * patch2: Added calls to new error/warning routines.
+ *
* Revision 3.0.1.1 89/11/18 14:08:09 craig
* patch1: Changes to reflect new names of transformation routines.
*
***************
*** 44,50 ****
Cone *cone;
Primitive *prim;
Object *newobj;
- extern int yylineno, Quiet;
double len, dtmp;
Vector axis, base, tmp;
--- 47,52 ----
***************
*** 96,104 ****
vecsub(*ax, *cent, &axis);
len = normalize(&axis);
if (len < EPSILON) {
! if (!Quiet)
! fprintf(stderr,"Degenerate cone (line %d).\n",
! yylineno);
free((char *)cone);
free((char *)prim);
free((char *)newobj);
--- 98,104 ----
vecsub(*ax, *cent, &axis);
len = normalize(&axis);
if (len < EPSILON) {
! yywarning("Degenerate cone.\n");
free((char *)cone);
free((char *)prim);
free((char *)newobj);
Index: src/cylinder.c
*** src/cylinder.c.old Thu Dec 7 23:19:30 1989
--- src/cylinder.c Thu Dec 7 23:19:32 1989
***************
*** 18,26 ****
* name of the person performing the modification, the date of modification,
* and the reason for such modification.
*
! * $Id: cylinder.c,v 3.0.1.1 89/11/18 14:07:52 craig Exp Locker: craig $
*
* $Log: cylinder.c,v $
* Revision 3.0.1.1 89/11/18 14:07:52 craig
* patch1: Changes to reflect new names of transformation routines.
*
--- 18,29 ----
* name of the person performing the modification, the date of modification,
* and the reason for such modification.
*
! * $Id: cylinder.c,v 3.0.1.2 89/12/06 16:33:41 craig Exp $
*
* $Log: cylinder.c,v $
+ * Revision 3.0.1.2 89/12/06 16:33:41 craig
+ * patch2: Added calls to new error/warning routines.
+ *
* Revision 3.0.1.1 89/11/18 14:07:52 craig
* patch1: Changes to reflect new names of transformation routines.
*
***************
*** 45,57 ****
Primitive *prim;
Object *newobj;
double len;
- extern int yylineno, Quiet;
Vector axis, dir;
if (r <= 0.) {
! if (!Quiet)
! fprintf(stderr,"Invalid cylinder radius (line %d)\n",
! yylineno);
return (Object *)0;
}
--- 48,57 ----
Primitive *prim;
Object *newobj;
double len;
Vector axis, dir;
if (r <= 0.) {
! yywarning("Invalid cylinder radius.\n");
return (Object *)0;
}
***************
*** 68,76 ****
len = normalize(&axis);
if(len < EPSILON) {
! if (!Quiet)
! fprintf(stderr,"Degenerate cylinder (line %d).\n",
! yylineno);
free((char *)cyl);
free((char *)prim);
return (Object *)0;
--- 68,74 ----
len = normalize(&axis);
if(len < EPSILON) {
! yywarning("Degenerate cylinder.\n");
free((char *)cyl);
free((char *)prim);
return (Object *)0;
Index: src/defaults.h
*** src/defaults.h.old Thu Dec 7 23:19:37 1989
--- src/defaults.h Thu Dec 7 23:19:38 1989
***************
*** 18,26 ****
* name of the person performing the modification, the date of modification,
* and the reason for such modification.
*
! * $Id: defaults.h,v 3.0 89/10/27 02:05:49 craig Exp $
*
* $Log: defaults.h,v $
* Revision 3.0 89/10/27 02:05:49 craig
* Baseline for first official release.
*
--- 18,29 ----
* name of the person performing the modification, the date of modification,
* and the reason for such modification.
*
! * $Id: defaults.h,v 3.0.1.1 89/12/02 16:50:42 craig Exp $
*
* $Log: defaults.h,v $
+ * Revision 3.0.1.1 89/12/02 16:50:42 craig
+ * patch2: Added default value for ReportFreq.
+ *
* Revision 3.0 89/10/27 02:05:49 craig
* Baseline for first official release.
*
***************
*** 43,48 ****
--- 46,52 ----
#define UPX 0 /* Up vector */
#define UPY 0
#define UPZ 1
+ #define REPORTFREQ 10 /* Frequency of status report */
#define DEFREDCONT 0.25 /* Default contrast threshold values. */
#define DEFGREENCONT 0.2
Index: src/hf.c
*** src/hf.c.old Thu Dec 7 23:19:44 1989
--- src/hf.c Thu Dec 7 23:19:45 1989
***************
*** 18,26 ****
* name of the person performing the modification, the date of modification,
* and the reason for such modification.
*
! * $Id: hf.c,v 3.0.1.1 89/11/16 20:44:28 craig Exp Locker: craig $
*
* $Log: hf.c,v $
* Revision 3.0.1.1 89/11/16 20:44:28 craig
* patch1: Fixed typos in code comments.
*
--- 18,29 ----
* name of the person performing the modification, the date of modification,
* and the reason for such modification.
*
! * $Id: hf.c,v 3.0.1.2 89/12/06 16:33:23 craig Exp $
*
* $Log: hf.c,v $
+ * Revision 3.0.1.2 89/12/06 16:33:23 craig
+ * patch2: Added calls to new error/warning routines.
+ *
* Revision 3.0.1.1 89/11/16 20:44:28 craig
* patch1: Fixed typos in code comments.
*
***************
*** 57,67 ****
* Used to differentiate between the two triangles used to represent a cell:
* a------d
* |\ |
! * | \TRI1| TRI1 == c-->d-->a-->c
* | \ |
* | \ |
* | \ |
! * |TRI2 \| TRI2 == c-->a-->b-->c
* b------c
*/
#define TRI1 1
--- 60,70 ----
* Used to differentiate between the two triangles used to represent a cell:
* a------d
* |\ |
! * | \TRI2| TRI2 == c-->d-->a-->c
* | \ |
* | \ |
* | \ |
! * |TRI1 \| TRI1 == c-->a-->b-->c
* b------c
*/
#define TRI1 1
***************
*** 93,99 ****
fp = fopen(filename, "r");
if (fp == (FILE *)NULL)
! yyerror("Cannot open heightfield file");
prim = mallocprim();
newobj = new_object(NULL, HF, (char *)prim, (Trans *)NULL);
--- 96,102 ----
fp = fopen(filename, "r");
if (fp == (FILE *)NULL)
! yyerror("Cannot open heightfield file \"%s\".", filename);
prim = mallocprim();
newobj = new_object(NULL, HF, (char *)prim, (Trans *)NULL);
Index: src/input.c
*** src/input.c.old Thu Dec 7 23:19:52 1989
--- src/input.c Thu Dec 7 23:19:53 1989
***************
*** 18,141 ****
* name of the person performing the modification, the date of modification,
* and the reason for such modification.
*
! * $Id: input.c,v 3.0 89/10/27 02:05:51 craig Exp $
*
* $Log: input.c,v $
* Revision 3.0 89/10/27 02:05:51 craig
* Baseline for first official release.
*
*/
#include <stdio.h>
- #ifdef SYSV
- #include <string.h>
- #else
- #ifndef AZTEC_C
- #include <strings.h>
- #else /* AZTEC_C */
-
- getpid()
- {
- return 123;
- }
- #endif
- #endif
- #include "constants.h"
- #include "typedefs.h"
-
- #define INCLUDE_STR "#include "
char *infilename; /* Name of input file. NULL signifies stdin. */
- char tmpname[BUFSIZ]; /* name of temporary file */
- extern FILE *yyin; /* lex/yacc file pointer */
read_input_file()
{
! extern char *infilename;
!
! /*
! * Open temporary file.
! */
! sprintf(tmpname,"%s/raytmp.%d",TMPDIR, getpid());
! yyin = fopen(tmpname, "w");
! if (yyin == (FILE *)NULL) {
! fprintf(stderr,"Cannot write to temp file %s\n",tmpname);
! exit(1);
}
-
- if (!process_file(infilename)) {
- /*
- * Some kind of error occurred -- unlink
- * temporary file and exit.
- */
- fclose(yyin);
- unlink(tmpname);
- exit(1);
- }
- /*
- * File processed okay. Close the file, open it again for
- * reading, and call lex/yacc.
- */
- fclose(yyin);
- yyin = fopen(tmpname, "r");
yyparse();
- /*
- * All done -- unlink temporary file.
- */
- unlink(tmpname);
}
/*
! * Open the named file and copy its contents into the temporary file.
! * If we run across a #include directive, recurse on the desired
! * file. Note that *no checking is performed* -- a file could,
! * for example, include itself. Rayshade will happily go on
! * copying data into the temporary file until it runs out
! * of file pointers (an fopen will fail), or you run out of disk space...
*/
! process_file(filename)
! char *filename;
{
! FILE *fp;
! char buf[BUFSIZ], *name, *np;
! extern int yylineno;
! if (filename == (char *)NULL)
! fp = stdin;
! else {
! fp = fopen(filename, "r");
! if (fp == (FILE *)NULL) {
! fprintf(stderr,"Cannot open %s for reading.\n",filename);
! return FALSE;
! }
! }
! while(fgets(buf, BUFSIZ, fp) != NULL) {
! if (strncmp(buf, INCLUDE_STR, strlen(INCLUDE_STR)) == 0) {
! /*
! * Got an "#include "...
! */
! #ifdef SYSV
! name = strchr(buf, '"');
! np = strrchr(buf, '"');
! #else
! name = index(buf, '"');
! np = rindex(buf, '"');
! #endif
! /*
! * Get name between quotes. If no or
! * one quote, complain.
! */
! if (name == (char *)0 || name == np) {
! fprintf(stderr,"Invalid include directive (line %d)\n", yylineno);
! return FALSE;
! }
! name++;
! *np = (char)NULL;
! if (process_file(name) == FALSE)
! return FALSE;
! } else
! fputs(buf, yyin);
! }
! return TRUE;
}
--- 18,96 ----
* name of the person performing the modification, the date of modification,
* and the reason for such modification.
*
! * $Id: input.c,v 3.0.1.2 89/12/07 22:53:32 craig Exp $
*
* $Log: input.c,v $
+ * Revision 3.0.1.2 89/12/07 22:53:32 craig
+ * patch2: Added comments, lint-related goofiness.
+ *
+ * Revision 3.0.1.1 89/12/06 16:08:43 craig
+ * patch2: Removed #include handling. Added RSmessage(), RSwarning(),
+ * patch2: and RSerror().
+ *
* Revision 3.0 89/10/27 02:05:51 craig
* Baseline for first official release.
*
*/
#include <stdio.h>
char *infilename; /* Name of input file. NULL signifies stdin. */
+ /*
+ * Open input file and call yyparse().
+ */
read_input_file()
{
! extern FILE *yyin; /* lex/yacc file pointer */
! extern char yyfilename[];
! if (infilename == (char *)NULL) {
! yyin = stdin;
! strcpy(yyfilename, "stdin");
! } else {
! yyin = fopen(infilename, "r");
! if (yyin == (FILE *)NULL)
! RSerror("Cannot open %s.\n",infilename);
! strcpy(yyfilename, infilename);
}
yyparse();
}
/*
! * Print message to standard output with format:
! * program_name: message_type: message
*/
! /*VARARGS2*/
! RSmessage(type, str, pat1, pat2, pat3)
! char *type, *str, *pat1, *pat2, *pat3;
{
! extern char *progname;
! fprintf(stderr,"%s: %s: ",progname, type);
! fprintf(stderr, str, pat1, pat2, pat3);
! fflush(stderr);
! }
! /*
! * Issue warning message if not in Quiet mode.
! */
! /*VARARGS1*/
! RSwarning(str, pat1, pat2, pat3)
! char *str, *pat1, *pat2, *pat3;
! {
! extern int Quiet;
!
! if (!Quiet)
! RSmessage("Warning", str, pat1, pat2, pat3);
! }
!
! /*
! * Issue error message and exit.
! */
! /*VARARGS1*/
! RSerror(str, pat1, pat2, pat3)
! char *str, *pat1, *pat2, *pat3;
! {
! RSmessage("Error", str, pat1, pat2, pat3);
! exit(1);
}
Index: src/input_lex.l
*** src/input_lex.l.old Thu Dec 7 23:20:09 1989
--- src/input_lex.l Thu Dec 7 23:20:10 1989
***************
*** 13,19 ****
/* without supplying the source, or without informing the end-user that the */
/* source is available for no extra charge. */
/* */
! /* $Id: input_lex.l,v 3.0 89/10/27 02:05:52 craig Exp $ */
%{
#include <stdio.h>
#ifdef SYSV
--- 13,19 ----
/* without supplying the source, or without informing the end-user that the */
/* source is available for no extra charge. */
/* */
! /* $Id: input_lex.l,v 3.0.1.3 89/12/07 23:00:54 craig Exp $ */
%{
#include <stdio.h>
#ifdef SYSV
***************
*** 33,43 ****
string ({alpha}|"/")({alpha}|{digit}|{special}|"/")*
%p 3000
%%
! " " ;
! \t ;
! \n ;
"/*" {skipcomments();}
adaptive {return(tADAPTIVE);}
background {return(tBACKGROUND);}
blotch {return(tBLOTCH);}
box {return(tBOX);}
--- 33,43 ----
string ({alpha}|"/")({alpha}|{digit}|{special}|"/")*
%p 3000
%%
! [ \t\n] ;
! ^# {handlehash();}
"/*" {skipcomments();}
adaptive {return(tADAPTIVE);}
+ aperture {return(tAPERTURE);}
background {return(tBACKGROUND);}
blotch {return(tBLOTCH);}
box {return(tBOX);}
***************
*** 55,60 ****
--- 55,61 ----
eyep {return(tEYEP);}
fbm {return(tFBM);}
fbmbump {return(tFBMBUMP);}
+ focaldist {return(tFOCALDIST);}
fog {return(tFOG);}
fov {return(tFOV);}
grid {return(tGRID);}
***************
*** 111,115 ****
--- 112,159 ----
if ((c = input()) == '/')
return;
unput(c);
+ }
+ }
+ /*
+ * Deal with ccp-produced lines of the form:
+ * # n "filename"
+ * and
+ * # n
+ * Where filename is the name of the file being processed, and n is
+ * the current line number in that file.
+ */
+ handlehash()
+ {
+ char buf[BUFSIZ];
+ int i;
+ extern int yylineno;
+ extern char yyfilename[];
+
+ /*
+ * Read the entire line into buf.
+ */
+ for (i = 0; (buf[i] = input()) != '\n'; i++)
+ ;
+ unput(buf[i]); /* To make sure consecutive # lines work. */
+ buf[i] = (char)NULL; /* Replace newline with NULL. */
+
+ /*
+ * Complain if the line was not of the form #n "filename"
+ */
+ if ((i = sscanf(buf, "%d \"%[^\"]s\"", &yylineno, yyfilename)) == 0) {
+ yyerror("Unknown '#' control.");
+ exit(1);
+ }
+ if (i == 1) {
+ #ifdef SYSV
+ if (strchr(buf, '"') != (char *)0) {
+ #else
+ if (index(buf, '"') != (char *)0) {
+ #endif
+ /*
+ * Filename was "", which means stdin.
+ */
+ strcpy(yyfilename, "stdin");
+ }
}
}
Index: src/input_yacc.y
*** src/input_yacc.y.old Thu Dec 7 23:20:17 1989
--- src/input_yacc.y Thu Dec 7 23:20:19 1989
***************
*** 17,23 ****
/* name of the person performing the modification, the date of modification,*/
/* and the reason for such modification. */
/* */
! /* $Id: input_yacc.y,v 3.0.1.3 89/11/20 13:05:33 craig Exp Locker: craig $ */
%{
#include <stdio.h>
#include "constants.h"
--- 17,23 ----
/* name of the person performing the modification, the date of modification,*/
/* and the reason for such modification. */
/* */
! /* $Id: input_yacc.y,v 3.0.1.6 89/12/07 22:55:53 craig Exp $ */
%{
#include <stdio.h>
#include "constants.h"
***************
*** 26,33 ****
#include "texture.h"
#include "atmosphere.h"
int Npoints=0, CurXSize, CurYSize, CurZSize;
! Object *LastObj = (Object *)0;
ObjList *CurObj, *ListTmp;
Surface *stmp;
Texture *CurText;
--- 26,34 ----
#include "texture.h"
#include "atmosphere.h"
+ char yyfilename[BUFSIZ];
int Npoints=0, CurXSize, CurYSize, CurZSize;
! Object *LastObj = (Object *)0;
ObjList *CurObj, *ListTmp;
Surface *stmp;
Texture *CurText;
***************
*** 40,46 ****
extern int ResolutionSet, ContrastSet, SamplesSet, CutoffSet;
extern int AdaptiveSet, JitteredSet;
extern double hfov, vfov, RedContrast, GreenContrast, BlueContrast;
! extern double TreeCutoff;
extern Vector eyep, lookp, up;
extern char outfilename[];
extern Color background;
--- 41,47 ----
extern int ResolutionSet, ContrastSet, SamplesSet, CutoffSet;
extern int AdaptiveSet, JitteredSet;
extern double hfov, vfov, RedContrast, GreenContrast, BlueContrast;
! extern double TreeCutoff, aperture, focaldist;
extern Vector eyep, lookp, up;
extern char outfilename[];
extern Color background;
***************
*** 60,67 ****
%token <i> tINT
%token <d> tFLOAT
%token <c> tSTRING
! %token tADAPTIVE tBACKGROUND tBLOTCH tBOX tBUMP tCONE tCYL tDIRECTIONAL
! %token tENDDEF tEXTENDED tEYEP tFBM tFBMBUMP tFOG tFOV tGRID
%token tHEIGHTFIELD tJITTERED tLIGHT tLIST tLOOKP tMARBLE tMAXDEPTH tMIST
%token tOBJECT tOUTFILE
%token tPLANE tPOINT tPOLY tROTATE tSAMPLES
--- 61,69 ----
%token <i> tINT
%token <d> tFLOAT
%token <c> tSTRING
! %token tADAPTIVE tAPERTURE
! %token tBACKGROUND tBLOTCH tBOX tBUMP tCONE tCYL tDIRECTIONAL
! %token tENDDEF tEXTENDED tEYEP tFBM tFBMBUMP tFOCALDIST tFOG tFOV tGRID
%token tHEIGHTFIELD tJITTERED tLIGHT tLIST tLOOKP tMARBLE tMAXDEPTH tMIST
%token tOBJECT tOUTFILE
%token tPLANE tPOINT tPOLY tROTATE tSAMPLES
***************
*** 82,87 ****
--- 84,91 ----
| Up
| Fov
| Screen
+ | Aperture
+ | Focaldist
| Maxdepth
| Samples
| Jittered
***************
*** 198,205 ****
*/
LastObj = (Object *)NULL;
if (CurObj->data->data == (char *)0) {
! fprintf(stderr,"Warning: null object defined");
! fprintf(stderr," (line %d)\n",yylineno);
} else {
if (CurObj->data->type == GRID) {
list2grid(CurObj->data, CurXSize,
--- 202,209 ----
*/
LastObj = (Object *)NULL;
if (CurObj->data->data == (char *)0) {
! yywarning("Null object \"%s\" defined.\n",
! CurObj->data->name);
} else {
if (CurObj->data->type == GRID) {
list2grid(CurObj->data, CurXSize,
***************
*** 471,476 ****
--- 475,490 ----
}
}
;
+ Aperture : tAPERTURE Fnumber
+ {
+ aperture = $2;
+ }
+ ;
+ Focaldist : tFOCALDIST Fnumber
+ {
+ focaldist = $2;
+ }
+ ;
Maxdepth : tMAXDEPTH tINT
{
maxlevel = $2;
***************
*** 505,511 ****
Lightdef : tLIGHT Fnumber
{
if (nlight == LIGHTS)
! yyerror("Too many lights.");
light[nlight].color.r = $2;
light[nlight].color.g = $2;
light[nlight].color.b = $2;
--- 519,525 ----
Lightdef : tLIGHT Fnumber
{
if (nlight == LIGHTS)
! yyerror("Too many lights.\n");
light[nlight].color.r = $2;
light[nlight].color.g = $2;
light[nlight].color.b = $2;
***************
*** 626,633 ****
Outfile : tOUTFILE String
{
if (*outfilename != (char)NULL)
! fprintf(stderr,"Ignoring output name \"%s\"\n",
! $2);
else
strcpy(outfilename, $2);
}
--- 640,647 ----
Outfile : tOUTFILE String
{
if (*outfilename != (char)NULL)
! yywarning("Ignoring output file name \"%s\".\n",
! $2);
else
strcpy(outfilename, $2);
}
***************
*** 670,682 ****
String : tSTRING
{ $$ = $1;}
%%
! yyerror(s)
! char *s;
{
! extern char tmpname[];
!
! fprintf(stderr,"rayshade: line %d: %s\n", yylineno, s);
! unlink(tmpname);
! exit(2);
}
--- 684,714 ----
String : tSTRING
{ $$ = $1;}
%%
! /*
! * Issue error message containing filename and line number, and exit.
! */
! /*VARARGS1*/
! yyerror(s, pat1, pat2)
! char *s, *pat1, *pat2;
{
! RSmessage("Error", "%s, line %d: ", yyfilename, yylineno);
! fprintf(stderr, s, pat1, pat2);
! fprintf(stderr,"\n"); /* yacc doesn't use newlines on syntax errors */
! exit(1);
}
+ /*
+ * Issue warning message containing filename and line number if not in
+ * Quiet mode.
+ */
+ /*VARARGS1*/
+ yywarning(s, pat1, pat2)
+ char *s, *pat1, *pat2;
+ {
+ extern int Quiet;
+
+ if (!Quiet) {
+ RSmessage("Warning", "%s, line %d: ",yyfilename, yylineno);
+ fprintf(stderr, s, pat1, pat2);
+ }
+ }
Index: src/main.c
*** src/main.c.old Thu Dec 7 23:20:27 1989
--- src/main.c Thu Dec 7 23:20:28 1989
***************
*** 1,5 ****
char rcsid[] =
! "$Id: main.c,v 3.0.1.1 89/11/16 18:28:21 craig Exp Locker: craig $";
/*
* main.c
*
--- 1,5 ----
char rcsid[] =
! "$Id: main.c,v 3.0.1.2 89/12/07 22:54:39 craig Exp $";
/*
* main.c
*
***************
*** 21,26 ****
--- 21,29 ----
* and the reason for such modification.
*
* $Log: main.c,v $
+ * Revision 3.0.1.2 89/12/07 22:54:39 craig
+ * patch2: Renamed utime and stime to avoid name clashes.
+ *
* Revision 3.0.1.1 89/11/16 18:28:21 craig
* patch1: Statistics are now reported in Linda implementation.
*
***************
*** 52,58 ****
BVTests, /* # of bounding volume tests. */
SuperSampled; /* # of supersampled pixels. */
double ftmp; /* Used by fabs() macro. */
! double utime, stime; /* user, system CPU time */
FILE *fstats; /* Statistics file */
/*
--- 55,61 ----
BVTests, /* # of bounding volume tests. */
SuperSampled; /* # of supersampled pixels. */
double ftmp; /* Used by fabs() macro. */
! double Utime, Stime; /* user, system CPU time */
FILE *fstats; /* Statistics file */
/*
***************
*** 106,114 ****
if (Verbose)
fprintf(fstats,"Setting up voxels...\n");
SetupWorld();
! get_cpu_time(&utime, &stime);
fprintf(fstats,"Preprocessing time:\t");
! fprintf(fstats,"%2.2lfu %2.2lfs\n",utime, stime);
fprintf(fstats,"Starting trace.\n");
fflush(fstats);
/*
--- 109,117 ----
if (Verbose)
fprintf(fstats,"Setting up voxels...\n");
SetupWorld();
! get_cpu_time(&Utime, &Stime);
fprintf(fstats,"Preprocessing time:\t");
! fprintf(fstats,"%2.2lfu %2.2lfs\n",Utime, Stime);
fprintf(fstats,"Starting trace.\n");
fflush(fstats);
/*
***************
*** 120,126 ****
*/
endpic();
#ifndef LINDA
! get_cpu_time(&utime, &stime);
#endif
TotalRays = EyeRays + ShadowRays + ReflectRays + RefractRays;
--- 123,129 ----
*/
endpic();
#ifndef LINDA
! get_cpu_time(&Utime, &Stime);
#endif
TotalRays = EyeRays + ShadowRays + ReflectRays + RefractRays;
***************
*** 153,179 ****
#else
fprintf(fstats,"Total CPU time (sec):\t\t");
#endif
! fprintf(fstats,"%2.2lf (%2.2lfu + %2.2lfs)\n",utime+stime, utime, stime);
if (TotalRays != 0.)
fprintf(fstats,"Seconds / ray:\t\t\t%4.4lf\n",
! (utime + stime) / (double)TotalRays);
if (HitRays != 0.)
fprintf(fstats, "Seconds / intersecting ray:\t%4.4lf\n",
! (utime + stime) / (double)HitRays);
PrintMemoryStats();
exit(0);
}
#ifdef SYSV
! get_cpu_time(utime, stime)
! double *utime, *stime;
{
struct tms time;
long times();
(void)times(&time);
! *utime = (double)time.tms_utime / (double)HZ;
! *stime = (double)time.tms_stime / (double)HZ;
}
#else
#ifdef AZTEC_C
--- 156,182 ----
#else
fprintf(fstats,"Total CPU time (sec):\t\t");
#endif
! fprintf(fstats,"%2.2lf (%2.2lfu + %2.2lfs)\n",Utime+Stime, Utime, Stime);
if (TotalRays != 0.)
fprintf(fstats,"Seconds / ray:\t\t\t%4.4lf\n",
! (Utime + Stime) / (double)TotalRays);
if (HitRays != 0.)
fprintf(fstats, "Seconds / intersecting ray:\t%4.4lf\n",
! (Utime + Stime) / (double)HitRays);
PrintMemoryStats();
exit(0);
}
#ifdef SYSV
! get_cpu_time(usertime, systime)
! double *usertime, *systime;
{
struct tms time;
long times();
(void)times(&time);
! *usertime = (double)time.tms_utime / (double)HZ;
! *systime = (double)time.tms_stime / (double)HZ;
}
#else
#ifdef AZTEC_C
***************
*** 181,196 ****
{
}
#else /* !SYSV && !AZTEC_C */
! get_cpu_time(utime, stime)
! double *utime, *stime;
{
struct rusage usage;
getrusage(RUSAGE_SELF, &usage);
! *utime = (double)usage.ru_utime.tv_sec +
(double)usage.ru_utime.tv_usec / 1000000.;
! *stime = (double)usage.ru_stime.tv_sec +
(double)usage.ru_stime.tv_usec / 1000000.;
}
#endif
--- 184,199 ----
{
}
#else /* !SYSV && !AZTEC_C */
! get_cpu_time(usertime, systime)
! double *usertime, *systime;
{
struct rusage usage;
getrusage(RUSAGE_SELF, &usage);
! *usertime = (double)usage.ru_utime.tv_sec +
(double)usage.ru_utime.tv_usec / 1000000.;
! *systime = (double)usage.ru_stime.tv_sec +
(double)usage.ru_stime.tv_usec / 1000000.;
}
#endif
Index: src/memory.c
*** src/memory.c.old Thu Dec 7 23:20:32 1989
--- src/memory.c Thu Dec 7 23:20:33 1989
***************
*** 18,26 ****
* name of the person performing the modification, the date of modification,
* and the reason for such modification.
*
! * $Id: memory.c,v 3.0 89/10/27 02:05:56 craig Exp $
*
* $Log: memory.c,v $
* Revision 3.0 89/10/27 02:05:56 craig
* Baseline for first official release.
*
--- 18,29 ----
* name of the person performing the modification, the date of modification,
* and the reason for such modification.
*
! * $Id: memory.c,v 3.0.1.1 89/12/06 16:33:59 craig Exp $
*
* $Log: memory.c,v $
+ * Revision 3.0.1.1 89/12/06 16:33:59 craig
+ * patch2: Added calls to new error/warning routines.
+ *
* Revision 3.0 89/10/27 02:05:56 craig
* Baseline for first official release.
*
***************
*** 40,49 ****
TotalAllocated += bytes;
res = malloc(bytes);
! if (res == (char *)0) {
! fprintf(stderr,"Out of memory trying to allocate %d bytes.\n");
! exit(0);
! }
return res;
}
--- 43,50 ----
TotalAllocated += bytes;
res = malloc(bytes);
! if (res == (char *)0)
! RSerror("Out of memory trying to allocate %d bytes.\n",bytes);
return res;
}
Index: src/object.c
*** src/object.c.old Thu Dec 7 23:20:38 1989
--- src/object.c Thu Dec 7 23:20:39 1989
***************
*** 18,26 ****
* name of the person performing the modification, the date of modification,
* and the reason for such modification.
*
! * $Id: object.c,v 3.0 89/10/27 02:05:58 craig Exp $
*
* $Log: object.c,v $
* Revision 3.0 89/10/27 02:05:58 craig
* Baseline for first official release.
*
--- 18,29 ----
* name of the person performing the modification, the date of modification,
* and the reason for such modification.
*
! * $Id: object.c,v 3.0.1.1 89/12/06 16:33:20 craig Exp $
*
* $Log: object.c,v $
+ * Revision 3.0.1.1 89/12/06 16:33:20 craig
+ * patch2: Added calls to new error/warning routines.
+ *
* Revision 3.0 89/10/27 02:05:58 craig
* Baseline for first official release.
*
***************
*** 83,92 ****
int i;
child = get_object_named(name);
! if (child == (Object *)0) {
! fprintf(stderr,"There is no object named \"%s\".\n",name);
! exit(1);
! }
/*
* Create new object that points to child
* and add to 'parent' list.
--- 86,93 ----
int i;
child = get_object_named(name);
! if (child == (Object *)0)
! yyerror("There is no object named \"%s\".", name);
/*
* Create new object that points to child
* and add to 'parent' list.
Index: src/outputp.c
*** src/outputp.c.old Thu Dec 7 23:20:43 1989
--- src/outputp.c Thu Dec 7 23:20:43 1989
***************
*** 18,26 ****
* name of the person performing the modification, the date of modification,
* and the reason for such modification.
*
! * $Id: outputp.c,v 3.0 89/10/27 02:05:58 craig Exp $
*
* $Log: outputp.c,v $
* Revision 3.0 89/10/27 02:05:58 craig
* Baseline for first official release.
*
--- 18,29 ----
* name of the person performing the modification, the date of modification,
* and the reason for such modification.
*
! * $Id: outputp.c,v 3.0.1.1 89/12/06 16:33:17 craig Exp $
*
* $Log: outputp.c,v $
+ * Revision 3.0.1.1 89/12/06 16:33:17 craig
+ * patch2: Added calls to new error/warning routines.
+ *
* Revision 3.0 89/10/27 02:05:58 craig
* Baseline for first official release.
*
***************
*** 73,83 ****
imgfile = fopen(outfilename, "r+");
} else
imgfile = fopen(outfilename, "w");
! if (imgfile == (FILE *)NULL) {
! fprintf(stderr,"Cannot open %s for writing.\n",
! outfilename);
! exit(2);
! }
} else
imgfile = stdout;
sv_globals.svfb_fd = imgfile;
--- 76,83 ----
imgfile = fopen(outfilename, "r+");
} else
imgfile = fopen(outfilename, "w");
! if (imgfile == (FILE *)NULL)
! yyerror("Cannot open %s for writing.", outfilename);
} else
imgfile = stdout;
sv_globals.svfb_fd = imgfile;
***************
*** 145,155 ****
imgfile = fopen(outfilename, "a");
else
imgfile = fopen(outfilename, "w");
! if (imgfile == (FILE *)NULL) {
! fprintf(stderr,"Cannot open %s for writing.\n",
! outfilename);
! exit(2);
! }
} else
imgfile = stdout;
--- 145,152 ----
imgfile = fopen(outfilename, "a");
else
imgfile = fopen(outfilename, "w");
! if (imgfile == (FILE *)NULL)
! RSerror("Cannot open %s for writing.", outfilename);
} else
imgfile = stdout;
Index: src/plane.c
*** src/plane.c.old Thu Dec 7 23:20:47 1989
--- src/plane.c Thu Dec 7 23:20:48 1989
***************
*** 18,26 ****
* name of the person performing the modification, the date of modification,
* and the reason for such modification.
*
! * $Id: plane.c,v 3.0 89/10/27 02:05:59 craig Exp $
*
* $Log: plane.c,v $
* Revision 3.0 89/10/27 02:05:59 craig
* Baseline for first official release.
*
--- 18,29 ----
* name of the person performing the modification, the date of modification,
* and the reason for such modification.
*
! * $Id: plane.c,v 3.0.1.1 89/12/06 16:34:03 craig Exp $
*
* $Log: plane.c,v $
+ * Revision 3.0.1.1 89/12/06 16:34:03 craig
+ * patch2: Added calls to new error/warning routines.
+ *
* Revision 3.0 89/10/27 02:05:59 craig
* Baseline for first official release.
*
***************
*** 42,54 ****
Vector tmpnrm;
Object *newobj;
Primitive *prim;
- extern int Quiet, yylineno;
tmpnrm = *norm;
if (normalize(&tmpnrm) == 0.) {
! if (!Quiet)
! fprintf(stderr, "Degenerate plane normal (line %d)\n",
! yylineno);
return (Object *)0;
}
prim = mallocprim();
--- 45,54 ----
Vector tmpnrm;
Object *newobj;
Primitive *prim;
tmpnrm = *norm;
if (normalize(&tmpnrm) == 0.) {
! yywarning("Degenerate plane normal.");
return (Object *)0;
}
prim = mallocprim();
Index: Examples/planet.ray
*** Examples/planet.ray.old Thu Dec 7 23:18:35 1989
--- Examples/planet.ray Thu Dec 7 23:18:36 1989
***************
*** 1,18 ****
/*
* Example rayshade input file describing a single texture-mapped sphere.
*
* C. Kolb 9/89
*/
screen 256 256
light 1.0 0.9 0.8 directional 1. -1. 1.
eyep 0. -4. 0.
! surface basesurf .16 .15 .14 .8 .75 .7 0 0 0 0 0 0 0
sphere basesurf 1.0 0 0 0
texture fbm 0. /* offset */
1. /* scale */
0.3 /* h */
! 2.0 /* lambda */
! 6 /* octaves */
-.2 /* thresh */
planet.map /* mapname */
! scale 0.7 0.7 0.7
--- 1,44 ----
/*
* Example rayshade input file describing a single texture-mapped sphere.
+ * To use, feed to the C pre-processor, and then to rayshade. Depending
+ * on your system type, this probably means doing something like:
*
+ * cpp thisfile | rayshade <options>
+ * or
+ *
+ * cc -E thisfile | rayshade <options>
+ *
+ * Note that using cpp means that, in addition to macros, you can use #include,
+ * #define, #ifdef, etc. in your input files.
+ *
* C. Kolb 9/89
+ *
+ * $Id: planet.ray,v 3.0.1.2 89/12/06 17:06:49 craig Exp $
+ *
+ * $Log: planet.ray,v $
+ * Revision 3.0.1.2 89/12/06 17:06:49 craig
+ * patch2: Changes to show use of cpp.
+ *
+ * Revision 3.0.1.1 89/11/28 13:57:21 craig
+ * patch2: Decreased intensity of planet's ambient color.
+ *
*/
+ #define EXPAND(x) scale x x x
+
+ #define BLACK 0 0 0
+ #define LACUNARITY 2.
+ #define OCTAVES 6
+
screen 256 256
light 1.0 0.9 0.8 directional 1. -1. 1.
eyep 0. -4. 0.
! surface basesurf .06 .05 .04 .9 .85 .8 BLACK 0 0 0 0
sphere basesurf 1.0 0 0 0
texture fbm 0. /* offset */
1. /* scale */
0.3 /* h */
! LACUNARITY /* lambda */
! OCTAVES /* octaves */
-.2 /* thresh */
planet.map /* mapname */
! EXPAND(0.7)
Index: src/poly.c
*** src/poly.c.old Thu Dec 7 23:20:52 1989
--- src/poly.c Thu Dec 7 23:20:53 1989
***************
*** 18,26 ****
* name of the person performing the modification, the date of modification,
* and the reason for such modification.
*
! * $Id: poly.c,v 3.0 89/10/27 02:05:59 craig Exp $
*
* $Log: poly.c,v $
* Revision 3.0 89/10/27 02:05:59 craig
* Baseline for first official release.
*
--- 18,29 ----
* name of the person performing the modification, the date of modification,
* and the reason for such modification.
*
! * $Id: poly.c,v 3.0.1.1 89/12/06 16:33:38 craig Exp $
*
* $Log: poly.c,v $
+ * Revision 3.0.1.1 89/12/06 16:33:38 craig
+ * patch2: Added calls to new error/warning routines.
+ *
* Revision 3.0 89/10/27 02:05:59 craig
* Baseline for first official release.
*
***************
*** 48,54 ****
Vector edge1, edge2, anorm;
PointList *cur;
int i;
! extern int yylineno, TrashBadPoly, Quiet;
prim = mallocprim();
prim->type = POLY;
--- 51,57 ----
Vector edge1, edge2, anorm;
PointList *cur;
int i;
! extern int TrashBadPoly;
prim = mallocprim();
prim->type = POLY;
***************
*** 101,107 ****
* then we didn't find a valid normal vector -- we
* must have a degenerate polygon of some sort.
*/
! fprintf(stderr,"Degenerate polygon (line %d).\n", yylineno);
free((char *)poly->points);
free((char *)poly);
free((char *)prim);
--- 104,110 ----
* then we didn't find a valid normal vector -- we
* must have a degenerate polygon of some sort.
*/
! yywarning("Degenerate polygon.\n");
free((char *)poly->points);
free((char *)poly);
free((char *)prim);
Index: src/ray_options.c
*** src/ray_options.c.old Thu Dec 7 23:20:57 1989
--- src/ray_options.c Thu Dec 7 23:20:58 1989
***************
*** 18,26 ****
* name of the person performing the modification, the date of modification,
* and the reason for such modification.
*
! * $Id: ray_options.c,v 3.0.1.2 89/11/20 13:02:22 craig Exp Locker: craig $
*
* $Log: ray_options.c,v $
* Revision 3.0.1.2 89/11/20 13:02:22 craig
* patch1: Fixed problems involving overriding values on the command line.
*
--- 18,32 ----
* name of the person performing the modification, the date of modification,
* and the reason for such modification.
*
! * $Id: ray_options.c,v 3.0.1.4 89/12/06 16:33:55 craig Exp $
*
* $Log: ray_options.c,v $
+ * Revision 3.0.1.4 89/12/06 16:33:55 craig
+ * patch2: Added calls to new error/warning routines.
+ *
+ * Revision 3.0.1.3 89/12/02 16:42:16 craig
+ * patch2: Added -F option.
+ *
* Revision 3.0.1.2 89/11/20 13:02:22 craig
* patch1: Fixed problems involving overriding values on the command line.
*
***************
*** 63,68 ****
--- 69,75 ----
extern double RedContrast, GreenContrast, BlueContrast, atof();
extern int pixel_div, JitSamples, Xres, Yres, Jittered, Cache;
extern int Stereo, StartLine, Appending, NoShadows, ClearShadows;
+ extern int ReportFreq;
extern double Separation, TreeCutoff;
extern char outfilename[];
extern FILE *fstats;
***************
*** 90,95 ****
--- 97,108 ----
Separation = atof(argv[1]);
argc--; argv++;
break;
+ case 'F':
+ ReportFreq = atoi(argv[1]);
+ if (ReportFreq < 1)
+ ReportFreq = 1;
+ argv++; argc--;
+ break;
case 'h':
usage();
exit(0);
***************
*** 168,175 ****
}
fstats = fopen(argv[1], "w");
if (fstats == (FILE *)0) {
! fprintf(stderr,"Cannot write to stats file %s\n",argv[0]);
! exit(2);
}
argv++; argc--;
break;
--- 181,188 ----
}
fstats = fopen(argv[1], "w");
if (fstats == (FILE *)0) {
! RSerror("Cannot open stats file %s.\n",
! argv[0]);
}
argv++; argc--;
break;
***************
*** 177,185 ****
case 'W':
Workers = atoi(argv[1]);
if (Workers < 0 || Workers > 17) {
! fprintf(stderr,"%d workers?!?\n",
! Workers);
! exit(3);
}
argv++; argc--;
break;
--- 190,196 ----
case 'W':
Workers = atoi(argv[1]);
if (Workers < 0 || Workers > 17) {
! RSerror("%d workers?\n",workers);
}
argv++; argc--;
break;
***************
*** 188,196 ****
break;
#endif
default:
! fprintf(stderr,"Bad argument: \"%s\"\n",argv[0]);
! usage();
! exit(1);
}
}
--- 199,205 ----
break;
#endif
default:
! RSerror("Bad argument: %s\n", argv[0]);
}
}
***************
*** 211,224 ****
* entire input file is read).
*/
if (Appending && *outfilename == (char)NULL) {
! fprintf(stderr,"The -L option requires the -O option.\n");
! exit(4);
}
if (Stereo && Separation == 0.) {
! fprintf(stderr,"You must specify eye separation (-E) in order ");
! fprintf(stderr,"to enable Stereo mode.\n");
! exit(4);
}
}
--- 220,230 ----
* entire input file is read).
*/
if (Appending && *outfilename == (char)NULL) {
! RSerror("The -L option requires the -O option.\n");
}
if (Stereo && Separation == 0.) {
! RSerror("Stereo mode requires use of -E option.\n");
}
}
***************
*** 229,234 ****
--- 235,241 ----
fprintf(stderr,"\t-C r g b\t(Set contrast threshold (0. - 1.).)\n");
fprintf(stderr,"\t-c \t\t(Trace shadow rays through clear objects.)\n");
fprintf(stderr,"\t-E eye_sep\t(Set eye separation.)\n");
+ fprintf(stderr,"\t-F freq\t\t(Frequency, in lines, of status report.)\n");
fprintf(stderr,"\t-h \t\t(Print this message.)\n");
fprintf(stderr,"\t-j \t\t(Antialias using jittered sampling.)\n");
fprintf(stderr,"\t-L line#\t(Begin rendering at specified line.)\n");
***************
*** 247,251 ****
--- 254,259 ----
fprintf(stderr,"\t-v \t\t(Verbose output.)\n");
#ifdef LINDA
fprintf(stderr,"\t-W workers (Specify number of worker processes.)\n");
+ fprintf(stderr,"\t-w \t\t(Verbose worker output.)\n");
#endif
}
Index: src/triangle.c
*** src/triangle.c.old Thu Dec 7 23:21:47 1989
--- src/triangle.c Thu Dec 7 23:21:48 1989
***************
*** 18,26 ****
* name of the person performing the modification, the date of modification,
* and the reason for such modification.
*
! * $Id: triangle.c,v 3.0 89/10/27 02:06:07 craig Exp $
*
* $Log: triangle.c,v $
* Revision 3.0 89/10/27 02:06:07 craig
* Baseline for first official release.
*
--- 18,29 ----
* name of the person performing the modification, the date of modification,
* and the reason for such modification.
*
! * $Id: triangle.c,v 3.0.1.1 89/12/06 16:33:32 craig Exp $
*
* $Log: triangle.c,v $
+ * Revision 3.0.1.1 89/12/06 16:33:32 craig
+ * patch2: Added calls to new error/warning routines.
+ *
* Revision 3.0 89/10/27 02:06:07 craig
* Baseline for first official release.
*
***************
*** 47,53 ****
Vector vc1, vc2, vc3, ptmp, anorm;
Object *newobj;
double indexval;
- extern int yylineno, Quiet;
prim = mallocprim();
triangle = (Triangle *)Malloc(sizeof(Triangle));
--- 50,55 ----
***************
*** 77,85 ****
rawcrossp(&triangle->nrm, &vc1, &vc2);
ptmp = triangle->nrm;
if (normalize(&ptmp) == 0.) {
! if (!Quiet)
! fprintf(stderr,"Degenerate triangle (line %d).\n",
! yylineno);
free((char *)prim);
free((char *)triangle);
free((char *)newobj);
--- 79,85 ----
rawcrossp(&triangle->nrm, &vc1, &vc2);
ptmp = triangle->nrm;
if (normalize(&ptmp) == 0.) {
! yywarning("Degenerate triangle.\n");
free((char *)prim);
free((char *)triangle);
free((char *)newobj);
Index: doc/texture.ms
*** doc/texture.ms.old Thu Dec 7 23:19:09 1989
--- doc/texture.ms Thu Dec 7 23:19:09 1989
***************
*** 2,10 ****
.\" Brief tutorial on adding textures to rayshade.
.\" Craig Kolb 10/89
.\"
! .\" $Id: texture.ms,v 3.0 89/10/23 16:42:57 craig Exp $
.\"
.\" $Log: texture.ms,v $
.\" Revision 3.0 89/10/23 16:42:57 craig
.\" Baseline for first official release.
.\"
--- 2,14 ----
.\" Brief tutorial on adding textures to rayshade.
.\" Craig Kolb 10/89
.\"
! .\" $Id: texture.ms,v 3.0.1.1 89/11/27 18:49:26 craig Exp $
.\"
.\" $Log: texture.ms,v $
+ .\" Revision 3.0.1.1 89/11/27 18:49:26 craig
+ .\" patch2: Example texture now uses colormap to scale ambient & diffuse
+ .\" patch2: components of surface color.
+ .\"
.\" Revision 3.0 89/10/23 16:42:57 craig
.\" Baseline for first official release.
.\"
***************
*** 99,107 ****
texture will modify the diffuse component of a surface as a function of the
Z component of the point of intersection. If the name of a colormap
is given, an index into
! the colormap is used to a color to be used as the diffuse component the
! surface.
! Otherwise, the diffuse component of the surface is simply scaled.
! To avoid strictly horizontal boundries
between colors when using a colormap, we add a bit of "noise" to the
Z component of the point of intersection. The magnitude and nature of the
--- 103,111 ----
texture will modify the diffuse component of a surface as a function of the
Z component of the point of intersection. If the name of a colormap
is given, an index into
! the colormap is computed and the corresponding color is used to scale
! the ambient and diffuse components of the surface.
! Otherwise, the ambient and diffuse components of the surface are simply scaled.
! To avoid strictly horizontal boundaries
between colors when using a colormap, we add a bit of "noise" to the
Z component of the point of intersection. The magnitude and nature of the
***************
*** 317,329 ****
index = 255;
if (index < 0)
index = 0;
! surf->diff = text->colormap[index];
} else {
/*
* If there's no colormap, simply scale the diffuse
* component.
*/
! surf->diff = ScaleColor(val, surf->diff);
}
}
.D)
--- 321,339 ----
index = 255;
if (index < 0)
index = 0;
! surf->diff.r *= text->colormap[index].r;
! surf->diff.g *= text->colormap[index].g;
! surf->diff.b *= text->colormap[index].b;
! surf->amb.r *= text->colormap[index].r;
! surf->amb.g *= text->colormap[index].g;
! surf->amb.b *= text->colormap[index].b;
} else {
/*
* If there's no colormap, simply scale the diffuse
* component.
*/
! ScaleColor(val, surf->diff, &surf->diff);
! ScaleColor(val, surf->amb, &surf->amb);
}
}
.D)
--
Please send comp.sources.unix-related mail to rsalz at uunet.uu.net.
Use a domain-based address or give alternate paths, or you may lose out.
More information about the Comp.sources.unix
mailing list