home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / general / raytrace / pxm_ray / pxm_ray.lha / pxm-ray / ray.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-12-09  |  3.0 KB  |  140 lines

  1. /*
  2.  * include file for the ray-tracer
  3.  */
  4.  
  5. /*
  6.  *    (c) 1988 by George Kyriazis
  7.  */
  8.  
  9. #ifndef    NULL
  10. #define    NULL 0
  11. #endif
  12.  
  13. #ifndef    FALSE
  14. #define    FALSE    0
  15. #endif
  16.  
  17. #ifndef    TRUE
  18. #define    TRUE    !FALSE
  19. #endif
  20.  
  21. #define    MINT    1e-5
  22.  
  23. #define    MAXLEVEL    3    /* maximum recursion level */
  24.  
  25. #define    SPHERE    0
  26. #define    SQUARE    1
  27.  
  28. #define    ABS(x)    ((x)<0?-(x):(x))
  29. #define    MIN(x, y)    ((x)<(y)?(x):(y))
  30.  
  31. struct    vector    {double x,y,z;};
  32.  
  33. /* the color structure */
  34. struct    color    {
  35.         double    r,g,b;
  36.         };
  37.  
  38. /* the object structure */
  39. struct    obj    {
  40.         int    type;
  41.         int    dummy;
  42.         union data {
  43.             struct sphere {
  44.                 struct    vector    center;
  45.                 double    radius;
  46.             } sphere;
  47.             struct quad {
  48.                 struct    vector    p1;
  49.                 struct    vector    p2;
  50.                 struct    vector    p3;
  51.             } quad;
  52.         } data;
  53.         double    reflection;    /* precentage reflection */
  54.         double    refraction;    /* percentage refraction */
  55.         struct    color    refl_color;    /* reflective color */
  56.         struct    color    refr_color;    /* refractive color */
  57.         struct    color    ambient;    /* ambient color */
  58.         struct    color    diffuse;        /* diffuse color */
  59.         struct    color    specular;    /* specular color */
  60.         double    width;        /* specular width factor */
  61.         double    index;        /* index of refraction */
  62.         double    refl_diffuse;    /* circle of diffusion in reflection */
  63.         double    refr_diffuse;    /* circle of diffusion in refraction */
  64.         struct    vector    time;    /* motion */
  65.         };
  66.  
  67. struct    light {
  68.     struct    vector    org;
  69.     double    angle;
  70. };
  71. #ifndef    SOMEDEFS
  72. /* light source */
  73. extern    struct    light    light;
  74.  
  75. /* number of spheres */
  76. extern    int    noo;
  77. extern    int    nos, nosq;
  78.  
  79. /* number of tries per pixel */
  80. extern    int    tries;
  81.  
  82. /* eye stuff */
  83. extern    struct    vector    hor, ver, eye_dir, eye, up;
  84. extern    double    fov;
  85. extern    double    foc, lens;
  86.  
  87. /* time information */
  88. extern    double    time1, time2;
  89. extern    double    time;
  90.  
  91. /* background cuing */
  92. extern    int    bgflag;
  93. #define    NONE    0
  94. #define    X    1
  95. #define    Y    2
  96. #define    Z    3
  97.  
  98.  
  99. /* the array of spheres */
  100. #ifdef    HOST
  101. extern    struct    obj    *obj;
  102. #endif
  103.  
  104. /* resolution */
  105. extern    int    xres, yres;
  106. #endif
  107.  
  108. /* the ray structure */
  109. struct    ray    {
  110.         struct    vector    pos;    /* origin */
  111.         struct    vector    dir;    /* direction */
  112.         struct    obj    *obj;    /* where the ray comes from */
  113.         double    theta;        /* the diffusion angle */
  114.         };
  115.  
  116. /* the intersection structure */
  117. struct    intersect    {
  118.         struct    obj    *obj;    /* which object */
  119.         struct    obj    *objaddr; /* logical address */
  120.         double    t;        /* where in the ray */
  121.         struct    vector    n;    /* the normal at that point */
  122.         };
  123.  
  124. #ifndef    SOMEDEFS
  125. /* some statistics variables */
  126. extern    int    raycount;    /* total number of rays */
  127. extern    int    shadowcount;    /* total number of shadow rays traced */
  128. extern    int    reflectcount;    /* total number of reflected rays */
  129. extern    int    refractcount;    /* total number of refracted rays */
  130. extern    int    intersectcount;    /* total number of object intersections */
  131. extern    int    objtestcount;    /* total number of intersection tests */
  132.  
  133. extern    int    rayline;    /* rays / line */
  134. extern    int    shadowline;    /* shadow rays / line */
  135. extern    int    reflectline;    /* reflected rays / line */
  136. extern    int    refractline;    /* refracted rays / line */
  137. extern    int    intersectline;    /* object intersections / line */
  138. extern    int    objtestline;    /* object intersection tests / line */
  139. #endif
  140.