home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-07-21 | 30.9 KB | 1,483 lines |
- Newsgroups: comp.sources.misc
- From: Rayshade Construction Co. <rayshade@weedeater.math.YALE.EDU>
- Subject: v21i021: rayshade - A raytracing package for UNIX, Part18/19
- Message-ID: <1991Jul21.223443.3943@sparky.IMD.Sterling.COM>
- X-Md4-Signature: be1f377f170779e089ebeb562537fad0
- Date: Sun, 21 Jul 1991 22:34:43 GMT
- Approved: kent@sparky.imd.sterling.com
-
- Submitted-by: Rayshade Construction Co. <rayshade@weedeater.math.YALE.EDU>
- Posting-number: Volume 21, Issue 21
- Archive-name: rayshade/part18
- 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 18 (of 19)."
- # Contents: libshade/yacc.y
- # Wrapped by kolb@woody on Wed Jul 17 17:57:01 1991
- PATH=/bin:/usr/bin:/usr/ucb ; export PATH
- if test -f 'libshade/yacc.y' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'libshade/yacc.y'\"
- else
- echo shar: Extracting \"'libshade/yacc.y'\" \(28326 characters\)
- sed "s/^X//" >'libshade/yacc.y' <<'END_OF_FILE'
- X/* yacc.y */
- 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/* $Id: yacc.y,v 4.0 91/07/17 17:39:39 kolb Exp Locker: kolb $ */
- X%{
- X#include "rayshade.h"
- X
- X#include "symtab.h"
- X#include "builtin.h"
- X
- X#include "libsurf/atmosphere.h"
- X#include "libsurf/surface.h"
- X#include "libtext/texture.h"
- X#include "libimage/image.h"
- X#include "libobj/geom.h"
- X#include "liblight/light.h"
- X#include "options.h"
- X#include "stats.h"
- X#include "viewing.h"
- X
- X#include "libobj/blob.h"
- X#include "libobj/box.h"
- X#include "libobj/cone.h"
- X#include "libobj/csg.h"
- X#include "libobj/cylinder.h"
- X#include "libobj/disc.h"
- X#include "libobj/grid.h"
- X#include "libobj/hf.h"
- X#include "libobj/instance.h"
- X#include "libobj/list.h"
- X#include "libobj/plane.h"
- X#include "libobj/poly.h"
- X#include "libobj/sphere.h"
- X#include "libobj/torus.h"
- X#include "libobj/triangle.h"
- X
- X#include "liblight/point.h"
- X#include "liblight/infinite.h"
- X#include "liblight/spot.h"
- X#include "liblight/jittered.h"
- X#include "liblight/extended.h"
- X
- X#include "libtext/blotch.h"
- X#include "libtext/bump.h"
- X#include "libtext/checker.h"
- X#include "libtext/cloud.h"
- X#include "libtext/fbm.h"
- X#include "libtext/fbmbump.h"
- X#include "libtext/gloss.h"
- X#include "libtext/imagetext.h"
- X#include "libtext/marble.h"
- X#include "libtext/mount.h"
- X#include "libtext/sky.h"
- X#include "libtext/stripe.h"
- X#include "libtext/windy.h"
- X#include "libtext/wood.h"
- X
- X#include "libsurf/fog.h"
- X#include "libsurf/fogdeck.h"
- X#include "libsurf/mist.h"
- X
- X#include "libcommon/rotate.h"
- X#include "libcommon/scale.h"
- X#include "libcommon/translate.h"
- X
- XGeom *NewAggregate();
- Xchar yyfilename[BUFSIZ]; /* Input filename */
- XGeomList *Defstack; /* Geom definition stack. */
- Xint Npoints = 0; /* # of points in Polypoints */
- XSurface *tmpsurf; /* Working surface */
- XSurfList *CurSurf;
- XTexture *CurText; /* Working list of textures */
- XImageText *Imagetext; /* Working image texture */
- XTrans *TransHead, *TransTail; /* Linked list of current transformations */
- XAtmosphere *CurEffect = (Atmosphere *)NULL; /* Current atmos. effects */
- XPointList *Polypoints; /* List of vertices */
- XMetaList *Metapoints, *Metapoint;
- Xextern FILE *yyin; /* input file pointer */
- Xextern int yylineno; /* Current line # in file */
- Xextern Atmosphere *AtmosEffects; /* atmospheric effects */
- Xextern Medium TopMedium; /* "air" */
- Xextern void GeomAddToDefined(),
- X LightAddToDefined(),
- X SurfaceAddToDefined();
- Xextern Surface *SurfaceGetNamed();
- Xextern Geom *GeomGetNamed();
- X%}
- X%union {
- X char *c;
- X int i;
- X Float d;
- X Vector v;
- X Vec2d uv;
- X Color col;
- X Atmosphere *atmos;
- X Light *light;
- X Surface *surf;
- X Geom *obj;
- X Texture *text;
- X Mapping *map;
- X Trans *trans;
- X Expr *e;
- X SymtabEntry *sym;
- X}
- X%token <d> tFLOAT
- X%token <c> tSTRING tFILENAME
- X%token tAPERTURE tAPPLYSURF
- X%token tBACKGROUND tBLOB tBLOTCH tBOX tBUMP tCONE tCYL tDIRECTIONAL tCURSURF
- X%token tEXTENDED tEYEP tFBM tFBMBUMP tFOCALDIST tFOG tFOGDECK tFOV tGLOSS tGRID
- X%token tHEIGHTFIELD tLIGHT tLIST tLOOKP tMARBLE tMAXDEPTH tMIST
- X%token tJITTER tNOJITTER tDEFINE
- X%token tOBJECT tOUTFILE tSKY tDISC tDIFFERENCE tUNION tINTERSECT
- X%token tPLANE tPOINT tPOLY tROTATE tSPOT tPRINT
- X%token tSCALE tSCREEN tSPHERE tSURFACE
- X%token tTHRESH tTRANSLATE tTRANSFORM tTRIANGLE tTRIANGLEUV tUP tEND
- X%token tTEXTURE tCHECKER tWOOD tCONTRAST tCUTOFF tCLOUD
- X%token tAMBIENT tDIFFUSE tREFLECT tTRANSP tSPECULAR tSPECPOW
- X%token tINDEX tATMOSPHERE tNOSHADOW tAREA tTRANSLU tTORUS
- X%token tEYESEP tSHADOWTRANSP tREPORT tVERBOSE tQUIET tWINDOW tSTRIPE
- X%token tMAP tUV tSPHERICAL tCYLINDRICAL tPLANAR
- X%token tIMAGE tSMOOTH tCOMPONENT tTEXTSURF tRANGE tTILE tSTARTTIME tFRAMELENGTH
- X%token tNAME tFILTER tGAUSS tBODY tSAMPLE tEXTINCT tWINDY tMOUNT
- X%token tSHUTTER tFRAMES
- X%type <c> Filename
- X%type <e> AnimExpr MExpr ParenExpr
- X%type <d> Expr Float
- X%type <v> Vector
- X%type <uv> Vec2d
- X%type <col> Color Intensity Lightdef
- X%type <text> Texturetype
- X%type <i> SurfCompName IExpr CombineOp
- X%type <atmos> EffectType
- X%type <light> LightType
- X%type <obj> PrimType Primitive TransTextObj
- X%type <obj> Csg Aggregate Object TransObj ObjType
- X%type <obj> Blob Box Cone Cylinder Disc HeightField Plane Poly
- X%type <obj> Sphere Triangle Torus AggregateType List Grid AggregateCreate
- X%type <obj> NamedObject
- X%type <surf> Surface OptSurface NamedSurf
- X%type <surf> SurfSpec ModifyNamedSurf
- X%type <map> Mapping MapMethod OptMapping
- X%type <trans> TransformType
- X%type <sym> Symtabent
- X
- X%left '+' '-'
- X%left '*' '/' '%'
- X%left UMINUS
- X%right '^'
- X%%
- XItems : /* empty */
- X | Items Item
- X ;
- XItem : Eyep
- X | Lookp
- X | Up
- X | Fov
- X | Screen
- X | Window
- X | Report
- X | Aperture
- X | Focaldist
- X | Eyesep
- X | Maxdepth
- X | Sample
- X | Filter
- X | Contrast
- X | Cutoff
- X | Background
- X | Shadowtransp
- X | Light
- X | SurfDef
- X | CurSurf
- X | Outfile
- X | Instance
- X | NameObject
- X | GlobalEffects
- X | Define
- X | Frames
- X | Starttime
- X | Shutter
- X | Framelength
- X | Print
- X ;
- XInstance : TransTextObj
- X {
- X if ($1) {
- X /*
- X * Add instance to current object.
- X */
- X $1->next = Defstack->obj->next;
- X Defstack->obj->next = $1;
- X }
- X }
- XTransTextObj : TransObj Textures
- X {
- X if ($$ && CurText) {
- X $$->texture = TextAppend(CurText, $$->texture);
- X }
- X CurText = (Texture *)NULL;
- X }
- X ;
- XTransObj : Object Transforms
- X {
- X $$ = $1;
- X if ($$ != (Geom *)NULL) {
- X if (TransHead) {
- X $$->trans = TransHead;
- X $$->transtail = TransTail;
- X /*
- X * We compose non-animated tranformation lists,
- X * so we're only animated if it's one long,
- X * or it's animated itself.
- X */
- X if ($$->trans->assoc || $$->trans->next)
- X /* geometry is animated...*/
- X $$->animtrans = TRUE;
- X }
- X }
- X }
- X ;
- XObject : ObjType
- X {
- X if ($$)
- X StatsAddRep($$);
- X }
- X | NamedObject
- X ;
- XObjType : Primitive
- X | Aggregate
- X ;
- XPrimitive : PrimType
- X {
- X if ($$)
- X $$->prims = 1; /* one primitive */
- X }
- X ;
- XPrimType : Plane
- X | Sphere
- X | Box
- X | Triangle
- X | Cylinder
- X | Cone
- X | Poly
- X | HeightField
- X | Disc
- X | Torus
- X | Blob
- X ;
- XNameObject : tNAME tSTRING TransTextObj
- X {
- X if ($3) {
- X $3->name = $2;
- X GeomAddToDefined($3);
- X }
- X };
- XAggdefs : Aggdefs Aggdef
- X |
- X ;
- XAggdef : Instance
- X | SurfDef
- X | CurSurf
- X | NameObject
- X ;
- XTextures : Textures Texture
- X |
- X ;
- XTexture : tTEXTURE Texturetype Transforms
- X {
- X if ($2 != (Texture *)NULL) {
- X /*
- X * Set transformation information.
- X */
- X if (TransHead) {
- X $2->trans = TransHead;
- X /*
- X * We compose non-animated tranformation lists,
- X * so we're only animated if it's one long,
- X * or it's animated itself.
- X */
- X if ($2->trans->assoc || $2->trans->next)
- X /* texture transformation is animated...*/
- X $2->animtrans = TRUE;
- X }
- X /*
- X * Walk to the end of list of textures and
- X * append new texture. This is done so that
- X * textures are applied in the expected order.
- X */
- X CurText = TextAppend($2, CurText);
- X }
- X }
- X ;
- XTexturetype : tCHECKER Surface
- X {
- X $$ = TextCheckerCreate($2);
- X }
- X | tBLOTCH Expr Surface
- X {
- X $$ = TextBlotchCreate($2, $3);
- X }
- X | tBUMP Expr
- X {
- X $$ = TextBumpCreate($2);
- X }
- X | tMARBLE
- X {
- X $$ = TextMarbleCreate((char *)NULL);
- X }
- X | tMARBLE Filename
- X {
- X $$ = TextMarbleCreate($2);
- X }
- X | tFBM Expr Expr Expr Expr IExpr Expr
- X {
- X $$ = TextFBmCreate($2, $3, $4, $5, $6, $7,
- X (char *)NULL);
- X }
- X | tFBM Expr Expr Expr Expr IExpr Expr Filename
- X {
- X $$ = TextFBmCreate($2, $3, $4, $5, $6, $7, $8);
- X }
- X | tFBMBUMP Expr Expr Expr Expr IExpr
- X {
- X $$ = TextFBmBumpCreate($2, $3, $4, $5, $6);
- X }
- X | tWOOD
- X {
- X $$ = TextWoodCreate();
- X }
- X | tGLOSS Expr
- X {
- X $$ = TextGlossCreate($2);
- X }
- X | tCLOUD Expr Expr Expr IExpr Expr Expr Expr
- X {
- X $$ = TextCloudCreate($2, $3, $4, $5, $6, $7, $8);
- X }
- X | tSKY Expr Expr Expr IExpr Expr Expr
- X {
- X $$ = TextSkyCreate($2, $3, $4, $5, $6, $7);
- X }
- X | ImageText
- X {
- X /*
- X * Image texturing has so many options
- X * that specification is keyword-based.
- X */
- X if (Imagetext->image == (Image *)NULL)
- X $$ = (Texture *)NULL;
- X else
- X $$ = TextCreate(Imagetext, ImageTextApply);
- X Imagetext = (ImageText *)NULL;
- X }
- X | tSTRIPE Surface Expr Expr OptMapping
- X {
- X $$ = TextStripeCreate($2, $3, $4, $5);
- X }
- X | tWINDY Expr Expr Expr Expr IExpr Expr Expr Expr
- X {
- X $$ = TextWindyCreate($2, $3, $4, $5, $6, $7, $8, $9);
- X }
- X | tMOUNT Filename Expr Expr
- X {
- X $$ = TextMountCreate($2, $3, $4);
- X }
- X ;
- XImageText : ImageTextType ImageTextOptions
- X ;
- XImageTextType : tIMAGE Filename
- X {
- X Imagetext = ImageTextCreate($2);
- X }
- X ;
- XImageTextOptions: ImageTextOptions ImageTextOption
- X | /* EMPTY */
- X ;
- XImageTextOption: tCOMPONENT SurfCompName
- X {
- X /* set texture to modify given component */
- X ImageTextSetComponent(Imagetext, $2);
- X }
- X | tTILE Expr Expr
- X {
- X Imagetext->tileu = $2;
- X Imagetext->tilev = $3;
- X }
- X | tTEXTSURF Surface
- X {
- X Imagetext->surf = $2;
- X }
- X | tRANGE Expr Expr
- X {
- X Imagetext->hi = $2;
- X Imagetext->lo = $3;
- X }
- X | tSMOOTH
- X {
- X Imagetext->smooth = TRUE;
- X }
- X | Mapping
- X {
- X Imagetext->mapping = $1;
- X };
- XNamedObject : tOBJECT Surface tSTRING
- X {
- X Geom *otmp;
- X /*
- X * Create an instance of the named object.
- X */
- X otmp = GeomGetNamed($3);
- X if (otmp == (Geom *)NULL)
- X RLerror(RL_PANIC,
- X "There is no object named \"%s\".", $3);
- X $$ = GeomInstanceCreate(otmp);
- X $$->surf = $2;
- X $$->prims = otmp->prims;
- X }
- X | tOBJECT tSTRING
- X {
- X Geom *otmp;
- X
- X otmp = GeomGetNamed($2);
- X if (otmp == (Geom *)NULL)
- X RLerror(RL_PANIC,
- X "There is no object named \"%s\".", $2);
- X $$ = GeomInstanceCreate(otmp);
- X $$->surf = CurSurf->surf;
- X $$->prims = otmp->prims;
- X };
- XTransforms : Transforms PostTransform
- X | /* empty */
- X {
- X TransHead = TransTail = (Trans *)NULL;
- X };
- XPostTransform : TransformType
- X {
- X if (TransHead == (Trans *)NULL) {
- X /* we're the list, head and tail */
- X TransHead = TransTail = $1;
- X } else {
- X if ($1->animated || TransTail->animated) {
- X /* new tail */
- X $1->prev = TransTail;
- X TransTail->next = $1;
- X TransTail = $1;
- X } else {
- X /* collapse with tail */
- X TransCompose(TransTail, $1, TransTail);
- X TransFree($1);
- X }
- X }
- X }
- X ;
- XTransformType : tSCALE AnimExpr AnimExpr AnimExpr
- X {
- X $$ = TransScaleCreate();
- X TransScaleSetX($$, $2);
- X TransScaleSetY($$, $3);
- X TransScaleSetZ($$, $4);
- X if (!$$->animated)
- X TransPropagate($$);
- X
- X }
- X | tTRANSLATE AnimExpr AnimExpr AnimExpr
- X {
- X $$ = TransTranslateCreate();
- X TransTranslateSetX($$, $2);
- X TransTranslateSetY($$, $3);
- X TransTranslateSetZ($$, $4);
- X if (!$$->animated)
- X TransPropagate($$);
- X }
- X | tROTATE AnimExpr AnimExpr AnimExpr AnimExpr
- X {
- X $$ = TransRotateCreate();
- X TransRotateSetX($$, $2);
- X TransRotateSetY($$, $3);
- X TransRotateSetZ($$, $4);
- X TransRotateSetTheta($$, $5);
- X if (!$$->animated)
- X TransPropagate($$);
- X };
- XEyep : tEYEP Vector Transforms
- X {
- X Camera.pos = $2;
- X /*
- X * Eye can be transformed...
- X if (CurMatrix) {
- X PointTransform(&Camera.pos, CurMatrix);
- X free((voidstar)CurMatrix);
- X CurMatrix = (Matrix*)NULL;
- X }
- X */
- X }
- X ;
- XLookp : tLOOKP Vector
- X {
- X Camera.lookp = $2;
- X }
- X ;
- XUp : tUP Vector
- X {
- X Camera.up = $2;
- X }
- X ;
- XFov : tFOV Expr Expr
- X {
- X Camera.hfov = $2;
- X Camera.vfov = $3;
- X }
- X | tFOV Expr
- X {
- X Camera.hfov = $2;
- X Camera.vfov = UNSET;
- X }
- X ;
- XSample : tSAMPLE IExpr tJITTER
- X {
- X if (!Options.samples_set)
- X Options.samples = $2;
- X if (!Options.jitter_set)
- X Options.jitter = TRUE;
- X }
- X | tSAMPLE IExpr tNOJITTER
- X {
- X if (!Options.samples_set)
- X Options.samples = $2;
- X if (!Options.jitter_set)
- X Options.jitter = FALSE;
- X }
- X | tSAMPLE IExpr
- X {
- X if (!Options.samples_set)
- X Options.samples = $2;
- X }
- X ;
- XFilter : tFILTER tBOX Expr
- X {
- X Options.gaussian = FALSE;
- X Options.filterwidth = $3;
- X }
- X | tFILTER tBOX
- X {
- X Options.gaussian = FALSE;
- X }
- X | tFILTER tGAUSS Expr
- X {
- X Options.gaussian = TRUE;
- X Options.filterwidth = $3;
- X }
- X | tFILTER tGAUSS
- X {
- X Options.gaussian = TRUE;
- X };
- XStarttime : tSTARTTIME Expr
- X {
- X Options.starttime = $2;
- X };
- XFrames : tFRAMES IExpr
- X {
- X if (!Options.totalframes_set)
- X Options.totalframes = $2;
- X };
- XFramelength : tFRAMELENGTH Expr
- X {
- X Options.framelength = $2;
- X };
- XShutter : tSHUTTER Expr
- X {
- X Options.shutterspeed = $2;
- X };
- XContrast : tCONTRAST Expr Expr Expr
- X {
- X if (!Options.contrast_set) {
- X Options.contrast.r = $2;
- X Options.contrast.g = $3;
- X Options.contrast.b = $4;
- X }
- X }
- X ;
- XCutoff : tCUTOFF Intensity
- X {
- X if (!Options.cutoff_set)
- X Options.cutoff = $2;
- X }
- X ;
- XScreen : tSCREEN IExpr IExpr
- X {
- X if (!Options.resolution_set) {
- X Screen.xres = $2;
- X Screen.yres = $3;
- X }
- X }
- X ;
- XWindow : tWINDOW Expr Expr Expr Expr
- X {
- X if (!Options.window_set) {
- X Options.xmin = $2;
- X Options.xmax = $3;
- X Options.ymin = $4;
- X Options.ymax = $5;
- X }
- X }
- XReport : tREPORT Verbose Quiet IExpr Filename
- X {
- X if (!Options.freq_set)
- X Options.report_freq = $4;
- X if (Options.statsname == (char *)NULL)
- X Options.statsname = strsave($5);
- X }
- X | tREPORT Verbose Quiet IExpr
- X {
- X if (!Options.freq_set)
- X Options.report_freq = $4;
- X }
- X | tREPORT Verbose Quiet Filename
- X {
- X if (Options.statsname == (char *)NULL)
- X Options.statsname = strsave($4);
- X }
- X | tREPORT Verbose Quiet
- X ;
- XVerbose : tVERBOSE
- X { Options.verbose = TRUE; }
- X |
- X ;
- XQuiet : tQUIET
- X { Options.quiet = TRUE; }
- X |
- X ;
- XAperture : tAPERTURE Expr
- X {
- X Camera.aperture = $2;
- X }
- X ;
- XFocaldist : tFOCALDIST Expr
- X {
- X Camera.focaldist = $2;
- X }
- X ;
- XEyesep : tEYESEP Expr
- X {
- X if (!Options.eyesep_set)
- X Options.eyesep = $2;
- X }
- X ;
- XMaxdepth : tMAXDEPTH IExpr
- X {
- X if (!Options.maxdepth_set)
- X Options.maxdepth = $2;
- X }
- X ;
- XBackground : tBACKGROUND Color
- X {
- X Screen.background = $2;
- X }
- X ;
- XShadowtransp : tSHADOWTRANSP
- X {
- X Options.shadowtransp = TRUE;
- X }
- X ;
- XLight : LightType
- X {
- X LightAddToDefined($1);
- X }
- X | LightType tNOSHADOW
- X {
- X $1->shadow = FALSE;
- X LightAddToDefined($1);
- X }
- X | tLIGHT Intensity tAMBIENT
- X {
- X Options.ambient = $2;
- X }
- X | Lightdef tAREA Vector Vector IExpr Vector IExpr
- X {
- X extern void AreaLightCreate();
- X /* Area light is strange in that the
- X * Creation routine does the installation.
- X */
- X AreaLightCreate(&$1, &$3, &$4, $5, &$6, $7, TRUE);
- X }
- X | Lightdef tAREA Vector Vector IExpr Vector IExpr tNOSHADOW
- X {
- X extern void AreaLightCreate();
- X /* Area light is strange in that the
- X * Creation routine does the installation.
- X */
- X AreaLightCreate(&$1, &$3, &$4, $5, &$6, $7, FALSE);
- X };
- XLightType : Lightdef tPOINT Vector
- X {
- X $$ = LightPointCreate(&$1, &$3);
- X }
- X | Lightdef tDIRECTIONAL Vector
- X {
- X $$ = LightInfiniteCreate(&$1, &$3);
- X }
- X | Lightdef tEXTENDED Expr Vector
- X {
- X $$ = LightExtendedCreate(&$1, $3, &$4);
- X }
- X | Lightdef tSPOT Vector Vector Expr
- X {
- X $$ = LightSpotCreate(&$1, &$3, &$4, $5, 0., 0.);
- X }
- X | Lightdef tSPOT Vector Vector Expr Expr Expr
- X {
- X /* light <intens> spot from <to> coef inner_rad
- X outer_rad */
- X $$ = LightSpotCreate(&$1, &$3, &$4, $5, $6, $7);
- X };
- XLightdef : tLIGHT Intensity
- X {
- X $$ = $2;
- X }
- X ;
- XCurSurf : tAPPLYSURF Surface
- X {
- X CurSurf->surf = $2;
- X }
- X ;
- XOptSurface : Surface
- X | /* EMPTY */
- X {
- X $$ = CurSurf->surf;
- X }
- X ;
- XSurface : NamedSurf
- X | ModifyNamedSurf
- X | SurfSpec
- X ;
- XNamedSurf : tSTRING
- X {
- X $$ = SurfaceGetNamed($1);
- X /*
- X * Free up memory allocated for surf name.
- X * We bother doing this because for large models
- X * converted from 3.0, surfnames this can account
- X * for lots o' bytes.
- X */
- X free((voidstar)$1);
- X }
- X | tCURSURF
- X {
- X extern Surface DefaultSurface;
- X
- X if (CurSurf->surf)
- X $$ = CurSurf->surf;
- X else
- X $$ = &DefaultSurface;
- X }
- X ;
- XModifyNamedSurf : CopyNamedSurf SurfComponent SurfComponents
- X {
- X $$ = tmpsurf;
- X tmpsurf = (Surface *)NULL;
- X }
- X | CopyCurSurf SurfComponent SurfComponents
- X {
- X $$ = tmpsurf;
- X tmpsurf = (Surface *)NULL;
- X }
- X ;
- XCopyNamedSurf : tSTRING
- X {
- X tmpsurf = SurfaceCopy(SurfaceGetNamed($1));
- X }
- X ;
- XCopyCurSurf : tCURSURF
- X {
- X extern Surface DefaultSurface;
- X if (CurSurf->surf)
- X tmpsurf = SurfaceCopy(CurSurf->surf);
- X else
- X tmpsurf = SurfaceCopy(&DefaultSurface);
- X }
- X ;
- XSurfSpec : SurfComponent SurfComponents
- X {
- X $$ = tmpsurf;
- X tmpsurf = (Surface *)NULL;
- X }
- X ;
- XSurfDef : tSURFACE tSTRING Surface
- X {
- X tmpsurf = SurfaceCopy($3);
- X tmpsurf->name = strsave($2);
- X SurfaceAddToDefined(tmpsurf);
- X tmpsurf = (Surface *)NULL;
- X }
- X | tSURFACE tSTRING
- X {
- X /* black surface */
- X tmpsurf = SurfaceCreate();
- X tmpsurf->name = strsave($2);
- X SurfaceAddToDefined(tmpsurf);
- X tmpsurf = (Surface *)NULL;
- X }
- X ;
- XSurfComponents : SurfComponents SurfComponent
- X | /* EMPTY */
- X ;
- XSurfComponent : Ambient
- X | Diffuse
- X | Specular
- X | Specpow
- X | Body
- X | Reflect
- X | Transp
- X | Extinct
- X | Index
- X | Translu
- X | Noshadow
- X ;
- XAmbient : tAMBIENT Color
- X {
- X if (tmpsurf == (Surface *)NULL)
- X tmpsurf = SurfaceCreate();
- X tmpsurf->amb = $2;
- X }
- X ;
- XDiffuse : tDIFFUSE Color
- X {
- X if (tmpsurf == (Surface *)NULL)
- X tmpsurf = SurfaceCreate();
- X tmpsurf->diff = $2;
- X }
- X ;
- XSpecular : tSPECULAR Color
- X {
- X if (tmpsurf == (Surface *)NULL)
- X tmpsurf = SurfaceCreate();
- X tmpsurf->spec = $2;
- X }
- X ;
- XBody : tBODY Color
- X {
- X if (tmpsurf == (Surface *)NULL)
- X tmpsurf = SurfaceCreate();
- X tmpsurf->body = $2;
- X };
- XExtinct : tEXTINCT Expr
- X {
- X if (tmpsurf == (Surface *)NULL)
- X tmpsurf = SurfaceCreate();
- X tmpsurf->statten = $2;
- X };
- XSpecpow : tSPECPOW Expr
- X {
- X if (tmpsurf == (Surface *)NULL)
- X tmpsurf = SurfaceCreate();
- X tmpsurf->srexp = $2;
- X }
- X ;
- XReflect : tREFLECT Expr
- X {
- X if (tmpsurf == (Surface *)NULL)
- X tmpsurf = SurfaceCreate();
- X tmpsurf->reflect = $2;
- X }
- X ;
- XTransp : tTRANSP Expr
- X {
- X if (tmpsurf == (Surface *)NULL)
- X tmpsurf = SurfaceCreate();
- X tmpsurf->transp = $2;
- X }
- X ;
- XIndex : tINDEX Expr
- X {
- X if (tmpsurf == (Surface *)NULL)
- X tmpsurf = SurfaceCreate();
- X tmpsurf->index = $2;
- X }
- X ;
- XTranslu : tTRANSLU Expr Color Expr
- X {
- X if (tmpsurf == (Surface *)NULL)
- X tmpsurf = SurfaceCreate();
- X tmpsurf->translucency = $2;
- X tmpsurf->translu = $3;
- X tmpsurf->stexp = $4;
- X }
- X ;
- XNoshadow : tNOSHADOW
- X {
- X if (tmpsurf == (Surface *)NULL)
- X tmpsurf = SurfaceCreate();
- X tmpsurf->noshadow = TRUE;
- X }
- X ;
- XHeightField : tHEIGHTFIELD Surface Filename
- X {
- X $$ = GeomHfCreate($3);
- X if ($$)
- X $$->surf = $2;
- X }
- X | tHEIGHTFIELD Filename
- X {
- X $$ = GeomHfCreate($2);
- X }
- X ;
- XPoly : tPOLY OptSurface Polypoints
- X {
- X $$ = GeomPolygonCreate(Polypoints, Npoints,
- X Options.flipnorm);
- X if ($$)
- X $$->surf = $2;
- X Polypoints = (PointList *)NULL;
- X Npoints = 0;
- X }
- X ;
- XPolypoints : /* empty */
- X | Polypoints Polypoint
- X ;
- XPolypoint : Vector
- X {
- X PointList *ptmp;
- X
- X ptmp = (PointList *)Malloc(sizeof(PointList));
- X ptmp->vec = $1;
- X ptmp->next = Polypoints;
- X Polypoints = ptmp;
- X Npoints++;
- X }
- X ;
- XAggregate : AggregateDef
- X {
- X if (Defstack->obj) {
- X /*
- X * Set object texture to current texture.
- X */
- X Defstack->obj->texture = CurText;
- X }
- X CurText = (Texture *)NULL;
- X /*
- X * Pop topmost object on stack.
- X */
- X $$ = Defstack->obj;
- X Defstack = GeomStackPop(Defstack);
- X /* Pop current surface */
- X CurSurf = SurfPop(CurSurf);
- X }
- X ;
- XAggregateDef : AggregateCreate Aggdefs tEND
- X {
- X /* Convert aggregate, pop stacks, etc. */
- X if ($1) {
- X if (Defstack->obj->next == (Geom *)NULL) {
- X RLerror(RL_WARN,
- X "Null object defined.\n");
- X Defstack->obj = (Geom *)NULL;
- X } else {
- X /*
- X * Convert the linked list of objects
- X * associated with the topmost object
- X * to the appropriate aggregate type.
- X */
- X Defstack->obj->prims=AggregateConvert(
- X Defstack->obj,
- X Defstack->obj->next);
- X /*
- X * Make sure conversion worked OK.
- X */
- X if (Defstack->obj->prims <= 0)
- X Defstack->obj = (Geom *)NULL;
- X }
- X }
- X }
- X ;
- XAggregateCreate : AggregateType
- X {
- X if ($1) {
- X Defstack = GeomStackPush($1, Defstack);
- X CurSurf = SurfPush((Surface *)NULL, CurSurf);
- X }
- X };
- XAggregateType : List
- X | Grid
- X | Csg
- X ;
- XList : tLIST
- X {
- X $$ = GeomListCreate();
- X }
- X ;
- XGrid : tGRID IExpr IExpr IExpr
- X {
- X $$ = GeomGridCreate($2, $3, $4);
- X }
- X ;
- XCsg : CombineOp
- X {
- X $$ = GeomCsgCreate($1);
- X Options.csg = TRUE;
- X }
- X ;
- XCombineOp : tUNION
- X {
- X $$ = CSG_UNION;
- X }
- X | tINTERSECT
- X {
- X $$ = CSG_INTERSECT;
- X }
- X | tDIFFERENCE
- X {
- X $$ = CSG_DIFFERENCE;
- X }
- X ;
- XCone : tCONE OptSurface Expr Vector Expr Vector
- X {
- X if (equal($3, $5)) {
- X /* It's really a cylinder */
- X $$ = GeomCylinderCreate($3, &$4, &$6);
- X } else
- X $$ = GeomConeCreate($3, &$4, $5, &$6);
- X if ($$)
- X $$->surf = $2;
- X }
- X ;
- XCylinder : tCYL OptSurface Expr Vector Vector
- X {
- X $$ = GeomCylinderCreate($3, &$4, &$5);
- X if ($$)
- X $$->surf = $2;
- X }
- X ;
- XSphere : tSPHERE OptSurface Expr Vector
- X {
- X $$ = GeomSphereCreate($3, &($4));
- X if ($$)
- X $$->surf = $2;
- X }
- X ;
- XDisc : tDISC OptSurface Expr Vector Vector
- X {
- X $$ = GeomDiscCreate($3, &($4), &($5));
- X if ($$)
- X $$->surf = $2;
- X }
- X ;
- XBox : tBOX OptSurface Vector Vector
- X {
- X $$ = GeomBoxCreate(&$3, &$4);
- X if ($$)
- X $$->surf = $2;
- X }
- X ;
- XTriangle : tTRIANGLE OptSurface Vector Vector Vector
- X {
- X $$ = GeomTriangleCreate(FLATTRI, &($3), &($4), &($5),
- X (Vector *)NULL, (Vector *)NULL, (Vector *)NULL,
- X (Vec2d *)NULL, (Vec2d *)NULL, (Vec2d *)NULL,
- X Options.flipnorm);
- X if ($$)
- X $$->surf = $2;
- X }
- X | tTRIANGLE OptSurface Vector Vector
- X Vector Vector
- X Vector Vector
- X {
- X $$ = GeomTriangleCreate(PHONGTRI, &($3), &($5),
- X &($7), &($4), &($6), &($8),
- X (Vec2d *)NULL, (Vec2d *)NULL, (Vec2d *)NULL,
- X Options.flipnorm);
- X if ($$)
- X $$->surf = $2;
- X }
- X | tTRIANGLEUV OptSurface Vector Vector Vec2d
- X Vector Vector Vec2d
- X Vector Vector Vec2d
- X {
- X $$ = GeomTriangleCreate(PHONGTRI, &($3), &($6), &($9),
- X &($4), &($7), &($10),
- X &($5), &($8), &($11),
- X Options.flipnorm);
- X if ($$)
- X $$->surf = $2;
- X }
- X ;
- XPlane : tPLANE OptSurface Vector Vector
- X {
- X $$ = GeomPlaneCreate(&($3), &($4));
- X if ($$)
- X $$->surf = $2;
- X }
- X ;
- XTorus : tTORUS OptSurface Expr Expr Vector Vector
- X {
- X $$ = GeomTorusCreate($3, $4, &($5), &($6));
- X if ($$)
- X $$->surf = $2;
- X }
- X ;
- XBlob : tBLOB OptSurface Expr MetaPoints
- X {
- X $$ = GeomBlobCreate($3, Metapoints, Npoints);
- X if ($$)
- X $$->surf = $2;
- X Metapoints = (MetaList *)NULL;
- X Npoints = 0;
- X }
- X ;
- XMetaPoints : /* empty */
- X | MetaPoints MetaPoint
- X ;
- XMetaPoint : Expr Expr Expr Expr Expr
- X {
- X Metapoint = (MetaList *)Malloc(sizeof(MetaList));
- X Metapoint->mvec.c0 = $1;
- X Metapoint->mvec.rs = $2;
- X Metapoint->mvec.x = $3;
- X Metapoint->mvec.y = $4;
- X Metapoint->mvec.z = $5;
- X Metapoint->next = Metapoints;
- X Metapoints = Metapoint;
- X Npoints++;
- X }
- X ;
- XOutfile : tOUTFILE Filename
- X {
- X if (Options.imgname != (char *)NULL)
- X /* Already set on command line. */
- X RLerror(RL_WARN,
- X "Ignoring output file name \"%s\".\n",
- X $2);
- X else
- X Options.imgname = strsave($2);
- X }
- X ;
- XGlobalEffects : tATMOSPHERE Effects
- X {
- X AtmosEffects = CurEffect;
- X CurEffect = (Atmosphere *)NULL;
- X }
- X | tATMOSPHERE IExpr Effects
- X {
- X if ($2 <= 0.)
- X RLerror(RL_PANIC,
- X "Index of refraction must be positive.\n");
- X TopMedium.index = $2;
- X AtmosEffects = CurEffect;
- X CurEffect = (Atmosphere *)NULL;
- X }
- X ;
- XEffects : Effects Effect
- X |
- X ;
- XEffect : EffectType
- X {
- X $1->next = CurEffect;
- X CurEffect = $1;
- X }
- X ;
- XEffectType : tMIST Color Color Expr Expr
- X {
- X $$ = AtmosMistCreate(&($2), &($3), $4, $5);
- X }
- X | tFOG Color Color
- X {
- X $$ = AtmosFogCreate(&($2), &($3));
- X }
- X | tFOGDECK Expr Expr Vector Expr IExpr Color Color
- X {
- X $$ = AtmosFogdeckCreate($2, $3, &$4, $5, $6, &$7, &$8);
- X }
- X ;
- XColor : Expr Expr Expr
- X {
- X $$.r = $1;
- X $$.g = $2;
- X $$.b = $3;
- X }
- X ;
- XVector : Expr Expr Expr
- X {
- X $$.x = $1;
- X $$.y = $2;
- X $$.z = $3;
- X }
- X ;
- XVec2d : Expr Expr
- X {
- X $$.u = $1;
- X $$.v = $2;
- X }
- X ;
- XOptMapping : Mapping
- X | /* EMPTY */
- X {
- X $$ = UVMappingCreate();
- X }
- X ;
- XMapping : tMAP MapMethod
- X {
- X $$ = $2;
- X }
- X ;
- XMapMethod : tUV
- X {
- X $$ = UVMappingCreate();
- X }
- X | tSPHERICAL
- X {
- X $$ = SphereMappingCreate((Vector *)NULL,
- X (Vector *)NULL, (Vector *)NULL);
- X }
- X | tSPHERICAL Vector Vector Vector
- X {
- X /* origin up uaxis */
- X $$ = SphereMappingCreate(&$2, &$3, &$4);
- X }
- X | tCYLINDRICAL
- X {
- X $$ = CylMappingCreate((Vector *)NULL,
- X (Vector *)NULL, (Vector *)NULL);
- X }
- X | tCYLINDRICAL Vector Vector Vector
- X {
- X /* origin up uaxis */
- X $$ = CylMappingCreate(&$2, &$3, &$4);
- X }
- X | tPLANAR
- X {
- X $$ = LinearMappingCreate((Vector *)NULL,
- X (Vector *)NULL, (Vector *)NULL);
- X }
- X | tPLANAR Vector Vector Vector
- X {
- X /* origin up uaxis */
- X $$ = LinearMappingCreate(&$2, &$3, &$4);
- X }
- X ;
- XSurfCompName : tAMBIENT
- X {
- X $$ = AMBIENT;
- X }
- X | tDIFFUSE
- X {
- X $$ = DIFFUSE;
- X }
- X | tBODY
- X {
- X $$ = BODY;
- X }
- X | tSPECULAR
- X {
- X $$ = SPECULAR;
- X }
- X | tREFLECT
- X {
- X $$ = REFLECT;
- X }
- X | tTRANSP
- X {
- X $$ = TRANSP;
- X }
- X | tSPECPOW
- X {
- X $$ = SPECPOW;
- X }
- X | tBUMP
- X {
- X $$ = BUMP;
- X }
- X | tINDEX
- X {
- X $$ = INDEX;
- X }
- X ;
- XIntensity : Expr
- X { $$.r = $$.g = $$.b = $1; }
- X | Color
- X ;
- XPrint : tPRINT Expr
- X {
- X fprintf(stderr,"%f\n",$2);
- X }
- XDefine : tDEFINE tSTRING AnimExpr
- X {
- X SymtabAddEntry($2, $3->type, $3, NULL, $3->timevary, 0);
- X };
- XIExpr : Expr
- X { $$ = (int)$1; }
- X ;
- XExpr : Float
- X | ParenExpr
- X {
- X if (!$1->timevary) {
- X $$ = ExprEval($1);
- X } else {
- X RLerror(RL_PANIC, "Illegal expression use.\n");
- X }
- X }
- X ;
- XAnimExpr : Float
- X {
- X $$ = ExprReuseFloatCreate($1);
- X }
- X | ParenExpr
- X ;
- XParenExpr : '(' MExpr ')'
- X {
- X $$ = $2;
- X };
- XMExpr : tFLOAT
- X {
- X $$ = ExprFloatCreate($1, FALSE);
- X }
- X | tSTRING
- X {
- X $$ = ExprFloatSymtabFind($1);
- X }
- X | Symtabent '(' MExpr ')'
- X {
- X $$ = ExprResolve1($3, $1->value.fp, $1->timevary);
- X }
- X | Symtabent '(' MExpr ',' MExpr ')'
- X {
- X $$ = ExprResolve2($3, $5,
- X $1->value.fp,
- X $1->timevary);
- X }
- X | Symtabent '(' MExpr ',' MExpr ',' MExpr ')'
- X {
- X $$ = ExprResolve3($3, $5, $7,
- X $1->value.fp,
- X $1->timevary);
- X }
- X | Symtabent '(' MExpr ',' MExpr ',' MExpr ',' MExpr ')'
- X {
- X $$ = ExprResolve4($3, $5, $7, $9,
- X $1->value.fp,
- X $1->timevary);
- X }
- X | Symtabent
- X '(' MExpr ',' MExpr ',' MExpr ',' MExpr ',' MExpr ')'
- X {
- X $$ = ExprResolve5($3, $5, $7, $9, $11,
- X $1->value.fp,
- X $1->timevary);
- X }
- X | '(' MExpr ')'
- X {
- X $$ = $2;
- X }
- X | MExpr '+' MExpr
- X {
- X $$ = ExprResolve2($1, $3, SumExpr, FALSE);
- X }
- X | MExpr '-' MExpr
- X {
- X $$ = ExprResolve2($1, $3, DiffExpr, FALSE);
- X }
- X | MExpr '*' MExpr
- X {
- X $$ = ExprResolve2($1, $3, MultExpr, FALSE);
- X }
- X | MExpr '/' MExpr
- X {
- X $$ = ExprResolve2($1, $3, DivideExpr, FALSE);
- X }
- X | MExpr '%' MExpr
- X {
- X $$ = ExprResolve2($1, $3, ModExpr, FALSE);
- X }
- X | '-' MExpr %prec UMINUS
- X {
- X $$ = ExprResolve1($2, NegateExpr, FALSE);
- X }
- X | '+' MExpr %prec UMINUS
- X {
- X $$ = $2;
- X }
- X | MExpr '^' MExpr
- X {
- X $$ = ExprResolve2($1, $3, pow, FALSE);
- X } ;
- XFloat : tFLOAT
- X | '-' tFLOAT
- X { $$ = -$2; }
- X | '+' tFLOAT
- X { $$ = $2; };
- XFilename : tSTRING
- X | tFILENAME
- X ;
- XSymtabent : tSTRING
- X {
- X $$ = SymtabBuiltinFind($1);
- X };
- X%%
- X/*
- X * Issue error message containing filename and line number, and exit.
- X */
- X/*VARARGS1*/
- Xyyerror(s, pat1, pat2)
- Xchar *s, *pat1, *pat2;
- X{
- X fprintf(stderr,"%s: Error: %s: line %d: ", Options.progname,
- X yyfilename, yylineno);
- X fprintf(stderr, s, pat1, pat2);
- X if (*s && s[strlen(s) -1] != '\n')
- X /* YACC doesn't put newlines on error messages. */
- X fprintf(stderr,"\n");
- X fflush(stderr);
- X exit(1);
- X}
- X
- XGeom *
- XNewAggregate(obj)
- XGeom *obj;
- X{
- X obj->name = Defstack->obj->name;
- X obj->next = Defstack->obj->next;
- X return obj;
- X}
- END_OF_FILE
- if test 28326 -ne `wc -c <'libshade/yacc.y'`; then
- echo shar: \"'libshade/yacc.y'\" unpacked with wrong size!
- fi
- # end of 'libshade/yacc.y'
- fi
- echo shar: End of archive 18 \(of 19\).
- cp /dev/null ark18isdone
- 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...
-