/**************************************************************************** * frame.h * * This header file is included by all C modules in POV-Ray. It defines all * globally-accessible types and constants. * * from Persistence of Vision(tm) Ray Tracer * Copyright 1996 Persistence of Vision Team *--------------------------------------------------------------------------- * NOTICE: This source code file is provided so that users may experiment * with enhancements to POV-Ray and to port the software to platforms other * than those supported by the POV-Ray Team. There are strict rules under * which you are permitted to use this file. The rules are in the file * named POVLEGAL.DOC which should be distributed with this file. If * POVLEGAL.DOC is not available or for more info please contact the POV-Ray * Team Coordinator by leaving a message in CompuServe's Graphics Developer's * Forum. The latest version of POV-Ray may be found there as well. * * This program is based on the popular DKB raytracer version 2.12. * DKBTrace was originally written by David K. Buck. * DKBTrace Ver 2.0-2.12 were written by David K. Buck & Aaron A. Collins. * * Modified by Andreas Dilger to add PNG file format support 05/09/95 * *****************************************************************************/ #ifndef FRAME_H #define FRAME_H /* Generic header for all modules */ #include #include #include #include #include "config.h" /* * These two are used if POV is being called from within another program * like a GUI interface. */ #ifndef MAIN_RETURN_TYPE #define MAIN_RETURN_TYPE void #endif #ifndef MAIN_RETURN_STATEMENT #define MAIN_RETURN_STATEMENT #endif /* * Functions that POV calls once per render to do various initializations, * in the order that they are normally called. */ #ifndef STARTUP_POVRAY /* First function called in main() for each render */ #define STARTUP_POVRAY #endif #ifndef PRINT_CREDITS /* Prints POV-Ray version information banner */ #define PRINT_CREDITS Print_Credits(); #endif #ifndef PRINT_OTHER_CREDITS /* Prints credits for custom POV versions */ #define PRINT_OTHER_CREDITS #endif /* * These read the INI files. READ_ENV_VAR reads an INI file specified by * (usually) the POVINI environment variable instead of the default file. * PROCESS_POVRAY_INI reads the INI file from the default location if * READ_ENV_VAR wasn't successful. ALT_WRITE_INI_FILE writes out a new * INI file with the values as specified by the used for this render. */ #ifndef READ_ENV_VAR #define READ_ENV_VAR Warning(0.0,"Environment variable not implemented on this platform.\n"); #endif #ifndef PROCESS_POVRAY_INI #define PROCESS_POVRAY_INI Warning(0.0,"Reading 'povray.ini' not implemented on this platform.\n"); #endif #ifndef ALT_WRITE_INI_FILE #define ALT_WRITE_INI_FILE #endif #ifndef FINISH_POVRAY /* The last call that POV makes to exit */ #define FINISH_POVRAY(n) exit(n); #endif /* * Functions that POV calls once per frame to do varios (de)initializations, * in the order they are normally called. */ #ifndef POV_PRE_RENDER /* Called just prior to the start of rendering */ #define POV_PRE_RENDER #endif #ifndef CONFIG_MATH /* Macro for setting up any special FP options */ #define CONFIG_MATH #endif #ifndef POV_PRE_PIXEL /* Called before each pixel is rendered */ #define POV_PRE_PIXEL(x,y,c) #endif #ifndef POV_POST_PIXEL /* Called after each pixel is rendered */ #define POV_POST_PIXEL(x,y,c) #endif #ifndef POV_PRE_SHUTDOWN /* Called before memory and objects are freed */ #define POV_PRE_SHUTDOWN #endif #ifndef POV_POST_SHUTDOWN /* Called after memory and objects are freed */ #define POV_POST_SHUTDOWN #endif #ifndef PRINT_STATS #ifndef NO_STATISTICS #define PRINT_STATS registry.PrintStats(); #else #define PRINT_STATS #endif #endif /* Various numerical constants that are used in the calculations */ #ifndef EPSILON /* A small value used to see if a value is nearly zero */ #define EPSILON 1.0e-10 #endif #ifndef HUGE_VAL /* A very large value, can be considered infinity */ #define HUGE_VAL 1.0e+17 #endif /* * If the width of a bounding box in one dimension is greater than * the critical length, the bounding box should be set to infinite. */ #ifndef CRITICAL_LENGTH #define CRITICAL_LENGTH 1.0e6 #endif #ifndef BOUND_HUGE /* Maximum lengths of a bounding box. */ #define BOUND_HUGE 2.0e10 #endif /* * These values determine the minumum and maximum distances * that qualify as ray-object intersections. */ #define Small_Tolerance 0.001 #define Max_Distance 1.0e7 #ifndef DBL #define DBL double #endif #ifndef SNGL #define SNGL float #endif #ifndef COLC #define COLC float #endif #ifndef M_PI #define M_PI 3.1415926535897932384626 #endif #ifndef M_PI_2 #define M_PI_2 1.57079632679489661923 #endif #ifndef TWO_M_PI #define TWO_M_PI 6.283185307179586476925286766560 #endif #ifndef M_PI_180 #define M_PI_180 0.01745329251994329576 #endif #ifndef M_PI_360 #define M_PI_360 0.00872664625997164788 #endif /* Get minimum/maximum of two values. */ #ifndef min #define min(x,y) (((x)>(y))?(y):(x)) #endif #ifndef max #define max(x,y) (((x)<(y))?(y):(x)) #endif /* Get minimum/maximum of three values. */ #define max3(x,y,z) (((x)>(y))?(((x)>(z))?(x):(z)):(((y)>(z))?(y):(z))) #define min3(x,y,z) (((x)<(y))?(((x)<(z))?(x):(z)):(((y)<(z))?(y):(z))) #ifndef labs /* Absolute value of the long integer x. */ #define labs(x) (long) (((x)<0)?-(x):(x)) #endif #ifndef fabs /* Absolute value of the double x. */ #define fabs(x) ((x) < 0.0 ? -(x) : (x)) #endif #ifndef TRUE #define TRUE 1 #define FALSE 0 #endif #ifndef CONST /* How to define a local variable - normally 'const' */ #define CONST #endif #ifndef CDECL #define CDECL #endif #ifndef NEW_LINE_STRING #define NEW_LINE_STRING "\n" #endif /* If compiler version is undefined, then make it 'u' for unknown */ #ifndef COMPILER_VER #define COMPILER_VER ".u" #endif #ifndef QSORT #define QSORT(a,b,c,d) qsort((a),(b),(c),(d)) #endif /* * POV_NAME_MAX is for file systems that have a separation of the filename * into name.ext. The POV_NAME_MAX is the name part. FILE_NAME_LENGTH * is the sum of name + extension. */ #ifndef POV_NAME_MAX #define POV_NAME_MAX 8 #endif #ifndef FILE_NAME_LENGTH #define FILE_NAME_LENGTH 150 #endif #ifndef FILENAME_SEPARATOR #define FILENAME_SEPARATOR '/' #endif #ifndef DRIVE_SEPARATOR #define DRIVE_SEPARATOR ':' #endif /* * Splits a given string into the path and file components using the * FILENAME_SEPARATOR and DRIVE_SEPARATOR */ #ifndef POV_SPLIT_PATH #define POV_SPLIT_PATH(s,p,f) POV_Split_Path((s),(p),(f)) #endif /* The output file format used if the user doesn't specify one */ #ifndef DEFAULT_OUTPUT_FORMAT #define DEFAULT_OUTPUT_FORMAT 't' #endif /* System specific image format like BMP for Windows or PICT for Mac */ #ifndef READ_SYS_IMAGE #define READ_SYS_IMAGE(i,n) Read_Targa_Image((i),(n)) #endif #ifndef GET_SYS_FILE_HANDLE #define GET_SYS_FILE_HANDLE Get_Targa_File_Handle #endif #ifndef SYS_DEF_EXT #define SYS_DEF_EXT ".tga" #endif /* Functions to delete and rename a file */ #ifndef DELETE_FILE_ERR #define DELETE_FILE_ERR -1 #endif #ifndef DELETE_FILE #define DELETE_FILE(name) unlink(name) #endif #ifndef RENAME_FILE_ERR #define RENAME_FILE_ERR -1 #endif #ifndef RENAME_FILE #define RENAME_FILE(orig,new) rename(orig,new) #endif #ifndef MAX_BUFSIZE /* The maximum size of the output file buffer */ #define MAX_BUFSIZE INT_MAX #endif /* * The TIME macros are used when displaying the rendering time for the user. * These are called in such a manner that STOP_TIME can be called multiple * times for a givn START_TIME in order to get intermediate TIME_ELAPSED * values. TIME_ELAPSED is often defined as (tstop - tstart). */ #ifndef START_TIME #define START_TIME time(&tstart); #endif #ifndef STOP_TIME #define STOP_TIME time(&tstop); #endif #ifndef TIME_ELAPSED #define TIME_ELAPSED difftime (tstop, tstart); #endif #ifndef SPLIT_TIME #define SPLIT_TIME(d,h,m,s) POV_Std_Split_Time ((d),(h),(m),(s)) #endif /* How to get input from the user */ #ifndef TEST_ABORT #define TEST_ABORT #endif #ifndef WAIT_FOR_KEYPRESS #define WAIT_FOR_KEYPRESS #else #define WAIT_FOR_KEYPRESS_EXISTS #endif #ifndef GET_KEY /* Gets a keystroke from the user without waiting */ #define GET_KEY #else #define GET_KEY_EXISTS #endif /* * Functions which have POV default replacements, but which can be replaced * by system-specific functions. Care should be taken with the RAND * functions, as changing these means your images will render differently. */ #ifndef POV_RAND /* Return a pseudo-random 32-bit value in [0, 2^32-1] */ #define POV_RAND() POV_Std_rand() #endif #ifndef POV_SRAND /* Seed the random number generator with the given value */ #define POV_SRAND(i) POV_Std_srand(i) #endif /* * Functions that write text for the user to see. These functions will * usually be customized for GUI environments so that POV outputs its * messages to a status bar or popup window. */ #ifndef POV_BANNER #define POV_BANNER registry.banner_stream() #endif #ifndef POV_WARNING #define POV_WARNING registry.warning_stream() #endif #ifndef POV_RENDER_INFO #define POV_RENDER_INFO registry.render_info_stream() #endif #ifndef POV_STATUS_INFO #define POV_STATUS_INFO registry.status_info_stream() #endif #ifndef POV_DEBUG_INFO #define POV_DEBUG_INFO registry.debug_info_stream() #endif #ifndef POV_FATAL #define POV_FATAL registry.fatal_stream() #endif #ifndef POV_STATISTICS #define POV_STATISTICS registry.statistics_stream() #endif /* * Functions that handle the graphical display preview. These functions * will be customized for all versions of POV that want to do any sort * of rendering preview. The default functions will create a 80x25 text * "rendering" using crude ASCII graphics. */ #ifndef POV_DISPLAY_INIT /* Initializes display for each frame rendered */ #define POV_DISPLAY_INIT(w,h) POV_Std_Display_Init((w),(h)); #endif #ifndef POV_DISPLAY_FINISHED /* Waits for user input after rendering done */ #define POV_DISPLAY_FINISHED POV_Std_Display_Finished(); #endif #ifndef POV_DISPLAY_CLOSE /* Closes the display window after each frame */ #define POV_DISPLAY_CLOSE POV_Std_Display_Close(); #endif #ifndef POV_DISPLAY_PLOT /* Plots a single pixel */ #define POV_DISPLAY_PLOT(x,y,r,g,b,a) POV_Std_Display_Plot((x),(y),(r),(g),(b),(a)); #endif #ifndef POV_DISPLAY_PLOT_RECT /* Plots a filled rectangle */ #define POV_DISPLAY_PLOT_RECT(x1,x2,y1,y2,r,g,b,a) POV_Std_Display_Plot_Rect((x1),(x2),(y1),(y2),(r),(g),(b),(a)); #endif #ifndef POV_DISPLAY_PLOT_BOX /* Plots a hollow box */ #define POV_DISPLAY_PLOT_BOX(x1,y1,x2,y2,r,g,b,a) POV_Std_Display_Plot_Box((x1),(y1),(x2),(y2),(r),(g),(b),(a)); #endif /* The next two are palette modes, for normal and grayscale display */ #ifndef NORMAL #define NORMAL '0' #endif #ifndef GREY #define GREY 'G' #endif /* * The DEFAULT_DISPLAY_GAMMA is used when there isn't one specified by the * user in the POVRAY.INI. For those systems that are very savvy, this * could be a function which returns the current display gamma. The * DEFAULT_ASSUMED_GAMMA should be left alone. */ #ifndef DEFAULT_DISPLAY_GAMMA #define DEFAULT_DISPLAY_GAMMA 2.2 #endif #ifndef DEFAULT_ASSUMED_GAMMA #define DEFAULT_ASSUMED_GAMMA 1.0 #endif /***************************************************************************** * * MEMIO.C Memory macros * *****************************************************************************/ #ifndef __FILE__ #define __FILE__ "" #endif #ifndef __LINE__ #define __LINE__ (-1) #endif /* * Functions which invoke external programs to do work for POV, generally * at the request of the user. */ #ifndef POV_SHELLOUT #define POV_SHELLOUT(string) pov_shellout(string) #endif #ifndef POV_MAX_CMD_LENGTH #define POV_MAX_CMD_LENGTH 250 #endif #ifndef POV_SYSTEM #define POV_SYSTEM(string) system(string) #endif /***************************************************************************** * * Scalar, color and vector stuff. * *****************************************************************************/ typedef pov_vector UV_VECT; typedef pov_vector VECTOR; typedef pov_vector EXPRESS; typedef pov_vector RGB; typedef pov_vector COLOUR; typedef pov_vector BBOX_VECT; typedef int TOKEN; typedef int CONSTANT; typedef short WORD; /* Vector elements. */ #define U 0 #define V 1 #define X 0 #define Y 1 #define Z 2 #define T 3 /* Colour vector elements. */ #define RED 0 #define GREEN 1 #define BLUE 2 #define FILTER 3 #define TRANSM 4 #if (0) /* this stuff will all move into class-specific files, and as such * is useless to us here (in addition to generating some stupid * errors), so it's conditioned-out from here to EOF. */ /***************************************************************************** * * Color map stuff. * *****************************************************************************/ #define MAX_BLEND_MAP_ENTRIES 256 typedef struct Blend_Map_Entry BLEND_MAP_ENTRY; typedef struct Blend_Map_Struct BLEND_MAP; typedef struct Pattern_Struct TPATTERN; typedef struct Texture_Struct TEXTURE; typedef struct Pigment_Struct PIGMENT; typedef struct Tnormal_Struct TNORMAL; typedef struct Finish_Struct FINISH; typedef struct Turb_Struct TURB; typedef struct Warps_Struct WARP; typedef struct Halo_Struct HALO; struct Blend_Map_Entry { SNGL value; unsigned char Same; union { COLOUR Colour; PIGMENT *Pigment; TNORMAL *Tnormal; TEXTURE *Texture; UV_VECT Point_Slope; } Vals; }; struct Blend_Map_Struct { short Number_Of_Entries, Transparency_Flag, Type; long Users; BLEND_MAP_ENTRY *Blend_Map_Entries; }; #define Make_Blend_Map_Entry(entry,v,s,r,g,b,a,t) \ { \ (entry).value = (v); \ (entry).Same = (s); \ Make_ColourA((entry).Vals.Colour, r, g, b, a, t); \ } /***************************************************************************** * * IFF file stuff. * *****************************************************************************/ #ifndef IFF_SWITCH_CAST #define IFF_SWITCH_CAST (int) #endif typedef struct Image_Colour_Struct IMAGE_COLOUR; struct Image_Colour_Struct { unsigned short Red, Green, Blue, Filter, Transmit; }; /***************************************************************************** * * Pigment, Tnormal, Finish, Halo, Texture & Warps stuff. * *****************************************************************************/ #define TPATTERN_FIELDS \ unsigned short Type, Wave_Type, Flags; \ int References; \ SNGL Frequency, Phase; \ WARP *Warps; \ TPATTERN *Next; \ BLEND_MAP *Blend_Map; \ union { \ IMAGE *Image; \ Vector Gradient; \ SNGL Agate_Turb_Scale; \ short Num_of_Waves; \ short Iterations; \ short Arms; \ struct {SNGL Mortar; Vector Size;} Brick; \ struct {SNGL Control0, Control1; } Quilted; \ } Vals; struct Pattern_Struct { TPATTERN_FIELDS }; struct Pigment_Struct { TPATTERN_FIELDS COLOUR Colour; }; struct Tnormal_Struct { TPATTERN_FIELDS SNGL Amount; }; #define TEXTURE_FIELDS \ TPATTERN_FIELDS \ TEXTURE *Next_Material; struct Texture_Struct { TEXTURE_FIELDS PIGMENT *Pigment; TNORMAL *Tnormal; FINISH *Finish; HALO *Halo; /* zss 10/03/95 */ TEXTURE *Materials; int Num_Of_Mats; }; struct Finish_Struct { SNGL Diffuse, Brilliance, Index_Of_Refraction; SNGL Refraction, Specular, Roughness, Phong, Phong_Size; SNGL Irid, Irid_Film_Thickness, Irid_Turb; SNGL Crand, Metallic, Caustics; SNGL Fade_Distance, Fade_Power; RGB Ambient, Reflection; }; struct Halo_Struct { char Type, Flags; char Dust_Type; char Mapping_Type; /* Geometry of density distributions */ char Rendering_Type; /* Type of rendering algorithm to be used */ TURB *Turb; /* Turbulence transformation */ BLEND_MAP *Blend_Map; /* Color map to be used */ TRANSFORM *Trans; /* Local transformation to be used */ TRANSFORM *Container_Trans; /* Transformation applied to container only */ DBL Max_Value, Exponent; /* Parameters of density functions */ DBL Eccentricity; /* Eccentricity of Heyney-Greenstein fn. */ DBL Samples; /* Number of samples to be used */ DBL Jitter; /* Amount of jitter */ int AA_Level; /* Max. level of subdivision */ DBL AA_Threshold; /* Threshold to kick in supersampling */ HALO *Next_Halo; /* Next halo description of this texture */ DBL Frequency, Phase; }; #define WARP_FIELDS unsigned short Warp_Type; WARP *Next_Warp; struct Warps_Struct { WARP_FIELDS }; struct Turb_Struct { WARP_FIELDS Vector Turbulence; int Octaves; SNGL Lambda, Omega; }; /***************************************************************************** * * Frame tracking information * *****************************************************************************/ typedef enum { FT_SINGLE_FRAME, FT_MULTIPLE_FRAME } FRAMETYPE; #define INT_VALUE_UNSET (-1) #define DBL_VALUE_UNSET (-1.0) typedef struct { FRAMETYPE FrameType; DBL Clock_Value; /* May change between frames of an animation */ int FrameNumber; /* May change between frames of an animation */ int InitialFrame; DBL InitialClock; int FinalFrame; int FrameNumWidth; DBL FinalClock; int SubsetStartFrame; DBL SubsetStartPercent; int SubsetEndFrame; DBL SubsetEndPercent; unsigned Field_Render_Flag; unsigned Odd_Field_Flag; } FRAMESEQ; #endif /* condition-out of class-specific information */ #endif /* FRAME_H */