1 /**************************************************************************** 2 * povray.h 3 * 4 * This module contains all defines, typedefs, and prototypes for POVRAY.CPP. 5 * 6 * from Persistence of Vision(tm) Ray Tracer version 3.6. 7 * Copyright 1991-2003 Persistence of Vision Team 8 * Copyright 2003-2004 Persistence of Vision Raytracer Pty. Ltd. 9 *--------------------------------------------------------------------------- 10 * NOTICE: This source code file is provided so that users may experiment 11 * with enhancements to POV-Ray and to port the software to platforms other 12 * than those supported by the POV-Ray developers. There are strict rules 13 * regarding how you are permitted to use this file. These rules are contained 14 * in the distribution and derivative versions licenses which should have been 15 * provided with this file. 16 * 17 * These licences may be found online, linked from the end-user license 18 * agreement that is located at http://www.povray.org/povlegal.html 19 *--------------------------------------------------------------------------- 20 * This program is based on the popular DKB raytracer version 2.12. 21 * DKBTrace was originally written by David K. Buck. 22 * DKBTrace Ver 2.0-2.12 were written by David K. Buck & Aaron A. Collins. 23 *--------------------------------------------------------------------------- 24 * $File: //depot/povray/3.6-release/source/povray.h $ 25 * $Revision: #2 $ 26 * $Change: 2939 $ 27 * $DateTime: 2004/07/04 13:43:26 $ 28 * $Author: root $ 29 * $Log$ 30 *****************************************************************************/ 31 32 33 #ifndef POVRAY_H 34 #define POVRAY_H 35 36 #include <time.h> 37 38 #include "frame.h" 39 #include "atmosph.h" 40 #include "camera.h" 41 #include "media.h" 42 #include "point.h" 43 #include "render.h" 44 #include "userio.h" 45 #include "povms.h" 46 #include "lightgrp.h" 47 48 BEGIN_POV_NAMESPACE 49 50 USING_POV_BASE_NAMESPACE 51 52 /***************************************************************************** 53 * Global preprocessor defines 54 ******************************************************************************/ 55 56 #define MAX_LIBRARIES 25 57 58 #define STAGE_PREINIT 0 /* set in POVRAY.C */ 59 #define STAGE_STARTUP 1 /* set in POVRAY.C */ 60 #define STAGE_BANNER 2 /* set in POVRAY.C */ 61 #define STAGE_INIT 3 /* set in POVRAY.C */ 62 #define STAGE_FILE_INIT 4 /* set in POVRAY.C */ 63 #define STAGE_PARSING 5 /* set in PARSE.C */ 64 #define STAGE_CONTINUING 6 /* set in POVRAY.C */ 65 #define STAGE_RENDERING 7 /* set in POVRAY.C */ 66 #define STAGE_SHUTDOWN 8 /* set in POVRAY.C */ 67 #define STAGE_CLEANUP_PARSE 9 /* set in PARSE.C */ 68 #define STAGE_SLAB_BUILDING 10 /* set in POVRAY.C */ 69 #define STAGE_TOKEN_INIT 11 /* set in TOKENIZE.C */ 70 #define STAGE_INCLUDE_ERR 12 /* set in TOKENIZE.C */ 71 #define STAGE_FOUND_INSTEAD 13 /* set in TOKENIZE.C */ 72 #define STAGECOUNT 14 /* number of stages */ 73 74 #define DISPLAY 0x000001L 75 #define VERBOSE 0x000002L 76 #define DISKWRITE 0x000004L 77 #define PROMPTEXIT 0x000008L 78 #define ANTIALIAS 0x000010L 79 #define RGBSEPARATE 0x000020L 80 #define EXITENABLE 0x000040L 81 #define CONTINUE_TRACE 0x000080L 82 #define JITTER 0x000100L 83 #define PREVIEW 0x000200L 84 #define SPLIT_UNION 0x000400L 85 #define USE_VISTA_BUFFER 0x000800L 86 #define USE_LIGHT_BUFFER 0x001000L 87 #define USE_VISTA_DRAW 0x002000L 88 #define REMOVE_BOUNDS 0x004000L 89 #define CYCLIC_ANIMATION 0x008000L 90 #define OUTPUT_ALPHA 0x010000L 91 #define HF_GRAY_16 0x020000L 92 #define GAMMA_CORRECT 0x040000L 93 #define FROM_STDIN 0x080000L 94 #define TO_STDOUT 0x100000L 95 96 #define Q_FULL_AMBIENT 0x000001L 97 #define Q_QUICKC 0x000002L 98 #define Q_SHADOW 0x000004L 99 #define Q_AREA_LIGHT 0x000008L 100 #define Q_REFRACT 0x000010L 101 #define Q_REFLECT 0x000020L 102 #define Q_NORMAL 0x000040L 103 #define Q_VOLUME 0x000080L 104 105 #define EF_RADIOS 1 106 #define EF_SLOPEM 2 107 #define EF_ISOFN 4 108 #define EF_SPLINE 8 109 #define EF_TIFF 16 110 111 #define QUALITY_0 Q_QUICKC+Q_FULL_AMBIENT 112 #define QUALITY_1 QUALITY_0 113 #define QUALITY_2 QUALITY_1-Q_FULL_AMBIENT 114 #define QUALITY_3 QUALITY_2 115 #define QUALITY_4 QUALITY_3+Q_SHADOW 116 #define QUALITY_5 QUALITY_4+Q_AREA_LIGHT 117 #define QUALITY_6 QUALITY_5-Q_QUICKC+Q_REFRACT 118 #define QUALITY_7 QUALITY_6 119 #define QUALITY_8 QUALITY_7+Q_REFLECT+Q_NORMAL 120 #define QUALITY_9 QUALITY_8+Q_VOLUME 121 122 123 /***************************************************************************** 124 * Global typedefs 125 ******************************************************************************/ 126 127 typedef struct Frame_Struct FRAME; 128 129 struct Frame_Struct 130 { 131 CAMERA *Camera; 132 int Screen_Height, Screen_Width; /* OPTIONS */ 133 int Number_Of_Light_Sources; 134 LIGHT_SOURCE *Light_Sources; 135 OBJECT *Objects; 136 DBL Atmosphere_IOR, Atmosphere_Dispersion, Antialias_Threshold; 137 COLOUR Background_Colour; 138 COLOUR Ambient_Light; 139 COLOUR Irid_Wavelengths; 140 IMEDIA *Atmosphere; 141 FOG *Fog; 142 RAINBOW *Rainbow; 143 SKYSPHERE *Skysphere; 144 LIGHT_GROUP_LIGHT *Light_Group_Lights; // Maintain a separate, independent list of all lights 145 // that are part of light groups. 146 }; 147 148 typedef enum STATS 149 { 150 /* Computations are performed on these three */ 151 Number_Of_Pixels = 0, 152 Number_Of_Pixels_Supersampled, 153 Number_Of_Samples, 154 Number_Of_Rays, 155 Calls_To_DNoise, 156 Calls_To_Noise, 157 ADC_Saves, 158 159 /* intersecion stack */ 160 Istack_overflows, 161 162 /* objects */ 163 Ray_RBezier_Tests, 164 Ray_RBezier_Tests_Succeeded, 165 Ray_Bicubic_Tests, 166 Ray_Bicubic_Tests_Succeeded, 167 Ray_Blob_Tests, 168 Ray_Blob_Tests_Succeeded, 169 Blob_Element_Tests, 170 Blob_Element_Tests_Succeeded, 171 Blob_Bound_Tests, 172 Blob_Bound_Tests_Succeeded, 173 Ray_Box_Tests, 174 Ray_Box_Tests_Succeeded, 175 Ray_Cone_Tests, 176 Ray_Cone_Tests_Succeeded, 177 Ray_CSG_Intersection_Tests, 178 Ray_CSG_Intersection_Tests_Succeeded, 179 Ray_CSG_Merge_Tests, 180 Ray_CSG_Merge_Tests_Succeeded, 181 Ray_CSG_Union_Tests, 182 Ray_CSG_Union_Tests_Succeeded, 183 Ray_Disc_Tests, 184 Ray_Disc_Tests_Succeeded, 185 Ray_Fractal_Tests, 186 Ray_Fractal_Tests_Succeeded, 187 Ray_HField_Tests, 188 Ray_HField_Tests_Succeeded, 189 Ray_HField_Box_Tests, 190 Ray_HField_Box_Tests_Succeeded, 191 Ray_HField_Triangle_Tests, 192 Ray_HField_Triangle_Tests_Succeeded, 193 Ray_HField_Block_Tests, 194 Ray_HField_Block_Tests_Succeeded, 195 Ray_HField_Cell_Tests, 196 Ray_HField_Cell_Tests_Succeeded, 197 Ray_IsoSurface_Tests, 198 Ray_IsoSurface_Tests_Succeeded, 199 Ray_IsoSurface_Bound_Tests, 200 Ray_IsoSurface_Bound_Tests_Succeeded, 201 Ray_IsoSurface_Cache, 202 Ray_IsoSurface_Cache_Succeeded, 203 Ray_Lathe_Tests, 204 Ray_Lathe_Tests_Succeeded, 205 Lathe_Bound_Tests, 206 Lathe_Bound_Tests_Succeeded, 207 Ray_Mesh_Tests, 208 Ray_Mesh_Tests_Succeeded, 209 Ray_Plane_Tests, 210 Ray_Plane_Tests_Succeeded, 211 Ray_Polygon_Tests, 212 Ray_Polygon_Tests_Succeeded, 213 Ray_Prism_Tests, 214 Ray_Prism_Tests_Succeeded, 215 Prism_Bound_Tests, 216 Prism_Bound_Tests_Succeeded, 217 Ray_Parametric_Tests, 218 Ray_Parametric_Tests_Succeeded, 219 Ray_Par_Bound_Tests, 220 Ray_Par_Bound_Tests_Succeeded, 221 Ray_Quadric_Tests, 222 Ray_Quadric_Tests_Succeeded, 223 Ray_Poly_Tests, 224 Ray_Poly_Tests_Succeeded, 225 Ray_Sphere_Tests, 226 Ray_Sphere_Tests_Succeeded, 227 Ray_Sphere_Sweep_Tests, 228 Ray_Sphere_Sweep_Tests_Succeeded, 229 Ray_Superellipsoid_Tests, 230 Ray_Superellipsoid_Tests_Succeeded, 231 Ray_Sor_Tests, 232 Ray_Sor_Tests_Succeeded, 233 Sor_Bound_Tests, 234 Sor_Bound_Tests_Succeeded, 235 Ray_Torus_Tests, 236 Ray_Torus_Tests_Succeeded, 237 Torus_Bound_Tests, 238 Torus_Bound_Tests_Succeeded, 239 Ray_Triangle_Tests, 240 Ray_Triangle_Tests_Succeeded, 241 Ray_TTF_Tests, 242 Ray_TTF_Tests_Succeeded, 243 244 /* bounding etc */ 245 Bounding_Region_Tests, 246 Bounding_Region_Tests_Succeeded, 247 Clipping_Region_Tests, 248 Clipping_Region_Tests_Succeeded, 249 250 /* isosurface and functions */ 251 Ray_IsoSurface_Find_Root, 252 Ray_Function_VM_Calls, 253 Ray_Function_VM_Instruction_Est, 254 255 /* Vista and light buffer */ 256 VBuffer_Tests, 257 VBuffer_Tests_Succeeded, 258 LBuffer_Tests, 259 LBuffer_Tests_Succeeded, 260 261 /* Media */ 262 Media_Samples, 263 Media_Intervals, 264 265 /* Ray */ 266 Reflected_Rays_Traced, 267 Refracted_Rays_Traced, 268 Transmitted_Rays_Traced, 269 Internal_Reflected_Rays_Traced, 270 Shadow_Cache_Hits, 271 Shadow_Rays_Succeeded, 272 Shadow_Ray_Tests, 273 274 nChecked, 275 nEnqueued, 276 totalQueues, 277 totalQueueResets, 278 totalQueueResizes, 279 Polynomials_Tested, 280 Roots_Eliminated, 281 282 #if defined(MEM_STATS) 283 MemStat_Smallest_Alloc, 284 MemStat_Largest_Alloc, 285 MemStat_Largest_Mem_Usage, 286 #if (MEM_STATS>=2) 287 MemStat_Total_Allocs, 288 MemStat_Total_Frees, 289 #endif 290 #endif 291 292 /* NK phmap */ 293 Number_Of_Photons_Shot, 294 Number_Of_Photons_Stored, 295 Number_Of_Global_Photons_Stored, 296 Number_Of_Media_Photons_Stored, 297 Priority_Queue_Add, 298 Priority_Queue_Remove, 299 Gather_Performed_Count, 300 Gather_Expanded_Count, 301 302 /* Must be the last */ 303 MaxStat 304 305 } Stats; 306 307 typedef struct intersection_stats_info 308 { 309 int povms_id; 310 Stats stat_test_id; 311 Stats stat_suc_id; 312 char *infotext; 313 } INTERSECTION_STATS_INFO; 314 315 typedef struct OPTIONS_STRUCT 316 { 317 unsigned int Options; 318 char DisplayFormat; 319 char PaletteOption; 320 321 char OutputFormat; 322 int OutputQuality; 323 int Output_File_Type; 324 char Input_File_Name[FILE_NAME_LENGTH]; 325 char Output_File_Name[FILE_NAME_LENGTH]; 326 char Output_Path[FILE_NAME_LENGTH]; 327 char Output_Numbered_Name[FILE_NAME_LENGTH]; 328 char Scene_Name[FILE_NAME_LENGTH]; 329 COLC DisplayGamma; 330 COLC GammaFactor; 331 332 unsigned int Quality_Flags; 333 334 int AntialiasDepth; 335 DBL Antialias_Threshold; 336 337 DBL JitterScale; 338 339 int Abort_Test_Counter; 340 341 char *Library_Paths[MAX_LIBRARIES]; 342 int Library_Path_Index; 343 344 int First_Column, Last_Column; 345 DBL First_Column_Percent, Last_Column_Percent; 346 347 int First_Line, Last_Line; 348 DBL First_Line_Percent, Last_Line_Percent; 349 350 /* Parse */ 351 int Language_Version; 352 353 bool Use_Slabs; 354 long BBox_Threshold; 355 356 int Quality; 357 358 int PreviewGridSize_Start; /* Mosaic Preview - Initial pixel grid size */ 359 int PreviewGridSize_End; /* Mosaic Preview - Ending pixel grid size */ 360 361 FRAMESEQ FrameSeq; 362 363 /* Should STREAM PATHS go somewhere here? */ 364 365 DBL Radiosity_Brightness; 366 long Radiosity_Count; 367 DBL Radiosity_Dist_Max; 368 DBL Radiosity_Error_Bound; 369 DBL Radiosity_Gray; /* degree to which gathered light is grayed */ 370 DBL Radiosity_Low_Error_Factor; 371 DBL Radiosity_Min_Reuse; 372 long Radiosity_Nearest_Count; 373 int Radiosity_Recursion_Limit; 374 long Radiosity_Quality; /* Q-flag value for light gathering */ 375 int Radiosity_File_ReadOnContinue; 376 int Radiosity_File_SaveWhileRendering; 377 int Radiosity_File_AlwaysReadAtStart; 378 int Radiosity_File_KeepOnAbort; 379 int Radiosity_File_KeepAlways; 380 int Radiosity_Preview_Done; /* used in cache file processing */ 381 382 /* NK rad */ 383 DBL Real_Radiosity_Error_Bound; 384 DBL Maximum_Sample_Brightness; 385 DBL Radiosity_ADC_Bailout; 386 int Radiosity_Use_Normal; 387 int Radiosity_Use_Media; 388 char *Radiosity_Load_File_Name; 389 char *Radiosity_Save_File_Name; 390 int Radiosity_Add_On_Final_Trace; 391 bool Radiosity_Enabled; 392 DBL radPretraceStart; 393 DBL radPretraceEnd; 394 395 int histogram_x, histogram_y; 396 bool histogram_on; 397 Histogram_Types histogram_type; 398 int histogram_file_type; 399 char Histogram_File_Name[FILE_NAME_LENGTH]; 400 401 SHELLDATA Shellouts[MAX_SHL]; 402 403 char Ini_Output_File_Name[FILE_NAME_LENGTH]; 404 405 char Header_File_Name[FILE_NAME_LENGTH]; 406 407 int Tracing_Method; 408 int Do_Stats; 409 410 unsigned long Preview_RefCon; 411 412 int Warning_Level; 413 414 int String_Encoding; 415 416 int Noise_Generator; 417 418 POVMSAttributeList Declared_Variables; 419 } Opts; 420 421 422 /***************************************************************************** 423 * Global variables 424 ******************************************************************************/ 425 426 extern char Actual_Output_Name[FILE_NAME_LENGTH]; 427 428 extern int Cooperate_Render_Flag; 429 430 extern FRAME Frame; 431 432 extern COUNTER stats[MaxStat]; 433 extern COUNTER totalstats[MaxStat]; 434 435 extern time_t tstart, tstop; 436 extern DBL tparse, tphoton, trender; 437 extern DBL tparse_frame, tphoton_frame, trender_frame; 438 extern DBL tparse_total, tphoton_total, trender_total; 439 440 extern char Color_Bits; 441 442 extern int Number_Of_Files; 443 extern Opts opts; 444 445 extern OStream *stat_file; 446 extern Image_File_Class *Output_File; 447 448 extern int Abort_Test_Every; 449 extern int Display_Started; 450 extern int Stage; 451 extern volatile int Stop_Flag; 452 extern int Experimental_Flag; 453 454 extern int Num_Echo_Lines; 455 extern char *Option_String_Ptr; 456 extern DBL Clock_Delta; 457 458 END_POV_NAMESPACE 459 460 #if(USE_LOCAL_POVMS_OUTPUT == 1) 461 extern POVMSContext POVMS_Output_Context; 462 #endif 463 464 465 /***************************************************************************** 466 * Global functions 467 ******************************************************************************/ 468 469 void povray_init(); 470 void povray_terminate(); 471 void povray_exit(int i); 472 473 void povray_cooperate(); 474 475 #if(USE_LOCAL_POVMS_OUTPUT == 1) 476 POVMSAddress povray_getoutputcontext(); 477 #endif 478 479 BEGIN_POV_NAMESPACE 480 481 void Do_Cooperate(int level); 482 483 END_POV_NAMESPACE 484 485 #endif 486