home *** CD-ROM | disk | FTP | other *** search
/ Crawly Crypt Collection 2 / crawlyvol2.bin / graphics / ftpovstc / frame.h < prev    next >
C/C++ Source or Header  |  1994-07-22  |  31KB  |  1,203 lines

  1. /****************************************************************************
  2. *
  3. *  ATTENTION!!!
  4. *
  5. *  THIS FILE HAS BEEN MODIFIED!!! IT IS NOT PART OF THE OFFICAL
  6. *  POV-RAY 2.2 DISTRIBUTION!!!
  7. *
  8. *  THIS FILE IS PART OF "FASTER THAN POV-RAY" (VERSION 1.1),
  9. *  A SPED-UP VERSION OF POV-RAY 2.2. USE AT YOUR OWN RISK!!!!!!
  10. *
  11. *  New files: addon0.c, addon1.c, addon2.c, addon3.c, addon.h
  12. *
  13. *  The additional modules were written by Dieter Bayer.
  14. *
  15. *  Send comments, suggestions, bugs, ideas ... to:
  16. *
  17. *  dieter@cip.e-technik.uni-erlangen.de
  18. *
  19. *  All changed/added lines are enclosed in #ifdef DB_CODE ... #endif
  20. *
  21. *  The vista projection was taken from:
  22. *
  23. *    A. Hashimoto, T. Akimoto, K. Mase, and Y. Suenaga, 
  24. *    "Vista Ray-Tracing: High Speed Ray Tracing Using Perspective
  25. *    Projection Image", New Advances in Computer Graphics, Proceedings
  26. *    of CG International '89, R. A. Earnshaw, B. Wyvill (Eds.), 
  27. *    Springer, ..., pp. 549-560
  28. *
  29. *  The idea for the light buffer was taken from:
  30. *
  31. *    E. Haines and D. Greenberg, "The Light Buffer: A Shadow-Testing 
  32. *    Accelerator", IEEE CG&A, Vol. 6, No. 9, Sept. 1986, pp. 6-16
  33. *
  34. *****************************************************************************/
  35. /****************************************************************************
  36. *                   frame.h
  37. *
  38. *  This header file is included by all C modules in POV-Ray. It defines all
  39. *  globally-accessible types and constants.
  40. *
  41. *  from Persistence of Vision Raytracer
  42. *  Copyright 1993 Persistence of Vision Team
  43. *---------------------------------------------------------------------------
  44. *  NOTICE: This source code file is provided so that users may experiment
  45. *  with enhancements to POV-Ray and to port the software to platforms other 
  46. *  than those supported by the POV-Ray Team.  There are strict rules under
  47. *  which you are permitted to use this file.  The rules are in the file
  48. *  named POVLEGAL.DOC which should be distributed with this file. If 
  49. *  POVLEGAL.DOC is not available or for more info please contact the POV-Ray
  50. *  Team Coordinator by leaving a message in CompuServe's Graphics Developer's
  51. *  Forum.  The latest version of POV-Ray may be found there as well.
  52. *
  53. * This program is based on the popular DKB raytracer version 2.12.
  54. * DKBTrace was originally written by David K. Buck.
  55. * DKBTrace Ver 2.0-2.12 were written by David K. Buck & Aaron A. Collins.
  56. *
  57. *****************************************************************************/
  58.  
  59. /* Generic header for all modules */
  60.  
  61. #include <math.h>
  62. #include <stdio.h>
  63. #include <stdlib.h>
  64. #include <stddef.h>
  65. #include <string.h>
  66. #include <limits.h>
  67. #include "config.h"
  68.  
  69. #include <time.h>
  70. #include <tos.h>
  71. #include <atarierr.h>
  72.  
  73. /* use the modified/added code of the FTPOV-Ray distribution. DB */
  74.  
  75. #define DB_CODE
  76.  
  77.  
  78. /* These are used by POVRAY.C and the machine specific modules */
  79.  
  80. #define POV_RAY_VERSION "2.2"
  81.  
  82. /* This message is for the personal distribution release. */
  83.  
  84. #ifdef DB_CODE
  85.   #define DISTRIBUTION_MESSAGE_1 "FASTER THAN POV-Ray (Ver 2.1) (sped-up and unoffical) by:"
  86.   #define DISTRIBUTION_MESSAGE_2 "Dieter Bayer (e-mail: dieter@cip.e-technik.uni-erlangen.de)"
  87. #else
  88.   #define DISTRIBUTION_MESSAGE_1 "This is an unofficial version compiled by:"
  89.   #define DISTRIBUTION_MESSAGE_2 "FILL IN NAME HERE........................."
  90. #endif
  91. #define DISTRIBUTION_MESSAGE_3 "The POV-Ray Team is not responsible for supporting this version."
  92.  
  93. #ifndef READ_ENV_VAR_BEFORE 
  94. #define READ_ENV_VAR_BEFORE 
  95. #endif
  96. #ifndef READ_ENV_VAR_AFTER
  97. #define READ_ENV_VAR_AFTER if ((Option_String_Ptr = getenv("POVRAYOPT")) != NULL) read_options(Option_String_Ptr);   
  98. #endif
  99.  
  100. #ifndef CONFIG_MATH
  101. #define CONFIG_MATH
  102. #endif
  103.  
  104. #ifndef EPSILON
  105. #define EPSILON 1.0e-10
  106. #endif
  107.  
  108. #ifndef FILE_NAME_LENGTH
  109. #define FILE_NAME_LENGTH 150
  110. #endif
  111.  
  112. #ifndef HUGE_VAL
  113. #define HUGE_VAL 1.0e+17
  114. #endif
  115.  
  116. #ifndef BOUND_HUGE
  117. #define BOUND_HUGE 1.0e30
  118. #endif
  119.  
  120. #ifndef DBL_FORMAT_STRING
  121. #define DBL_FORMAT_STRING "%lf"
  122. #endif
  123.  
  124. #ifndef DEFAULT_OUTPUT_FORMAT
  125. #define DEFAULT_OUTPUT_FORMAT    'd'
  126. #endif
  127.  
  128. #ifndef RED_RAW_FILE_EXTENSION
  129. #define RED_RAW_FILE_EXTENSION ".red"
  130. #endif
  131.  
  132. #ifndef GREEN_RAW_FILE_EXTENSION
  133. #define GREEN_RAW_FILE_EXTENSION ".grn"
  134. #endif
  135.  
  136. #ifndef BLUE_RAW_FILE_EXTENSION
  137. #define BLUE_RAW_FILE_EXTENSION ".blu"
  138. #endif
  139.  
  140. #ifndef FILENAME_SEPARATOR
  141. #define FILENAME_SEPARATOR "/"
  142. #endif
  143.  
  144. /* 0==yes 1==no 2==opt */
  145. #ifndef CASE_SENSITIVE_DEFAULT
  146. #define CASE_SENSITIVE_DEFAULT 0
  147. #endif
  148.  
  149. #ifndef READ_FILE_STRING
  150. #define READ_FILE_STRING "rb"
  151. #endif
  152.  
  153. #ifndef WRITE_FILE_STRING
  154. #define WRITE_FILE_STRING "wb"
  155. #endif
  156.  
  157. #ifndef APPEND_FILE_STRING
  158. #define APPEND_FILE_STRING "ab"
  159. #endif
  160.  
  161. #ifndef NORMAL
  162. #define NORMAL '0'
  163. #endif
  164.  
  165. #ifndef GREY
  166. #define GREY   'G'
  167. #endif
  168.  
  169. #ifndef START_TIME
  170. #define START_TIME time(&tstart);     
  171. #endif
  172.  
  173. #ifndef STOP_TIME
  174. #define STOP_TIME  time(&tstop);
  175. #endif
  176.  
  177. #ifndef TIME_ELAPSED
  178. #define TIME_ELAPSED difftime (tstop, tstart);
  179. #endif
  180.  
  181. #ifndef STARTUP_POVRAY
  182. #define STARTUP_POVRAY
  183. #endif
  184.  
  185. #ifndef PRINT_OTHER_CREDITS
  186. #define PRINT_OTHER_CREDITS
  187. #endif
  188.  
  189. #ifndef TEST_ABORT
  190. #define TEST_ABORT
  191. #endif
  192.  
  193. #ifndef FINISH_POVRAY
  194. #define FINISH_POVRAY
  195. #endif
  196.  
  197. #ifndef COOPERATE
  198. #define COOPERATE 
  199. #endif
  200.  
  201. #ifndef DBL
  202. #define DBL double
  203. #endif
  204.  
  205. #ifndef ACOS
  206. #define ACOS acos
  207. #endif
  208.  
  209. #ifndef SQRT
  210. #define SQRT sqrt
  211. #endif
  212.  
  213. #ifndef POW
  214. #define POW pow
  215. #endif
  216.  
  217. #ifndef COS
  218. #define COS cos
  219. #endif
  220.  
  221. #ifndef SIN
  222. #define SIN sin
  223. #endif
  224.  
  225. #ifndef labs
  226. #define labs(x) (long) ((x<0)?-x:x)
  227. #endif
  228.  
  229. #ifndef max
  230. #define max(x,y) ((x<y)?y:x)
  231. #endif
  232.  
  233. #ifndef STRLN
  234. #define STRLN(x) x
  235. #endif
  236.  
  237. #ifndef PARAMS
  238. #define PARAMS(x) x
  239. #endif
  240.  
  241. #ifndef ANSIFUNC
  242. #define ANSIFUNC 1
  243. #endif
  244.  
  245. #ifndef M_PI
  246. #define M_PI 3.1415926535897932384626
  247. #endif
  248.  
  249. #ifndef TRUE
  250. #define TRUE 1
  251. #define FALSE 0
  252. #endif
  253.  
  254. #ifndef IFF_SWITCH_CAST
  255. #define IFF_SWITCH_CAST (int)
  256. #endif
  257.  
  258. #ifndef PRINT_CREDITS
  259. #define PRINT_CREDITS print_credits();
  260. #endif
  261.  
  262. #ifndef PRINT_STATS
  263. #define PRINT_STATS print_stats();
  264. #endif
  265.  
  266. #ifndef MAX_CONSTANTS
  267. #define MAX_CONSTANTS 1000
  268. #endif
  269.  
  270. #ifndef WAIT_FOR_KEYPRESS
  271. #define WAIT_FOR_KEYPRESS
  272. #endif
  273.  
  274. #ifndef CDECL
  275. #define CDECL
  276. #endif
  277.  
  278. #ifndef MAX_BUFSIZE
  279. #define MAX_BUFSIZE INT_MAX
  280. #endif
  281.  
  282. /* If compiler version is undefined, then make it 'u' for unknown */
  283. #ifndef COMPILER_VER
  284. #define COMPILER_VER ".u"
  285. #endif
  286.  
  287. #ifndef QSORT_FUNCT_RET
  288. #define QSORT_FUNCT_RET int CDECL
  289. #endif
  290.  
  291. #ifndef QSORT_FUNCT_PARAM
  292. #define QSORT_FUNCT_PARAM void *
  293. #endif
  294.  
  295. #ifndef MAIN_RETURN_TYPE
  296. #define MAIN_RETURN_TYPE void
  297. #endif
  298.  
  299. #ifndef MAIN_RETURN_STATEMENT
  300. #define MAIN_RETURN_STATEMENT
  301. #endif
  302.  
  303. /* These values determine the minumum and maximum distances
  304.    that qualify as ray-object intersections */
  305. #define Small_Tolerance 0.001
  306. #define Max_Distance 1.0e7
  307.  
  308. #ifdef DB_CODE
  309.  
  310. /* define structures needed for vista/light tree */
  311.  
  312. typedef struct Project_Struct PROJECT;
  313.  
  314. typedef struct Project_Tree_Node_Struct PROJECT_TREE_NODE;
  315. typedef struct Project_Tree_Leaf_Struct PROJECT_TREE_LEAF;
  316.  
  317. struct Project_Struct
  318. {
  319.   int x1, y1, x2, y2;
  320. };
  321.  
  322. #endif
  323.  
  324.  
  325. typedef struct istk_entry INTERSECTION;
  326. typedef struct Vector_Struct VECTOR;
  327. typedef DBL MATRIX [4][4];
  328. typedef struct Bounding_Box_Struct BBOX;
  329. typedef struct Colour_Struct COLOUR;
  330. typedef struct Colour_Map_Entry COLOUR_MAP_ENTRY;
  331. typedef struct Colour_Map_Struct COLOUR_MAP;
  332. typedef struct Transform_Struct TRANSFORM;
  333. typedef struct Image_Struct IMAGE;
  334. typedef struct Texture_Struct TEXTURE;
  335. typedef struct Material_Texture_Struct MATERIAL;
  336. typedef struct Tiles_Texture_Struct TILES;
  337. typedef struct Pattern_Struct TPATTERN;
  338. typedef struct Pigment_Struct PIGMENT;
  339. typedef struct Tnormal_Struct TNORMAL;
  340. typedef struct Finish_Struct FINISH;
  341. typedef struct Method_Struct METHODS;
  342. typedef struct Camera_Struct CAMERA;
  343. typedef struct Object_Struct OBJECT;
  344. typedef struct Composite_Struct COMPOSITE;
  345. typedef struct Sphere_Struct SPHERE;
  346. typedef struct Quadric_Struct QUADRIC;
  347. typedef struct Poly_Struct POLY;
  348. typedef struct Disc_Struct DISC;
  349. typedef struct Cone_Struct CYLINDER;
  350. typedef struct Cone_Struct CONE;
  351. typedef struct Light_Source_Struct LIGHT_SOURCE;
  352. typedef struct Bicubic_Patch_Struct BICUBIC_PATCH;
  353. typedef struct Triangle_Struct TRIANGLE;
  354. typedef struct Smooth_Triangle_Struct SMOOTH_TRIANGLE;
  355. typedef struct Plane_Struct PLANE;
  356. typedef struct CSG_Struct CSG;
  357. typedef struct Box_Struct BOX;
  358. typedef struct Blob_Struct BLOB;
  359. typedef struct Ray_Struct RAY;
  360. typedef struct Frame_Struct FRAME;
  361. typedef struct istack_struct ISTACK;
  362. typedef int TOKEN;
  363. typedef int CONSTANT;
  364. typedef struct Chunk_Header_Struct CHUNK_HEADER;
  365. typedef struct Data_File_Struct DATA_FILE;
  366. typedef struct complex_block complex;
  367. typedef struct Height_Field_Struct HEIGHT_FIELD;
  368. typedef short WORD;
  369.  
  370. struct Vector_Struct
  371.   {
  372.    DBL x, y, z;
  373.   };
  374. #define Destroy_Vector(x) if ((x)!=NULL) free(x)
  375. #define Destroy_Float(x) if ((x)!=NULL) free(x)
  376.  
  377. struct Colour_Struct
  378.   {
  379.    DBL Red, Green, Blue, Filter;
  380.   };
  381.  
  382. #define Make_Colour(c,r,g,b) {(c)->Red=(r);(c)->Green=(g);(c)->Blue=(b);(c)->Filter=0.0;}
  383. #define Make_ColourA(c,r,g,b,a) {(c)->Red=(r);(c)->Green=(g);(c)->Blue=(b);(c)->Filter=(a);}
  384. #define Make_Vector(v,a,b,c) { (v)->x=(a);(v)->y=(b);(v)->z=(c); }
  385. #define Destroy_Colour(x) if ((x)!=NULL) free(x)
  386. #define MAX_COLOUR_MAP_ENTRIES 40
  387.  
  388. struct Colour_Map_Entry
  389.   {
  390.    DBL value;
  391.    COLOUR Colour;
  392.   };
  393.  
  394. struct Colour_Map_Struct
  395.   {
  396.    int Number_Of_Entries, Transparency_Flag, Users;
  397.    COLOUR_MAP_ENTRY *Colour_Map_Entries;
  398.   };
  399.  
  400. struct Transform_Struct
  401.   {
  402.    MATRIX matrix;
  403.    MATRIX inverse;
  404.   };
  405.  
  406. #define Destroy_Transform(x) if ((x)!=NULL) free(x)
  407.  
  408. /* Types for reading IFF files. */
  409. typedef struct {unsigned short Red, Green, Blue, Filter;} IMAGE_COLOUR;
  410.  
  411. struct Image_Line
  412.   {
  413.    unsigned char *red, *green, *blue;
  414.   };
  415.  
  416. typedef struct Image_Line IMAGE_LINE;
  417.  
  418. /* Legal image attributes */
  419. #define GIF_FILE   1
  420. #define POT_FILE   2
  421. #define DUMP_FILE  4
  422. #define IFF_FILE   8
  423. #define TGA_FILE  16
  424. #define GRAD_FILE 32
  425.  
  426. #define IMAGE_FILE    GIF_FILE+DUMP_FILE+IFF_FILE+GRAD_FILE+TGA_FILE
  427. #define NORMAL_FILE   GIF_FILE+DUMP_FILE+IFF_FILE+GRAD_FILE+TGA_FILE
  428. #define MATERIAL_FILE GIF_FILE+DUMP_FILE+IFF_FILE+GRAD_FILE+TGA_FILE
  429. #define HF_FILE       GIF_FILE+POT_FILE+TGA_FILE
  430.  
  431. struct Image_Struct
  432.   {
  433.    int Map_Type;
  434.    int File_Type;
  435.    int Interpolation_Type;
  436.    short Once_Flag;
  437.    short Use_Colour_Flag;
  438.    VECTOR Gradient;
  439.    DBL width, height;
  440.    int iwidth, iheight;
  441.    short Colour_Map_Size;
  442.    IMAGE_COLOUR *Colour_Map;
  443.    union 
  444.     {
  445.      IMAGE_LINE *rgb_lines;
  446.      unsigned char **map_lines;
  447.     } data;  
  448.   };
  449.  
  450. /* Texture types */
  451. #define PNF_TEXTURE     0
  452. #define TILE_TEXTURE    1
  453. #define MAT_TEXTURE     2
  454.  
  455. /* Image/Bump Map projection types */
  456. #define PLANAR_MAP      0
  457. #define SPHERICAL_MAP   1
  458. #define CYLINDRICAL_MAP 2
  459. #define PARABOLIC_MAP   3
  460. #define HYPERBOLIC_MAP  4
  461. #define TORUS_MAP       5
  462. #define PIRIFORM_MAP    6
  463. #define OLD_MAP         7
  464.  
  465. /* Bit map interpolation types */
  466. #define NO_INTERPOLATION 0
  467. #define NEAREST_NEIGHBOR 1
  468. #define BILINEAR         2
  469. #define CUBIC_SPLINE     3
  470. #define NORMALIZED_DIST  4
  471.  
  472. /* Coloration pigment list */
  473. #define NO_PIGMENT               0
  474. #define COLOUR_PIGMENT           1
  475. #define BOZO_PIGMENT             2
  476. #define MARBLE_PIGMENT           3
  477. #define WOOD_PIGMENT             4
  478. #define CHECKER_PIGMENT          5
  479. #define SPOTTED_PIGMENT          6
  480. #define AGATE_PIGMENT            7
  481. #define GRANITE_PIGMENT          8
  482. #define GRADIENT_PIGMENT         9
  483. #define IMAGE_MAP_PIGMENT       10
  484. #define PAINTED1_PIGMENT        11
  485. #define PAINTED2_PIGMENT        12
  486. #define PAINTED3_PIGMENT        13
  487. #define ONION_PIGMENT           14
  488. #define LEOPARD_PIGMENT         15
  489. #define BRICK_PIGMENT           16
  490. #define MANDEL_PIGMENT          17
  491. #define HEXAGON_PIGMENT         18
  492. #define RADIAL_PIGMENT          19
  493.  
  494.  
  495. /* Normal perturbation (bumpy) texture list  */
  496. #define NO_NORMAL  0
  497. #define WAVES      1
  498. #define RIPPLES    2
  499. #define WRINKLES   3
  500. #define BUMPS      4
  501. #define DENTS      5
  502. #define BUMPY1     6
  503. #define BUMPY2     7
  504. #define BUMPY3     8
  505. #define BUMP_MAP   9
  506.  
  507. /* Pattern flags */
  508. #define NO_FLAGS      0
  509. #define HAS_FILTER    1
  510. #define FULL_BLOCKING 2
  511. #define HAS_TURB      4
  512. #define POST_DONE     8
  513.  
  514. #define TPATTERN_FIELDS int Type, Octaves, Flags; VECTOR Turbulence;  \
  515.   DBL omega, lambda, Frequency, Phase; IMAGE *Image; TRANSFORM *Trans;
  516.  
  517. #define INIT_TPATTERN_FIELDS(p,t) p->Type=t; p->Octaves=6; p->Image=NULL; \
  518.  p->Frequency=1.0; p->Phase=0.0;\
  519.  p->Trans=NULL; p->Flags=NO_FLAGS; p->omega=0.5;p->lambda=2.0; \
  520.  Make_Vector(&(p->Turbulence),0.0,0.0,0.0);
  521.  
  522. /* This is an abstract structure that is never actually used.
  523.    Pigment and Tnormal are descendents of this primative type */
  524.  
  525. struct Pattern_Struct
  526.   {
  527.    TPATTERN_FIELDS
  528.   };
  529.  
  530. struct Pigment_Struct
  531.   {
  532.    TPATTERN_FIELDS
  533.    COLOUR *Colour1;
  534.    COLOUR Quick_Colour;
  535.    COLOUR_MAP *Colour_Map;
  536.    VECTOR Colour_Gradient;
  537.    DBL Mortar, Agate_Turb_Scale;
  538.    int Iterations; /* mhs 10/92 for fractal textures */
  539.   };
  540.  
  541. struct Tnormal_Struct
  542.   {
  543.    TPATTERN_FIELDS
  544.    DBL Amount;
  545.   };
  546.  
  547. struct Finish_Struct
  548.   {
  549.    DBL Reflection, Ambient, Diffuse, Brilliance, Index_Of_Refraction;
  550.    DBL Refraction, Specular, Roughness, Phong, Phong_Size;
  551.    DBL Crand;
  552.    short Metallic_Flag;
  553.   };
  554.  
  555. #define Destroy_Finish(x) if ((x)!=NULL) free(x)
  556.  
  557. #define TEXTURE_FIELDS unsigned char Type,Flags; TEXTURE *Next_Material; \
  558.  TEXTURE *Next_Layer;
  559. #define TRANS_TEXTURE_FIELDS TEXTURE_FIELDS TRANSFORM *Trans;
  560.  
  561. struct Texture_Struct
  562.   {
  563.    TEXTURE_FIELDS
  564.    PIGMENT *Pigment;
  565.    TNORMAL *Tnormal;
  566.    FINISH *Finish;
  567.   };
  568.  
  569. struct Tiles_Texture_Struct
  570.   {
  571.    TRANS_TEXTURE_FIELDS
  572.    TEXTURE *Tile1;
  573.    TEXTURE *Tile2;
  574.   };
  575.  
  576. struct Material_Texture_Struct
  577.   {
  578.    TRANS_TEXTURE_FIELDS
  579.    TEXTURE *Materials;
  580.    IMAGE *Image;
  581.    int Num_Of_Mats;
  582.   };
  583.  
  584. /* Object types */
  585. #define BASIC_OBJECT            0
  586. #define PATCH_OBJECT            1   /* Has no inside, no inverse */
  587. #define TEXTURED_OBJECT         2   /* Has texture, possibly in children */
  588.  
  589. #define CHILDREN_FLAGS (PATCH_OBJECT+TEXTURED_OBJECT)
  590.                     /* Reverse inherited flags */
  591.  
  592. #define COMPOUND_OBJECT         4   /* Has children field */
  593. #define STURM_OK_OBJECT         8   /* STRUM legal */
  594. #define WATER_LEVEL_OK_OBJECT  16   /* WATER_LEVEL legal */
  595. #define LIGHT_SOURCE_OBJECT    32   /* link me in frame.light_sources */
  596. #define BOUNDING_OBJECT        64   /* This is a holder for bounded object */
  597. #define SMOOTH_OK_OBJECT      128   /* SMOOTH legal */
  598. #define IS_CHILD_OBJECT       256   /* Object is inside a COMPOUND */
  599. #define DOUBLE_ILLUMINATE     512   /* Illuminate both sides of surface to
  600.                        avoid normal purturb bug */
  601.  
  602.  
  603. #define COMPOSITE_OBJECT       (BOUNDING_OBJECT)
  604. #define SPHERE_OBJECT          (BASIC_OBJECT)
  605. #define PLANE_OBJECT           (BASIC_OBJECT)
  606. #define QUADRIC_OBJECT         (BASIC_OBJECT)
  607. #define BOX_OBJECT             (BASIC_OBJECT)
  608. #define CONE_OBJECT            (BASIC_OBJECT)
  609. #define DISC_OBJECT            (BASIC_OBJECT)
  610. #define HEIGHT_FIELD_OBJECT    (BASIC_OBJECT+WATER_LEVEL_OK_OBJECT+SMOOTH_OK_OBJECT)
  611. #define TRIANGLE_OBJECT        (PATCH_OBJECT)
  612. #define SMOOTH_TRIANGLE_OBJECT (PATCH_OBJECT+DOUBLE_ILLUMINATE)
  613. #define BICUBIC_PATCH_OBJECT   (PATCH_OBJECT+DOUBLE_ILLUMINATE)
  614. #define UNION_OBJECT           (COMPOUND_OBJECT)
  615. #define MERGE_OBJECT           (COMPOUND_OBJECT)
  616. #define INTERSECTION_OBJECT    (COMPOUND_OBJECT)
  617. #define CUBIC_OBJECT           (STURM_OK_OBJECT)
  618. #define QUARTIC_OBJECT         (STURM_OK_OBJECT)
  619. #define POLY_OBJECT            (STURM_OK_OBJECT)
  620. #define BLOB_OBJECT            (STURM_OK_OBJECT)
  621. #define LIGHT_OBJECT           (COMPOUND_OBJECT+PATCH_OBJECT+LIGHT_SOURCE_OBJECT)
  622.  
  623. typedef int (*ALL_INTERSECTIONS_METHOD)PARAMS((OBJECT *, RAY *, ISTACK *));
  624. typedef int (*INSIDE_METHOD)PARAMS((VECTOR *, OBJECT *));
  625. typedef void (*NORMAL_METHOD)PARAMS((VECTOR *, OBJECT *, VECTOR *));
  626. typedef void *(*COPY_METHOD)PARAMS((OBJECT *));
  627. typedef void (*TRANSLATE_METHOD)PARAMS((OBJECT *, VECTOR *));
  628. typedef void (*ROTATE_METHOD)PARAMS((OBJECT *, VECTOR *));
  629. typedef void (*SCALE_METHOD)PARAMS((OBJECT *, VECTOR *));
  630. typedef void (*TRANSFORM_METHOD)PARAMS((OBJECT *, TRANSFORM *));
  631. typedef void (*INVERT_METHOD)PARAMS((OBJECT *));
  632. typedef void (*DESTROY_METHOD)PARAMS((OBJECT *));
  633.  
  634. struct Method_Struct
  635.   {
  636.    ALL_INTERSECTIONS_METHOD All_Intersections_Method;
  637.    INSIDE_METHOD Inside_Method;
  638.    NORMAL_METHOD Normal_Method;
  639.    COPY_METHOD Copy_Method;
  640.    TRANSLATE_METHOD Translate_Method;
  641.    ROTATE_METHOD Rotate_Method;
  642.    SCALE_METHOD Scale_Method;
  643.    TRANSFORM_METHOD Transform_Method;
  644.    INVERT_METHOD Invert_Method;
  645.    DESTROY_METHOD Destroy_Method;
  646.   };
  647.  
  648. #define All_Intersections(x,y,z) ((*((x)->Methods->All_Intersections_Method)) (x,y,z))
  649. #define Inside(x,y) ((*((y)->Methods->Inside_Method)) (x,y))
  650. #define Normal(x,y,z) ((*((y)->Methods->Normal_Method)) (x,y,z))
  651. #define Copy(x) ((*((x)->Methods->Copy_Method)) (x))
  652. #define Translate(x,y) ((*((x)->Methods->Translate_Method)) (x,y))
  653. #define Scale(x,y) ((*((x)->Methods->Scale_Method)) (x,y))
  654. #define Rotate(x,y) ((*((x)->Methods->Rotate_Method)) (x,y))
  655. #define Transform(x,y) ((*((x)->Methods->Transform_Method)) (x,y))
  656. #define Invert(x) ((*((x)->Methods->Invert_Method)) (x))
  657. #define Destroy(x) ((*((x)->Methods->Destroy_Method)) (x))
  658.  
  659. #define Destroy_Camera(x) if ((x)!=NULL) free(x)
  660.  
  661. struct Camera_Struct
  662.   {
  663.    VECTOR Location;
  664.    VECTOR Direction;
  665.    VECTOR Up;
  666.    VECTOR Right;
  667.    VECTOR Sky;
  668.   };
  669.  
  670. struct Bounding_Box_Struct {
  671.    VECTOR Lower_Left, Lengths;
  672.    };
  673.  
  674. /* These fields are common to all objects */
  675.  
  676.   #define OBJECT_FIELDS \
  677.    METHODS *Methods;\
  678.    int Type;\
  679.    OBJECT *Sibling;\
  680.    TEXTURE *Texture;\
  681.    OBJECT *Bound;\
  682.    OBJECT *Clip;\
  683.    BBOX Bounds;\
  684.    short No_Shadow_Flag;
  685.  
  686. /* These fields are common to all compound objects */
  687. #define COMPOUND_FIELDS \
  688.  OBJECT_FIELDS \
  689.  OBJECT *Children;
  690.  
  691. #define INIT_OBJECT_FIELDS(o,t,m)\
  692.  o->Type=t;o->Methods= m;o->Sibling=NULL;o->Texture=NULL;\
  693.  o->Bound=NULL;o->Clip=NULL;o->No_Shadow_Flag=FALSE;\
  694.  Make_Vector(&o->Bounds.Lower_Left, -BOUND_HUGE/2, -BOUND_HUGE/2, -BOUND_HUGE/2)\
  695.  Make_Vector(&o->Bounds.Lengths, BOUND_HUGE, BOUND_HUGE, BOUND_HUGE)
  696.  
  697. /* This is an abstract structure that is never actually used.
  698.    All other objects are descendents of this primative type */
  699.  
  700. struct Object_Struct
  701.   {
  702.    OBJECT_FIELDS
  703.   };
  704.  
  705. struct CSG_Struct
  706.   {
  707.    COMPOUND_FIELDS
  708. #ifdef DB_CODE
  709.    /* to calculate the bounding box for CSG intersections
  710.       we need to know if the CSG is inverted or not */
  711.    unsigned short int Inverted;
  712. #endif
  713.   };
  714.  
  715. struct Light_Source_Struct
  716.   {
  717.    COMPOUND_FIELDS
  718.    COLOUR Colour;
  719.    VECTOR Center, Points_At, Axis1, Axis2;
  720.    DBL Coeff, Radius, Falloff;
  721.    LIGHT_SOURCE *Next_Light_Source;
  722.    unsigned char Light_Type, Area_Light, Jitter, Track;
  723.    int    Area_Size1, Area_Size2;
  724.    int    Adaptive_Level;
  725.    COLOUR **Light_Grid;
  726.    OBJECT *Shadow_Cached_Object;
  727. #ifdef DB_CODE
  728.    /* pointer to the light buffers for the six general directions in space */
  729.    PROJECT_TREE_NODE *Light_Buffer[6];
  730. #endif
  731.   };
  732.  
  733. /* Light source types */
  734. #define POINT_SOURCE     1
  735. #define SPOT_SOURCE      2
  736.  
  737. #define BUNCHING_FACTOR 4
  738. struct Composite_Struct
  739.   {
  740.    OBJECT_FIELDS
  741.    unsigned short int Entries;
  742.    OBJECT *Objects[BUNCHING_FACTOR];
  743.   };
  744.  
  745. #ifdef DB_CODE
  746. /* The following structure represent the bounding box hierarchy in 2d space.
  747.    Because is_leaf, Object and Project are the first elements in both
  748.    structures they can be accessed without knowing at which structure
  749.    a pointer is pointing. */
  750.  
  751. struct Project_Tree_Node_Struct
  752. {
  753.   unsigned short is_leaf;
  754.   OBJECT *Object;
  755.   PROJECT Project;
  756.   unsigned short Entries;
  757.   PROJECT_TREE_NODE *Entry[BUNCHING_FACTOR];
  758. };
  759.  
  760. struct Project_Tree_Leaf_Struct
  761. {
  762.   unsigned short is_leaf;
  763.   OBJECT *Object;
  764.   PROJECT Project;
  765. };
  766.  
  767. /* The following structures have been moved from bound.c
  768.    because they are used in addon1.c */
  769.  
  770. typedef struct
  771. {
  772.   int x,y,z;
  773. }
  774. VECTORI, *pVECTORI;
  775.  
  776. typedef struct
  777. {
  778.   VECTOR slab_num;
  779.   VECTOR slab_den;
  780.   VECTORI nonzero;
  781.   VECTORI positive;
  782. }
  783. RAYINFO, *pRAYINFO;
  784.  
  785. typedef struct t_qelem
  786. {
  787.   DBL     q_key;
  788.   OBJECT *q_obj;
  789. }
  790. Qelem;
  791. #endif
  792.  
  793. struct Sphere_Struct
  794.   {
  795.    OBJECT_FIELDS
  796.    TRANSFORM *Trans;
  797.    VECTOR  Center;
  798.    DBL     Radius;
  799.    DBL     Radius_Squared;
  800.    DBL     Inverse_Radius;
  801.    VECTOR  CMOtoC, CMInitial;
  802.    DBL     CMOCSquared;
  803.    short   CMinside, CMCached, Inverted;
  804.   };
  805.  
  806. struct Quadric_Struct
  807.   {
  808.    OBJECT_FIELDS
  809.    VECTOR  Square_Terms;
  810.    VECTOR  Mixed_Terms;
  811.    VECTOR  Terms;
  812.    DBL Constant;
  813.    DBL CM_Constant;
  814.    short Constant_Cached;
  815.    short Non_Zero_Square_Term;
  816. #ifdef DB_CODE
  817.    /* In calculating the bounding box for a CSG intersection it is
  818.       necessary to know if the quadric is inverted or not! */
  819.    short Inverted;
  820. #endif
  821.   };
  822.  
  823. typedef unsigned short HF_val;
  824.  
  825. typedef struct {
  826.    HF_val min_y, max_y;
  827. } HF_BLOCK;
  828.  
  829. typedef struct {
  830.         float x, z;
  831.         VECTOR normal;
  832. } Cached_Normals;
  833.  
  834. typedef short HF_Normals[3];
  835. #define HF_CACHE_SIZE 16
  836. #define LOWER_TRI 0
  837. #define UPPER_TRI 1
  838.  
  839.  
  840.  
  841. struct Height_Field_Struct
  842.   {
  843.    OBJECT_FIELDS
  844.    TRANSFORM *Trans;
  845.    BOX *bounding_box;
  846.    DBL Block_Size;
  847.    DBL Inv_Blk_Size;
  848.    HF_BLOCK **Block;
  849.    HF_val **Map;
  850.    int Inverted;
  851.    int cache_pos;
  852.    Cached_Normals Normal_Vector[HF_CACHE_SIZE];
  853.    int Smoothed;
  854.    HF_Normals **Normals;
  855.    };
  856.  
  857. struct Box_Struct
  858.   {
  859.    OBJECT_FIELDS
  860.    TRANSFORM *Trans;
  861.    VECTOR bounds[2];
  862.    short Inverted;
  863.   };
  864.  
  865. #define MAX_ORDER 15
  866.  
  867. #define STURM_FIELDS  OBJECT_FIELDS int Sturm_Flag;
  868.  
  869. /* Number of coefficients of a three variable polynomial of order x */
  870. #define term_counts(x) (((x)+1)*((x)+2)*((x)+3)/6)
  871.  
  872. struct Poly_Struct
  873.   {
  874.    STURM_FIELDS
  875.    TRANSFORM *Trans;
  876.    short Inverted;
  877.    int Order;
  878.    DBL *Coeffs;
  879.   };
  880.  
  881. struct Disc_Struct {
  882.    OBJECT_FIELDS
  883.    TRANSFORM *Trans; /* Transformation of a Disc object */
  884.    VECTOR center;    /* Center of the disc */
  885.    VECTOR normal;    /* Direction perpendicular to the disc (plane normal) */
  886.    DBL d;            /* The constant part of the plane equation */
  887.    DBL iradius2;     /* Distance from center to inner circle of the disc */
  888.    DBL oradius2;     /* Distance from center to outer circle of the disc */
  889.    short Inverted;
  890.    };
  891.  
  892. struct Cone_Struct {
  893.    OBJECT_FIELDS
  894.    TRANSFORM *Trans;   /* Transformation of a Cone object */
  895.    short int cyl_flag; /* Is this a cone or a cylinder? */
  896.    short int closed;   /* Currently unused - for making caps on the cone */
  897.    VECTOR apex;        /* Center of the top of the cone */
  898.    VECTOR base;        /* Center of the bottom of the cone */
  899.    DBL apex_radius;    /* Radius of the cone at the top */
  900.    DBL base_radius;    /* Radius of the cone at the bottom */
  901.    DBL dist;           /* Distance to end of cone in canonical coords */
  902.    short Inverted;
  903.    };
  904.  
  905. typedef struct Bezier_Node_Struct BEZIER_NODE;
  906. typedef struct Bezier_Child_Struct BEZIER_CHILDREN;
  907. typedef struct Bezier_Vertices_Struct BEZIER_VERTICES;
  908.  
  909. struct Bezier_Child_Struct
  910.   {
  911.    BEZIER_NODE *Children[4];
  912.   };
  913.  
  914. struct Bezier_Vertices_Struct
  915.   {
  916.    float uvbnds[4];
  917.    VECTOR Vertices[4];
  918.   };
  919.  
  920. struct Bezier_Node_Struct
  921.   {
  922.    int Node_Type;      /* Is this an interior node, or a leaf */
  923.    VECTOR Center;      /* Center of sphere bounding the (sub)patch */
  924.    DBL Radius_Squared; /* Radius of bounding sphere (squared) */
  925.    int Count;          /* # of subpatches associated with this node */
  926.    void *Data_Ptr;     /* Either pointer to vertices or pointer to children */
  927.   };
  928.  
  929. #define BEZIER_INTERIOR_NODE 0
  930. #define BEZIER_LEAF_NODE 1
  931.  
  932. #define MAX_PATCH_TYPE 4
  933.  
  934. struct Bicubic_Patch_Struct
  935.   {
  936.    OBJECT_FIELDS
  937.    int Patch_Type, U_Steps, V_Steps;
  938.    VECTOR Control_Points[4][4];
  939.    VECTOR Bounding_Sphere_Center;
  940.    DBL Bounding_Sphere_Radius;
  941.    DBL Flatness_Value;
  942.    BEZIER_NODE *Node_Tree;
  943.   };
  944.    
  945. #define X_AXIS 0
  946. #define Y_AXIS 1
  947. #define Z_AXIS 2
  948.  
  949. struct Triangle_Struct
  950.   {
  951.    OBJECT_FIELDS
  952.    VECTOR  Normal_Vector;
  953.    DBL     Distance;
  954.    DBL     CMNormDotOrigin;
  955.    unsigned int  CMCached:1;
  956.    unsigned int  Dominant_Axis:2;
  957.    unsigned int  vAxis:2;  /* used only for smooth triangles */
  958.    VECTOR  P1, P2, P3;
  959.    short int Degenerate_Flag;
  960.   };
  961.  
  962. struct Smooth_Triangle_Struct
  963.   {
  964.    OBJECT_FIELDS
  965.    VECTOR  Normal_Vector;
  966.    DBL     Distance;
  967.    DBL     CMNormDotOrigin;
  968.    unsigned int  CMCached:1;
  969.    unsigned int  Dominant_Axis:2;
  970.    unsigned int  vAxis:2;         /* used only for smooth triangles */
  971.    VECTOR  P1, P2, P3;
  972.    short int Degenerate_Flag;
  973.    VECTOR  N1, N2, N3, Perp;
  974.    DBL  BaseDelta;
  975.   };
  976.  
  977. struct Plane_Struct
  978.   {
  979.    OBJECT_FIELDS
  980.    VECTOR  Normal_Vector;
  981.    DBL     Distance;
  982.    DBL     CMNormDotOrigin;
  983.    int     CMCached;
  984.   };
  985.  
  986. typedef struct {
  987.    VECTOR pos;
  988.    DBL radius2;
  989.    DBL coeffs[3];
  990.    DBL tcoeffs[5];
  991.    } Blob_Element;
  992.  
  993. typedef struct blob_list_struct *blobstackptr;
  994. struct blob_list_struct {
  995.    Blob_Element elem;
  996.    blobstackptr next;
  997.    };
  998.  
  999. typedef struct {
  1000.    int type, index;
  1001.    DBL bound;
  1002.    } Blob_Interval;
  1003.  
  1004. struct Blob_Struct
  1005.    {
  1006.    STURM_FIELDS
  1007.    TRANSFORM *Trans;
  1008.    short Inverted;
  1009.    int count;
  1010.    DBL threshold;
  1011.    Blob_Element **list;
  1012.    Blob_Interval *intervals;
  1013. };
  1014.  
  1015. #define MAX_CONTAINING_OBJECTS 10
  1016.  
  1017. struct Ray_Struct
  1018.   {
  1019.    VECTOR Initial;               /*  Xo  Yo  Zo  */
  1020.    VECTOR Direction;             /*  Xv  Yv  Zv  */
  1021.    VECTOR Initial_2;             /*  Xo^2  Yo^2  Zo^2  */
  1022.    VECTOR Direction_2;           /*  Xv^2  Yv^2  Zv^2  */
  1023.    VECTOR Initial_Direction;     /*  XoXv  YoYv  ZoZv  */
  1024.    VECTOR Mixed_Initial_Initial; /*  XoYo  XoZo  YoZo  */
  1025.    VECTOR Mixed_Dir_Dir;         /*  XvYv  XvZv  YvZv  */
  1026.    VECTOR Mixed_Init_Dir;        /*  XoYv+XvYo  XoZv+XvZo  YoZv+YvZo  */
  1027.    int Containing_Index;
  1028.    TEXTURE *Containing_Textures [MAX_CONTAINING_OBJECTS];
  1029.    DBL Containing_IORs [MAX_CONTAINING_OBJECTS];
  1030.    int Quadric_Constants_Cached;
  1031.   };
  1032.  
  1033. struct Frame_Struct
  1034.   {
  1035.    CAMERA *Camera;
  1036.    int Screen_Height, Screen_Width;
  1037.    LIGHT_SOURCE *Light_Sources;
  1038.    OBJECT *Objects;
  1039.    DBL Atmosphere_IOR, Antialias_Threshold;
  1040.    DBL Fog_Distance;
  1041.    COLOUR Fog_Colour;
  1042.    COLOUR Background_Colour;
  1043.   };
  1044.  
  1045. #define DISPLAY 1
  1046. #define VERBOSE 2
  1047. #define DISKWRITE 4
  1048. #define PROMPTEXIT 8
  1049. #define ANTIALIAS 16
  1050. #define DEBUGGING 32
  1051. #define RGBSEPARATE 64
  1052. #define EXITENABLE 128
  1053. #define CONTINUE_TRACE 256
  1054. #define VERBOSE_FILE 512
  1055. #define JITTER 1024
  1056.  
  1057. /* Definitions for ISTACK structure */
  1058.  
  1059. struct istk_entry
  1060.   {
  1061.    DBL Depth;
  1062.    VECTOR IPoint;
  1063.    VECTOR INormal;
  1064.    int NFlag;
  1065.    OBJECT *Object;
  1066.   };
  1067.  
  1068. struct istack_struct
  1069.   {
  1070.    struct istack_struct *next;
  1071.    struct istk_entry *istack;
  1072.    unsigned int top_entry;
  1073.   };
  1074.  
  1075. #define itop(i) i->istack[i->top_entry]
  1076. #define push_entry(d,v,o,i) itop(i).Depth=d; itop(i).IPoint=v; \
  1077.  itop(i).NFlag=0; itop(i).Object=o; incstack(i);
  1078. #define push_normal_entry(d,v,n,o,i) itop(i).Depth=d; itop(i).IPoint=v; \
  1079.  itop(i).INormal=n; itop(i).NFlag=1; itop(i).Object=o; incstack(i);
  1080. #define push_copy(i,e) itop(i)= *e; incstack(i);
  1081. #define pop_entry(i) (i->top_entry > 0)?&(i->istack[--i->top_entry]):NULL
  1082.  
  1083. #define MAX_STRING_INDEX 41
  1084.  
  1085. struct Reserved_Word_Struct
  1086.   {
  1087.    TOKEN Token_Number;
  1088.    char *Token_Name;
  1089.   };
  1090.  
  1091. /* Here's where you dump the information on the current token (fm. PARSE.C) */
  1092.  
  1093. struct Token_Struct
  1094.   {
  1095.    TOKEN Token_Id;
  1096.    int Token_Line_No;
  1097.    char *Token_String;
  1098.    DBL Token_Float;
  1099.    TOKEN Begin_Id;
  1100.    int Constant_Index;
  1101.    int Unget_Token, End_Of_File;
  1102.    char *Filename, *Constant_Data;
  1103.   };
  1104.  
  1105. /* Types of constants allowed in DECLARE statement (fm. PARSE.C) */
  1106.  
  1107. #define COLOUR_CONSTANT         0
  1108. #define VECTOR_CONSTANT         1
  1109. #define FLOAT_CONSTANT          2
  1110. #define PIGMENT_CONSTANT        3
  1111. #define TNORMAL_CONSTANT        4
  1112. #define FINISH_CONSTANT         5
  1113. #define TEXTURE_CONSTANT        6
  1114. #define OBJECT_CONSTANT         7
  1115. #define COLOUR_MAP_CONSTANT     8
  1116. #define TRANSFORM_CONSTANT      9
  1117. #define CAMERA_CONSTANT        10
  1118.  
  1119. /* CSG types */
  1120. #define CSG_UNION_TYPE             1
  1121. #define CSG_INTERSECTION_TYPE      2
  1122. #define CSG_DIFFERENCE_TYPE        4
  1123. #define CSG_MERGE_TYPE             8
  1124. #define CSG_SINGLE_TYPE           16
  1125.  
  1126. struct Constant_Struct
  1127.   {
  1128.    int Identifier_Number;
  1129.    CONSTANT Constant_Type;
  1130.    char *Constant_Data;
  1131.   };
  1132.  
  1133. struct Chunk_Header_Struct 
  1134.   {
  1135.    long name;
  1136.    long size;
  1137.   };
  1138.  
  1139. struct Data_File_Struct 
  1140.   {
  1141.    FILE *File;
  1142.    char *Filename;
  1143.    int Line_Number;
  1144.   };
  1145.  
  1146. struct complex_block 
  1147.   {
  1148.    DBL r, c;
  1149.   };
  1150.  
  1151. #define READ_MODE 0
  1152. #define WRITE_MODE 1
  1153. #define APPEND_MODE 2
  1154.  
  1155. struct file_handle_struct 
  1156.   {
  1157.    char *filename;
  1158.    int  mode;
  1159.    int width, height;
  1160.    int buffer_size;
  1161.    char *buffer;
  1162.    FILE *file;
  1163.    char *(*Default_File_Name_p) PARAMS((void));
  1164.    int  (*Open_File_p) PARAMS((struct file_handle_struct *handle,
  1165.            char *name, int *width, int *height, int buffer_size,
  1166.            int mode));
  1167.    void (*Write_Line_p) PARAMS((struct file_handle_struct *handle,
  1168.            COLOUR *line_data, int line_number));
  1169.    int  (*Read_Line_p) PARAMS((struct file_handle_struct *handle,
  1170.            COLOUR *line_data, int *line_number));
  1171.    void (*Read_Image_p) PARAMS((IMAGE *Image, char *filename));
  1172.    void (*Close_File_p) PARAMS((struct file_handle_struct *handle));
  1173.   };
  1174.  
  1175. typedef struct file_handle_struct FILE_HANDLE;
  1176.  
  1177. #define Default_File_Name(h) ((*((h)->Default_File_Name_p)) ())
  1178. #define Open_File(h,n,wd,ht,sz,m) ((*((h)->Open_File_p)) (h,n,wd,ht,sz,m))
  1179. #define Write_Line(h,l,n) ((*((h)->Write_Line_p)) (h, l, n))
  1180. #define Read_Line(h,l,n) ((*((h)->Read_Line_p)) (h, l, n))
  1181. #define Read_Image(h,i) ((*((h)->Read_Image_p)) (h, i))
  1182. #define Close_File(h) ((*((h)->Close_File_p)) (h))
  1183.  
  1184.  
  1185. #define Q_FULL_AMBIENT 1
  1186. #define Q_QUICKC       2
  1187. #define Q_SHADOW       4
  1188. #define Q_AREA_LIGHT   8
  1189. #define Q_REFRACT     16
  1190. #define Q_REFLECT     32
  1191. #define Q_NORMAL      64
  1192.  
  1193. #define QUALITY_0 Q_QUICKC+Q_FULL_AMBIENT
  1194. #define QUALITY_1 QUALITY_0
  1195. #define QUALITY_2 QUALITY_1-Q_FULL_AMBIENT
  1196. #define QUALITY_3 QUALITY_2
  1197. #define QUALITY_4 QUALITY_3+Q_SHADOW
  1198. #define QUALITY_5 QUALITY_4+Q_AREA_LIGHT
  1199. #define QUALITY_6 QUALITY_5-Q_QUICKC+Q_REFRACT
  1200. #define QUALITY_7 QUALITY_6
  1201. #define QUALITY_8 QUALITY_7+Q_REFLECT+Q_NORMAL
  1202. #define QUALITY_9 QUALITY_8
  1203.