home *** CD-ROM | disk | FTP | other *** search
/ Altsys Virtuoso 2.0K / virtuoso_20k.iso / DemoApps / Graphics / Viewers / raytracers / rpi / Source / ray.h < prev    next >
Encoding:
C/C++ Source or Header  |  1991-10-08  |  2.9 KB  |  130 lines

  1.  
  2. /*
  3.  * (c) 1988 by George Kyriazis
  4.  */
  5.  
  6. /*
  7.  * include file for the ray-tracer
  8.  */
  9.  
  10. #ifndef    NULL
  11. #define    NULL 0
  12. #endif
  13.  
  14. #ifndef    FALSE
  15. #define    FALSE    0
  16. #endif
  17.  
  18. #ifndef    TRUE
  19. #define    TRUE    !FALSE
  20. #endif
  21.  
  22. #define    MINT    1e-5
  23.  
  24. #define    ABS(a)    ( ((a) > 0 ) ? (a) : -(a) )
  25. #define    MIN(a, b)    ( (a) < (b) ? (a) : (b) )
  26.  
  27. #define    MAXLEVEL    3    /* maximum recursion level */
  28.  
  29. #define    SPHERE        0
  30. #define    SQUARE        1
  31.  
  32. struct    vector    {double x,y,z;};
  33.  
  34. /* the color structure */
  35. struct    color    {
  36.         double    r,g,b;
  37.         };
  38.  
  39. /* the object structure */
  40. struct    obj    {
  41.         int    type;        /* type of object */
  42.         union data {
  43.             struct    sphere {    /* sphere definition */
  44.                 struct    vector    center;
  45.                 double    radius;
  46.                 } sphere;
  47.             struct    quad {        /* quad definition */
  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 coefficients */
  65.         };
  66.  
  67. /* light source */
  68. struct    light {
  69.     struct    vector    org;
  70.     double    angle;
  71. };
  72. struct    light    light;
  73.  
  74. /* number of objects */
  75. int    noo;
  76.  
  77. /* number of tries per pixel */
  78. int    tries;
  79.  
  80. /* eye viewing stuff */
  81. struct    vector    hor, ver, eye_dir, eye, up;
  82. double    fov;
  83.  
  84. /* time information */
  85. double    time1, time2;        /* time limits */
  86. double    Time;            /* current time */
  87.  
  88. /* background cuing info */
  89. int    bgflag;
  90. #define    NONE    0
  91. #define    X    1
  92. #define    Y    2
  93. #define    Z    3
  94.  
  95. /* the array of spheres */
  96. struct    obj    *obj;
  97.  
  98. /* resolution */
  99. long int    xres, yres;
  100.  
  101. /* the ray structure */
  102. struct    ray    {
  103.         struct    vector    pos;    /* origin */
  104.         struct    vector    dir;    /* direction */
  105.         struct    obj    *obj;    /* where the ray comes from */
  106.         double    theta;        /* the diffusion angle */
  107.         };
  108.  
  109. /* the intersection structure */
  110. struct    intersect    {
  111.         struct    obj    *obj;    /* which object */
  112.         double    t;        /* where in the ray */
  113.         struct    vector    n;    /* the normal at that point */
  114.         };
  115.  
  116. /* some statistics variables */
  117. int    raycount;        /* total number of rays */
  118. int    shadowcount;        /* total number of shadow rays traced */
  119. int    reflectcount;        /* total number of reflected rays */
  120. int    refractcount;        /* total number of refracted rays */
  121. int    intersectcount;        /* total number of object intersections */
  122. int    objtestcount;        /* total number of intersection tests */
  123.  
  124. int    rayline;        /* rays / line */
  125. int    shadowline;        /* shadow rays / line */
  126. int    reflectline;        /* reflected rays / line */
  127. int    refractline;        /* refracted rays / line */
  128. int    intersectline;        /* object intersections / line */
  129. int    objtestline;        /* object intersection tests / line */
  130.