home *** CD-ROM | disk | FTP | other *** search
/ RISC DISC 3 / RISC_DISC_3.iso / resources / etexts / gems / gemsv / ch7_6 / zrendv3.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-02-09  |  2.5 KB  |  113 lines

  1. /* Accurate Rendering Algorithm Based on the Z-Buffer Algorithm
  2.    Developed by Raghu Karinthi
  3.                 West Virginia University
  4.         Department of Computer Science
  5.         P.O.Box 6330
  6.         Morgantown WV 26506-6330
  7.         raghu@cs.wvu.edu
  8.                 Version 3  01/20/95  */
  9.  
  10. #include <stdio.h>
  11. #include <time.h>
  12. #include <math.h>
  13. #include "matrix/mat3.h"
  14. #ifndef NOLUG 
  15. #include "lug/lug.h"
  16. #include "lug/lugfnts.h"
  17. #define DEFAULTOUT "a.tga"
  18. #else
  19. #define DEFAULTOUT "a.im"
  20. #endif
  21.  
  22. /* Constants for Fixpoint Arithmetic */
  23. /* Requires: LOBITS to be divisible by 2, HIBITS<=16, and LOBITS <=16. */
  24.  
  25. #define HIBITS                        15
  26. #define LOBITS                        14
  27.  
  28. #ifndef TRUE
  29. #define TRUE                          1
  30. #endif
  31.  
  32. #ifndef FALSE
  33. #define FALSE                         0
  34. #endif
  35.  
  36. #define LOMASK       (~(0xffffffff << LOBITS))
  37. #define HIMASK       ((~(0xffffffff << HIBITS)) << LOBITS)
  38. #define FIX1         (1 << LOBITS)
  39. #define LOCMASK      (0xffffffff << LOBITS)
  40.  
  41. typedef int fixpoint;
  42.  
  43. /* NFF Parser constants */
  44.  
  45. #define WAITING           0 
  46. #define VIEWING           1
  47. #define TRIDATA           2
  48.  
  49. #ifndef CLOCKS_PER_SEC
  50. #define CLOCKS_PER_SEC    1000000.0 /* Timing Constant */
  51. #endif
  52.  
  53. /* Renderer Constants */
  54.  
  55. #define NUM_TRIANGLES     500
  56. #define X                 0
  57. #define Y                 1
  58. #define Z                 2
  59.  
  60. #define WINDOW_WIDTH      500
  61. #define WINDOW_HEIGHT     500
  62.  
  63. #define MAX_INTENSITY     256
  64. #define NUM_LIGHT_SOURCES 4
  65. #define BW_DEPTH          8
  66. #define COLOR_DEPTH       (3*BW_DEPTH)
  67.  
  68.  
  69. typedef MAT3vec Point; /* Point Type */
  70.  
  71. typedef unsigned char color;  /* Framebuffer Color */
  72.  
  73. typedef fixpoint fcolor;  /* Vertex Color */
  74.  
  75. typedef struct Color_Vertex_struct {
  76.   Point vertex;
  77.   fcolor red, green, blue;
  78.   MAT3vec normal;
  79. } Color_Vertex;
  80.  
  81. typedef struct FrameBuffer_Entry_struct {
  82.   color red, green, blue;
  83.   fixpoint z;
  84. } FrameBuffer_Entry;
  85. typedef FrameBuffer_Entry *FrameBuffer_EntryP;
  86. typedef FrameBuffer_Entry FrameBuffer[WINDOW_WIDTH][WINDOW_HEIGHT];
  87.  
  88. typedef struct _triangle {
  89.   Color_Vertex vertices[3];
  90.   unsigned char accept;
  91. } Triangle;
  92. typedef Triangle *InDataSet;
  93.  
  94. typedef struct BackgroundColor_struct {
  95.   color red, green, blue;
  96. } BackGroundColor;
  97.  
  98. typedef struct LightPoint_struct {
  99.   Point location;
  100.   double red, green, blue; 
  101. } LightPoint;
  102. typedef LightPoint *Lights;
  103.  
  104. typedef struct MtlProperties_struct {
  105.   double red, green, blue, diffuseK, ambientK, c1, c2;
  106. } MtlProp;
  107.  
  108. typedef union fix_dbl_union {
  109.   unsigned int i[2];
  110.   double d;
  111. } fix_dbl;
  112.  
  113.