⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pov.y

📁 [Game.Programming].Academic - Graphics Gems (6 books source code)
💻 Y
📖 第 1 页 / 共 2 页
字号:
%{#include <iostream.h>#include <string.h>#include <stdlib.h>#include "global.h"//      DECLARATIONStexture *deftexture;declarations<object> odecls;declarations<texture> tdecls;declarations<pigment> pdecls;declarations<normal> ndecls;declarations<finish> fdecls;declarations<color> cdecls;declarations<colormap> cmdecls;declarations<vector> vdecls;declarations<camera> camdecls;int max_intersections=64;double version=2.2;double clock=0.;intensity background=intensity(0.,0.,0.);%}%start  items%union {        int ival;        double dval;        char* sval;        vector* vval;        object* oval;        color* cval;        list<object*>* olval;        texture* tval;        pigment* pval;        normal* nval;        finish* fval;        camera* camval;        colormap* cmval;        lightsource *lval;}/**       KEYWORD TOKENS*/%token  <ival> ADAPTIVE%token  <ival> AGATE%token  <ival> AGATE_TURB%token  <ival> ALL%token  <ival> ALPHA%token  <ival> AMBIENT%token  <ival> AREA_LIGHT%token  <ival> BACKGROUND%token  <ival> BICUBIC_PATCH%token  <ival> BLOB%token  <ival> BLUE%token  <ival> BOUNDED_BY%token  <ival> BOX%token  <ival> BOZO%token  <ival> BRICK%token  <ival> BRILLIANCE%token  <ival> BUMPS%token  <ival> BUMPY1%token  <ival> BUMPY2%token  <ival> BUMPY3%token  <ival> BUMP_MAP%token  <ival> BUMP_SIZE%token  <ival> CAMERA_ID%token  <ival> CAMERA%token  <ival> CHECKER%token  <ival> CLIPPED_BY%token  <ival> CLOCK%token  <ival> COLOR_ID%token  <ival> COLOR_MAP_ID%token  <ival> COLOR_MAP%token  <ival> COLOR%token  <ival> COMPONENT%token  <ival> COMPOSITE%token  <ival> CONE%token  <ival> CRAND%token  <ival> CUBIC%token  <ival> CYLINDER%token  <ival> DECLARE%token  <ival> DEFAULT%token  <ival> DENTS%token  <ival> DIFFERENCE%token  <ival> DIFFUSE%token  <ival> DIRECTION%token  <ival> DISC%token  <ival> DISTANCE%token  <ival> DUMP%token  <ival> END_OF_FILE%token  <ival> FALLOFF%token  <ival> FILTER%token  <ival> FINISH_ID%token  <ival> FINISH%token  <ival> FLATNESS%token  <ival> FLOAT_ID%token  <ival> FLOAT%token  <ival> FOG%token  <ival> FREQUENCY%token  <ival> GIF%token  <ival> GRADIENT%token  <ival> GRANITE%token  <ival> GREEN%token  <ival> HEIGHT_FIELD%token  <ival> HEXAGON%token  <ival> IFF%token  <ival> IMAGE_MAP%token  <ival> INCLUDE%token  <ival> INTERPOLATE%token  <ival> INTERSECTION%token  <ival> INVERSE%token  <ival> IOR%token  <ival> JITTER%token  <ival> LAMBDA%token  <ival> LEOPARD%token  <ival> LIGHT_SOURCE%token  <ival> LOCATION%token  <ival> LOOKS_LIKE%token  <ival> LOOK_AT%token  <ival> MANDEL%token  <ival> MAP_TYPE%token  <ival> MARBLE%token  <ival> MATERIAL_MAP%token  <ival> MAX_INTERSECTIONS%token  <ival> MAX_TRACE_LEVEL%token  <ival> MERGE%token  <ival> METALLIC%token  <ival> MORTAR%token  <ival> NO_SHADOW%token  <ival> OBJECT_ID%token  <ival> OBJECT%token  <ival> OCTAVES%token  <ival> OMEGA%token  <ival> ONCE%token  <ival> ONION%token  <ival> OPEN%token  <ival> PAINTED1%token  <ival> PAINTED2%token  <ival> PAINTED3%token  <ival> PHASE%token  <ival> PHONG_SIZE%token  <ival> PHONG%token  <ival> PIGMENT_ID%token  <ival> PIGMENT%token  <ival> PLANE%token  <ival> POINT_AT%token  <ival> POLY%token  <ival> POT%token  <ival> QUADRIC%token  <ival> QUARTIC%token  <ival> QUICK_COLOR%token  <ival> RADIAL%token  <ival> RADIUS%token  <ival> RAW%token  <ival> RED%token  <ival> REFLECTION%token  <ival> REFRACTION%token  <ival> RGBF%token  <ival> RGB%token  <ival> RIGHT%token  <ival> RIPPLES%token  <ival> ROTATE%token  <ival> ROUGHNESS%token  <ival> SCALE%token  <ival> SKY%token  <ival> SMOOTH%token  <ival> SMOOTH_TRIANGLE%token  <ival> SPECULAR%token  <ival> SPHERE%token  <ival> SPOTLIGHT%token  <ival> SPOTTED%token  <ival> STRING%token  <ival> STURM%token  <ival> TEXTURE_ID%token  <ival> TEXTURE%token  <ival> TGA%token  <ival> THRESHOLD%token  <ival> TIGHTNESS%token  <ival> TILE2%token  <ival> TILES%token  <ival> TNORMAL_ID%token  <ival> NORMAL%token  <ival> TORUS%token  <ival> TRACK%token  <ival> TRANSFORM_ID%token  <ival> TRANSFORM%token  <ival> TRANSLATE%token  <ival> TRIANGLE%token  <ival> TURBULENCE%token  <ival> TYPE%token  <ival> UNION%token  <ival> UP%token  <ival> USE_COLOR%token  <ival> USE_INDEX%token  <ival> U_STEPS%token  <ival> VECTOR_ID%token  <ival> VERSION%token  <ival> V_STEPS%token  <ival> WATER_LEVEL%token  <ival> WAVES%token  <ival> WOOD%token  <ival> WRINKLES%token  <ival> X%token  <ival> Y%token  <ival> Z/**       OTHER TOKENS*/%token  <dval> LITERAL%token  <sval> IDENTIFIER/**       NONTERMINALS*/%type   <vval> expr%type   <oval> object objopts%type   <olval> objects moreobjects%type   <cval> color colorvalues%type   <tval> texture textureitems%type   <pval> pigment pigmentitems pigmentpatt%type   <nval> normal normalitems normalpatt%type   <fval> finish finishitems%type   <camval> camera cameraitems%type   <cmval> colormap colormapitems%type   <sval> identifier%type   <lval> lightsource lightsrcitems lightsrctype spotlight%type   <vval> tightness%left   '+' '-'%left   '*' '/'%left   UMINUS%%/**       SCENE FILE ITEMS AT TOP LEVEL*/items   :       /* empty */                        {deftexture=new texture;}        |       items item        ;item    :       camera                        {actcamera=*$1; delete $1;}        |       object                        {{if(verbose) cout<<*$1;} objects+=$1;}        |       lightsource                        {lightsources+=$1;}        |       '#' DECLARE identifier '=' object                        {odecls+=new declaration<object>($3,$5);}        |       '#' DECLARE identifier '=' texture                        {tdecls+=new declaration<texture>($3,$5);}        |       '#' DECLARE identifier '=' pigment                        {pdecls+=new declaration<pigment>($3,$5);}        |       '#' DECLARE identifier '=' normal                        {ndecls+=new declaration<normal>($3,$5);}        |       '#' DECLARE identifier '=' finish                        {fdecls+=new declaration<finish>($3,$5);}        |       '#' DECLARE identifier '=' color                        {cdecls+=new declaration<color>($3,$5);}        |       '#' DECLARE identifier '=' colormap                        {cmdecls+=new declaration<colormap>($3,$5);}        |       '#' DECLARE identifier '=' expr                        {vdecls+=new declaration<vector>($3,$5);}        |       '#' DECLARE identifier '=' camera                        {camdecls+=new declaration<camera>($3,$5);}        |       '#' MAX_TRACE_LEVEL expr                        {lmax=(int)((double)*$3); delete $3;}        |       '#' MAX_INTERSECTIONS expr                        {max_intersections=(int)((double)*$3); delete $3;}        |       '#' VERSION expr                        {version=(double)*$3; delete $3;}        |       '#' DEFAULT '{' texture '}'                        {delete deftexture; deftexture=$4;}        |       '#' DEFAULT '{' pigment '}'                        {deftexture->setp(*$4); delete $4;}        |       '#' DEFAULT '{' normal '}'                        {deftexture->setn(*$4); delete $4;}        |       '#' DEFAULT '{' finish '}'                        {deftexture->setf(*$4); delete $4;}        |       BACKGROUND '{' color '}'                        {background=(intensity)(*$3); delete $3;}        ;identifier      :       IDENTIFIER                                {$$=new char[strlen($1)+1]; strcpy($$,$1);}                ;/**       FLOAT AND VECTOR EXPRESSIONS UNIFIED IN ORDER TO GET LR(1) GRAMMAR*/expr    :       LITERAL                        {$$=new vector($1,$1,$1);}        |       identifier                        {$$=new vector; *$$=*vdecls[$1]; delete $1;}        |       X                        {$$=new vector(1.,0.,0.);}        |       Y                        {$$=new vector(0.,1.,0.);}        |       Z                        {$$=new vector(0.,0.,1.);}        |       '<' expr ',' expr ',' expr '>'                        {$$=new vector((double)*$2,(double)*$4,(double)*$6);                         delete $2; delete $4; delete $6;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -