1 /****************************************************************************
2 * frame.h
3 *
4 * This header file is included by all C modules in POV-Ray. It defines all
5 * globally-accessible types and constants.
6 *
7 * from Persistence of Vision(tm) Ray Tracer version 3.6.
8 * Copyright 1991-2003 Persistence of Vision Team
9 * Copyright 2003-2004 Persistence of Vision Raytracer Pty. Ltd.
10 *---------------------------------------------------------------------------
11 * NOTICE: This source code file is provided so that users may experiment
12 * with enhancements to POV-Ray and to port the software to platforms other
13 * than those supported by the POV-Ray developers. There are strict rules
14 * regarding how you are permitted to use this file. These rules are contained
15 * in the distribution and derivative versions licenses which should have been
16 * provided with this file.
17 *
18 * These licences may be found online, linked from the end-user license
19 * agreement that is located at http://www.povray.org/povlegal.html
20 *---------------------------------------------------------------------------
21 * This program is based on the popular DKB raytracer version 2.12.
22 * DKBTrace was originally written by David K. Buck.
23 * DKBTrace Ver 2.0-2.12 were written by David K. Buck & Aaron A. Collins.
24 *---------------------------------------------------------------------------
25 *
26 *===========================================================================
27 * This file is part of MegaPOV, a modified and unofficial version of POV-Ray
28 * For more information on MegaPOV visit our website:
29 * http://megapov.inetart.net/
30 *===========================================================================
31 *
32 * $RCSfile: frame.h,v $
33 * $Revision: 1.35 $
34 * $Author: chris $
35 *
36 *****************************************************************************/
37
38 #include "patches.h"
39
40 #ifndef FRAME_H
41 #define FRAME_H
42
43 /* Generic header for all modules */
44
45 #include <math.h>
46 #ifdef HMATH_PATCH
47 #ifdef __BORLANDC__
48 #include <fastmath.h>
asinh(double val)49 inline double asinh(double val){return (double) asinhl((long double)val);}
acosh(double val)50 inline double acosh(double val){return (double) acoshl((long double)val);}
atanh(double val)51 inline double atanh(double val){return (double) atanhl((long double)val);}
52 #endif
53 #endif
54 #include <stdio.h>
55 #include <string.h>
56 #include <limits.h>
57
58 #include "config.h"
59
60 #include "configbase.h"
61 #include "fileinputoutput.h"
62
63 #ifndef POV_NAMESPACE
64 #define POV_NAMESPACE pov
65 #endif
66
67 #ifndef BEGIN_POV_NAMESPACE
68 #define BEGIN_POV_NAMESPACE namespace POV_NAMESPACE { using namespace std;
69 #endif
70
71 #ifndef END_POV_NAMESPACE
72 #define END_POV_NAMESPACE }
73 #endif
74
75 #ifndef USING_POV_NAMESPACE
76 #define USING_POV_NAMESPACE using namespace POV_NAMESPACE;
77 #endif
78
79 #include "pov_mem.h"
80
81 BEGIN_POV_NAMESPACE
82
83 //---------------------------------MegaPOV Switches
84 #ifdef LESS_MEMORY_IN_PATTERNS_PATCH
85 #define LESS_MEMORY_PATCH_MO ->
86 #else
87 #define LESS_MEMORY_PATCH_MO .
88 #endif
89
90 #ifndef VERSIONBUILDERS_MESSAGE
91 #define VERSIONBUILDERS_MESSAGE "Define this in your platform config.h file"
92 #endif
93
94 #if defined( PIGMENT_CAMERA_VIEW_PATCH ) && !defined( POST_PROCESS_PATCH )
95 #define POST_PROCESS_PATCH // camera_view allows the same output and use code of post_process
96 #endif
97
98 #if defined(POST_PROCESS_PATCH) || defined(USER_DEFINED_CAMERA_PATCH)
99 #define ALTERNATIVE_VECTOR_FUNCTION
100 #endif
101
102 //---------------------------------End MegaPOV Switches
103
104 /*
105 * Platform name default.
106 */
107 #ifndef POVRAY_PLATFORM_NAME
108 #define POVRAY_PLATFORM_NAME "Unknown Platform"
109 #endif
110
111 /*
112 * You have to define the macros POVRAY_BEGIN_COOPERATE and POVRAY_END_COOPERATE!
113 */
114
115 #ifndef ALTMAIN
116 #define USE_LOCAL_POVMS_OUTPUT 1
117 #endif
118
119 #ifndef POVRAY_BEGIN_COOPERATE
120 *** ERROR ***
121 #endif
122 #ifndef POVRAY_END_COOPERATE
123 *** ERROR ***
124 #endif
125
126 #if(USE_LOCAL_POVMS_OUTPUT == 1)
127 #define FRONTEND_ADDRESS povray_getoutputcontext()
128 #endif
129
130 #ifndef FRONTEND_ADDRESS
131 #define FRONTEND_ADDRESS 0
132 #endif
133
134 /*
135 * Functions that POV calls once per run to do various initializations,
136 * in the order that they are normally called.
137 */
138 #ifndef STARTUP_POVRAY /* First function called for each run */
139 #define STARTUP_POVRAY
140 #endif
141
142 #ifndef PRINT_CREDITS /* Prints POV-Ray version information banner */
143 #define PRINT_CREDITS Print_Credits();
144 #endif
145
146 #ifndef PRINT_OTHER_CREDITS /* Prints credits for custom POV versions */
147 #define PRINT_OTHER_CREDITS
148 #endif
149
150 /*
151 * To allow GUI platforms like the Mac to access a command line and provide
152 * a command line only interface (for debugging) a different call to an
153 * internal function of the standard library is required. This macro takes
154 * both argc and argv and is expected to return argc.
155 */
156 #ifndef GETCOMMANDLINE
157 #define GETCOMMANDLINE(ac,av) ac
158 #endif
159
160 /*
161 * Functions that POV calls in povray_terminate (FINISH_POVRAY) or
162 * povray_exit (EXIT_POVRAY).
163 */
164
165 #ifndef FINISH_POVRAY /* The last call that POV makes to terminate */
166 #define FINISH_POVRAY
167 #endif
168
169 #ifndef EXIT_POVRAY /* The last call that POV makes to exit after rendering */
170 #define EXIT_POVRAY(n) povray_terminate(); exit(n);
171 #endif
172
173
174 /*
175 * Functions that POV calls once per frame to do varios (de)initializations,
176 * in the order they are normally called.
177 */
178 #ifndef POV_PRE_RENDER /* Called just prior to the start of rendering */
179 #define POV_PRE_RENDER
180 #endif
181
182 #ifndef CONFIG_MATH /* Macro for setting up any special FP options */
183 #define CONFIG_MATH
184 #endif
185
186 #ifndef POV_PRE_PIXEL /* Called before each pixel is rendered */
187 #define POV_PRE_PIXEL(x,y,c)
188 #endif
189
190 #ifndef POV_POST_PIXEL /* Called after each pixel is rendered */
191 #define POV_POST_PIXEL(x,y,c)
192 #endif
193
194 #ifndef POV_PRE_SHUTDOWN /* Called before memory and objects are freed */
195 #define POV_PRE_SHUTDOWN
196 #endif
197
198 #ifndef POV_POST_SHUTDOWN /* Called after memory and objects are freed */
199 #define POV_POST_SHUTDOWN
200 #endif
201
202 /* Specify number of source file lines printed before error line, their maximum length and
203 * the error marker text that is appended to mark the error
204 */
205 #ifndef POV_NUM_ECHO_LINES
206 #define POV_NUM_ECHO_LINES 5
207 #endif
208
209 #ifndef POV_ERROR_MARKER_TEXT
210 #define POV_ERROR_MARKER_TEXT " <----ERROR\n"
211 #endif
212
213 #ifndef POV_WHERE_ERROR
214 #define POV_WHERE_ERROR(fn,ln,cl,ts)
215 #endif
216
217 /* Upper bound for max_trace_level specified by the user */
218 #ifndef MAX_TRACE_LEVEL_LIMIT
219 #define MAX_TRACE_LEVEL_LIMIT 256
220 #endif
221
222 /* Various numerical constants that are used in the calculations */
223 #ifndef EPSILON /* A small value used to see if a value is nearly zero */
224 #define EPSILON 1.0e-10
225 #endif
226
227 #ifndef HUGE_VAL /* A very large value, can be considered infinity */
228 #define HUGE_VAL 1.0e+17
229 #endif
230
231 /*
232 * If the width of a bounding box in one dimension is greater than
233 * the critical length, the bounding box should be set to infinite.
234 */
235
236 #ifndef CRITICAL_LENGTH
237 #define CRITICAL_LENGTH 1.0e6
238 #endif
239
240 #ifndef BOUND_HUGE /* Maximum lengths of a bounding box. */
241 #define BOUND_HUGE 2.0e10
242 #endif
243
244 /*
245 * These values determine the minumum and maximum distances
246 * that qualify as ray-object intersections.
247 */
248
249 #define Small_Tolerance 0.001
250 #define Max_Distance 1.0e7
251
252
253 #ifndef DBL_FORMAT_STRING
254 #define DBL_FORMAT_STRING "%lf"
255 #endif
256
257 #ifndef DBL
258 #define DBL double
259 #endif
260
261 #ifndef SNGL
262 #define SNGL float
263 #endif
264
265 #ifndef COLC
266 #define COLC float
267 #endif
268
269 #ifndef UCS2
270 #define UCS2 unsigned short
271 #endif
272
273 #ifndef UCS4
274 #define UCS4 unsigned int
275 #endif
276
277 #ifndef POV_LONG
278 #define POV_LONG long long
279 #define POV_ULONG unsigned long long
280 #endif
281
282 #ifndef POV_ULONG
283 #define POV_ULONG unsigned POV_LONG
284 #endif
285
286 #ifndef M_PI
287 #define M_PI 3.1415926535897932384626
288 #endif
289
290 #ifndef M_PI_2
291 #define M_PI_2 1.57079632679489661923
292 #endif
293
294 #ifndef TWO_M_PI
295 #define TWO_M_PI 6.283185307179586476925286766560
296 #endif
297
298 #ifndef M_PI_180
299 #define M_PI_180 0.01745329251994329576
300 #endif
301
302 #ifndef M_PI_360
303 #define M_PI_360 0.00872664625997164788
304 #endif
305
306 /* Some implementations of scanf return 0 on failure rather than EOF */
307 #ifndef SCANF_EOF
308 #define SCANF_EOF EOF
309 #endif
310
311 /* Adjust to match floating-point parameter(s) of functions in math.h/cmath */
312 #ifndef SYS_MATH_PARAM
313 #define SYS_MATH_PARAM double
314 #endif
315
316 /* Adjust to match floating-point return value of functions in math.h/cmath */
317 #ifndef SYS_MATH_RETURN
318 #define SYS_MATH_RETURN double
319 #endif
320
321 /* Function that executes functions, the parameter is the function index */
322 #ifndef POVFPU_Run
323 #define POVFPU_Run(fn) POVFPU_RunDefault(fn)
324 #endif
325
326 /* Adjust to add system specific handling of functions like just-in-time compilation */
327 #if (SYS_FUNCTIONS == 0)
328
329 // Note that if SYS_FUNCTIONS is 1, it will enable the field dblstack
330 // in FPUContext_Struct and corresponding calculations in POVFPU_SetLocal
331 // as well as POVFPU_NewContext.
332 #define SYS_FUNCTIONS 0
333
334 // Called after a function has been added, parameter is the function index
335 #define SYS_ADD_FUNCTION(fe)
336 // Called before a function is deleted, parameter is a pointer to the FunctionEntry_Struct
337 #define SYS_DELETE_FUNCTION(fe)
338 // Called inside POVFPU_Init after everything else has been inited
339 #define SYS_INIT_FUNCTIONS()
340 // Called inside POVFPU_Terminate before anything else is deleted
341 #define SYS_TERM_FUNCTIONS()
342 // Called inside POVFPU_Reset before anything else is reset
343 #define SYS_RESET_FUNCTIONS()
344
345 // Adjust to add system specific fields to FunctionEntry_Struct
346 #define SYS_FUNCTION_ENTRY
347
348 #endif // SYS_FUNCTIONS
349
350 #ifndef CDECL
351 #define CDECL
352 #endif
353
354 #ifndef ALIGN16
355 #define ALIGN16
356 #endif
357
358 #ifndef INLINE_NOISE
359 #define INLINE_NOISE
360 #endif
361
362 #ifndef USE_FASTER_NOISE
363 #define USE_FASTER_NOISE 0
364 #endif
365
366 #ifndef NEW_LINE_STRING
367 #define NEW_LINE_STRING "\n"
368 #endif
369
370 /* If compiler version is undefined, then make it 'u' for unknown */
371 #ifndef COMPILER_VER
372 #define COMPILER_VER ".u"
373 #endif
374
375 #ifndef QSORT
376 #define QSORT(a,b,c,d) qsort((a),(b),(c),(d))
377 #endif
378
379 /* Get minimum/maximum of three values. */
380
381 #define max3(x,y,z) (max((x), max((y), (z))))
382 #define min3(x,y,z) (min((x), min((y), (z))))
383
384
385 /*
386 * POV_NAME_MAX is for file systems that have a separation of the filename
387 * into name.ext. The POV_NAME_MAX is the name part. FILE_NAME_LENGTH
388 * is the sum of name + extension.
389 */
390 #ifndef POV_NAME_MAX
391 #define POV_NAME_MAX 8
392 #endif
393
394 #ifndef FILE_NAME_LENGTH
395 #define FILE_NAME_LENGTH 150
396 #endif
397
398 #ifndef FILENAME_SEPARATOR
399 #define FILENAME_SEPARATOR '/'
400 #endif
401
402 #ifndef DRIVE_SEPARATOR
403 #define DRIVE_SEPARATOR ':'
404 #endif
405
406 /*
407 * Splits a given string into the path and file components using the
408 * FILENAME_SEPARATOR and DRIVE_SEPARATOR
409 */
410 #ifndef POV_SPLIT_PATH
411 #define POV_SPLIT_PATH(s,p,f) POV_BASE_NAMESPACE::Split_Path((s),(p),(f))
412 #endif
413
414 /* The output file format used if the user doesn't specify one */
415 #ifndef DEFAULT_OUTPUT_FORMAT
416 #define DEFAULT_OUTPUT_FORMAT 't'
417 #endif
418
419 /* System specific image format like BMP for Windows or PICT for Mac */
420 #ifndef READ_SYS_IMAGE
421 #define READ_SYS_IMAGE(i,f) Read_Targa_Image(i,f)
422 #endif
423
424 #ifndef SYS_IMAGE_CLASS
425 #define SYS_IMAGE_CLASS Targa_Image
426 #endif
427
428 #ifndef SYS_DEF_EXT
429 #define SYS_DEF_EXT ".tga"
430 #endif
431
432
433 /*
434 * The TIME macros are used when displaying the rendering time for the user.
435 * These are called in such a manner that STOP_TIME can be called multiple
436 * times for a givn START_TIME in order to get intermediate TIME_ELAPSED
437 * values. TIME_ELAPSED is often defined as (tstop - tstart).
438 */
439 #ifndef START_TIME
440 #define START_TIME time(&tstart);
441 #endif
442
443 #ifndef STOP_TIME
444 #define STOP_TIME time(&tstop);
445 #endif
446
447 #ifndef TIME_ELAPSED
448 #define TIME_ELAPSED difftime (tstop, tstart);
449 #endif
450
451 #ifndef SPLIT_TIME
452 #define SPLIT_TIME(d,h,m,s) POV_Std_Split_Time ((d),(h),(m),(s))
453 #endif
454
455
456 /*
457 * The PRECISION_TIMER macros are used in generating histogram images on
458 * systems that have very accurate timers (usually in the microsecond range).
459 */
460 #ifndef PRECISION_TIMER_AVAILABLE
461 #define PRECISION_TIMER_AVAILABLE 0
462 #endif
463
464 #ifndef PRECISION_TIMER_INIT /* Called once to initialize the timer */
465 #define PRECISION_TIMER_INIT
466 #endif
467
468 #ifndef PRECISION_TIMER_START
469 #define PRECISION_TIMER_START ;
470 #endif
471
472 #ifndef PRECISION_TIMER_STOP
473 #define PRECISION_TIMER_STOP
474 #endif
475
476 #ifndef PRECISION_TIMER_COUNT /* The difference between START and STOP times */
477 #define PRECISION_TIMER_COUNT 0
478 #endif
479
480 /*
481 * Font related macros [trf]
482 */
483
484 #ifndef POV_CONVERT_TEXT_TO_UCS2
485 #define POV_CONVERT_TEXT_TO_UCS2(ts, tsl, as) (NULL)
486 #endif
487
488 /*
489 * The COOPERATE macros are used on co-operative multi-tasking systems to
490 * return control to the GUI or OS. COOPERATE is the old form, and one
491 * or both of COOPERATE_0 and COOPERATE_1 should be defined instead.
492 */
493 #ifdef COOPERATE
494 #define COOPERATE_0 COOPERATE
495 #define COOPERATE_1 COOPERATE
496 #define COOPERATE_2 COOPERATE
497 #endif
498
499 #ifndef COOPERATE_0 /* Called less frequently */
500 #define COOPERATE_0
501 #endif
502
503 #ifndef COOPERATE_1 /* Called more frequently */
504 #define COOPERATE_1
505 #endif
506
507 #ifndef COOPERATE_2 /* Called only when using povray_cooperate */
508 #define COOPERATE_2
509 #endif
510
511
512 /* How to get input from the user */
513 #ifndef TEST_ABORT
514 #define TEST_ABORT
515 #endif
516
517 #ifndef WAIT_FOR_KEYPRESS
518 #define WAIT_FOR_KEYPRESS
519 #else
520 #define WAIT_FOR_KEYPRESS_EXISTS
521 #endif
522
523 #ifndef GET_KEY /* Gets a keystroke from the user without waiting */
524 #define GET_KEY
525 #else
526 #define GET_KEY_EXISTS
527 #endif
528
529 /*
530 * Functions that handle the graphical display preview. These functions
531 * will be customeized for all versions of POV that want to do any sort
532 * of rendering preview. The default functions will create a 80x25 text
533 * "rendering" using crude ASCII graphics.
534 */
535 #ifndef POV_DISPLAY_INIT /* Initializes display for each frame rendered */
536 #define POV_DISPLAY_INIT(ref,w,h) POV_Std_Display_Init((w),(h));
537 #endif
538
539 #ifndef POV_DISPLAY_FINISHED /* Waits for user input after rendering done */
540 #define POV_DISPLAY_FINISHED(ref) POV_Std_Display_Finished();
541 #endif
542
543 #ifndef POV_DISPLAY_CLOSE /* Closes the display window after each frame */
544 #define POV_DISPLAY_CLOSE(ref) POV_Std_Display_Close();
545 #endif
546
547 #ifndef POV_DISPLAY_PLOT /* Plots a single pixel */
548 #define POV_DISPLAY_PLOT(ref,x,y,r,g,b,a) POV_Std_Display_Plot((x),(y),(r),(g),(b),(a));
549 #endif
550
551 #ifndef POV_DISPLAY_PLOT_ROW /* Plots a row of pixels */
552 #define POV_DISPLAY_PLOT_ROW(ref,w,y,s,e,r,g,b,a) // do nothing because POV_DISPLAY_PLOT will be used to send the same data by default
553 #endif
554
555 #ifndef POV_DISPLAY_PLOT_RECT /* Plots a filled rectangle */
556 #define POV_DISPLAY_PLOT_RECT(ref,x1,y1,x2,y2,r,g,b,a) POV_Std_Display_Plot_Rect((x1),(y1),(x2),(y2),(r),(g),(b),(a));
557 #endif
558
559 #ifndef POV_DISPLAY_PLOT_BOX /* Plots a hollow box */
560 #define POV_DISPLAY_PLOT_BOX(ref,x1,y1,x2,y2,r,g,b,a) POV_Std_Display_Plot_Box((x1),(y1),(x2),(y2),(r),(g),(b),(a));
561 #endif
562
563 #ifndef POV_GET_FULL_PATH /* returns full pathspec */
564 #define POV_GET_FULL_PATH(f,p,b) if (b) strcpy(b,p);
565 #endif
566
567 #ifndef POV_WRITE_LINE /* write the current line to something */
568 #define POV_WRITE_LINE(line,y)
569 #endif
570
571 #ifndef POV_ASSIGN_PIXEL /* assign the colour of a pixel */
572 #define POV_ASSIGN_PIXEL(x,y,colour)
573 #endif
574
575 #ifndef POV_ASSIGN_PIXEL_UNCLIPPED /* assign the unclipped colour of a pixel */
576 #define POV_ASSIGN_PIXEL_UNCLIPPED(x,y,colour)
577 #endif
578
579 /* The next two are palette modes, for normal and grayscale display */
580 #ifndef NORMAL
581 #define NORMAL '0'
582 #endif
583
584 #ifndef GREY
585 #define GREY 'G'
586 #endif
587
588 /*
589 * The DEFAULT_DISPLAY_GAMMA is used when there isn't one specified by the
590 * user in the POVRAY.INI. For those systems that are very savvy, this
591 * could be a function which returns the current display gamma. The
592 * DEFAULT_ASSUMED_GAMMA should be left alone.
593 */
594 #ifndef DEFAULT_DISPLAY_GAMMA
595 #define DEFAULT_DISPLAY_GAMMA 2.2
596 #endif
597
598 #ifndef DEFAULT_ASSUMED_GAMMA
599 #define DEFAULT_ASSUMED_GAMMA 1.0
600 #endif
601
602
603 /*****************************************************************************
604 *
605 * MEMIO.C Memory macros
606 *
607 *****************************************************************************/
608
609 /*
610 * These functions define macros which do checking for memory allocation,
611 * and can also do other things. Check mem.c before you change them, since
612 * they aren't simply replacements for malloc, calloc, realloc, and free.
613 */
614 #ifndef POV_MALLOC
615 #define POV_MALLOC(size,msg) pov_malloc ((size), __FILE__, __LINE__, (msg))
616 #endif
617
618 #ifndef POV_CALLOC
619 #define POV_CALLOC(nitems,size,msg) pov_calloc ((nitems), (size), __FILE__, __LINE__, (msg))
620 #endif
621
622 #ifndef POV_REALLOC
623 #define POV_REALLOC(ptr,size,msg) pov_realloc ((ptr), (size), __FILE__, __LINE__, (msg))
624 #endif
625
626 #ifndef POV_FREE
627 #define POV_FREE(ptr) { pov_free ((void *)(ptr), __FILE__, __LINE__); (ptr) = NULL; }
628 #endif
629
630 #ifndef POV_MEM_INIT
631 #define POV_MEM_INIT() mem_init()
632 #endif
633
634 #ifndef POV_MEM_RELEASE_ALL
635 #define POV_MEM_RELEASE_ALL() mem_release_all()
636 #endif
637
638 #ifndef POV_STRDUP
639 #ifdef STRDUP_MEM_TRACE_PATCH
640 #define POV_STRDUP(str) pov_strdup(str, __FILE__, __LINE__)
641 #else
642 #define POV_STRDUP(str) pov_strdup(str)
643 #endif
644 #endif
645
646 /* For those systems that don't have memmove, this can also be pov_memmove */
647 #ifndef POV_MEMMOVE
648 #define POV_MEMMOVE(dst,src,len) pov_memmove((dst),(src),(len))
649 #endif
650
651 #ifndef POV_MEMCPY
652 #define POV_MEMCPY(dst,src,len) memcpy((dst),(src),(len))
653 #endif
654
655 /*
656 * Functions which invoke external programs to do work for POV, generally
657 * at the request of the user.
658 */
659 #ifndef POV_SHELLOUT
660 #define POV_SHELLOUT(string) pov_shellout(string)
661 #endif
662
663 #ifndef POV_MAX_CMD_LENGTH
664 #define POV_MAX_CMD_LENGTH 250
665 #endif
666
667 #ifndef POV_SYSTEM
668 #define POV_SYSTEM(string) system(string)
669 #endif
670
671 /* Functions to delete and rename a file */
672 #ifndef DELETE_FILE_ERR
673 #define DELETE_FILE_ERR -1
674 #endif
675
676 #ifndef DELETE_FILE
677 #define DELETE_FILE(name) unlink(name)
678 #endif
679
680 #ifndef RENAME_FILE_ERR
681 #define RENAME_FILE_ERR -1
682 #endif
683
684 #ifndef RENAME_FILE
685 #define RENAME_FILE(orig,new) rename(orig,new)
686 #endif
687
688 #ifndef MAX_BUFSIZE /* The maximum size of the output file buffer */
689 #define MAX_BUFSIZE INT_MAX
690 #endif
691
692 /*****************************************************************************
693 *
694 * Typedefs that need to be known here.
695 *
696 *****************************************************************************/
697
698 typedef struct Object_Struct OBJECT;
699 typedef struct Compound_Object_Struct COMPOUND_OBJECT;
700 typedef struct Ray_Struct RAY;
701 typedef struct istack_struct ISTACK;
702 typedef struct istk_entry INTERSECTION;
703
704 /*****************************************************************************
705 *
706 * Scalar, color and vector stuff.
707 *
708 *****************************************************************************/
709
710 typedef DBL UV_VECT[2];
711 typedef DBL VECTOR[3];
712 typedef DBL VECTOR_4D[4];
713 typedef DBL MATRIX[4][4];
714 typedef DBL EXPRESS[5];
715 typedef COLC COLOUR[5];
716 typedef COLC RGB[3];
717 typedef SNGL SNGL_VECT[3];
718
719 /* Vector array elements. */
720 enum
721 {
722 U = 0,
723 V = 1
724 };
725
726 enum
727 {
728 X = 0,
729 Y = 1,
730 Z = 2,
731 T = 3
732 };
733
734 /* Color array elements. */
735 enum
736 {
737 pRED = 0,
738 pGREEN = 1,
739 pBLUE = 2,
740 pFILTER = 3,
741 pTRANSM = 4
742 };
743
744 /* Macros to manipulate scalars, vectors, and colors. */
745
Assign_Vector(VECTOR d,VECTOR s)746 inline void Assign_Vector(VECTOR d, VECTOR s)
747 {
748 d[X] = s[X];
749 d[Y] = s[Y];
750 d[Z] = s[Z];
751 }
752
Assign_Vector(VECTOR d,SNGL_VECT s)753 inline void Assign_Vector(VECTOR d, SNGL_VECT s)
754 {
755 d[X] = s[X];
756 d[Y] = s[Y];
757 d[Z] = s[Z];
758 }
759
Assign_Vector(SNGL_VECT d,VECTOR s)760 inline void Assign_Vector(SNGL_VECT d, VECTOR s)
761 {
762 d[X] = s[X];
763 d[Y] = s[Y];
764 d[Z] = s[Z];
765 }
766
Assign_Vector(SNGL_VECT d,SNGL_VECT s)767 inline void Assign_Vector(SNGL_VECT d, SNGL_VECT s)
768 {
769 d[X] = s[X];
770 d[Y] = s[Y];
771 d[Z] = s[Z];
772 }
773
Assign_UV_Vect(UV_VECT d,UV_VECT s)774 inline void Assign_UV_Vect(UV_VECT d, UV_VECT s)
775 {
776 d[X] = s[X];
777 d[Y] = s[Y];
778 }
779
Assign_Vector_4D(VECTOR_4D d,VECTOR_4D s)780 inline void Assign_Vector_4D(VECTOR_4D d, VECTOR_4D s)
781 {
782 d[X] = s[X];
783 d[Y] = s[Y];
784 d[Z] = s[Z];
785 d[T] = s[T];
786 }
787
Assign_Colour(COLOUR d,COLOUR s)788 inline void Assign_Colour(COLOUR d, COLOUR s)
789 {
790 d[pRED] = s[pRED];
791 d[pGREEN] = s[pGREEN];
792 d[pBLUE] = s[pBLUE];
793 d[pFILTER] = s[pFILTER];
794 d[pTRANSM] = s[pTRANSM];
795 }
796
Assign_RGB(RGB d,RGB s)797 inline void Assign_RGB(RGB d, RGB s)
798 {
799 d[pRED] = s[pRED];
800 d[pGREEN] = s[pGREEN];
801 d[pBLUE] = s[pBLUE];
802 }
803
Assign_Colour_Express(COLOUR d,EXPRESS s)804 inline void Assign_Colour_Express(COLOUR d, EXPRESS s)
805 {
806 d[pRED] = s[pRED];
807 d[pGREEN] = s[pGREEN];
808 d[pBLUE] = s[pBLUE];
809 d[pFILTER] = s[pFILTER];
810 d[pTRANSM] = s[pTRANSM];
811 }
812
Assign_Express(EXPRESS d,EXPRESS s)813 inline void Assign_Express(EXPRESS d, EXPRESS s)
814 {
815 d[pRED] = s[pRED];
816 d[pGREEN] = s[pGREEN];
817 d[pBLUE] = s[pBLUE];
818 d[pFILTER] = s[pFILTER];
819 d[pTRANSM] = s[pTRANSM];
820 }
821
Make_Colour(COLOUR c,COLC r,COLC g,COLC b)822 inline void Make_Colour(COLOUR c, COLC r, COLC g, COLC b)
823 {
824 c[pRED] = r;
825 c[pGREEN] = g;
826 c[pBLUE] = b;
827 #ifdef MAKE_COLOR_SHORTER_PATCH
828 c[pFILTER] = c[pTRANSM] = 0.0;
829 #else
830 c[pFILTER] = 0.0;
831 c[pTRANSM] = 0.0;
832 #endif
833 }
834
835 #ifdef MAKE_COLOR_SHORTER_PATCH
Make_Gray_Colour(COLOUR c,COLC g)836 inline void Make_Gray_Colour(COLOUR c, COLC g)
837 {
838 c[pRED] = c[pGREEN] = c[pBLUE] = g;
839 c[pFILTER] = c[pTRANSM] = 0.0;
840 }
841 #endif
842
Make_ColourA(COLOUR c,COLC r,COLC g,COLC b,COLC a,COLC t)843 inline void Make_ColourA(COLOUR c, COLC r, COLC g, COLC b, COLC a, COLC t)
844 {
845 c[pRED] = r;
846 c[pGREEN] = g;
847 c[pBLUE] = b;
848 c[pFILTER] = a;
849 c[pTRANSM] = t;
850 }
851
Make_Vector(VECTOR v,DBL a,DBL b,DBL c)852 inline void Make_Vector(VECTOR v, DBL a, DBL b, DBL c)
853 {
854 v[X] = a;
855 v[Y] = b;
856 v[Z] = c;
857 }
858
Make_Vector(SNGL_VECT v,SNGL a,SNGL b,SNGL c)859 inline void Make_Vector(SNGL_VECT v, SNGL a, SNGL b, SNGL c)
860 {
861 v[X] = a;
862 v[Y] = b;
863 v[Z] = c;
864 }
865
Make_UV_Vector(UV_VECT v,DBL a,DBL b)866 inline void Make_UV_Vector(UV_VECT v, DBL a, DBL b)
867 {
868 v[U] = a;
869 v[V] = b;
870 }
871
Make_RGB(RGB c,COLC r,COLC g,COLC b)872 inline void Make_RGB(RGB c, COLC r, COLC g, COLC b)
873 {
874 c[pRED] = r;
875 c[pGREEN] = g;
876 c[pBLUE] = b;
877 }
878
879 #ifdef MAKE_COLOR_SHORTER_PATCH
Make_RGB_Gray_Colour(COLOUR c,COLC g)880 inline void Make_RGB_Gray_Colour(COLOUR c, COLC g)
881 {
882 c[pRED] = c[pGREEN] = c[pBLUE] = g;
883 }
884 #endif
885
Destroy_Float(DBL * x)886 inline void Destroy_Float(DBL *x)
887 {
888 if(x != NULL)
889 POV_FREE(x);
890 }
891
Destroy_Vector(VECTOR * x)892 inline void Destroy_Vector(VECTOR *x)
893 {
894 if(x != NULL)
895 POV_FREE(x);
896 }
897
Destroy_UV_Vect(UV_VECT * x)898 inline void Destroy_UV_Vect(UV_VECT *x)
899 {
900 if(x != NULL)
901 POV_FREE(x);
902 }
903
Destroy_Vector_4D(VECTOR_4D * x)904 inline void Destroy_Vector_4D(VECTOR_4D *x)
905 {
906 if(x != NULL)
907 POV_FREE(x);
908 }
909
Destroy_Colour(COLOUR * x)910 inline void Destroy_Colour(COLOUR *x)
911 {
912 if(x != NULL)
913 POV_FREE(x);
914 }
915
916
917 /*****************************************************************************
918 *
919 * Bounding box stuff (see also BOUND.H).
920 *
921 *****************************************************************************/
922
923 typedef SNGL BBOX_VAL;
924
925 typedef BBOX_VAL BBOX_VECT[3];
926
927 typedef struct Bounding_Box_Struct BBOX;
928
929 struct Bounding_Box_Struct
930 {
931 BBOX_VECT Lower_Left, Lengths;
932 };
933
Assign_BBox_Vect(BBOX_VECT & d,BBOX_VECT s)934 inline void Assign_BBox_Vect(BBOX_VECT& d, BBOX_VECT s)
935 {
936 d[X] = s[X];
937 d[Y] = s[Y];
938 d[Z] = s[Z];
939 }
940
Assign_BBox_Vect(BBOX_VECT & d,VECTOR s)941 inline void Assign_BBox_Vect(BBOX_VECT& d, VECTOR s)
942 {
943 d[X] = s[X];
944 d[Y] = s[Y];
945 d[Z] = s[Z];
946 }
947
Assign_BBox_Vect(VECTOR & d,BBOX_VECT s)948 inline void Assign_BBox_Vect(VECTOR& d, BBOX_VECT s)
949 {
950 d[X] = s[X];
951 d[Y] = s[Y];
952 d[Z] = s[Z];
953 }
954
Make_BBox(BBOX & BBox,BBOX_VAL llx,BBOX_VAL lly,BBOX_VAL llz,BBOX_VAL lex,BBOX_VAL ley,BBOX_VAL lez)955 inline void Make_BBox(BBOX& BBox, BBOX_VAL llx, BBOX_VAL lly, BBOX_VAL llz, BBOX_VAL lex, BBOX_VAL ley, BBOX_VAL lez)
956 {
957 BBox.Lower_Left[X] = (BBOX_VAL)(llx);
958 BBox.Lower_Left[Y] = (BBOX_VAL)(lly);
959 BBox.Lower_Left[Z] = (BBOX_VAL)(llz);
960 BBox.Lengths[X] = (BBOX_VAL)(lex);
961 BBox.Lengths[Y] = (BBOX_VAL)(ley);
962 BBox.Lengths[Z] = (BBOX_VAL)(lez);
963 }
964
Make_BBox_from_min_max(BBOX & BBox,BBOX_VECT mins,BBOX_VECT maxs)965 inline void Make_BBox_from_min_max(BBOX& BBox, BBOX_VECT mins, BBOX_VECT maxs)
966 {
967 BBox.Lower_Left[X] = (BBOX_VAL)(mins[X]);
968 BBox.Lower_Left[Y] = (BBOX_VAL)(mins[Y]);
969 BBox.Lower_Left[Z] = (BBOX_VAL)(mins[Z]);
970 BBox.Lengths[X] = (BBOX_VAL)(maxs[X]-mins[X]);
971 BBox.Lengths[Y] = (BBOX_VAL)(maxs[Y]-mins[Y]);
972 BBox.Lengths[Z] = (BBOX_VAL)(maxs[Z]-mins[Z]);
973 }
974
Make_BBox_from_min_max(BBOX & BBox,VECTOR mins,VECTOR maxs)975 inline void Make_BBox_from_min_max(BBOX& BBox, VECTOR mins, VECTOR maxs)
976 {
977 BBox.Lower_Left[X] = (BBOX_VAL)(mins[X]);
978 BBox.Lower_Left[Y] = (BBOX_VAL)(mins[Y]);
979 BBox.Lower_Left[Z] = (BBOX_VAL)(mins[Z]);
980 BBox.Lengths[X] = (BBOX_VAL)(maxs[X]-mins[X]);
981 BBox.Lengths[Y] = (BBOX_VAL)(maxs[Y]-mins[Y]);
982 BBox.Lengths[Z] = (BBOX_VAL)(maxs[Z]-mins[Z]);
983 }
984
Make_min_max_from_BBox(BBOX_VECT & mins,BBOX_VECT & maxs,BBOX BBox)985 inline void Make_min_max_from_BBox(BBOX_VECT& mins, BBOX_VECT& maxs, BBOX BBox)
986 {
987 mins[X] = BBox.Lower_Left[X];
988 mins[Y] = BBox.Lower_Left[Y];
989 mins[Z] = BBox.Lower_Left[Z];
990 maxs[X] = mins[X] + BBox.Lengths[X];
991 maxs[Y] = mins[Y] + BBox.Lengths[Y];
992 maxs[Z] = mins[Z] + BBox.Lengths[Z];
993 }
994
Make_min_max_from_BBox(VECTOR & mins,VECTOR & maxs,BBOX BBox)995 inline void Make_min_max_from_BBox(VECTOR& mins, VECTOR& maxs, BBOX BBox)
996 {
997 mins[X] = BBox.Lower_Left[X];
998 mins[Y] = BBox.Lower_Left[Y];
999 mins[Z] = BBox.Lower_Left[Z];
1000 maxs[X] = mins[X] + BBox.Lengths[X];
1001 maxs[Y] = mins[Y] + BBox.Lengths[Y];
1002 maxs[Z] = mins[Z] + BBox.Lengths[Z];
1003 }
1004
1005
1006 /*****************************************************************************
1007 *
1008 * Hi-resolution counter.
1009 *
1010 *****************************************************************************/
1011
1012 /* 64bit counter. */
1013
1014 typedef POV_LONG COUNTER;
1015
DBL_Counter(COUNTER x)1016 inline DBL DBL_Counter(COUNTER x)
1017 {
1018 return (DBL)(x);
1019 }
1020
Long_To_Counter(long i,COUNTER & x)1021 inline void Long_To_Counter(long i, COUNTER& x)
1022 {
1023 x = i;
1024 }
1025
Init_Counter(COUNTER & x)1026 inline void Init_Counter(COUNTER& x)
1027 {
1028 x = 0;
1029 }
1030
Increase_Counter(COUNTER & x)1031 inline void Increase_Counter(COUNTER& x)
1032 {
1033 x++;
1034 }
1035
Decrease_Counter(COUNTER & x)1036 inline void Decrease_Counter(COUNTER& x)
1037 {
1038 x--;
1039 }
1040
Add_Counter(COUNTER & x,COUNTER a,COUNTER b)1041 inline void Add_Counter(COUNTER& x, COUNTER a, COUNTER b)
1042 {
1043 x = a + b;
1044 }
1045
1046
1047 /*****************************************************************************
1048 *
1049 * Transformation stuff.
1050 *
1051 *****************************************************************************/
1052
1053 typedef struct Transform_Struct TRANSFORM;
1054
1055 struct Transform_Struct
1056 {
1057 MATRIX matrix;
1058 MATRIX inverse;
1059 };
1060
1061
1062
1063 /*****************************************************************************
1064 *
1065 * Color map stuff.
1066 *
1067 *****************************************************************************/
1068
1069 const int MAX_BLEND_MAP_ENTRIES = 256;
1070
1071 typedef struct Blend_Map_Entry BLEND_MAP_ENTRY;
1072 typedef struct Blend_Map_Struct BLEND_MAP;
1073 typedef struct Pattern_Struct TPATTERN;
1074 typedef struct Texture_Struct TEXTURE;
1075 typedef struct Pigment_Struct PIGMENT;
1076 typedef struct Tnormal_Struct TNORMAL;
1077 typedef struct Finish_Struct FINISH;
1078 typedef struct Turb_Struct TURB;
1079 typedef struct Warps_Struct WARP;
1080 typedef struct Light_Source_Struct LIGHT_SOURCE;
1081 typedef struct Spline_Entry SPLINE_ENTRY;
1082 typedef struct Spline_Struct SPLINE;
1083
1084 struct Blend_Map_Entry
1085 {
1086 SNGL value;
1087 unsigned char Same;
1088 union
1089 {
1090 COLOUR Colour;
1091 PIGMENT *Pigment;
1092 TNORMAL *Tnormal;
1093 TEXTURE *Texture;
1094 UV_VECT Point_Slope;
1095 } Vals;
1096 };
1097
1098 struct Blend_Map_Struct
1099 {
1100 int Users;
1101 short Number_Of_Entries;
1102 char Transparency_Flag, Type;
1103 BLEND_MAP_ENTRY *Blend_Map_Entries;
1104 };
1105
Make_Blend_Map_Entry(BLEND_MAP_ENTRY & entry,SNGL v,unsigned char s,COLC r,COLC g,COLC b,COLC a,COLC t)1106 inline void Make_Blend_Map_Entry(BLEND_MAP_ENTRY& entry, SNGL v, unsigned char s, COLC r, COLC g, COLC b, COLC a, COLC t)
1107 {
1108 entry.value = v;
1109 entry.Same = s;
1110 Make_ColourA(entry.Vals.Colour, r, g, b, a, t);
1111 }
1112
1113
1114 #ifdef FUR_PATCH
1115 typedef struct Fur_Struct FUR;
1116
1117 struct Fur_Struct
1118 {
1119 int Type;
1120 union {
1121 struct { VECTOR Center; DBL Radius; } Sphere;
1122 struct { DBL Major_Radius, Minor_Radius; } Torus;
1123 struct { VECTOR Size; } Box;
1124 struct { VECTOR Normal; DBL Distance; } Plane;
1125 struct { VECTOR P1, P2, P3, N1, N2, N3, Normal_Vector, Perp;
1126 DBL Distance;
1127 unsigned int vAxis:2; } Smooth_Triangle;
1128 struct { VECTOR Point, Direction; DBL Length; DBL Radius; } Cylinder;
1129 struct { VECTOR Point, Direction; DBL Angle; } Cone;
1130 } Vals;
1131 DBL Ratio, Falloff, Frequency;
1132 VECTOR Force;
1133 DBL Diffuse, Reflection, Reflection_Exponent, Waves_Frequency, Waves_Factor;
1134 TRANSFORM *Trans;
1135 };
1136 #endif
1137
1138 /*****************************************************************************
1139 *
1140 * Media stuff.
1141 *
1142 *****************************************************************************/
1143
1144 typedef struct Media_Struct IMEDIA;
1145
1146 struct Media_Struct
1147 {
1148 int Type;
1149 int Intervals;
1150 int Min_Samples;
1151 int Max_Samples;
1152 int Sample_Method; /* MH */
1153 DBL Jitter; /* MH */
1154 int is_constant;
1155 DBL Eccentricity,sc_ext;
1156 int use_absorption;
1157 int use_emission;
1158 int use_extinction;
1159 int use_scattering;
1160 COLOUR Absorption;
1161 COLOUR Emission;
1162 COLOUR Extinction;
1163 COLOUR Scattering;
1164
1165 #ifdef FUR_PATCH
1166 FUR *Fur; /* ThW */
1167 PIGMENT *Pigment; /* ThW */
1168 #endif
1169
1170 DBL Ratio;
1171 DBL Confidence;
1172 DBL Variance;
1173 DBL *Sample_Threshold;
1174
1175 DBL AA_Threshold;
1176 int AA_Level;
1177 int ignore_photons;
1178
1179 PIGMENT *Density;
1180
1181 IMEDIA *Next_Media;
1182 };
1183
1184
1185
1186 /*****************************************************************************
1187 *
1188 * Interior stuff.
1189 *
1190 *****************************************************************************/
1191
1192 typedef struct Interior_Struct INTERIOR;
1193
1194 struct Interior_Struct
1195 {
1196 int References;
1197 int hollow, Disp_NElems;
1198 SNGL IOR, Dispersion;
1199 SNGL Caustics, Old_Refract;
1200 SNGL Fade_Distance, Fade_Power;
1201 COLOUR Fade_Colour;
1202 IMEDIA *IMedia;
1203 };
1204
1205 struct Spline_Entry
1206 {
1207 DBL par; /* Parameter */
1208 DBL vec[5]; /* Value at the parameter */
1209 DBL coeff[5]; /* Interpolating coefficients at the parameter */
1210 #ifdef SOR_SPLINE_PATCH
1211 DBL sor_coeff[5][4];
1212 #endif
1213 #ifdef TCB_SPLINE_PATCH
1214 DBL tcb_coeff[5][2];
1215 DBL In_Tension;
1216 DBL In_Continuity;
1217 DBL In_Bias;
1218 DBL Out_Tension;
1219 DBL Out_Continuity;
1220 DBL Out_Bias;
1221 #endif
1222 #ifdef AKIMA_SPLINE_PATCH
1223 DBL akima_coeff[5][4];
1224 #endif
1225 #ifdef EXTENDED_X_SPLINE_PATCH
1226 DBL Freedom_Degree;
1227 #endif
1228 };
1229
1230 struct Spline_Struct
1231 {
1232 int Number_Of_Entries, Type;
1233 int Max_Entries;
1234 SPLINE_ENTRY *SplineEntries;
1235 int Coeffs_Computed;
1236 int Terms;
1237 bool Cache_Valid;
1238 int Cache_Type;
1239 DBL Cache_Point;
1240 EXPRESS Cache_Data;
1241 #ifdef SOR_SPLINE_PATCH
1242 bool SOR_Coeffs_Computed;
1243 #endif
1244 #ifdef TCB_SPLINE_PATCH
1245 bool TCB_Coeffs_Computed;
1246 DBL Tension;
1247 DBL Continuity;
1248 DBL Bias;
1249 #endif
1250 #ifdef AKIMA_SPLINE_PATCH
1251 bool Akima_Coeffs_Computed;
1252 #endif
1253 #ifdef BASIC_X_SPLINE_PATCH
1254 DBL Freedom_Degree;
1255 #endif
1256 };
1257
1258 typedef struct Spline_Entry SPLINE_ENTRY;
1259
1260 /*****************************************************************************
1261 *
1262 * IFF file stuff.
1263 *
1264 *****************************************************************************/
1265
1266 #ifndef IFF_SWITCH_CAST
1267 #define IFF_SWITCH_CAST (int)
1268 #endif
1269
1270 typedef struct Image_Colour_Struct IMAGE_COLOUR;
1271
1272 typedef struct Image8_Line_Struct IMAGE8_LINE;
1273
1274 typedef struct Image16_Line_Struct IMAGE16_LINE;
1275
1276 struct Image_Colour_Struct
1277 {
1278 unsigned short Red, Green, Blue, Filter, Transmit;
1279 };
1280
1281 struct Image8_Line_Struct
1282 {
1283 unsigned char *red, *green, *blue, *transm;
1284 };
1285
1286 struct Image16_Line_Struct
1287 {
1288 unsigned short *red, *green, *blue, *transm;
1289 };
1290
1291 //ML: hdr_patch
1292 #ifdef HDR_PATCH
1293 typedef struct Image_Float_Line_Struct IMAGE_FLOAT_LINE;
1294
1295 struct Image_Float_Line_Struct
1296 {
1297 float *red, *green, *blue;
1298 };
1299 #endif
1300 //-ML: hdr_patch
1301
1302
1303 /*****************************************************************************
1304 *
1305 * Image stuff.
1306 *
1307 *****************************************************************************/
1308
1309 /* Legal image attributes. */
1310
1311 #define NO_FILE 0x00000000
1312 #define GIF_FILE 0x00000001
1313 #define POT_FILE 0x00000002
1314 #define SYS_FILE 0x00000004
1315 #define IFF_FILE 0x00000008
1316 #define TGA_FILE 0x00000010
1317 #define GRAD_FILE 0x00000020
1318 #define PGM_FILE 0x00000040
1319 #define PPM_FILE 0x00000080
1320 #define PNG_FILE 0x00000100
1321 #define JPEG_FILE 0x00000200
1322 #define TIFF_FILE 0x00000400
1323
1324 #ifdef MPEG_PORT_PATCH
1325 #define MPEG_FILE 0x00000800
1326 #endif
1327
1328 /*ML: hdr_patch*/
1329 #ifdef HDR_PATCH
1330 #ifdef MPEG_PORT_PATCH
1331 #define HDR_FILE (0x00000800 << 1)
1332 #else
1333 #define HDR_FILE 0x00000800
1334 #endif
1335 #endif
1336 /*-ML: hdr_patch*/
1337
1338 /*====================================================================*/
1339
1340 #if ( defined(MPEG_PORT_PATCH) || defined(HDR_PATCH) )
1341 #if ( defined(MPEG_PORT_PATCH) && defined(HDR_PATCH) )
1342 #define POV_FILE_TYPES_ADD 2
1343 #else
1344 #define POV_FILE_TYPES_ADD 1
1345 #endif
1346
1347 #define IMAGE_FILE_MASK ((0x00000800 << POV_FILE_TYPES_ADD) - 1)
1348
1349 #define IMAGE_FTYPE (0x00000800 << POV_FILE_TYPES_ADD)
1350 #define HF_FTYPE (0x00001000 << POV_FILE_TYPES_ADD)
1351 #define HIST_FTYPE (0x00002000 << POV_FILE_TYPES_ADD)
1352 #define GRAY_FTYPE (0x00004000 << POV_FILE_TYPES_ADD)
1353 #define NORMAL_FTYPE (0x00008000 << POV_FILE_TYPES_ADD)
1354 #define MATERIAL_FTYPE (0x00010000 << POV_FILE_TYPES_ADD)
1355
1356 #define IS16BITIMAGE (0x00020000 << POV_FILE_TYPES_ADD)
1357 #define IS16GRAYIMAGE (0x00040000 << POV_FILE_TYPES_ADD)
1358
1359 #ifdef HDR_PATCH
1360 #define ISFLOATIMAGE (0x00080000 << POV_FILE_TYPES_ADD)
1361 #endif
1362
1363 #else
1364 #define IMAGE_FILE_MASK 0x000007FF
1365
1366 #define IMAGE_FTYPE 0x00000800
1367 #define HF_FTYPE 0x00001000
1368 #define HIST_FTYPE 0x00002000
1369 #define GRAY_FTYPE 0x00004000
1370 #define NORMAL_FTYPE 0x00008000
1371 #define MATERIAL_FTYPE 0x00010000
1372
1373 #define IS16BITIMAGE 0x00020000
1374 #define IS16GRAYIMAGE 0x00040000
1375 #endif
1376
1377 /*====================================================================*/
1378
1379
1380 /* Image types. */
1381
1382 #if ( defined(MPEG_PORT_PATCH) && defined(HDR_PATCH) )
1383 #define IMAGE_FILE_PATCH (HDR_FILE+MPEG_FILE)
1384 #define IMAGE_FILE_PATCH (HDR_FILE+MPEG_FILE)
1385 #define NORMAL_FILE_PATCH (HDR_FILE+MPEG_FILE)
1386 #define MATERIAL_FILE_PATCH (HDR_FILE+MPEG_FILE)
1387 #define HF_FILE_PATCH (HDR_FILE+MPEG_FILE)
1388 #else
1389 #ifdef MPEG_PORT_PATCH
1390 #define IMAGE_FILE_PATCH MPEG_FILE
1391 #define IMAGE_FILE_PATCH MPEG_FILE
1392 #define NORMAL_FILE_PATCH MPEG_FILE
1393 #define MATERIAL_FILE_PATCH MPEG_FILE
1394 #define HF_FILE_PATCH MPEG_FILE
1395 #endif
1396
1397 /*ML: hdr_patch*/
1398 #ifdef HDR_PATCH
1399 #define IMAGE_FILE_PATCH HDR_FILE
1400 #define IMAGE_FILE_PATCH HDR_FILE
1401 #define NORMAL_FILE_PATCH HDR_FILE
1402 #define MATERIAL_FILE_PATCH HDR_FILE
1403 #define HF_FILE_PATCH HDR_FILE
1404 #endif
1405 /*-ML: hdr_patch*/
1406 #endif
1407
1408 /*====================================================================*/
1409
1410 #if ( defined(MPEG_PORT_PATCH) || defined(HDR_PATCH) )
1411 #define IMAGE_FILE IMAGE_FTYPE+GIF_FILE+SYS_FILE+IFF_FILE+GRAD_FILE+TGA_FILE+PGM_FILE+PPM_FILE+PNG_FILE+JPEG_FILE+TIFF_FILE+IMAGE_FILE_PATCH
1412 #define NORMAL_FILE NORMAL_FTYPE+GIF_FILE+SYS_FILE+IFF_FILE+GRAD_FILE+TGA_FILE+PGM_FILE+PPM_FILE+PNG_FILE+JPEG_FILE+TIFF_FILE+NORMAL_FILE_PATCH
1413 #define MATERIAL_FILE MATERIAL_FTYPE+GIF_FILE+SYS_FILE+IFF_FILE+GRAD_FILE+TGA_FILE+PGM_FILE+PPM_FILE+PNG_FILE+JPEG_FILE+TIFF_FILE+MATERIAL_FILE_PATCH
1414 #define HF_FILE HF_FTYPE+GIF_FILE+SYS_FILE+POT_FILE+TGA_FILE+PGM_FILE+PPM_FILE+PNG_FILE+JPEG_FILE+TIFF_FILE+HF_FILE_PATCH
1415 #else
1416 #define IMAGE_FILE IMAGE_FTYPE+GIF_FILE+SYS_FILE+IFF_FILE+GRAD_FILE+TGA_FILE+PGM_FILE+PPM_FILE+PNG_FILE+JPEG_FILE+TIFF_FILE
1417 #define NORMAL_FILE NORMAL_FTYPE+GIF_FILE+SYS_FILE+IFF_FILE+GRAD_FILE+TGA_FILE+PGM_FILE+PPM_FILE+PNG_FILE+JPEG_FILE+TIFF_FILE
1418 #define MATERIAL_FILE MATERIAL_FTYPE+GIF_FILE+SYS_FILE+IFF_FILE+GRAD_FILE+TGA_FILE+PGM_FILE+PPM_FILE+PNG_FILE+JPEG_FILE+TIFF_FILE
1419 #define HF_FILE HF_FTYPE+GIF_FILE+SYS_FILE+POT_FILE+TGA_FILE+PGM_FILE+PPM_FILE+PNG_FILE+JPEG_FILE+TIFF_FILE
1420 #endif
1421
1422 /*====================================================================*/
1423
1424 typedef struct Image_Struct IMAGE;
1425
1426 struct Image_Struct
1427 {
1428 int References; /* Keeps track of number of pointers to this structure */
1429 int Map_Type;
1430 int File_Type;
1431 int Image_Type; /* What this image is being used for */
1432 int Interpolation_Type;
1433 int iwidth, iheight;
1434 short Colour_Map_Size;
1435 char Once_Flag;
1436 char Use_Colour_Flag;
1437 VECTOR Gradient;
1438 SNGL width, height;
1439 UV_VECT Offset;
1440 DBL AllFilter, AllTransmit;
1441 IMAGE_COLOUR *Colour_Map;
1442 //ML: hdr_patch
1443 #ifdef HDR_PATCH
1444 DBL exposure;
1445 #endif
1446 //-ML: hdr_patch
1447 void *Object;
1448 union
1449 {
1450 IMAGE8_LINE *rgb8_lines;
1451 IMAGE16_LINE *rgb16_lines;
1452 unsigned short **gray16_lines;
1453 unsigned char **map_lines;
1454 //ML: hdr_patch
1455 #ifdef HDR_PATCH
1456 IMAGE_FLOAT_LINE *rgb_float_lines;
1457 #endif
1458 //-ML: hdr_patch
1459 } data;
1460 };
1461
1462 #define PIGMENT_TYPE 0
1463 #define NORMAL_TYPE 1
1464 #define PATTERN_TYPE 2
1465 #define TEXTURE_TYPE 4
1466 #define COLOUR_TYPE 5
1467 #define SLOPE_TYPE 6
1468 #define DENSITY_TYPE 7
1469
1470 #define DEFAULT_FRACTAL_EXTERIOR_TYPE 1
1471 #define DEFAULT_FRACTAL_INTERIOR_TYPE 0
1472 #define DEFAULT_FRACTAL_EXTERIOR_FACTOR 1
1473 #define DEFAULT_FRACTAL_INTERIOR_FACTOR 1
1474
1475
1476 /*****************************************************************************
1477 *
1478 * Pigment, Tnormal, Finish, Texture & Warps stuff.
1479 *
1480 *****************************************************************************/
1481
1482 typedef struct Density_file_Struct DENSITY_FILE;
1483 typedef struct Density_file_Data_Struct DENSITY_FILE_DATA;
1484
1485 struct Density_file_Struct
1486 {
1487 int Interpolation;
1488 DENSITY_FILE_DATA *Data;
1489 };
1490
1491 struct Density_file_Data_Struct
1492 {
1493 int References;
1494 char *Name;
1495 int Sx, Sy, Sz;
1496 int Type;
1497 union
1498 {
1499 unsigned char *Density8;
1500 unsigned short *Density16;
1501 unsigned int *Density32;
1502 };
1503 };
1504
1505 #ifdef PIGMENT_CAMERA_VIEW_PATCH
1506 typedef struct Camera_Struct CAMERA;
1507 #define CameraViewDef CAMERA *Camera;
1508 #else
1509 #define CameraViewDef
1510 #endif
1511
1512
1513 #ifdef LISTED_PATTERN_PATCH
1514 #define ListPatternDef SNGL ListedVal;
1515 #else
1516 #define ListPatternDef
1517 #endif
1518
1519 #ifdef SIMPLE_PATTERN_CACHE_PATCH
1520 #define SimplePatternCacheDef \
1521 VECTOR Last_Point; \
1522 COLOUR Last_Colour;
1523 #else
1524 #define SimplePatternCacheDef
1525 #endif
1526
1527 #ifdef NOISE_PIGMENT_PATCH
1528 #ifdef LESS_MEMORY_IN_PATTERNS_PATCH
1529 typedef struct { int NoiseType; COLOUR Min; COLOUR Max;
1530 }NOISEPIGMENT, *NOISEPIGMENTPTR ;
1531 #define NoisePigmentPatternDef NOISEPIGMENTPTR NoisePigment;
1532 #else
1533 #define NoisePigmentPatternDef struct {int NoiseType; COLOUR Min; COLOUR Max;} NoisePigment;
1534 #endif
1535 #else //NOISE_PIGMENT_PATCH
1536 #define NoisePigmentPatternDef
1537 #endif
1538
1539 #ifdef ANGLE_OF_INCIDENCE_PATCH
1540 #ifdef LESS_MEMORY_IN_PATTERNS_PATCH
1541 typedef struct { VECTOR AOI_origin; unsigned char pt_fixed;
1542 }AOI, *AOIPTR ;
1543 #define AngleOfIncidenceDef AOIPTR Aoi;
1544 #else
1545 #define AngleOfIncidenceDef struct { VECTOR AOI_origin; unsigned char pt_fixed; } Aoi;
1546 #endif
1547 #else //ANGLE_OF_INCIDENCE_PATCH
1548 #define AngleOfIncidenceDef
1549 #endif
1550
1551
1552 #ifdef PROJECTION_PATCH
1553 #ifdef LESS_MEMORY_IN_PATTERNS_PATCH
1554 typedef struct { VECTOR dirv; OBJECT *obj; unsigned char type; int samples; DBL blurr;
1555 }PROJECTION, *PROJECTIONPTR;
1556 #define ProjectionDef PROJECTIONPTR projection;
1557 #else
1558 #define ProjectionDef struct { VECTOR dirv; OBJECT *obj; unsigned char type; int samples; DBL blurr; } projection;
1559 #endif
1560 #else //PROJECTION_PATCH
1561 #define ProjectionDef
1562 #endif
1563
1564 #ifdef LESS_MEMORY_IN_PATTERNS_PATCH
1565 typedef struct { SNGL Mortar; VECTOR Size;
1566 }BRICK,*BRICKPTR ;
1567 #define BrickDef BRICKPTR Brick;
1568 #else
1569 #define BrickDef struct { SNGL Mortar; VECTOR Size; } Brick;
1570 #endif
1571
1572 #ifdef LESS_MEMORY_IN_PATTERNS_PATCH
1573 typedef struct { SNGL Control0;SNGL Control1;
1574 }QUILTED, *QUILTEDPTR;
1575 #define QuiltedDef QUILTEDPTR Quilted;
1576 #else
1577 #define QuiltedDef struct { SNGL Control0, Control1; } Quilted;
1578 #endif
1579
1580 #ifdef LESS_MEMORY_IN_PATTERNS_PATCH
1581 typedef struct { DBL Size; DBL UseCoords; VECTOR Metric;
1582 }FACETS, *FACETSPTR;
1583 #define FacetsDef FACETSPTR Facets;
1584 #else
1585 #define FacetsDef struct { DBL Size, UseCoords; VECTOR Metric; } Facets;
1586 #endif
1587
1588 #ifdef LESS_MEMORY_IN_PATTERNS_PATCH
1589 typedef struct { VECTOR Form; VECTOR Metric; DBL Offset;
1590 DBL Dim; short IsSolid; VECTOR *cv; int lastseed; VECTOR lastcenter;
1591 } CRACKLE, *CRACKLEPTR ;
1592 #define CrackleDef CRACKLEPTR Crackle;
1593 #else
1594 #define CrackleDef struct { VECTOR Form; VECTOR Metric; DBL Offset; DBL Dim; \
1595 short IsSolid; VECTOR *cv; int lastseed; \
1596 VECTOR lastcenter; } Crackle;
1597 #endif
1598
1599 #ifdef LESS_MEMORY_IN_PATTERNS_PATCH
1600 typedef struct { VECTOR Slope_Vector;VECTOR Altit_Vector;short Slope_Base, Altit_Base;
1601 DBL Slope_Len, Altit_Len; UV_VECT Slope_Mod, Altit_Mod;
1602 }SLOPE, *SLOPEPTR;
1603 #define SlopeDef SLOPEPTR Slope;
1604 #else
1605 #define SlopeDef struct { VECTOR Slope_Vector, Altit_Vector; \
1606 short Slope_Base, Altit_Base; DBL Slope_Len, \
1607 Altit_Len; UV_VECT Slope_Mod, Altit_Mod; } Slope;
1608 #endif
1609
1610 #ifdef LESS_MEMORY_IN_PATTERNS_PATCH
1611 typedef struct { UV_VECT Coord; short Iterations; short nterior_type;
1612 short interior_type; short exterior_type; DBL efactor, ifactor; int Exponent;
1613 }FRACTALVALS, *FRACTALVALSPTR;
1614 #define FractalsDef FRACTALVALSPTR Fractal;
1615 #else
1616 #define FractalsDef struct { UV_VECT Coord; short Iterations, interior_type, \
1617 exterior_type; DBL efactor, ifactor; \
1618 int Exponent; } Fractal;
1619 #endif
1620
1621 #ifdef LESS_MEMORY_IN_PATTERNS_PATCH
1622 typedef struct { void *Fn; void *Data;
1623 }FUNCTIONS, *FUNCTIONSPTR;
1624 #define FunctionDef FUNCTIONSPTR Function;
1625 #else
1626 #define FunctionDef struct { void *Fn; void *Data; } Function;
1627 #endif
1628
1629 #ifdef LESS_MEMORY_IN_PATTERNS_PATCH
1630 #define GradientDef VECTOR *Gradient;
1631 #else
1632 #define GradientDef VECTOR Gradient;
1633 #endif
1634
1635 #define TPATTERN_FIELDS \
1636 unsigned short Type, Wave_Type, Flags; \
1637 int References; \
1638 SNGL Frequency, Phase; \
1639 SNGL Exponent; \
1640 WARP *Warps; \
1641 TPATTERN *Next; \
1642 BLEND_MAP *Blend_Map; \
1643 SimplePatternCacheDef \
1644 union { \
1645 DENSITY_FILE *Density_File; \
1646 IMAGE *Image; \
1647 GradientDef \
1648 SNGL Agate_Turb_Scale; \
1649 short Num_of_Waves; \
1650 short Iterations; \
1651 short Arms; \
1652 BrickDef \
1653 FacetsDef \
1654 QuiltedDef \
1655 CrackleDef \
1656 SlopeDef \
1657 FractalsDef \
1658 FunctionDef \
1659 PIGMENT *Pigment; \
1660 OBJECT *Object;\
1661 CameraViewDef \
1662 ListPatternDef\
1663 NoisePigmentPatternDef\
1664 AngleOfIncidenceDef \
1665 ProjectionDef \
1666 } Vals;
1667
1668 struct Pattern_Struct
1669 {
1670 TPATTERN_FIELDS
1671 };
1672
1673 struct Pigment_Struct
1674 {
1675 TPATTERN_FIELDS
1676 COLOUR Colour;
1677 };
1678
1679 struct Tnormal_Struct
1680 {
1681 TPATTERN_FIELDS
1682 SNGL Amount;
1683 SNGL Delta; /* NK delta */
1684 };
1685
1686 #define TEXTURE_FIELDS \
1687 TPATTERN_FIELDS \
1688 TEXTURE *Next_Material;
1689
1690 struct Texture_Struct
1691 {
1692 TEXTURE_FIELDS
1693 PIGMENT *Pigment;
1694 TNORMAL *Tnormal;
1695 FINISH *Finish;
1696 TEXTURE *Materials;
1697 int Num_Of_Mats;
1698
1699 };
1700
1701 struct Finish_Struct
1702 {
1703 SNGL Diffuse, Brilliance;
1704 SNGL Specular, Roughness;
1705 SNGL Phong, Phong_Size;
1706 SNGL Irid, Irid_Film_Thickness, Irid_Turb;
1707 SNGL Temp_Caustics, Temp_IOR, Temp_Dispersion, Temp_Refract, Reflect_Exp;
1708 SNGL Crand, Metallic;
1709 RGB Ambient, Reflection_Max, Reflection_Min; /* Changed by MBP 8/27/98 */
1710 SNGL Reflection_Falloff; /* Added by MBP 8/27/98 */
1711 int Reflection_Type; /* Added by MBP 9/5/98 */
1712 SNGL Reflect_Metallic; /* MBP */
1713 int Conserve_Energy; /* added by NK Dec 19 1999 */
1714 };
1715
1716 #define WARP_FIELDS unsigned short Warp_Type; WARP *Prev_Warp; WARP *Next_Warp;
1717
1718 struct Warps_Struct
1719 {
1720 WARP_FIELDS
1721 };
1722
1723 struct Turb_Struct
1724 {
1725 WARP_FIELDS
1726 VECTOR Turbulence;
1727 int Octaves;
1728 SNGL Lambda, Omega;
1729 };
1730
1731 #define Destroy_Finish(x) if ((x)!=NULL) POV_FREE(x)
1732
1733 typedef struct Material_Struct MATERIAL;
1734
1735 struct Material_Struct
1736 {
1737 TEXTURE *Texture;
1738 INTERIOR *Interior;
1739 TEXTURE * Interior_Texture;
1740 };
1741
1742
1743
1744
1745 /*****************************************************************************
1746 *
1747 * Object stuff (see also OBJECTS.H and primitive include files).
1748 *
1749 *****************************************************************************/
1750
1751 #define All_Intersections(x,y,z) ((*((x)->Methods->All_Intersections_Method)) (x,y,z))
1752 #define Inside(x,y) ((*((y)->Methods->Inside_Method)) (x,y))
1753 #define Normal(x,y,z) ((*((y)->Methods->Normal_Method)) (x,y,z))
1754 #define UVCoord(x,y,z) ((*((y)->Methods->UVCoord_Method)) (x,y,z))
1755 #define Copy(x) ((*((x)->Methods->Copy_Method)) (x))
1756 #define Translate(x,y,z) ((*((x)->Methods->Translate_Method)) (x,y,z))
1757 #define Scale(x,y,z) ((*((x)->Methods->Scale_Method)) (x,y,z))
1758 #define Rotate(x,y,z) ((*((x)->Methods->Rotate_Method)) (x,y,z))
1759 #define Transform(x,y) ((*((x)->Methods->Transform_Method)) (x,y))
1760 #define Invert(x) ((*((x)->Methods->Invert_Method)) (x))
1761 #define Destroy(x) ((*((x)->Methods->Destroy_Method)) (x))
1762
1763 typedef struct Method_Struct METHODS;
1764
1765 typedef int (*ALL_INTERSECTIONS_METHOD)(OBJECT *, RAY *, ISTACK *);
1766 typedef int (*INSIDE_METHOD)(VECTOR , OBJECT *);
1767 typedef void (*NORMAL_METHOD)(VECTOR, OBJECT *, INTERSECTION *);
1768 typedef void (*UVCOORD_METHOD)(UV_VECT, OBJECT *, INTERSECTION *);
1769 typedef void *(*COPY_METHOD)(OBJECT *);
1770 typedef void (*TRANSLATE_METHOD)(OBJECT *, VECTOR, TRANSFORM *);
1771 typedef void (*ROTATE_METHOD)(OBJECT *, VECTOR, TRANSFORM *);
1772 typedef void (*SCALE_METHOD)(OBJECT *, VECTOR, TRANSFORM *);
1773 typedef void (*TRANSFORM_METHOD)(OBJECT *, TRANSFORM *);
1774 typedef void (*INVERT_METHOD)(OBJECT *);
1775 typedef void (*DESTROY_METHOD)(OBJECT *);
1776
1777 /* These fields are common to all objects. */
1778
1779 #ifdef GLOW_PATCH
1780 typedef struct Glow_Struct GLOW;
1781 typedef GLOW * GLOW_PTR;
1782
1783 #define GlowPatchDef unsigned int numOfGlows; GLOW_PTR * glowList;/*a dynamically allocated array of glow pointers*/
1784 #define GlowPatchInit(o) o->numOfGlows = 0; o->glowList = NULL;
1785 #else
1786 #define GlowPatchDef
1787 #define GlowPatchInit(o)
1788 #endif
1789
1790 #ifdef MOTION_BLUR_PATCH
1791 #define TimeStampDef int TimeStamp;
1792 #define TimeStampInit(o) o->TimeStamp = 0;
1793 #else
1794 #define TimeStampDef
1795 #define TimeStampInit(o)
1796 #endif
1797
1798 #define OBJECT_FIELDS \
1799 METHODS *Methods; \
1800 int Type; \
1801 OBJECT *Sibling; \
1802 TEXTURE *Texture; \
1803 TEXTURE *Interior_Texture; \
1804 INTERIOR *Interior; \
1805 OBJECT *Bound; \
1806 OBJECT *Clip; \
1807 LIGHT_SOURCE *LLights; \
1808 BBOX BBox; \
1809 TRANSFORM *Trans; \
1810 TRANSFORM *UV_Trans; \
1811 SNGL Ph_Density; \
1812 TimeStampDef \
1813 unsigned int Flags; \
1814 GlowPatchDef \
1815 /* End of OBJECT_FIELDS */
1816
1817
1818 /* These fields are common to all compound objects */
1819
1820 #define COMPOUND_FIELDS \
1821 OBJECT_FIELDS \
1822 OBJECT *Children;
1823
1824 #define INIT_OBJECT_FIELDS(o,t,m) \
1825 o->Type = t; \
1826 o->Methods = m; \
1827 o->Sibling = NULL; \
1828 o->Texture = NULL; \
1829 o->Interior_Texture = NULL; \
1830 o->Interior = NULL; \
1831 o->Bound = NULL; \
1832 o->Clip = NULL; \
1833 o->LLights = NULL; \
1834 o->Trans = NULL; \
1835 o->UV_Trans = NULL; \
1836 o->Ph_Density = 0; \
1837 o->Flags = 0; \
1838 TimeStampInit(o) \
1839 GlowPatchInit(o) \
1840 Make_BBox(o->BBox, -BOUND_HUGE/2.0, -BOUND_HUGE/2.0, -BOUND_HUGE/2.0, \
1841 BOUND_HUGE, BOUND_HUGE, BOUND_HUGE);
1842
1843 #define DUMP_OBJECT_FIELDS(o) \
1844 Debug_Info("\tNULL, // Methods\n"); \
1845 Debug_Info("\t%d, // Type\n", (int)o->Type); \
1846 Debug_Info("\tNULL, // Sibling\n"); \
1847 Debug_Info("\tNULL, // Texture\n"); \
1848 Debug_Info("\tNULL, // Interior_Texture\n"); \
1849 Debug_Info("\tNULL, // Interior\n"); \
1850 Debug_Info("\tNULL, // Bound\n"); \
1851 Debug_Info("\tNULL, // Clip\n"); \
1852 Debug_Info("\tNULL, // LLights\n"); \
1853 Debug_Info("\t{ // BBox\n"); \
1854 Debug_Info("\t\t{ %f, %f, %f }, // Lower_Left\n", \
1855 (DBL)o->BBox.Lower_Left[X], \
1856 (DBL)o->BBox.Lower_Left[Y], \
1857 (DBL)o->BBox.Lower_Left[Z]); \
1858 Debug_Info("\t\t{ %f, %f, %f } // Lengths\n", \
1859 (DBL)o->BBox.Lengths[X], \
1860 (DBL)o->BBox.Lengths[Y], \
1861 (DBL)o->BBox.Lengths[Z]); \
1862 Debug_Info("\t},\n"); \
1863 Debug_Info("\tNULL, // Trans\n"); \
1864 Debug_Info("\tNULL, // UV_Trans\n"); \
1865 Debug_Info("\t%f, // Ph_Density\n", (DBL)o->Ph_Density); \
1866 Debug_Info("\t0x%x, // Flags\n", (unsigned int)o->Flags);
1867
1868 #ifndef DUMP_OBJECT_DATA
1869 #define DUMP_OBJECT_DATA 0
1870 #endif
1871
1872
1873 struct Method_Struct
1874 {
1875 ALL_INTERSECTIONS_METHOD All_Intersections_Method;
1876 INSIDE_METHOD Inside_Method;
1877 NORMAL_METHOD Normal_Method;
1878 UVCOORD_METHOD UVCoord_Method;
1879 COPY_METHOD Copy_Method;
1880 TRANSLATE_METHOD Translate_Method;
1881 ROTATE_METHOD Rotate_Method;
1882 SCALE_METHOD Scale_Method;
1883 TRANSFORM_METHOD Transform_Method;
1884 INVERT_METHOD Invert_Method;
1885 DESTROY_METHOD Destroy_Method;
1886 };
1887
1888 /* This is an abstract structure that is never actually used.
1889 All other objects are descendents of this primative type */
1890
1891 struct Object_Struct
1892 {
1893 OBJECT_FIELDS
1894 };
1895
1896 struct Compound_Object_Struct
1897 {
1898 COMPOUND_FIELDS
1899 };
1900
1901
1902 typedef struct BBox_Tree_Struct BBOX_TREE;
1903
1904 struct BBox_Tree_Struct
1905 {
1906 short Infinite; /* Flag if node is infinite */
1907 short Entries; /* Number of sub-nodes in this node */
1908 BBOX BBox; /* Bounding box of this node */
1909 BBOX_TREE **Node; /* If node: children; if leaf: element */
1910 };
1911
1912 typedef struct Project_Struct PROJECT;
1913 typedef struct Project_Tree_Node_Struct PROJECT_TREE_NODE;
1914
1915 struct Project_Struct
1916 {
1917 int x1, y1, x2, y2;
1918 };
1919
1920 /*
1921 * The following structure represent the bounding box hierarchy in 2d space.
1922 * Because is_leaf, Object and Project are the first elements in both
1923 * structures they can be accessed without knowing at which structure
1924 * a pointer is pointing.
1925 */
1926
1927 struct Project_Tree_Node_Struct
1928 {
1929 unsigned short is_leaf;
1930 BBOX_TREE *Node;
1931 PROJECT Project;
1932 unsigned short Entries;
1933 PROJECT_TREE_NODE **Entry;
1934 };
1935
1936 struct Light_Source_Struct
1937 {
1938 COMPOUND_FIELDS
1939 COLOUR Colour;
1940 VECTOR Direction, Center, Points_At, Axis1, Axis2;
1941 DBL Coeff, Radius, Falloff;
1942 DBL Fade_Distance, Fade_Power;
1943 LIGHT_SOURCE *Next_Light_Source;
1944 unsigned char Light_Type, Area_Light, Jitter;
1945 bool Orient;
1946 bool Circular;
1947 unsigned char Track, Parallel;
1948 unsigned char Photon_Area_Light; /* these bytes could be compressed to a single flag byte */
1949 int Area_Size1, Area_Size2;
1950 int Adaptive_Level;
1951 int Media_Attenuation;
1952 int Media_Interaction;
1953 COLOUR **Light_Grid;
1954 OBJECT *Shadow_Cached_Object,*Projected_Through_Object;
1955 BLEND_MAP *blend_map;/* NK for dispersion */
1956 PROJECT_TREE_NODE *Light_Buffer[6]; /* Light buffers for the six general directions in space. [DB 9/94] */
1957 #ifdef GLOW_PATCH
1958 DBL Glow_Amt;
1959 int Glow_Type;
1960 #endif
1961 #ifdef AREA_LIGHT_REFLECTION_PATCH
1962 int Area_Light_Max_Trace_Level;
1963 #endif
1964 };
1965
1966
1967 /*****************************************************************************
1968 *
1969 * Intersection stack stuff.
1970 *
1971 *****************************************************************************/
1972
1973 struct istk_entry
1974 {
1975 DBL Depth;
1976 VECTOR IPoint;
1977 VECTOR INormal;
1978 VECTOR PNormal; /* perturbed normal vector; -hdf- June 98 */
1979 UV_VECT Iuv;
1980 OBJECT *Object;
1981 /*
1982 * [DB 8/94]
1983 *
1984 * Pass additional values from the intersection function to other functions
1985 * (normal calculation).
1986 */
1987 int i1, i2;
1988 DBL d1, d2;
1989 DBL u,v;
1990 DBL d3,d4;
1991 DBL w1,w2,w3;
1992 /* Arbitrary pointer that can be passed. */
1993 void *Pointer;
1994 /* pass root-level parent CSG object for cutaway textures */
1995 void *Csg;
1996 #ifdef ANGLE_OF_INCIDENCE_PATCH
1997 VECTOR RDir; /* view ray direction */
1998 #endif
1999 };
2000
2001 struct istack_struct
2002 {
2003 struct istack_struct *next;
2004 struct istk_entry *istack;
2005 unsigned int max_entries;
2006 unsigned int top_entry;
2007 };
2008
itop(istack_struct * i)2009 inline istk_entry& itop(istack_struct *i)
2010 {
2011 return (i->istack[i->top_entry]);
2012 }
2013
2014 void incstack(ISTACK *istk);
2015
2016 /* Macros to push intersection onto stack. */
2017
push_entry(DBL d,VECTOR v,OBJECT * o,istack_struct * i)2018 inline void push_entry(DBL d, VECTOR v, OBJECT *o, istack_struct *i)
2019 {
2020 itop(i).Depth = d;
2021 itop(i).Object = o;
2022 Assign_Vector(itop(i).IPoint,v);
2023 Assign_UV_Vect(itop(i).Iuv, v);
2024 itop(i).Csg = NULL;
2025 incstack(i);
2026 }
2027
push_normal_entry(DBL d,VECTOR v,VECTOR n,OBJECT * o,istack_struct * i)2028 inline void push_normal_entry(DBL d, VECTOR v, VECTOR n, OBJECT *o, istack_struct *i)
2029 {
2030 itop(i).Depth = d;
2031 itop(i).Object = o;
2032 Assign_Vector(itop(i).IPoint,v);
2033 Assign_UV_Vect(itop(i).Iuv, v);
2034 Assign_Vector(itop(i).INormal,n);
2035 itop(i).Csg = NULL;
2036 incstack(i);
2037 }
2038
push_uv_entry(DBL d,VECTOR v,UV_VECT uv,OBJECT * o,istack_struct * i)2039 inline void push_uv_entry(DBL d, VECTOR v, UV_VECT uv, OBJECT *o, istack_struct *i)
2040 {
2041 itop(i).Depth = d;
2042 itop(i).Object = o;
2043 Assign_Vector(itop(i).IPoint,v);
2044 Assign_UV_Vect(itop(i).Iuv,uv);
2045 itop(i).Csg = NULL;
2046 incstack(i);
2047 }
2048
push_normal_uv_entry(DBL d,VECTOR v,VECTOR n,UV_VECT uv,OBJECT * o,istack_struct * i)2049 inline void push_normal_uv_entry(DBL d, VECTOR v, VECTOR n, UV_VECT uv, OBJECT *o, istack_struct *i)
2050 {
2051 itop(i).Depth = d;
2052 itop(i).Object = o;
2053 Assign_Vector(itop(i).IPoint,v);
2054 Assign_Vector(itop(i).INormal,n);
2055 Assign_UV_Vect(itop(i).Iuv,uv);
2056 itop(i).Csg = NULL;
2057 incstack(i);
2058 }
2059
2060
2061 /* Use these macros to push additional parameters onto the stack. [DB 8/94] */
2062
push_entry_pointer(DBL d,VECTOR v,OBJECT * o,void * a,istack_struct * i)2063 inline void push_entry_pointer(DBL d, VECTOR v, OBJECT *o, void *a, istack_struct *i)
2064 {
2065 itop(i).Depth = d;
2066 itop(i).Object = o;
2067 itop(i).Pointer = (void *)(a);
2068 Assign_Vector(itop(i).IPoint,v);
2069 Assign_UV_Vect(itop(i).Iuv, v);
2070 itop(i).Csg = NULL;
2071 incstack(i);
2072 }
2073
push_entry_pointer_uv(DBL d,VECTOR v,UV_VECT uv,OBJECT * o,void * a,istack_struct * i)2074 inline void push_entry_pointer_uv(DBL d, VECTOR v, UV_VECT uv, OBJECT *o, void *a, istack_struct *i)
2075 {
2076 itop(i).Depth = d;
2077 itop(i).Object = o;
2078 itop(i).Pointer = (void *)(a);
2079 Assign_Vector(itop(i).IPoint,v);
2080 Assign_UV_Vect(itop(i).Iuv,uv);
2081 itop(i).Csg = NULL;
2082 incstack(i);
2083 }
2084
push_entry_i1(DBL d,VECTOR v,OBJECT * o,int a,istack_struct * i)2085 inline void push_entry_i1(DBL d, VECTOR v, OBJECT *o, int a, istack_struct *i)
2086 {
2087 itop(i).Depth = d;
2088 itop(i).Object = o;
2089 itop(i).i1 = a;
2090 Assign_Vector(itop(i).IPoint,v);
2091 itop(i).Csg = NULL;
2092 incstack(i);
2093 }
2094
push_entry_d1(DBL d,VECTOR v,OBJECT * o,DBL a,istack_struct * i)2095 inline void push_entry_d1(DBL d, VECTOR v, OBJECT *o, DBL a, istack_struct *i)
2096 {
2097 itop(i).Depth = d;
2098 itop(i).Object = o;
2099 itop(i).d1 = a;
2100 Assign_Vector(itop(i).IPoint,v);
2101 itop(i).Csg = NULL;
2102 incstack(i);
2103 }
2104
push_entry_i1_i2(DBL d,VECTOR v,OBJECT * o,int a,int b,istack_struct * i)2105 inline void push_entry_i1_i2(DBL d, VECTOR v, OBJECT *o, int a, int b, istack_struct *i)
2106 {
2107 itop(i).Depth = d;
2108 itop(i).Object = o;
2109 itop(i).i1 = a;
2110 itop(i).i2 = b;
2111 Assign_Vector(itop(i).IPoint,v);
2112 itop(i).Csg = NULL;
2113 incstack(i);
2114 }
2115
push_entry_i1_d1(DBL d,VECTOR v,OBJECT * o,int a,DBL b,istack_struct * i)2116 inline void push_entry_i1_d1(DBL d, VECTOR v, OBJECT *o, int a, DBL b, istack_struct *i)
2117 {
2118 itop(i).Depth = d;
2119 itop(i).Object = o;
2120 itop(i).i1 = a;
2121 itop(i).d1 = b;
2122 Assign_Vector(itop(i).IPoint,v);
2123 itop(i).Csg = NULL;
2124 incstack(i);
2125 }
2126
push_entry_i1_i2_d1(DBL d,VECTOR v,OBJECT * o,int a,int b,DBL c,istack_struct * i)2127 inline void push_entry_i1_i2_d1(DBL d, VECTOR v, OBJECT *o, int a, int b, DBL c, istack_struct *i)
2128 {
2129 itop(i).Depth = d;
2130 itop(i).Object = o;
2131 itop(i).i1 = a;
2132 itop(i).i2 = b;
2133 itop(i).d1 = c;
2134 Assign_Vector(itop(i).IPoint,v);
2135 itop(i).Csg = NULL;
2136 incstack(i);
2137 }
2138
push_copy(istack_struct * i,istk_entry * e)2139 inline void push_copy(istack_struct *i, istk_entry *e)
2140 {
2141 itop(i)= *e;
2142 incstack(i);
2143 }
2144
pop_entry(istack_struct * i)2145 inline istk_entry *pop_entry(istack_struct *i)
2146 {
2147 return (i->top_entry > 0)?&(i->istack[--i->top_entry]):NULL;
2148 }
2149
2150
2151
2152 /*****************************************************************************
2153 *
2154 * Ray stuff (see also RAY.H).
2155 *
2156 *****************************************************************************/
2157
2158 #define MAX_CONTAINING_OBJECTS 100
2159
2160 #define OPTIMISE_NONE 0
2161 #define OPTIMISE_SHADOW_TEST 1
2162
2163 struct Ray_Struct
2164 {
2165 VECTOR Initial;
2166 VECTOR Direction;
2167 int Index;
2168 unsigned int Optimisiation_Flags;
2169 INTERIOR *Interiors[MAX_CONTAINING_OBJECTS];
2170 };
2171
2172
2173 /*****************************************************************************
2174 *
2175 * Frame tracking information
2176 *
2177 *****************************************************************************/
2178
2179 typedef enum
2180 {
2181 FT_SINGLE_FRAME,
2182 FT_MULTIPLE_FRAME
2183 } FRAMETYPE;
2184
2185 #define INT_VALUE_UNSET (-1)
2186 #define DBL_VALUE_UNSET (-1.0)
2187
2188 typedef struct
2189 {
2190 FRAMETYPE FrameType;
2191 DBL Clock_Value; /* May change between frames of an animation */
2192 int FrameNumber; /* May change between frames of an animation */
2193
2194 int InitialFrame;
2195 DBL InitialClock;
2196
2197 int FinalFrame;
2198 int FrameNumWidth;
2199 DBL FinalClock;
2200
2201 int SubsetStartFrame;
2202 DBL SubsetStartPercent;
2203 int SubsetEndFrame;
2204 DBL SubsetEndPercent;
2205
2206 #ifdef FRAME_STEP_PATCH
2207 int FrameStep;
2208 #endif
2209
2210 bool Field_Render_Flag;
2211 bool Odd_Field_Flag;
2212 } FRAMESEQ;
2213
2214
2215 /*****************************************************************************
2216 *
2217 * Miscellaneous stuff.
2218 *
2219 *****************************************************************************/
2220
2221 typedef struct Chunk_Header_Struct CHUNK_HEADER;
2222 typedef struct complex_block complex;
2223 typedef struct file_handle_struct FILE_HANDLE;
2224 typedef struct Reserved_Word_Struct RESERVED_WORD;
2225 typedef int TOKEN;
2226
2227 struct Reserved_Word_Struct
2228 {
2229 TOKEN Token_Number;
2230 char *Token_Name;
2231 };
2232
2233 typedef struct Sym_Table_Entry SYM_ENTRY;
2234
2235 struct Sym_Table_Entry
2236 {
2237 SYM_ENTRY *next;
2238 char *Token_Name;
2239 void *Data;
2240 TOKEN Token_Number;
2241 };
2242
2243 struct Chunk_Header_Struct
2244 {
2245 int name;
2246 int size;
2247 };
2248
2249 struct complex_block
2250 {
2251 DBL r, c;
2252 };
2253
2254 enum
2255 {
2256 READ_MODE = 0,
2257 WRITE_MODE = 1,
2258 APPEND_MODE = 2
2259 };
2260
2261 // This is a terrible class design, but it fits well with the even worse 3.1 code... [trf]
2262 class Image_File_Class
2263 {
2264 public:
Image_File_Class()2265 Image_File_Class() { valid = false; };
~Image_File_Class()2266 virtual ~Image_File_Class() { };
2267
2268 virtual void Write_Line(COLOUR *line_data) = 0;
2269 virtual int Read_Line(COLOUR *line_data) = 0;
2270
2271 virtual int Line() = 0;
2272 virtual int Width() = 0;
2273 virtual int Height() = 0;
2274
Valid()2275 bool Valid() { return valid; };
2276 protected:
2277 bool valid;
2278 };
2279
2280 #ifndef POV_ALLOW_FILE_READ
2281 #define POV_ALLOW_FILE_READ(f,t) (1)
2282 #endif
2283
2284 #ifndef POV_ALLOW_FILE_WRITE
2285 #define POV_ALLOW_FILE_WRITE(f,t) (1)
2286 #endif
2287
2288 END_POV_NAMESPACE
2289
2290 #ifdef USE_SYSPROTO
2291 #include "sysproto.h"
2292 #endif
2293
2294 #endif
2295