POVRAY.H 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428
  1. /****************************************************************************
  2. * povray.h
  3. *
  4. * This module contains all defines, typedefs, and prototypes for POVRAY.C.
  5. *
  6. * from Persistence of Vision(tm) Ray Tracer
  7. * Copyright 1996,1999 Persistence of Vision Team
  8. *---------------------------------------------------------------------------
  9. * NOTICE: This source code file is provided so that users may experiment
  10. * with enhancements to POV-Ray and to port the software to platforms other
  11. * than those supported by the POV-Ray Team. There are strict rules under
  12. * which you are permitted to use this file. The rules are in the file
  13. * named POVLEGAL.DOC which should be distributed with this file.
  14. * If POVLEGAL.DOC is not available or for more info please contact the POV-Ray
  15. * Team Coordinator by email to team-coord@povray.org or visit us on the web at
  16. * http://www.povray.org. The latest version of POV-Ray may be found at this site.
  17. *
  18. * This program is based on the popular DKB raytracer version 2.12.
  19. * DKBTrace was originally written by David K. Buck.
  20. * DKBTrace Ver 2.0-2.12 were written by David K. Buck & Aaron A. Collins.
  21. *
  22. *****************************************************************************/
  23. #ifndef POVRAY_H
  24. #define POVRAY_H
  25. #include <time.h>
  26. #include "atmosph.h"
  27. #include "camera.h"
  28. #include "media.h"
  29. #include "point.h"
  30. #include "render.h"
  31. /*****************************************************************************
  32. * Global preprocessor defines
  33. ******************************************************************************/
  34. #define MAX_LIBRARIES 25
  35. #define STAGE_STARTUP 0 /* set in POVRAY.C */
  36. #define STAGE_BANNER 1 /* set in POVRAY.C */
  37. #define STAGE_INIT 2 /* set in POVRAY.C */
  38. #define STAGE_ENVIRONMENT 3 /* set in POVRAY.C */
  39. #define STAGE_COMMAND_LINE 4 /* set in POVRAY.C */
  40. #define STAGE_FILE_INIT 5 /* set in POVRAY.C */
  41. #define STAGE_PARSING 7 /* set in PARSE.C */
  42. #define STAGE_CONTINUING 8 /* set in POVRAY.C */
  43. #define STAGE_RENDERING 9 /* set in POVRAY.C */
  44. #define STAGE_SHUTDOWN 10 /* set in POVRAY.C */
  45. #define STAGE_INI_FILE 11 /* set in POVRAY.C */
  46. #define STAGE_CLEANUP_PARSE 12 /* set in PARSE.C */
  47. #define STAGE_SLAB_BUILDING 13 /* set in POVRAY.C */
  48. #define STAGE_TOKEN_INIT 14 /* set in TOKENIZE.C */
  49. #define STAGE_INCLUDE_ERR 15 /* set in TOKENIZE.C */
  50. #define STAGE_FOUND_INSTEAD 16 /* set in TOKENIZE.C */
  51. #define DISPLAY 0x000001L
  52. #define VERBOSE 0x000002L
  53. #define DISKWRITE 0x000004L
  54. #define PROMPTEXIT 0x000008L
  55. #define ANTIALIAS 0x000010L
  56. #define RGBSEPARATE 0x000020L
  57. #define EXITENABLE 0x000040L
  58. #define CONTINUE_TRACE 0x000080L
  59. #define BUFFERED_OUTPUT 0x000100L
  60. #define JITTER 0x000200L
  61. #define PREVIEW 0x000400L
  62. #define SPLIT_UNION 0x000800L
  63. #define USE_VISTA_BUFFER 0x001000L
  64. #define USE_LIGHT_BUFFER 0x002000L
  65. #define USE_VISTA_DRAW 0x004000L
  66. #define REMOVE_BOUNDS 0x008000L
  67. #define CYCLIC_ANIMATION 0x010000L
  68. #define OUTPUT_ALPHA 0x020000L
  69. #define HF_GRAY_16 0x040000L
  70. #define GAMMA_CORRECT 0x080000L
  71. #define RADIOSITY 0x100000L
  72. #define FROM_STDIN 0x200000L
  73. #define TO_STDOUT 0x400000L
  74. #define Q_FULL_AMBIENT 0x000001L
  75. #define Q_QUICKC 0x000002L
  76. #define Q_SHADOW 0x000004L
  77. #define Q_AREA_LIGHT 0x000008L
  78. #define Q_REFRACT 0x000010L
  79. #define Q_REFLECT 0x000020L
  80. #define Q_NORMAL 0x000040L
  81. #define Q_VOLUME 0x000080L
  82. #define EF_RADIOS 1
  83. #define QUALITY_0 Q_QUICKC+Q_FULL_AMBIENT
  84. #define QUALITY_1 QUALITY_0
  85. #define QUALITY_2 QUALITY_1-Q_FULL_AMBIENT
  86. #define QUALITY_3 QUALITY_2
  87. #define QUALITY_4 QUALITY_3+Q_SHADOW
  88. #define QUALITY_5 QUALITY_4+Q_AREA_LIGHT
  89. #define QUALITY_6 QUALITY_5-Q_QUICKC+Q_REFRACT
  90. #define QUALITY_7 QUALITY_6
  91. #define QUALITY_8 QUALITY_7+Q_REFLECT+Q_NORMAL
  92. #define QUALITY_9 QUALITY_8+Q_VOLUME
  93. /*****************************************************************************
  94. * Global typedefs
  95. ******************************************************************************/
  96. typedef struct Frame_Struct FRAME;
  97. struct Frame_Struct
  98. {
  99. CAMERA *Camera;
  100. int Screen_Height, Screen_Width; /* OPTIONS */
  101. int Number_Of_Light_Sources;
  102. LIGHT_SOURCE *Light_Sources;
  103. OBJECT *Objects;
  104. DBL Atmosphere_IOR, Antialias_Threshold;
  105. COLOUR Background_Colour;
  106. COLOUR Ambient_Light;
  107. COLOUR Irid_Wavelengths;
  108. IMEDIA *Atmosphere;
  109. FOG *Fog;
  110. RAINBOW *Rainbow;
  111. SKYSPHERE *Skysphere;
  112. };
  113. typedef enum STATS
  114. {
  115. /* Computations are performed on these three */
  116. Number_Of_Pixels = 0,
  117. Number_Of_Pixels_Supersampled,
  118. Number_Of_Samples,
  119. Number_Of_Rays,
  120. Calls_To_DNoise,
  121. Calls_To_Noise,
  122. ADC_Saves,
  123. /* objects */
  124. Bounding_Region_Tests,
  125. Bounding_Region_Tests_Succeeded,
  126. Clipping_Region_Tests,
  127. Clipping_Region_Tests_Succeeded,
  128. Istack_overflows,
  129. Ray_Bicubic_Tests,
  130. Ray_Bicubic_Tests_Succeeded,
  131. Ray_Blob_Tests,
  132. Ray_Blob_Tests_Succeeded,
  133. Blob_Element_Tests,
  134. Blob_Element_Tests_Succeeded,
  135. Blob_Bound_Tests,
  136. Blob_Bound_Tests_Succeeded,
  137. Ray_Box_Tests,
  138. Ray_Box_Tests_Succeeded,
  139. Ray_Cone_Tests,
  140. Ray_Cone_Tests_Succeeded,
  141. Ray_Disc_Tests,
  142. Ray_Disc_Tests_Succeeded,
  143. Ray_HField_Tests,
  144. Ray_HField_Tests_Succeeded,
  145. Ray_HField_Box_Tests,
  146. Ray_HField_Box_Tests_Succeeded,
  147. Ray_HField_Triangle_Tests,
  148. Ray_HField_Triangle_Tests_Succeeded,
  149. Ray_HField_Block_Tests,
  150. Ray_HField_Block_Tests_Succeeded,
  151. Ray_HField_Cell_Tests,
  152. Ray_HField_Cell_Tests_Succeeded,
  153. Ray_Fractal_Tests,
  154. Ray_Fractal_Tests_Succeeded,
  155. Ray_Lathe_Tests,
  156. Ray_Lathe_Tests_Succeeded,
  157. Lathe_Bound_Tests,
  158. Lathe_Bound_Tests_Succeeded,
  159. Ray_Mesh_Tests,
  160. Ray_Mesh_Tests_Succeeded,
  161. Ray_Plane_Tests,
  162. Ray_Plane_Tests_Succeeded,
  163. Ray_Poly_Tests,
  164. Ray_Poly_Tests_Succeeded,
  165. Ray_Polygon_Tests,
  166. Ray_Polygon_Tests_Succeeded,
  167. Ray_Prism_Tests,
  168. Ray_Prism_Tests_Succeeded,
  169. Prism_Bound_Tests,
  170. Prism_Bound_Tests_Succeeded,
  171. Ray_Quadric_Tests,
  172. Ray_Quadric_Tests_Succeeded,
  173. Ray_Sor_Tests,
  174. Ray_Sor_Tests_Succeeded,
  175. Sor_Bound_Tests,
  176. Sor_Bound_Tests_Succeeded,
  177. Ray_Sphere_Tests,
  178. Ray_Sphere_Tests_Succeeded,
  179. Ray_Torus_Tests,
  180. Ray_Torus_Tests_Succeeded,
  181. Torus_Bound_Tests,
  182. Torus_Bound_Tests_Succeeded,
  183. Ray_CSG_Intersection_Tests,
  184. Ray_CSG_Intersection_Tests_Succeeded,
  185. Ray_CSG_Merge_Tests,
  186. Ray_CSG_Merge_Tests_Succeeded,
  187. Ray_CSG_Union_Tests,
  188. Ray_CSG_Union_Tests_Succeeded,
  189. Ray_Triangle_Tests,
  190. Ray_Triangle_Tests_Succeeded,
  191. Ray_TTF_Tests,
  192. Ray_TTF_Tests_Succeeded,
  193. Ray_Superellipsoid_Tests,
  194. Ray_Superellipsoid_Tests_Succeeded,
  195. Media_Samples,
  196. Media_Intervals,
  197. Reflected_Rays_Traced,
  198. Refracted_Rays_Traced,
  199. Transmitted_Rays_Traced,
  200. Internal_Reflected_Rays_Traced,
  201. Shadow_Cache_Hits,
  202. Shadow_Rays_Succeeded,
  203. Shadow_Ray_Tests,
  204. nChecked,
  205. nEnqueued,
  206. totalQueues,
  207. totalQueueResets,
  208. totalQueueResizes,
  209. Polynomials_Tested,
  210. Roots_Eliminated,
  211. VBuffer_Tests,
  212. VBuffer_Tests_Succeeded,
  213. LBuffer_Tests,
  214. LBuffer_Tests_Succeeded,
  215. #if defined(MEM_STATS)
  216. MemStat_Smallest_Alloc,
  217. MemStat_Largest_Alloc,
  218. MemStat_Largest_Mem_Usage,
  219. #if (MEM_STATS>=2)
  220. MemStat_Total_Allocs,
  221. MemStat_Total_Frees,
  222. #endif
  223. #endif
  224. /* Must be the last */
  225. MaxStat
  226. } Stats;
  227. typedef enum shelltype
  228. {
  229. PRE_SCENE_SHL = 0,
  230. PRE_FRAME_SHL,
  231. POST_FRAME_SHL,
  232. POST_SCENE_SHL,
  233. USER_ABORT_SHL,
  234. FATAL_SHL,
  235. MAX_SHL /* Must be last */
  236. } SHELLTYPE;
  237. typedef enum shellret
  238. {
  239. IGNORE_RET = 0,
  240. QUIT_RET,
  241. USER_RET,
  242. FATAL_RET,
  243. SKIP_ONCE_RET,
  244. ALL_SKIP_RET
  245. } SHELLRET;
  246. #ifdef __cplusplus
  247. #undef POV_SHELLOUT_CAST
  248. #define POV_SHELLOUT_CAST SHELLRET
  249. #else
  250. #define POV_SHELLOUT_CAST int
  251. #endif
  252. typedef struct shelldata
  253. {
  254. SHELLRET Ret;
  255. int Inverse;
  256. char Command[POV_MAX_CMD_LENGTH];
  257. } SHELLDATA;
  258. typedef struct OPTIONS_STRUCT
  259. {
  260. int File_Buffer_Size;
  261. unsigned long Options;
  262. char DisplayFormat;
  263. char PaletteOption;
  264. char OutputFormat;
  265. int OutputQuality;
  266. char Input_File_Name[FILE_NAME_LENGTH];
  267. char Output_File_Name[FILE_NAME_LENGTH];
  268. char Output_Path[FILE_NAME_LENGTH];
  269. char Output_Numbered_Name[FILE_NAME_LENGTH];
  270. char Scene_Name[FILE_NAME_LENGTH];
  271. DBL DisplayGamma;
  272. DBL GammaFactor;
  273. unsigned long Quality_Flags;
  274. long AntialiasDepth;
  275. DBL Antialias_Threshold;
  276. DBL JitterScale;
  277. int Abort_Test_Counter;
  278. char *Library_Paths[MAX_LIBRARIES];
  279. int Library_Path_Index;
  280. int First_Column, Last_Column;
  281. DBL First_Column_Percent, Last_Column_Percent;
  282. int First_Line, Last_Line;
  283. DBL First_Line_Percent, Last_Line_Percent;
  284. /* Parse */
  285. DBL Language_Version;
  286. unsigned Use_Slabs;
  287. long BBox_Threshold;
  288. int Quality;
  289. int PreviewGridSize_Start; /* Mosaic Preview - Initial pixel grid size */
  290. int PreviewGridSize_End; /* Mosaic Preview - Ending pixel grid size */
  291. FRAMESEQ FrameSeq;
  292. /* Should STREAM PATHS go somewhere here? */
  293. DBL Radiosity_Brightness;
  294. long Radiosity_Count;
  295. DBL Radiosity_Dist_Max;
  296. DBL Radiosity_Error_Bound;
  297. DBL Radiosity_Gray; /* degree to which gathered light is grayed */
  298. DBL Radiosity_Low_Error_Factor;
  299. DBL Radiosity_Min_Reuse;
  300. long Radiosity_Nearest_Count;
  301. int Radiosity_Recursion_Limit;
  302. long Radiosity_Quality; /* Q-flag value for light gathering */
  303. int Radiosity_File_ReadOnContinue;
  304. int Radiosity_File_SaveWhileRendering;
  305. int Radiosity_File_AlwaysReadAtStart;
  306. int Radiosity_File_KeepOnAbort;
  307. int Radiosity_File_KeepAlways;
  308. int Radiosity_Preview_Done; /* used in cache file processing */
  309. int histogram_x, histogram_y, histogram_on;
  310. Histogram_Types histogram_type;
  311. char Histogram_File_Name[FILE_NAME_LENGTH];
  312. SHELLDATA *Shellouts;
  313. char Ini_Output_File_Name[FILE_NAME_LENGTH];
  314. int Tracing_Method;
  315. int Do_Stats;
  316. } Opts;
  317. /*****************************************************************************
  318. * Global variables
  319. ******************************************************************************/
  320. extern FRAME Frame;
  321. extern COUNTER stats[MaxStat];
  322. extern COUNTER totalstats[MaxStat];
  323. extern time_t tstart, tstop;
  324. extern DBL tparse, trender, tparse_total, trender_total;
  325. extern char Color_Bits;
  326. extern int Number_Of_Files;
  327. extern Opts opts;
  328. extern FILE *stat_file;
  329. extern FILE_HANDLE *Output_File_Handle;
  330. extern int Help_Available;
  331. extern int Abort_Test_Every;
  332. extern int Display_Started;
  333. extern int Stage;
  334. extern volatile int Stop_Flag;
  335. extern int pre_init_flag;
  336. extern int Experimental_Flag;
  337. extern int Num_Echo_Lines, Echo_Line_Length;
  338. extern char *Option_String_Ptr;
  339. extern DBL Clock_Delta;
  340. /*****************************************************************************
  341. * Global functions
  342. ******************************************************************************/
  343. #ifdef NOCMDLINE
  344. # ifdef ALTMAIN
  345. MAIN_RETURN_TYPE alt_main (void);
  346. # else
  347. MAIN_RETURN_TYPE main (void);
  348. # endif
  349. #else
  350. # ifdef ALTMAIN
  351. MAIN_RETURN_TYPE alt_main (int argc, char ** argv);
  352. # else
  353. MAIN_RETURN_TYPE main (int argc, char ** argv);
  354. # endif
  355. #endif
  356. int pov_stricmp (char *s1,char *s2);
  357. void close_all (void);
  358. void POV_Std_Split_Time (DBL time_dif,unsigned long *hrs,unsigned long *mins,DBL *secs);
  359. FILE *Locate_File (char *filename, char *mode, char *ext1, char *ext2, char *buffer, int err_flag);
  360. SHELLRET pov_shellout (SHELLTYPE Type);
  361. void pre_init_povray (void);
  362. void POV_Split_Path (char *s, char *p, char *f);
  363. #endif