home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / INFO / IRIT / POLY3DRS.ZIP / PROGRAM.H < prev    next >
Encoding:
C/C++ Source or Header  |  1990-05-05  |  4.1 KB  |  126 lines

  1. /*****************************************************************************
  2. * Definitions for the Poly3D-R program:                                      *
  3. *****************************************************************************/
  4.  
  5. #ifndef POLY_3D_R_H
  6. #define POLY_3D_R_H
  7.  
  8. #ifdef NO_VOID_PTR
  9. #define VoidPtr        char *
  10. #else
  11. #define VoidPtr        void *
  12. #endif /* NO_VOID_PTR */
  13.  
  14. #include "genmat.h"
  15. #include "parser.h"
  16. #include "gif_lib.h"
  17.  
  18. #ifndef __MSDOS__
  19. #include "xgeneral.h"
  20. #endif /* __MSDOS__ */
  21.  
  22. #ifndef LINE_LEN
  23. #define LINE_LEN    255
  24. #endif  LINE_LEN
  25.  
  26. #define FILE_NAME_LEN    80
  27.  
  28. #ifndef NULL
  29. #define NULL    0
  30. #endif
  31.  
  32. #ifndef TRUE
  33. #define TRUE    -1
  34. #define FALSE    0
  35. #endif
  36.  
  37. #define EPSILON    1e-4  /* Make it smaller if you changed to double precision. */
  38.  
  39. #define DEFAULT_COLOR    63           /* White - in case no color is given. */
  40. #define DEFAULT_BACK_GROUND_COLOR  1         /* Blue as default back ground. */
  41. #define RGB_COLOR_GIVEN    -1            /* Or if fill RGB was given. */
  42.  
  43. /* General macro definitions for evry day usage... */
  44.  
  45. #define ABS(y)        ((y) > 0 ? (y) : (-(y)))
  46. #define SQR(y)        ((y) * (y))
  47. #define SGN(x)        ((x) > 0 ? 1 : ((x) == 0 ? 0 : -1))
  48. #define MIN(x, y)    ((x) > (y) ? (y) : (x))
  49. #define MAX(x, y)    ((x) > (y) ? (x) : (y))
  50. #define BOUND(x, Min, Max) (MIN(MAX((x), (Min)), (Max)))
  51. #define APX_EQ(x, y)    (ABS(x - y) < EPSILON)
  52. #define APX_PT_EQ(p1, p2)    (APX_EQ(p1[0], p2[0]) && \
  53.                  APX_EQ(p1[1], p2[1]) && \
  54.                  APX_EQ(p1[2], p2[2]))
  55.  
  56. #define GEN_COPY(Dest, Src, Size)       memcpy(Dest, Src, Size)
  57.  
  58. #define DEG2RAD(Deg)    ((Deg) * M_PI / 180.0)
  59. #define RAD2DEG(Rad)    ((Rad) * 180.0 / M_PI)
  60.  
  61. #define DEFAULT_SCREEN_XSIZE    320
  62. #define DEFAULT_SCREEN_YSIZE    200
  63.  
  64. #define DEFAULT_BITS_PER_PIXEL    7
  65. #define DEFAULT_LIGHT_SOURCE    { 1.0, 3.0, 7.0 }
  66. #define DEFAULT_AMBIENT        0.3
  67.  
  68. #define DEFAULT_NORMAL_AVG_DEGREE    30
  69.  
  70. typedef struct ShadingInfoStruct {
  71.     int SubSamplePixel;
  72.     int BitsPerPixel;         /* 2^BitsPerPixel == number of colors possible. */
  73.     int LevelsPerColor;        /* Number of levels per each required color. */
  74.     int DefaultColor;
  75.     int BackGroundColor;
  76.     int TwoSources;  /* If true - two sources at opposite direction assumed. */
  77.     GifColorType *PColorMap;
  78.     int *MinIntensityIndex;   /* Hold minimum intensity of this color index. */
  79.     double LightSource[3];        /* Vector direction of light source. */
  80.     double Ambient;
  81. } ShadingInfoStruct;
  82.  
  83. /* The following are global setable variables (via config file poly3d-r.cfg).*/
  84. extern int MoreFlag, GouraudFlag, BackFacingFlag, ScreenXSize, ScreenYSize,
  85.     MouseExists, GraphDriver;
  86. extern double NormalAvgDegree;
  87. extern struct ShadingInfoStruct ShadingInfo;
  88.  
  89. /* Total number of polygons/verticesa to scan converted, in current scene:   */
  90. extern int NumOfPolygons;
  91. extern int NumOfVertices;
  92.  
  93. /* Amount scene was scaled up from normalized [-1..1] size on both X & Y:    */
  94. extern float ScaleUpFactor;
  95.  
  96. /* Global transformation matrix: */
  97. extern MatrixType GlblViewMat;              /* Current view of object. */
  98.  
  99. /* All polygons to be scan convert will be inserted into this hash table     */
  100. /* during the preprocessing (PrepareXXXX functions).                 */
  101. extern struct PolygonStruct **PolyHashTable;
  102.  
  103. /* And finally the prototypes of the Poly3D-H.c module: */
  104. char *MyMalloc(unsigned size);
  105. void MyExit(int ExitCode);
  106. void QuitGifError(void);
  107.  
  108. /* Prototypes of the PrepData.c module: */
  109. void PrepareViewData(FileDescription **FD, int *NumOfObjects, char **Objects);
  110. ObjectStruct *SearchObject(FileDescription **FD, char *Object);
  111.  
  112. /* Prototypes of the ColorTbl.c module: */
  113. void PrepareColorTable(FileDescription **FD, int NumOfObjects,
  114.                     int RealNumOfObjects, char **Objects);
  115.  
  116. /* Prototypes of the EvalColr.c module: */
  117. void EvalVrtxColors(FileDescription **FD, int NumOfObjects, char **Objects);
  118. int UpdateEqnPolygon(PolygonStruct *PPolygon, int SetFlipDir);
  119. int CrossProd(float Pt1[3], float Pt2[3], float Pt3[3]);
  120. void PrintPolyContent(PolygonStruct *PPoly);
  121.  
  122. /* Prototypes of the ScnCnvrt.c module: */
  123. void ScanConvertData(GifFileType *GifFile, GifFileType *GifMask);
  124.  
  125. #endif POLY_3D_R_H
  126.