home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-07-21 | 53.1 KB | 1,935 lines |
- Newsgroups: comp.sources.misc
- From: Rayshade Construction Co. <rayshade@weedeater.math.YALE.EDU>
- Subject: v21i007: rayshade - A raytracing package for UNIX, Part04/19
- Message-ID: <1991Jul20.043407.11353@sparky.IMD.Sterling.COM>
- X-Md4-Signature: 7b543a14c18501c9a4c88042d53111e6
- Date: Sat, 20 Jul 1991 04:34:07 GMT
- Approved: kent@sparky.imd.sterling.com
-
- Submitted-by: Rayshade Construction Co. <rayshade@weedeater.math.YALE.EDU>
- Posting-number: Volume 21, Issue 7
- Archive-name: rayshade/part04
- Environment: UNIX, !16BIT
-
- #! /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 <file", e.g.. If this archive is complete, you
- # will see the following message at the end:
- # "End of archive 4 (of 19)."
- # Contents: etc/rsconvert/Makefile.SH etc/rsconvert/main.c
- # libray/libcommon/Makefile.SH libray/libcommon/memory.c
- # libray/libcommon/scale.c libray/libcommon/translate.c
- # libray/libimage/Makefile.SH libray/liblight/Makefile.SH
- # libray/liblight/infinite.c libray/liblight/point.c
- # libray/libobj/Makefile.SH libray/libobj/blob.h
- # libray/libobj/grid.h libray/libobj/triangle.h
- # libray/libsurf/Makefile.SH libray/libsurf/fog.c
- # libray/libsurf/mist.c libray/libtext/Makefile.SH
- # libray/libtext/marble.c libray/libtext/sky.c
- # libray/libtext/windy.c libshade/defaults.h raypaint/README
- # rayview/main.c
- # Wrapped by kolb@woody on Wed Jul 17 17:56:43 1991
- PATH=/bin:/usr/bin:/usr/ucb ; export PATH
- if test -f 'etc/rsconvert/Makefile.SH' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'etc/rsconvert/Makefile.SH'\"
- else
- echo shar: Extracting \"'etc/rsconvert/Makefile.SH'\" \(1615 characters\)
- sed "s/^X//" >'etc/rsconvert/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 etc/rsconvert/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 <<!GROK!THIS!
- XOPTIMIZE = $optimize
- XCCFLAGS = $ccflags $large
- XCC = $cc
- XMKDEP = $mkdep
- XYACC = $yacc
- X!GROK!THIS!
- X
- X: In the following dollars and backticks do not need the extra backslash.
- X$spitshell >>Makefile <<'!NO!SUBS!'
- XLIBRAYDIR = ../../libray
- XINCLUDE = -I$(LIBRAYDIR) -I../../
- XCFLAGS = $(CCFLAGS) $(INCLUDE) $(OPTIMIZE)
- XLIBS =
- XYFLAGS = -d
- X
- XCFILES = main.c yacc.c lex.c
- XOBJS = $(CFILES:.c=.o)
- XDEPENDSRC = main.c yacc.y lex.l
- X
- Xrsconvert: $(OBJS)
- X $(CC) $(CFLAGS) -o rsconvert $(OBJS) $(LIBS)
- 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
- Xclean:
- X /bin/rm -f y.tab.h $(OBJS) lex.c
- X
- X# DO NOT DELETE THIS LINE
- X!NO!SUBS!
- Xchmod 755 Makefile
- X$eunicefix Makefile
- END_OF_FILE
- if test 1615 -ne `wc -c <'etc/rsconvert/Makefile.SH'`; then
- echo shar: \"'etc/rsconvert/Makefile.SH'\" unpacked with wrong size!
- fi
- chmod +x 'etc/rsconvert/Makefile.SH'
- # end of 'etc/rsconvert/Makefile.SH'
- fi
- if test -f 'etc/rsconvert/main.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'etc/rsconvert/main.c'\"
- else
- echo shar: Extracting \"'etc/rsconvert/main.c'\" \(1614 characters\)
- sed "s/^X//" >'etc/rsconvert/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 14:29:30 kolb Exp Locker: kolb $
- X *
- X * $Log: main.c,v $
- X * Revision 4.0 91/07/17 14:29:30 kolb
- X * Initial version.
- X *
- X */
- X#include <stdio.h>
- X#ifdef SYSV
- X#include <memory.h>
- X#endif
- X#include "libcommon/common.h"
- X
- Xextern FILE *yyin;
- X
- X#define usage(v) fprintf(stderr,"usage: %s [oldfile]\n",v)
- X
- Xmain(argc, argv)
- Xint argc;
- Xchar **argv;
- X{
- X if (argc > 2) {
- X usage(argv[0]);
- X exit(1);
- X }
- X
- X if (argc == 2) {
- X yyin = fopen(argv[1], "r");
- X if (yyin == (FILE *)NULL) {
- X fprintf(stderr,"Cannot open %s\n",argv[1]);
- X exit(2);
- X }
- X } else
- X yyin = stdin;
- X printf("/* Converted by rsconvert */\n");
- X yyparse();
- X}
- X
- Xchar *
- Xstrsave(s)
- Xchar *s;
- X{
- X extern voidstar Malloc();
- X char *r;
- X
- X r = (char *)Malloc(strlen(s) + 1);
- X strcpy(r, s);
- X return r;
- X}
- X
- Xvoidstar
- XMalloc(n)
- Xunsigned n;
- X{
- X voidstar r;
- X extern voidstar malloc();
- X
- X r = malloc(n);
- X if (r == (voidstar)NULL) {
- X fprintf(stderr,"Out of memory allocating %d bytes.\n");
- X exit(1);
- X }
- X return r;
- X}
- X
- Xvoidstar
- XCalloc(nelem, elen)
- Xunsigned nelem, elen;
- X{
- X voidstar res;
- X
- X res = Malloc(nelem*elen);
- X bzero(res, (int)nelem*elen);
- X return res;
- X}
- END_OF_FILE
- if test 1614 -ne `wc -c <'etc/rsconvert/main.c'`; then
- echo shar: \"'etc/rsconvert/main.c'\" unpacked with wrong size!
- fi
- # end of 'etc/rsconvert/main.c'
- fi
- if test -f 'libray/libcommon/Makefile.SH' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'libray/libcommon/Makefile.SH'\"
- else
- echo shar: Extracting \"'libray/libcommon/Makefile.SH'\" \(1594 characters\)
- sed "s/^X//" >'libray/libcommon/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 libcommon/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 <<!GROK!THIS!
- XOPTIMIZE = $optimize
- XCCFLAGS = $ccflags $large
- XRANLIB = $ranlib
- XCC = $cc
- XMKDEP = $mkdep
- X
- X!GROK!THIS!
- X
- X: In the following dollars and backticks do not need the extra backslash.
- X$spitshell >>Makefile <<'!NO!SUBS!'
- XLIB = ../libray.a
- XINCLUDE = -I../..
- XCFLAGS = $(CCFLAGS) $(INCLUDE) $(OPTIMIZE)
- XSHELL = /bin/sh
- X
- XCFILES = memory.c expr.c transform.c rotate.c sampling.c scale.c translate.c vecmath.c
- XOFILES = $(CFILES:.c=.o)
- X
- X$(LIB): $(OFILES)
- X ar cur $(LIB) $(OFILES)
- X $(RANLIB) $(LIB)
- X
- Xclean:
- X rm -f $(OFILES)
- X
- Xdepend:
- X (sed '/^# DO NOT DELETE THIS LINE/q' Makefile && \
- X $(MKDEP) $(CFILES) | 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# DO NOT DELETE THIS LINE
- X!NO!SUBS!
- Xchmod 755 Makefile
- X$eunicefix Makefile
- END_OF_FILE
- if test 1594 -ne `wc -c <'libray/libcommon/Makefile.SH'`; then
- echo shar: \"'libray/libcommon/Makefile.SH'\" unpacked with wrong size!
- fi
- chmod +x 'libray/libcommon/Makefile.SH'
- # end of 'libray/libcommon/Makefile.SH'
- fi
- if test -f 'libray/libcommon/memory.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'libray/libcommon/memory.c'\"
- else
- echo shar: Extracting \"'libray/libcommon/memory.c'\" \(1646 characters\)
- sed "s/^X//" >'libray/libcommon/memory.c' <<'END_OF_FILE'
- X/*
- X * memory.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: memory.c,v 4.0 91/07/17 14:30:57 kolb Exp Locker: kolb $
- X *
- X * $Log: memory.c,v $
- X * Revision 4.0 91/07/17 14:30:57 kolb
- X * Initial version.
- X *
- X */
- X#ifdef SYSV
- X#include <memory.h>
- X#endif
- X#include "common.h"
- X
- Xunsigned long TotalAllocated;
- X
- Xvoidstar
- XMalloc(bytes)
- Xunsigned bytes;
- X{
- X voidstar res;
- X
- X TotalAllocated += bytes;
- X
- X res = (voidstar)malloc(bytes);
- X if (res == (voidstar)NULL)
- X RLerror(RL_PANIC,
- X "Out of memory trying to allocate %d bytes.\n",bytes);
- X return res;
- X}
- X
- Xvoidstar
- XCalloc(nelem, elen)
- Xunsigned nelem, elen;
- X{
- X voidstar res;
- X
- X res = Malloc(nelem*elen);
- X bzero(res, (int)nelem*elen);
- X return res;
- X}
- X
- Xvoid
- XPrintMemoryStats(fp)
- XFILE *fp;
- X{
- X fprintf(fp,"Total memory allocated:\t\t%lu bytes\n",
- X TotalAllocated);
- X}
- X
- X/*
- X * Allocate space for a string, copy string into space.
- X */
- Xchar *
- Xstrsave(s)
- Xchar *s;
- X{
- X char *tmp;
- X
- X if (s == (char *)NULL)
- X return (char *)NULL;
- X
- X tmp = (char *)Malloc((unsigned)strlen(s) + 1);
- X (void)strcpy(tmp, s);
- X return tmp;
- X}
- X
- X#ifdef MULTIMAX
- X
- Xchar *
- Xshare_calloc(num, siz)
- Xint num;
- Xunsigned int siz;
- X{
- X char *res;
- X
- X res = share_malloc(num*siz);
- X bzero(res, num*siz);
- X return res;
- X}
- X#endif
- END_OF_FILE
- if test 1646 -ne `wc -c <'libray/libcommon/memory.c'`; then
- echo shar: \"'libray/libcommon/memory.c'\" unpacked with wrong size!
- fi
- # end of 'libray/libcommon/memory.c'
- fi
- if test -f 'libray/libcommon/scale.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'libray/libcommon/scale.c'\"
- else
- echo shar: Extracting \"'libray/libcommon/scale.c'\" \(1761 characters\)
- sed "s/^X//" >'libray/libcommon/scale.c' <<'END_OF_FILE'
- X/*
- X * scale.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: scale.c,v 4.0 91/07/17 14:32:08 kolb Exp Locker: kolb $
- X *
- X * $Log: scale.c,v $
- X * Revision 4.0 91/07/17 14:32:08 kolb
- X * Initial version.
- X *
- X */
- X#include "common.h"
- X#include "scale.h"
- X
- XTransMethods *iScaleMethods;
- Xvoid ScaleMatrix();
- X
- XScale *
- XScaleCreate()
- X{
- X Scale *res;
- X
- X res = (Scale *)Malloc(sizeof(Scale));
- X res->x = res->y = res->z = 1.;
- X return res;
- X}
- X
- XTransMethods *
- XScaleMethods()
- X{
- X if (iScaleMethods == (TransMethods *)NULL) {
- X iScaleMethods = (TransMethods *)Malloc(sizeof(TransMethods));
- X iScaleMethods->create = (TransCreateFunc *)ScaleCreate;
- X iScaleMethods->propagate = ScalePropagate;
- X }
- X return iScaleMethods;
- X}
- X
- Xvoid
- XScalePropagate(scale, trans, itrans)
- XScale *scale;
- XRSMatrix *trans, *itrans;
- X{
- X if (equal(scale->x, 0.) || equal(scale->y, 0.) || equal(scale->z, 0.))
- X RLerror(RL_PANIC, "Degenerate scale %g %g %g\n", scale->x, scale->y, scale->z);
- X ScaleMatrix(scale->x, scale->y, scale->z, trans);
- X /*
- X * Build the inverse
- X */
- X MatrixInit(itrans);
- X itrans->matrix[0][0] = 1. / scale->x;
- X itrans->matrix[1][1] = 1. / scale->y;
- X itrans->matrix[2][2] = 1. / scale->z;
- X}
- X
- Xvoid
- XScaleMatrix(x, y, z, mat)
- XFloat x, y, z;
- XRSMatrix *mat;
- X{
- X MatrixInit(mat);
- X mat->matrix[0][0] = x;
- X mat->matrix[1][1] = y;
- X mat->matrix[2][2] = z;
- X}
- END_OF_FILE
- if test 1761 -ne `wc -c <'libray/libcommon/scale.c'`; then
- echo shar: \"'libray/libcommon/scale.c'\" unpacked with wrong size!
- fi
- # end of 'libray/libcommon/scale.c'
- fi
- if test -f 'libray/libcommon/translate.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'libray/libcommon/translate.c'\"
- else
- echo shar: Extracting \"'libray/libcommon/translate.c'\" \(1722 characters\)
- sed "s/^X//" >'libray/libcommon/translate.c' <<'END_OF_FILE'
- X/*
- X * translate.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: translate.c,v 4.0 91/07/17 14:32:42 kolb Exp Locker: kolb $
- X *
- X * $Log: translate.c,v $
- X * Revision 4.0 91/07/17 14:32:42 kolb
- X * Initial version.
- X *
- X */
- X#include "common.h"
- X#include "translate.h"
- X
- XTransMethods *iTranslateMethods;
- Xvoid TranslationMatrix();
- X
- XTranslate *
- XTranslateCreate()
- X{
- X Translate *res;
- X
- X res = (Translate *)Malloc(sizeof(Translate));
- X res->x = res->y = res->z = 0.;
- X return res;
- X}
- X
- XTransMethods *
- XTranslateMethods()
- X{
- X if (iTranslateMethods == (TransMethods *)NULL) {
- X iTranslateMethods = (TransMethods *)Malloc(sizeof(TransMethods));
- X iTranslateMethods->create = (TransCreateFunc *)TranslateCreate;
- X iTranslateMethods->propagate = TranslatePropagate;
- X }
- X return iTranslateMethods;
- X}
- X
- Xvoid
- XTranslatePropagate(translate, trans, itrans)
- XTranslate *translate;
- XRSMatrix *trans, *itrans;
- X{
- X TranslationMatrix(translate->x, translate->y, translate->z, trans);
- X /*
- X * Build the inverse...
- X */
- X MatrixInit(itrans);
- X itrans->translate.x = -translate->x;
- X itrans->translate.y = -translate->y;
- X itrans->translate.z = -translate->z;
- X}
- X
- Xvoid
- XTranslationMatrix(x, y, z, mat)
- XFloat x, y, z;
- XRSMatrix *mat;
- X{
- X MatrixInit(mat);
- X mat->translate.x = x;
- X mat->translate.y = y;
- X mat->translate.z = z;
- X}
- END_OF_FILE
- if test 1722 -ne `wc -c <'libray/libcommon/translate.c'`; then
- echo shar: \"'libray/libcommon/translate.c'\" unpacked with wrong size!
- fi
- # end of 'libray/libcommon/translate.c'
- fi
- if test -f 'libray/libimage/Makefile.SH' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'libray/libimage/Makefile.SH'\"
- else
- echo shar: Extracting \"'libray/libimage/Makefile.SH'\" \(1548 characters\)
- sed "s/^X//" >'libray/libimage/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 libimage/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 <<!GROK!THIS!
- XOPTIMIZE = $optimize
- XCCFLAGS = $ccflags $large
- XRANLIB = $ranlib
- XCC = $cc
- XMKDEP = $mkdep
- XURTINC = $urtinc
- X
- X!GROK!THIS!
- X
- X: In the following dollars and backticks do not need the extra backslash.
- X$spitshell >>Makefile <<'!NO!SUBS!'
- XLIB = ../libray.a
- XINCLUDE = -I.. -I../.. $(URTINC)
- XCFLAGS = $(CCFLAGS) $(INCLUDE) $(OPTIMIZE)
- XSHELL = /bin/sh
- X
- XOFILES = image.o
- XCFILES = image.c
- X
- X
- X$(LIB): $(OFILES)
- X ar cur $(LIB) $(OFILES)
- X $(RANLIB) $(LIB)
- X
- Xclean:
- X rm -f $(OFILES)
- X
- Xdepend:
- X (sed '/^# DO NOT DELETE THIS LINE/q' Makefile && \
- X $(MKDEP) $(CFILES) | 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# DO NOT DELETE THIS LINE
- X!NO!SUBS!
- Xchmod 755 Makefile
- X$eunicefix Makefile
- END_OF_FILE
- if test 1548 -ne `wc -c <'libray/libimage/Makefile.SH'`; then
- echo shar: \"'libray/libimage/Makefile.SH'\" unpacked with wrong size!
- fi
- chmod +x 'libray/libimage/Makefile.SH'
- # end of 'libray/libimage/Makefile.SH'
- fi
- if test -f 'libray/liblight/Makefile.SH' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'libray/liblight/Makefile.SH'\"
- else
- echo shar: Extracting \"'libray/liblight/Makefile.SH'\" \(1585 characters\)
- sed "s/^X//" >'libray/liblight/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 liblight/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 <<!GROK!THIS!
- XOPTIMIZE = $optimize
- XCCFLAGS = $ccflags $large
- XRANLIB = $ranlib
- XCC = $cc
- XMKDEP = $mkdep
- X
- X!GROK!THIS!
- X
- X: In the following dollars and backticks do not need the extra backslash.
- X$spitshell >>Makefile <<'!NO!SUBS!'
- XLIB = ../libray.a
- XINCLUDE = -I.. -I../..
- XCFLAGS = $(CCFLAGS) $(INCLUDE) $(OPTIMIZE)
- XSHELL = /bin/sh
- X
- XCFILES = light.c extended.c infinite.c jittered.c point.c shadow.c spot.c
- XOFILES = $(CFILES:.c=.o)
- X
- X$(LIB): $(OFILES)
- X ar cur $(LIB) $(OFILES)
- X $(RANLIB) $(LIB)
- X
- Xclean:
- X rm -f $(OFILES)
- X
- Xdepend:
- X (sed '/^# DO NOT DELETE THIS LINE/q' Makefile && \
- X $(MKDEP) $(CFILES) | 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# DO NOT DELETE THIS LINE
- X!NO!SUBS!
- Xchmod 755 Makefile
- X$eunicefix Makefile
- END_OF_FILE
- if test 1585 -ne `wc -c <'libray/liblight/Makefile.SH'`; then
- echo shar: \"'libray/liblight/Makefile.SH'\" unpacked with wrong size!
- fi
- chmod +x 'libray/liblight/Makefile.SH'
- # end of 'libray/liblight/Makefile.SH'
- fi
- if test -f 'libray/liblight/infinite.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'libray/liblight/infinite.c'\"
- else
- echo shar: Extracting \"'libray/liblight/infinite.c'\" \(1698 characters\)
- sed "s/^X//" >'libray/liblight/infinite.c' <<'END_OF_FILE'
- X/*
- X * infinite.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: infinite.c,v 4.0 91/07/17 14:34:28 kolb Exp Locker: kolb $
- X *
- X * $Log: infinite.c,v $
- X * Revision 4.0 91/07/17 14:34:28 kolb
- X * Initial version.
- X *
- X */
- X#include "light.h"
- X#include "infinite.h"
- X
- Xstatic LightMethods *iInfMethods = NULL;
- X
- XInfinite *
- XInfiniteCreate(dir)
- XVector *dir;
- X{
- X Infinite *inf;
- X
- X inf = (Infinite *)share_malloc(sizeof(Infinite));
- X inf->dir = *dir;
- X if (VecNormalize(&inf->dir) == 0.) {
- X RLerror(RL_ABORT, "Invalid directional light.\n");
- X return (Infinite *)NULL;
- X }
- X return inf;
- X}
- X
- XLightMethods *
- XInfiniteMethods()
- X{
- X if (iInfMethods == (LightMethods *)NULL) {
- X iInfMethods = LightMethodsCreate();
- X iInfMethods->intens = InfiniteIntens;
- X iInfMethods->dir = InfiniteDirection;
- X }
- X return iInfMethods;
- X}
- X
- Xint
- XInfiniteIntens(inf, lcolor, cache, ray, dist, noshadow, color)
- XInfinite *inf;
- XColor *lcolor, *color;
- XShadowCache *cache;
- XRay *ray;
- XFloat dist;
- Xint noshadow;
- X{
- X return !Shadowed(color, lcolor, cache, ray, dist, noshadow);
- X}
- X
- Xvoid
- XInfiniteDirection(lp, pos, dir, dist)
- XInfinite *lp;
- XVector *pos, *dir;
- XFloat *dist;
- X{
- X *dir = lp->dir;
- X *dist = FAR_AWAY;
- X}
- X
- XInfiniteMethodRegister(meth)
- XUserMethodType meth;
- X{
- X if (iInfMethods)
- X iInfMethods->user = meth;
- X}
- END_OF_FILE
- if test 1698 -ne `wc -c <'libray/liblight/infinite.c'`; then
- echo shar: \"'libray/liblight/infinite.c'\" unpacked with wrong size!
- fi
- # end of 'libray/liblight/infinite.c'
- fi
- if test -f 'libray/liblight/point.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'libray/liblight/point.c'\"
- else
- echo shar: Extracting \"'libray/liblight/point.c'\" \(1655 characters\)
- sed "s/^X//" >'libray/liblight/point.c' <<'END_OF_FILE'
- X/*
- X * point.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: point.c,v 4.0 91/07/17 14:35:20 kolb Exp Locker: kolb $
- X *
- X * $Log: point.c,v $
- X * Revision 4.0 91/07/17 14:35:20 kolb
- X * Initial version.
- X *
- X */
- X#include "light.h"
- X#include "point.h"
- X
- Xstatic LightMethods *iPointMethods = NULL;
- X
- XPointlight *
- XPointCreate(pos)
- XVector *pos;
- X{
- X Pointlight *p;
- X
- X p = (Pointlight *)share_malloc(sizeof(Pointlight));
- X p->pos = *pos;
- X return p;
- X}
- X
- XLightMethods *
- XPointMethods()
- X{
- X if (iPointMethods == (LightMethods *)NULL) {
- X iPointMethods = LightMethodsCreate();
- X iPointMethods->intens = PointIntens;
- X iPointMethods->dir = PointDirection;
- X }
- X return iPointMethods;
- X}
- X
- Xint
- XPointIntens(lp, lcolor, cache, ray, dist, noshadow, color)
- XPointlight *lp;
- XColor *lcolor, *color;
- XShadowCache *cache;
- XRay *ray;
- XFloat dist;
- Xint noshadow;
- X{
- X return !Shadowed(color, lcolor, cache, ray, dist, noshadow);
- X}
- X
- Xvoid
- XPointDirection(lp, pos, dir, dist)
- XPointlight *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
- XPointMethodRegister(meth)
- XUserMethodType meth;
- X{
- X if (iPointMethods)
- X iPointMethods->user = meth;
- X}
- END_OF_FILE
- if test 1655 -ne `wc -c <'libray/liblight/point.c'`; then
- echo shar: \"'libray/liblight/point.c'\" unpacked with wrong size!
- fi
- # end of 'libray/liblight/point.c'
- fi
- if test -f 'libray/libobj/Makefile.SH' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'libray/libobj/Makefile.SH'\"
- else
- echo shar: Extracting \"'libray/libobj/Makefile.SH'\" \(1680 characters\)
- sed "s/^X//" >'libray/libobj/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 libobj/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 <<!GROK!THIS!
- XOPTIMIZE = $optimize
- XCCFLAGS = $ccflags $large
- XRANLIB = $ranlib
- XCC = $cc
- XMKDEP = $mkdep
- X
- X!GROK!THIS!
- X
- X: In the following dollars and backticks do not need the extra backslash.
- X$spitshell >>Makefile <<'!NO!SUBS!'
- XLIB = ../libray.a
- XINCLUDE = -I.. -I../..
- XCFLAGS = $(CCFLAGS) $(INCLUDE) $(OPTIMIZE)
- XSHELL = /bin/sh
- X
- XCFILES = blob.c bounds.c box.c cone.c csg.c cylinder.c disc.c grid.c \
- X hf.c instance.c list.c intersect.c geom.c plane.c poly.c \
- X roots.c sphere.c torus.c triangle.c
- X
- XOFILES = $(CFILES:.c=.o)
- X
- X$(LIB): $(OFILES)
- X ar cur $(LIB) $(OFILES)
- X $(RANLIB) $(LIB)
- X
- Xclean:
- X rm -f $(OFILES)
- X
- Xdepend:
- X (sed '/^# DO NOT DELETE THIS LINE/q' Makefile && \
- X $(MKDEP) $(CFILES) | 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# DO NOT DELETE THIS LINE
- X!NO!SUBS!
- Xchmod 755 Makefile
- X$eunicefix Makefile
- END_OF_FILE
- if test 1680 -ne `wc -c <'libray/libobj/Makefile.SH'`; then
- echo shar: \"'libray/libobj/Makefile.SH'\" unpacked with wrong size!
- fi
- chmod +x 'libray/libobj/Makefile.SH'
- # end of 'libray/libobj/Makefile.SH'
- fi
- if test -f 'libray/libobj/blob.h' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'libray/libobj/blob.h'\"
- else
- echo shar: Extracting \"'libray/libobj/blob.h'\" \(1574 characters\)
- sed "s/^X//" >'libray/libobj/blob.h' <<'END_OF_FILE'
- X/*
- X * blob.h
- X *
- X * Copyright (C) 1990, 1991, Mark Polipec, 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: blob.h,v 4.0 91/07/17 14:36:12 kolb Exp Locker: kolb $
- X *
- X * $Log: blob.h,v $
- X * Revision 4.0 91/07/17 14:36:12 kolb
- X * Initial version.
- X *
- X */
- X#ifndef BLOB_H
- X#define BLOB_H
- X
- X#define GeomBlobCreate(t,m,n) GeomCreate((GeomRef)BlobCreate(t,m,n), BlobMethods())
- X
- X#define R_START 1
- X#define R_END 0
- X
- X/*
- X * Blob
- X */
- Xtypedef struct {
- X Float rs; /* radius */
- X Float c4; /* coeefficient */
- X Float c2; /* coeefficient */
- X Float c0; /* coeefficient */
- X Float x; /* x position */
- X Float y; /* y position */
- X Float z; /* z position */
- X} MetaVector;
- X
- Xtypedef struct {
- X int type,pnt;
- X Float bound;
- X Float c[5];
- X} MetaInt;
- X
- Xtypedef struct {
- X Float T; /* Threshold */
- X int num; /* number of points */
- X MetaVector *list; /* list of points */
- X MetaInt *ilist, **iarr;
- X
- X} Blob;
- X
- Xtypedef struct MetaList {
- X MetaVector mvec;
- X struct MetaList *next;
- X} MetaList;
- X
- Xextern int BlobIntersect(), BlobNormal();
- Xextern void BlobBounds(), BlobStats();
- Xextern Blob *BlobCreate();
- Xextern char *BlobName();
- Xextern Methods *BlobMethods();
- X
- X#endif /* BLOB_H */
- END_OF_FILE
- if test 1574 -ne `wc -c <'libray/libobj/blob.h'`; then
- echo shar: \"'libray/libobj/blob.h'\" unpacked with wrong size!
- fi
- # end of 'libray/libobj/blob.h'
- fi
- if test -f 'libray/libobj/grid.h' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'libray/libobj/grid.h'\"
- else
- echo shar: Extracting \"'libray/libobj/grid.h'\" \(1751 characters\)
- sed "s/^X//" >'libray/libobj/grid.h' <<'END_OF_FILE'
- X/*
- X * grid.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: grid.h,v 4.0 91/07/17 14:38:07 kolb Exp Locker: kolb $
- X *
- X * $Log: grid.h,v $
- X * Revision 4.0 91/07/17 14:38:07 kolb
- X * Initial version.
- X *
- X */
- X#ifndef GRID_H
- X#define GRID_H
- X
- X#define GeomGridCreate(x,y,z) GeomCreate((GeomRef)GridCreate(x,y,z), \
- X GridMethods())
- X/*
- X * Convert from voxel number along X/Y/Z to corresponding coordinate.
- X */
- X#define voxel2x(g,x) ((x) * g->voxsize[0] + g->bounds[0][0])
- X#define voxel2y(g,y) ((y) * g->voxsize[1] + g->bounds[0][1])
- X#define voxel2z(g,z) ((z) * g->voxsize[2] + g->bounds[0][2])
- X/*
- X * And vice-versa.
- X */
- X#define x2voxel(g,x) (((x) - g->bounds[0][0]) / g->voxsize[0])
- X#define y2voxel(g,y) (((y) - g->bounds[0][1]) / g->voxsize[1])
- X#define z2voxel(g,z) (((z) - g->bounds[0][2]) / g->voxsize[2])
- X
- X/*
- X * Grid object
- X */
- Xtypedef struct {
- X short xsize, ysize, zsize; /* # of voxels along each axis */
- X Float bounds[2][3]; /* bounding box */
- X Float voxsize[3]; /* size of a voxel */
- X struct Geom *unbounded, /* unbounded objects */
- X *objects; /* all bounded objects */
- X struct GeomList ****cells; /* Voxels */
- X} Grid;
- X
- Xextern char *GridName();
- Xextern void *GirdBounds();
- Xextern int GridIntersect(), GridConvert();
- Xextern Grid *GridCreate();
- Xextern Methods *GridMethods();
- X
- X#endif /* GRID_H */
- END_OF_FILE
- if test 1751 -ne `wc -c <'libray/libobj/grid.h'`; then
- echo shar: \"'libray/libobj/grid.h'\" unpacked with wrong size!
- fi
- # end of 'libray/libobj/grid.h'
- fi
- if test -f 'libray/libobj/triangle.h' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'libray/libobj/triangle.h'\"
- else
- echo shar: Extracting \"'libray/libobj/triangle.h'\" \(1589 characters\)
- sed "s/^X//" >'libray/libobj/triangle.h' <<'END_OF_FILE'
- X/*
- X * triangle.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: triangle.h,v 4.0 91/07/17 14:39:43 kolb Exp Locker: kolb $
- X *
- X * $Log: triangle.h,v $
- X * Revision 4.0 91/07/17 14:39:43 kolb
- X * Initial version.
- X *
- X */
- X#ifndef TRIANGLE_H
- X#define TRIANGLE_H
- X
- X#define FLATTRI 0
- X#define PHONGTRI 1
- X
- X#define GeomTriangleCreate(t,a,b,c,d,e,f,g,h,i,s) GeomCreate( \
- X (GeomRef)TriangleCreate(t,a,b,c,d,e,f,g,h,i,s), TriangleMethods())
- X
- X/*
- X * Triangle
- X */
- Xtypedef struct {
- X Vector nrm, /* triangle normal */
- X p[3], /* vertices */
- X e[3], /* "edge" vectors (scaled) */
- X *vnorm, /* Array of vertex normals */
- X *dpdu, *dpdv; /* U and V direction vectors */
- X Float d, /* plane constant */
- X b[3]; /* Array of barycentric coordinates */
- X Vec2d *uv; /* Array of UV coordinates of vertices */
- X char index, /* Flag used for shading/intersection test. */
- X type; /* type (to detect if phong or flat) */
- X} Triangle;
- X
- Xextern Triangle *TriangleCreate();
- Xextern int TriangleIntersect(), TriangleNormal();
- Xextern void TriangleBounds(), TriangleUV(),
- X TriangleStats();
- Xextern Methods *TriangleMethods();
- Xchar *TriangleName();
- X#endif /* TRIANGLE_H */
- END_OF_FILE
- if test 1589 -ne `wc -c <'libray/libobj/triangle.h'`; then
- echo shar: \"'libray/libobj/triangle.h'\" unpacked with wrong size!
- fi
- # end of 'libray/libobj/triangle.h'
- fi
- if test -f 'libray/libsurf/Makefile.SH' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'libray/libsurf/Makefile.SH'\"
- else
- echo shar: Extracting \"'libray/libsurf/Makefile.SH'\" \(1577 characters\)
- sed "s/^X//" >'libray/libsurf/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 libsurf/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 <<!GROK!THIS!
- XOPTIMIZE = $optimize
- XCCFLAGS = $ccflags $large
- XRANLIB = $ranlib
- XCC = $cc
- XMKDEP = $mkdep
- X
- X!GROK!THIS!
- X
- X: In the following dollars and backticks do not need the extra backslash.
- X$spitshell >>Makefile <<'!NO!SUBS!'
- XLIB = ../libray.a
- XINCLUDE = -I.. -I../..
- XCFLAGS = $(INCLUDE) $(CCFLAGS) $(OPTIMIZE)
- XSHELL = /bin/sh
- X
- XCFILES = atmosphere.c fog.c fogdeck.c mist.c surface.c surfshade.c
- XOFILES = $(CFILES:.c=.o)
- X
- X$(LIB): $(OFILES)
- X ar cur $(LIB) $(OFILES)
- X $(RANLIB) $(LIB)
- X
- Xclean:
- X rm -f $(OFILES)
- X
- Xdepend:
- X (sed '/^# DO NOT DELETE THIS LINE/q' Makefile && \
- X $(MKDEP) $(CFILES) | 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# DO NOT DELETE THIS LINE
- X!NO!SUBS!
- Xchmod 755 Makefile
- X$eunicefix Makefile
- END_OF_FILE
- if test 1577 -ne `wc -c <'libray/libsurf/Makefile.SH'`; then
- echo shar: \"'libray/libsurf/Makefile.SH'\" unpacked with wrong size!
- fi
- chmod +x 'libray/libsurf/Makefile.SH'
- # end of 'libray/libsurf/Makefile.SH'
- fi
- if test -f 'libray/libsurf/fog.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'libray/libsurf/fog.c'\"
- else
- echo shar: Extracting \"'libray/libsurf/fog.c'\" \(1675 characters\)
- sed "s/^X//" >'libray/libsurf/fog.c' <<'END_OF_FILE'
- X/*
- X * fog.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: fog.c,v 4.0 91/07/17 14:40:14 kolb Exp Locker: kolb $
- X *
- X * $Log: fog.c,v $
- X * Revision 4.0 91/07/17 14:40:14 kolb
- X * Initial version.
- X *
- X */
- X#include "atmosphere.h"
- X#include "fog.h"
- X
- XFog *
- XFogCreate(color, trans)
- XColor *color, *trans;
- X{
- X Fog *fog;
- X static void ComputeFog();
- X
- X fog = (Fog *)Malloc(sizeof(Fog));
- X
- X if (color == (Color *)NULL)
- X fog->color.r = fog->color.g = fog->color.b = 0.;
- X else
- X fog->color = *color;
- X if (trans == (Color *)NULL)
- X fog->trans.r = fog->trans.g = fog->trans.b = FAR_AWAY;
- X else {
- X fog->trans = *trans;
- X }
- X return fog;
- X}
- X
- X/*
- X * Add fog to the given color.
- X */
- Xvoid
- XFogApply(fog, ray, pos, dist, color)
- XFog *fog;
- XRay *ray;
- XVector *pos;
- XFloat dist;
- XColor *color;
- X{
- X Float atten;
- X extern Float ExpAtten();
- X
- X atten = ExpAtten(dist, fog->trans.r);
- X if (fog->trans.r == fog->trans.g && fog->trans.r == fog->trans.b) {
- X ColorBlend(color, &fog->color, atten, 1. - atten);
- X return;
- X }
- X color->r = atten*color->r + (1. - atten) * fog->color.r;
- X
- X atten = ExpAtten(dist, fog->trans.g);
- X color->g = atten*color->g + (1. - atten) * fog->color.g;
- X atten = ExpAtten(dist, fog->trans.b);
- X color->b = atten*color->b + (1. - atten) * fog->color.b;
- X}
- END_OF_FILE
- if test 1675 -ne `wc -c <'libray/libsurf/fog.c'`; then
- echo shar: \"'libray/libsurf/fog.c'\" unpacked with wrong size!
- fi
- # end of 'libray/libsurf/fog.c'
- fi
- if test -f 'libray/libsurf/mist.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'libray/libsurf/mist.c'\"
- else
- echo shar: Extracting \"'libray/libsurf/mist.c'\" \(1698 characters\)
- sed "s/^X//" >'libray/libsurf/mist.c' <<'END_OF_FILE'
- X/*
- X * mist.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: mist.c,v 4.0 91/07/17 14:40:42 kolb Exp Locker: kolb $
- X *
- X * $Log: mist.c,v $
- X * Revision 4.0 91/07/17 14:40:42 kolb
- X * Initial version.
- X *
- X */
- X#include "atmosphere.h"
- X#include "mist.h"
- X
- XMist *
- XMistCreate(color, trans, zero, scale)
- XColor *color, *trans;
- XFloat zero, scale;
- X{
- X Mist *mist;
- X
- X mist = (Mist *)Malloc(sizeof(Mist));
- X mist->color = *color;
- X mist->trans = *trans;
- X mist->zero = zero;
- X mist->scale = 1. / scale;
- X return mist;
- X}
- X
- X/*
- X * Add low-altitude mist to the given color.
- X */
- Xvoid
- XMistApply(mist, ray, pos, dist, color)
- XMist *mist;
- XRay *ray;
- XVector *pos;
- XFloat dist;
- XColor *color;
- X{
- X Float deltaZ, d, atten;
- X extern Float ExpAtten();
- X
- X deltaZ = mist->scale * (pos->z - ray->pos.z);
- X if (fabs(deltaZ) > EPSILON)
- X d = (exp(-ray->pos.z*mist->scale + mist->zero) -
- X exp(-pos->z*mist->scale + mist->zero)) / deltaZ;
- X else
- X d = exp(-pos->z*mist->scale + mist->zero);
- X
- X dist *= d;
- X
- X atten = ExpAtten(dist, mist->trans.r);
- X color->r = atten*color->r + (1. - atten)*mist->color.r;
- X
- X atten = ExpAtten(dist, mist->trans.g);
- X color->g = atten*color->g + (1. - atten)*mist->color.g;
- X
- X atten = ExpAtten(dist, mist->trans.b);
- X color->b = atten*color->b + (1. - atten)*mist->color.b;
- X}
- END_OF_FILE
- if test 1698 -ne `wc -c <'libray/libsurf/mist.c'`; then
- echo shar: \"'libray/libsurf/mist.c'\" unpacked with wrong size!
- fi
- # end of 'libray/libsurf/mist.c'
- fi
- if test -f 'libray/libtext/Makefile.SH' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'libray/libtext/Makefile.SH'\"
- else
- echo shar: Extracting \"'libray/libtext/Makefile.SH'\" \(1683 characters\)
- sed "s/^X//" >'libray/libtext/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 libtext/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 <<!GROK!THIS!
- XOPTIMIZE = $optimize
- XCCFLAGS = $ccflags $large
- XRANLIB = $ranlib
- XCC = $cc
- XMKDEP = $mkdep
- X
- X!GROK!THIS!
- X
- X: In the following dollars and backticks do not need the extra backslash.
- X$spitshell >>Makefile <<'!NO!SUBS!'
- XLIB = ../libray.a
- XINCLUDE = -I.. -I../..
- XCFLAGS = $(CCFLAGS) $(INCLUDE) $(OPTIMIZE)
- XSHELL = /bin/sh
- X
- XCFILES = blotch.c bump.c checker.c cloud.c fbm.c fbmbump.c gloss.c \
- X imagetext.c mapping.c marble.c mount.c noise.c sky.c stripe.c \
- X textaux.c texture.c windy.c wood.c
- X
- XOFILES = $(CFILES:.c=.o)
- X
- X$(LIB): $(OFILES)
- X ar cur $(LIB) $(OFILES)
- X $(RANLIB) $(LIB)
- X
- Xclean:
- X rm -f $(OFILES)
- X
- Xdepend:
- X (sed '/^# DO NOT DELETE THIS LINE/q' Makefile && \
- X $(MKDEP) $(CFILES) | 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# DO NOT DELETE THIS LINE
- X!NO!SUBS!
- Xchmod 755 Makefile
- X$eunicefix Makefile
- END_OF_FILE
- if test 1683 -ne `wc -c <'libray/libtext/Makefile.SH'`; then
- echo shar: \"'libray/libtext/Makefile.SH'\" unpacked with wrong size!
- fi
- chmod +x 'libray/libtext/Makefile.SH'
- # end of 'libray/libtext/Makefile.SH'
- fi
- if test -f 'libray/libtext/marble.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'libray/libtext/marble.c'\"
- else
- echo shar: Extracting \"'libray/libtext/marble.c'\" \(1558 characters\)
- sed "s/^X//" >'libray/libtext/marble.c' <<'END_OF_FILE'
- X/*
- X * marble.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: marble.c,v 4.0 91/07/17 14:43:06 kolb Exp Locker: kolb $
- X *
- X * $Log: marble.c,v $
- X * Revision 4.0 91/07/17 14:43:06 kolb
- X * Initial version.
- X *
- X */
- X#include "texture.h"
- X#include "marble.h"
- X
- XMarbleText *
- XMarbleCreate(mapname)
- Xchar *mapname;
- X{
- X MarbleText *marble;
- X
- X marble = (MarbleText *)Malloc(sizeof(MarbleText));
- X if (mapname)
- X marble->colormap = ColormapRead(mapname);
- X else
- X marble->colormap = (Color *)NULL;
- X return marble;
- X}
- X
- Xvoid
- XMarbleApply(marble, prim, ray, pos, norm, gnorm, surf)
- XMarbleText *marble;
- XGeom *prim;
- XRay *ray;
- XVector *pos, *norm, *gnorm;
- XSurface *surf;
- X{
- X Float val;
- X int index;
- X
- X val = Marble(pos);
- X if (marble->colormap) {
- X index = (int)(255. * val);
- X surf->diff.r *= marble->colormap[index].r;
- X surf->diff.g *= marble->colormap[index].g;
- X surf->diff.b *= marble->colormap[index].b;
- X surf->amb.r *= marble->colormap[index].r;
- X surf->amb.g *= marble->colormap[index].g;
- X surf->amb.b *= marble->colormap[index].b;
- X } else {
- X ColorScale(val, surf->amb, &surf->amb);
- X ColorScale(val, surf->diff, &surf->diff);
- X }
- X}
- END_OF_FILE
- if test 1558 -ne `wc -c <'libray/libtext/marble.c'`; then
- echo shar: \"'libray/libtext/marble.c'\" unpacked with wrong size!
- fi
- # end of 'libray/libtext/marble.c'
- fi
- if test -f 'libray/libtext/sky.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'libray/libtext/sky.c'\"
- else
- echo shar: Extracting \"'libray/libtext/sky.c'\" \(1656 characters\)
- sed "s/^X//" >'libray/libtext/sky.c' <<'END_OF_FILE'
- X/*
- X * sky.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: sky.c,v 4.0 91/07/17 14:43:43 kolb Exp Locker: kolb $
- X *
- X * $Log: sky.c,v $
- X * Revision 4.0 91/07/17 14:43:43 kolb
- X * Initial version.
- X *
- X */
- X#include "texture.h"
- X#include "sky.h"
- X
- XSky *
- XSkyCreate(scale, h, lambda, octaves, cthresh, lthresh)
- XFloat h, lambda, scale, cthresh, lthresh;
- Xint octaves;
- X{
- X Sky *sky;
- X
- X sky = (Sky *)Malloc(sizeof(Sky));
- X sky->beta = 1. + 2 * h;
- X sky->omega = pow(lambda, -0.5 * sky->beta);
- X sky->lambda = lambda;
- X sky->scale = scale;
- X sky->cthresh = cthresh;
- X sky->lthresh = lthresh;
- X sky->octaves = octaves;
- X return sky;
- X}
- X
- Xvoid
- XSkyApply(sky, prim, ray, pos, norm, gnorm, surf)
- XSky *sky;
- XGeom *prim;
- XRay *ray;
- XVector *pos, *norm, *gnorm;
- XSurface *surf;
- X{
- X Float It, maxval;
- X
- X It = fBm(pos, sky->omega, sky->lambda, sky->octaves);
- X maxval = 1. / (1. - sky->omega);
- X /*
- X * Map from [-maxval,maxval] to [0,1]
- X */
- X It = (maxval + It) * 0.5/maxval;
- X
- X It = (It - sky->lthresh) / (sky->cthresh - sky->lthresh);
- X if (It < 0.)
- X It = 0;
- X else if (It > 1.)
- X It = 1;
- X
- X if (sky->scale != 0.)
- X It = pow(It, sky->scale);
- X
- X surf->transp = 1. - It;
- X
- X ColorScale(It, surf->diff, &surf->diff);
- X ColorScale(It, surf->amb, &surf->amb);
- X}
- END_OF_FILE
- if test 1656 -ne `wc -c <'libray/libtext/sky.c'`; then
- echo shar: \"'libray/libtext/sky.c'\" unpacked with wrong size!
- fi
- # end of 'libray/libtext/sky.c'
- fi
- if test -f 'libray/libtext/windy.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'libray/libtext/windy.c'\"
- else
- echo shar: Extracting \"'libray/libtext/windy.c'\" \(1688 characters\)
- sed "s/^X//" >'libray/libtext/windy.c' <<'END_OF_FILE'
- X/*
- X * windy.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: windy.c,v 4.0 91/07/17 14:44:25 kolb Exp Locker: kolb $
- X *
- X * $Log: windy.c,v $
- X * Revision 4.0 91/07/17 14:44:25 kolb
- X * Initial version.
- X *
- X */
- X#include "texture.h"
- X#include "windy.h"
- X
- X/*
- X * Create and return a reference to a "windy" texture.
- X */
- XWindyText *
- XWindyCreate(scale, wscale, cscale, bscale, octaves, tscale, hscale, offset)
- XFloat scale, wscale, cscale, bscale, tscale, hscale, offset;
- Xint octaves;
- X{
- X WindyText *windy;
- X
- X windy = (WindyText *)Malloc(sizeof(WindyText));
- X windy->scale = scale;
- X windy->windscale = wscale;
- X windy->chaoscale = cscale;
- X windy->bumpscale = bscale;
- X windy->tscale = tscale;
- X windy->hscale = hscale;
- X windy->offset = offset;
- X windy->octaves = octaves;
- X return windy;
- X}
- X
- X/*
- X * Apply a "windy" texture.
- X */
- Xvoid
- XWindyApply(windy, prim, ray, pos, norm, gnorm, surf)
- XWindyText *windy;
- XGeom *prim;
- XRay *ray;
- XVector *pos, *norm, *gnorm;
- XSurface *surf;
- X{
- X Vector bump;
- X
- X Windy(pos, windy->windscale, windy->chaoscale, windy->bumpscale,
- X windy->octaves, windy->tscale, windy->hscale, windy->offset,
- X &bump);
- X
- X norm->x += windy->scale * bump.x;
- X norm->y += windy->scale * bump.y;
- X norm->z += windy->scale * bump.z;
- X VecNormalize(norm);
- X}
- END_OF_FILE
- if test 1688 -ne `wc -c <'libray/libtext/windy.c'`; then
- echo shar: \"'libray/libtext/windy.c'\" unpacked with wrong size!
- fi
- # end of 'libray/libtext/windy.c'
- fi
- if test -f 'libshade/defaults.h' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'libshade/defaults.h'\"
- else
- echo shar: Extracting \"'libshade/defaults.h'\" \(1637 characters\)
- sed "s/^X//" >'libshade/defaults.h' <<'END_OF_FILE'
- X/*
- X * defaults.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: defaults.h,v 4.0 91/07/17 14:45:18 kolb Exp Locker: kolb $
- X *
- X * $Log: defaults.h,v $
- X * Revision 4.0 91/07/17 14:45:18 kolb
- X * Initial version.
- X *
- X */
- X#ifndef DEFAULTS_H
- X#define DEFAULTS_H
- X
- X#define DEFSAMPLES 3 /* sqrt of number of samples */
- X
- X#define XRESOLUTION 512 /* Default screen size (pixels) */
- X#define YRESOLUTION 512
- X#define DEFCUTOFF 0.002 /* Default tree cutoff value */
- X#define MAXDEPTH 5 /* Maximum ray tree depth. */
- X#define HFOV 45 /* Field-of-view */
- X#define EYEX 0 /* Eye position */
- X#define EYEY -10
- X#define EYEZ 0
- X#define LOOKX 0 /* Look point */
- X#define LOOKY 0
- X#define LOOKZ 0
- X#define UPX 0 /* Up vector */
- X#define UPY 0
- X#define UPZ 1
- X#define GAMMA 1. /* Default gamma */
- X#define GAUSSIAN FALSE /* Use gaussian pixel filter? */
- X#define FILTERWIDTH 1.8 /* Default gaussian filter width */
- X
- X#if defined(LINDA) && !defined(WORKERS)
- X#define WORKERS 4 /* Default # of workers. */
- X#endif
- X
- X#define REPORTFREQ 10 /* Frequency of status report */
- X
- X#define DEFREDCONT 0.2 /* Default contrast threshold values. */
- X#define DEFGREENCONT 0.15
- X#define DEFBLUECONT 0.3
- X
- X#endif /* DEFAULTS_H */
- END_OF_FILE
- if test 1637 -ne `wc -c <'libshade/defaults.h'`; then
- echo shar: \"'libshade/defaults.h'\" unpacked with wrong size!
- fi
- # end of 'libshade/defaults.h'
- fi
- if test -f 'raypaint/README' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'raypaint/README'\"
- else
- echo shar: Extracting \"'raypaint/README'\" \(1775 characters\)
- sed "s/^X//" >'raypaint/README' <<'END_OF_FILE'
- XRaypaint reads a rayshade input file and opens a graphics window into
- Xwhich the image is progressively rendered. Graphics support routines
- Xare provided for X11 and GL (SGI / RS6000).
- X
- XCommand-line arguments to raypaint are identical to rayshade arguments.
- X
- XBy default, raypaint refines areas of the image that it considers
- X"interesting" (largish and contrasty). The mouse may be used to direct
- Xraypaint to concentrate on particular regions. Holding down the
- Xleft mouse button causes the indicated region to be single-sampled down
- Xto the pixel level. The right button causes the region to be supersampled.
- XWhen either button is released, raypaint continues to refine by
- Xeither single-sampling (if the left button was pressed) or supersampling
- X(if the right button was pressed). If either button is pressed while the
- Xcursor is pointing at a region that has already been resolved to the
- Xpixel-level, raypaint will instead choose its own region to refine.
- X
- XThe middle mouse button may be used to sweep out a rectangular region to
- Xwhich raypaint should restrict its refinement: Press and hold the middle
- Xmouse button while pointing at one corner of the region on interest,
- Xdrag the cursor to the opposite corner and release the mouse button.
- XNote that no rectangle will be drawn. Refinement will continue inside
- Xof the indicated region, using whatever sampling
- X
- XWhen every pixel has been sampled, an image file is written.
- X
- XNote that raypaint is intended to be an example application, not a
- Xpolished tool. You are encouraged to tear apart raypaint to improve
- Xit or build your own application.
- X
- XTo compile, move either xgraphics.c (X11) or glgraphics.c (SGI) to
- Xgraphics.c, edit the Makefile and change GRAPHICSLIB to reflect your
- Xchoice of graphics support, and run make.
- END_OF_FILE
- if test 1775 -ne `wc -c <'raypaint/README'`; then
- echo shar: \"'raypaint/README'\" unpacked with wrong size!
- fi
- # end of 'raypaint/README'
- fi
- if test -f 'rayview/main.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'rayview/main.c'\"
- else
- echo shar: Extracting \"'rayview/main.c'\" \(1592 characters\)
- sed "s/^X//" >'rayview/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 14:55:35 kolb Exp Locker: kolb $
- X *
- X * $Log: main.c,v $
- X * Revision 4.0 91/07/17 14:55:35 kolb
- X * Initial version.
- X *
- X */
- X
- Xchar rcsid[] = "$Id: main.c,v 4.0 91/07/17 14:55:35 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
- 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 MethodsRegister();
- X
- X RSStartFrame(0);
- 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 * Draw the image.
- X */
- X Render();
- X StatsPrint();
- X return 0;
- X}
- END_OF_FILE
- if test 1592 -ne `wc -c <'rayview/main.c'`; then
- echo shar: \"'rayview/main.c'\" unpacked with wrong size!
- fi
- # end of 'rayview/main.c'
- fi
- echo shar: End of archive 4 \(of 19\).
- cp /dev/null ark4isdone
- 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
-
- exit 0 # Just in case...
-