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 * 25 *=========================================================================== 26 * This file is part of MegaPOV, a modified and unofficial version of POV-Ray 27 * For more information on MegaPOV visit our website: 28 * http://megapov.inetart.net/ 29 *=========================================================================== 30 * 31 * $RCSfile: povray.h,v $ 32 * $Revision: 1.28 $ 33 * $Author: chris $ 34 * 35 *****************************************************************************/ 36 37 38 #ifndef POVRAY_H 39 #define POVRAY_H 40 41 #include <time.h> 42 43 #include "frame.h" 44 #include "atmosph.h" 45 #include "camera.h" 46 #include "media.h" 47 #include "point.h" 48 #include "render.h" 49 #include "userio.h" 50 #include "povms.h" 51 #include "lightgrp.h" 52 53 #ifdef GLOW_PATCH 54 #include "glow.h" 55 #endif 56 57 BEGIN_POV_NAMESPACE 58 59 USING_POV_BASE_NAMESPACE 60 61 /***************************************************************************** 62 * Global preprocessor defines 63 ******************************************************************************/ 64 65 #define MAX_LIBRARIES 25 66 67 #define STAGE_PREINIT 0 /* set in POVRAY.C */ 68 #define STAGE_STARTUP 1 /* set in POVRAY.C */ 69 #define STAGE_BANNER 2 /* set in POVRAY.C */ 70 #define STAGE_INIT 3 /* set in POVRAY.C */ 71 #define STAGE_FILE_INIT 4 /* set in POVRAY.C */ 72 #define STAGE_PARSING 5 /* set in PARSE.C */ 73 #define STAGE_CONTINUING 6 /* set in POVRAY.C */ 74 #define STAGE_RENDERING 7 /* set in POVRAY.C */ 75 #define STAGE_SHUTDOWN 8 /* set in POVRAY.C */ 76 #define STAGE_CLEANUP_PARSE 9 /* set in PARSE.C */ 77 #define STAGE_SLAB_BUILDING 10 /* set in POVRAY.C */ 78 #define STAGE_TOKEN_INIT 11 /* set in TOKENIZE.C */ 79 #define STAGE_INCLUDE_ERR 12 /* set in TOKENIZE.C */ 80 #define STAGE_FOUND_INSTEAD 13 /* set in TOKENIZE.C */ 81 #define STAGECOUNT 14 /* number of stages */ 82 83 #define DISPLAY 0x000001L 84 #define VERBOSE 0x000002L 85 #define DISKWRITE 0x000004L 86 #define PROMPTEXIT 0x000008L 87 #define ANTIALIAS 0x000010L 88 #define RGBSEPARATE 0x000020L 89 #define EXITENABLE 0x000040L 90 #define CONTINUE_TRACE 0x000080L 91 #define JITTER 0x000100L 92 #define PREVIEW 0x000200L 93 #define SPLIT_UNION 0x000400L 94 #define USE_VISTA_BUFFER 0x000800L 95 #define USE_LIGHT_BUFFER 0x001000L 96 #define USE_VISTA_DRAW 0x002000L 97 #define REMOVE_BOUNDS 0x004000L 98 #define CYCLIC_ANIMATION 0x008000L 99 #define OUTPUT_ALPHA 0x010000L 100 #define HF_GRAY_16 0x020000L 101 #define GAMMA_CORRECT 0x040000L 102 #define FROM_STDIN 0x080000L 103 #define TO_STDOUT 0x100000L 104 105 #define Q_FULL_AMBIENT 0x000001L 106 #define Q_QUICKC 0x000002L 107 #define Q_SHADOW 0x000004L 108 #define Q_AREA_LIGHT 0x000008L 109 #define Q_REFRACT 0x000010L 110 #define Q_REFLECT 0x000020L 111 #define Q_NORMAL 0x000040L 112 #define Q_VOLUME 0x000080L 113 114 #define EF_RADIOS 1 115 #define EF_SLOPEM 2 116 #define EF_ISOFN 4 117 #define EF_SPLINE 8 118 #define EF_TIFF 16 119 120 #define QUALITY_0 Q_QUICKC+Q_FULL_AMBIENT 121 #define QUALITY_1 QUALITY_0 122 #define QUALITY_2 QUALITY_1-Q_FULL_AMBIENT 123 #define QUALITY_3 QUALITY_2 124 #define QUALITY_4 QUALITY_3+Q_SHADOW 125 #define QUALITY_5 QUALITY_4+Q_AREA_LIGHT 126 #define QUALITY_6 QUALITY_5-Q_QUICKC+Q_REFRACT 127 #define QUALITY_7 QUALITY_6 128 #define QUALITY_8 QUALITY_7+Q_REFLECT+Q_NORMAL 129 #define QUALITY_9 QUALITY_8+Q_VOLUME 130 131 132 /***************************************************************************** 133 * Global typedefs 134 ******************************************************************************/ 135 136 typedef struct Frame_Struct FRAME; 137 138 struct Frame_Struct 139 { 140 CAMERA *Camera; 141 int Screen_Height, Screen_Width; /* OPTIONS */ 142 int Number_Of_Light_Sources; 143 LIGHT_SOURCE *Light_Sources; 144 OBJECT *Objects; 145 DBL Atmosphere_IOR, Atmosphere_Dispersion, Antialias_Threshold; 146 COLOUR Background_Colour; 147 COLOUR Ambient_Light; 148 COLOUR Irid_Wavelengths; 149 IMEDIA *Atmosphere; 150 FOG *Fog; 151 RAINBOW *Rainbow; 152 SKYSPHERE *Skysphere; 153 LIGHT_GROUP_LIGHT *Light_Group_Lights; // Maintain a separate, independent list of all lights 154 // that are part of light groups. 155 #ifdef GLOW_PATCH 156 GLOW * Glows; 157 unsigned int NumOfGlows; 158 #endif 159 }; 160 161 typedef enum STATS 162 { 163 /* Computations are performed on these three */ 164 Number_Of_Pixels = 0, 165 Number_Of_Pixels_Supersampled, 166 Number_Of_Samples, 167 Number_Of_Rays, 168 Calls_To_DNoise, 169 Calls_To_Noise, 170 ADC_Saves, 171 172 /* intersecion stack */ 173 Istack_overflows, 174 175 /* objects */ 176 Ray_RBezier_Tests, 177 Ray_RBezier_Tests_Succeeded, 178 Ray_Bicubic_Tests, 179 Ray_Bicubic_Tests_Succeeded, 180 Ray_Blob_Tests, 181 Ray_Blob_Tests_Succeeded, 182 Blob_Element_Tests, 183 Blob_Element_Tests_Succeeded, 184 Blob_Bound_Tests, 185 Blob_Bound_Tests_Succeeded, 186 Ray_Box_Tests, 187 Ray_Box_Tests_Succeeded, 188 Ray_Cone_Tests, 189 Ray_Cone_Tests_Succeeded, 190 Ray_CSG_Intersection_Tests, 191 Ray_CSG_Intersection_Tests_Succeeded, 192 Ray_CSG_Merge_Tests, 193 Ray_CSG_Merge_Tests_Succeeded, 194 Ray_CSG_Union_Tests, 195 Ray_CSG_Union_Tests_Succeeded, 196 Ray_Disc_Tests, 197 Ray_Disc_Tests_Succeeded, 198 Ray_Fractal_Tests, 199 Ray_Fractal_Tests_Succeeded, 200 Ray_HField_Tests, 201 Ray_HField_Tests_Succeeded, 202 Ray_HField_Box_Tests, 203 Ray_HField_Box_Tests_Succeeded, 204 Ray_HField_Triangle_Tests, 205 Ray_HField_Triangle_Tests_Succeeded, 206 Ray_HField_Block_Tests, 207 Ray_HField_Block_Tests_Succeeded, 208 Ray_HField_Cell_Tests, 209 Ray_HField_Cell_Tests_Succeeded, 210 Ray_IsoSurface_Tests, 211 Ray_IsoSurface_Tests_Succeeded, 212 Ray_IsoSurface_Bound_Tests, 213 Ray_IsoSurface_Bound_Tests_Succeeded, 214 Ray_IsoSurface_Cache, 215 Ray_IsoSurface_Cache_Succeeded, 216 Ray_Lathe_Tests, 217 Ray_Lathe_Tests_Succeeded, 218 Lathe_Bound_Tests, 219 Lathe_Bound_Tests_Succeeded, 220 Ray_Mesh_Tests, 221 Ray_Mesh_Tests_Succeeded, 222 Ray_Plane_Tests, 223 Ray_Plane_Tests_Succeeded, 224 Ray_Polygon_Tests, 225 Ray_Polygon_Tests_Succeeded, 226 Ray_Prism_Tests, 227 Ray_Prism_Tests_Succeeded, 228 Prism_Bound_Tests, 229 Prism_Bound_Tests_Succeeded, 230 Ray_Parametric_Tests, 231 Ray_Parametric_Tests_Succeeded, 232 Ray_Par_Bound_Tests, 233 Ray_Par_Bound_Tests_Succeeded, 234 Ray_Quadric_Tests, 235 Ray_Quadric_Tests_Succeeded, 236 Ray_Poly_Tests, 237 Ray_Poly_Tests_Succeeded, 238 Ray_Sphere_Tests, 239 Ray_Sphere_Tests_Succeeded, 240 Ray_Sphere_Sweep_Tests, 241 Ray_Sphere_Sweep_Tests_Succeeded, 242 Ray_Superellipsoid_Tests, 243 Ray_Superellipsoid_Tests_Succeeded, 244 Ray_Sor_Tests, 245 Ray_Sor_Tests_Succeeded, 246 Sor_Bound_Tests, 247 Sor_Bound_Tests_Succeeded, 248 Ray_Torus_Tests, 249 Ray_Torus_Tests_Succeeded, 250 Torus_Bound_Tests, 251 Torus_Bound_Tests_Succeeded, 252 Ray_Triangle_Tests, 253 Ray_Triangle_Tests_Succeeded, 254 Ray_TTF_Tests, 255 Ray_TTF_Tests_Succeeded, 256 257 /* bounding etc */ 258 Bounding_Region_Tests, 259 Bounding_Region_Tests_Succeeded, 260 Clipping_Region_Tests, 261 Clipping_Region_Tests_Succeeded, 262 263 /* isosurface and functions */ 264 Ray_IsoSurface_Find_Root, 265 Ray_Function_VM_Calls, 266 Ray_Function_VM_Instruction_Est, 267 268 /* Vista and light buffer */ 269 VBuffer_Tests, 270 VBuffer_Tests_Succeeded, 271 LBuffer_Tests, 272 LBuffer_Tests_Succeeded, 273 274 /* Media */ 275 Media_Samples, 276 Media_Intervals, 277 278 /* Ray */ 279 Reflected_Rays_Traced, 280 Refracted_Rays_Traced, 281 Transmitted_Rays_Traced, 282 Internal_Reflected_Rays_Traced, 283 Shadow_Cache_Hits, 284 Shadow_Rays_Succeeded, 285 Shadow_Ray_Tests, 286 287 nChecked, 288 nEnqueued, 289 totalQueues, 290 totalQueueResets, 291 totalQueueResizes, 292 Polynomials_Tested, 293 Roots_Eliminated, 294 295 #if defined(MEM_STATS) 296 MemStat_Smallest_Alloc, 297 MemStat_Largest_Alloc, 298 MemStat_Largest_Mem_Usage, 299 #if (MEM_STATS>=2) 300 MemStat_Total_Allocs, 301 MemStat_Total_Frees, 302 #endif 303 #endif 304 305 /* NK phmap */ 306 Number_Of_Photons_Shot, 307 Number_Of_Photons_Stored, 308 Number_Of_Global_Photons_Stored, 309 Number_Of_Media_Photons_Stored, 310 Priority_Queue_Add, 311 Priority_Queue_Remove, 312 Gather_Performed_Count, 313 Gather_Expanded_Count, 314 315 #ifdef MECHANICS_SIMULATION_PATCH /* Christoph Hormann September 2002 */ 316 MechSim_Steps, 317 MechSim_Mass_Collisions, 318 MechSim_Face_Collisions, 319 MechSim_Connection_Collisions, 320 MechSim_Environment_Collisions, 321 MechSim_Environment_Penetrations, 322 #endif 323 324 #ifdef SIMPLE_PATTERN_CACHE_PATCH 325 SimplePigmentCache_Tests, 326 SimplePigmentCache_Tests_Succeeded, 327 #endif 328 329 #ifdef MOTION_BLUR_PATCH 330 Ray_Motion_Blur_Tests, 331 Ray_Motion_Blur_Tests_Succeeded, 332 #endif 333 334 #ifdef RADIOSITY_STATISTICS_PATCH 335 Radiosity_GatherFinal, 336 Radiosity_GatherFirst, 337 Radiosity_GatherSecond, 338 Radiosity_GatherThird, 339 #endif 340 341 /* Must be the last */ 342 MaxStat 343 344 } Stats; 345 346 typedef struct intersection_stats_info 347 { 348 int povms_id; 349 Stats stat_test_id; 350 Stats stat_suc_id; 351 char *infotext; 352 } INTERSECTION_STATS_INFO; 353 354 typedef struct OPTIONS_STRUCT 355 { 356 unsigned int Options; 357 char DisplayFormat; 358 char PaletteOption; 359 360 char OutputFormat; 361 int OutputQuality; 362 int Output_File_Type; 363 char Input_File_Name[FILE_NAME_LENGTH]; 364 char Output_File_Name[FILE_NAME_LENGTH]; 365 char Output_Path[FILE_NAME_LENGTH]; 366 char Output_Numbered_Name[FILE_NAME_LENGTH]; 367 char Scene_Name[FILE_NAME_LENGTH]; 368 COLC DisplayGamma; 369 COLC GammaFactor; 370 371 unsigned int Quality_Flags; 372 373 int AntialiasDepth; 374 DBL Antialias_Threshold; 375 376 DBL JitterScale; 377 378 int Abort_Test_Counter; 379 380 char *Library_Paths[MAX_LIBRARIES]; 381 int Library_Path_Index; 382 383 int First_Column, Last_Column; 384 DBL First_Column_Percent, Last_Column_Percent; 385 386 int First_Line, Last_Line; 387 DBL First_Line_Percent, Last_Line_Percent; 388 389 /* Parse */ 390 int Language_Version; 391 392 bool Use_Slabs; 393 long BBox_Threshold; 394 395 int Quality; 396 397 int PreviewGridSize_Start; /* Mosaic Preview - Initial pixel grid size */ 398 int PreviewGridSize_End; /* Mosaic Preview - Ending pixel grid size */ 399 400 FRAMESEQ FrameSeq; 401 402 /* Should STREAM PATHS go somewhere here? */ 403 404 DBL Radiosity_Brightness; 405 long Radiosity_Count; 406 DBL Radiosity_Dist_Max; 407 DBL Radiosity_Error_Bound; 408 DBL Radiosity_Gray; /* degree to which gathered light is grayed */ 409 DBL Radiosity_Low_Error_Factor; 410 DBL Radiosity_Min_Reuse; 411 long Radiosity_Nearest_Count; 412 int Radiosity_Recursion_Limit; 413 long Radiosity_Quality; /* Q-flag value for light gathering */ 414 int Radiosity_File_ReadOnContinue; 415 int Radiosity_File_SaveWhileRendering; 416 int Radiosity_File_AlwaysReadAtStart; 417 int Radiosity_File_KeepOnAbort; 418 int Radiosity_File_KeepAlways; 419 int Radiosity_Preview_Done; /* used in cache file processing */ 420 421 /* NK rad */ 422 DBL Real_Radiosity_Error_Bound; 423 DBL Maximum_Sample_Brightness; 424 DBL Radiosity_ADC_Bailout; 425 int Radiosity_Use_Normal; 426 int Radiosity_Use_Media; 427 char *Radiosity_Load_File_Name; 428 char *Radiosity_Save_File_Name; 429 int Radiosity_Add_On_Final_Trace; 430 bool Radiosity_Enabled; 431 DBL radPretraceStart; 432 DBL radPretraceEnd; 433 434 #ifdef NEW_RADIOSITY_PRETRACE_PATCH /* Christoph Hormann March 2005 */ 435 int radPretraceAdaptive; 436 #endif 437 438 #ifdef RAD_CUSTOM_SAMPLES_PATCH 439 VECTOR *Rad_Samples; 440 int Rad_Samples_Count; 441 int Rad_Samples_Type; 442 int Rad_Samples_Weight; 443 #endif 444 #ifdef RAD_SAMPLES_RANDOMIZE_PATCH /* Christoph Hormann January 2003 */ 445 bool Rad_Samples_Random; 446 #endif 447 448 int histogram_x, histogram_y; 449 bool histogram_on; 450 Histogram_Types histogram_type; 451 int histogram_file_type; 452 char Histogram_File_Name[FILE_NAME_LENGTH]; 453 454 SHELLDATA Shellouts[MAX_SHL]; 455 456 char Ini_Output_File_Name[FILE_NAME_LENGTH]; 457 458 char Header_File_Name[FILE_NAME_LENGTH]; 459 460 int Tracing_Method; 461 int Do_Stats; 462 463 unsigned long Preview_RefCon; 464 465 int Warning_Level; 466 467 int String_Encoding; 468 469 int Noise_Generator; 470 //patches from here on please 471 #ifdef UNOFFICIAL_BLOCKING_PATCH 472 int unofficialVersion; /* only set after parse is done */ 473 #endif 474 #ifdef FILM_EXPOSURE_SIMULATION_PATCH 475 DBL Exposure; 476 DBL Exposure_Gain; 477 #endif 478 #ifdef PIGMENT_CAMERA_VIEW_PATCH 479 bool Camera_View_Not_In_Rendering; 480 #endif 481 #ifdef MOTION_BLUR_PATCH 482 int motionBlurCount; 483 DBL blurClockDelta; 484 int Radiosity_Use_Motion_Blur; 485 #endif 486 #ifdef CUSTOM_TONE_MAPPING_PATCH /* Christoph Hormann September 2004 */ 487 FUNCTION_PTR Mapping_Function; 488 FUNCTION_PTR Mapping_Function_Inverse; 489 int Mapping_Function_Invert; 490 COLC *Mapping_Function_Inverse_Lookup_Table; 491 bool Use_Mapping_Function; 492 #endif 493 494 #ifdef RADIOSITY_VISUALIZE_PATCH 495 bool Radiosity_Show_Low_Count; 496 COLOUR Radiosity_Low_Count_Color; 497 COLOUR Radiosity_Gather_Final_Color; 498 COLOUR Radiosity_Show_Sample_Points; 499 DBL Radiosity_Show_Sample_Points_Radius; 500 #endif 501 502 #ifdef RADIOSITY_ADAPTIVE_RADIUS_PATCH 503 DBL Radiosity_Error_Bound_Multiplier; 504 DBL Radiosity_Error_Bound_Max; 505 #endif 506 507 POVMSAttributeList Declared_Variables; 508 } Opts; 509 510 511 /***************************************************************************** 512 * Global variables 513 ******************************************************************************/ 514 515 extern char Actual_Output_Name[FILE_NAME_LENGTH]; 516 517 extern int Cooperate_Render_Flag; 518 519 extern FRAME Frame; 520 521 extern COUNTER stats[MaxStat]; 522 extern COUNTER totalstats[MaxStat]; 523 524 extern time_t tstart, tstop; 525 extern DBL tparse, tphoton, trender; 526 extern DBL tparse_frame, tphoton_frame, trender_frame; 527 extern DBL tparse_total, tphoton_total, trender_total; 528 529 #ifdef CLOTHRAY_PATCH 530 extern DBL tcloth, tcloth_frame, tcloth_total ; 531 #endif 532 #ifdef MECHANICS_SIMULATION_PATCH 533 extern DBL tmechsim, tmechsim_frame, tmechsim_total ; 534 #endif 535 #ifdef POST_PROCESS_PATCH 536 extern DBL tpostproc, tpostproc_frame, tpostproc_total; 537 #endif 538 539 extern char Color_Bits; 540 541 extern int Number_Of_Files; 542 extern Opts opts; 543 544 extern OStream *stat_file; 545 extern Image_File_Class *Output_File; 546 547 extern int Abort_Test_Every; 548 extern int Display_Started; 549 extern int Stage; 550 extern volatile int Stop_Flag; 551 extern int Experimental_Flag; 552 553 extern int Num_Echo_Lines; 554 extern char *Option_String_Ptr; 555 extern DBL Clock_Delta; 556 557 END_POV_NAMESPACE 558 559 #if(USE_LOCAL_POVMS_OUTPUT == 1) 560 extern POVMSContext POVMS_Output_Context; 561 #endif 562 563 564 /***************************************************************************** 565 * Global functions 566 ******************************************************************************/ 567 568 void povray_init(); 569 void povray_terminate(); 570 void povray_exit(int i); 571 572 void povray_cooperate(); 573 574 #if(USE_LOCAL_POVMS_OUTPUT == 1) 575 POVMSAddress povray_getoutputcontext(); 576 #endif 577 578 BEGIN_POV_NAMESPACE 579 580 void Do_Cooperate(int level); 581 582 END_POV_NAMESPACE 583 584 #endif 585