home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / general / raytrace / radiance / simplerd.lha / simplerad / FinalFTP / Light / rayhit.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-05-21  |  2.3 KB  |  66 lines

  1. /**********************************************************************/
  2. /* rayhit.c :                                                         */
  3. /*                                                                    */
  4. /* Intersection support routines                                      */
  5. /*                                                                    */
  6. /* Copyright (C) 1992, Bernard Kwok                                   */
  7. /* All rights reserved.                                               */
  8. /* Revision 1.0                                                       */
  9. /* May, 1992                                                          */
  10. /**********************************************************************/
  11. #include <stdio.h>
  12. #include "geo.h"
  13. #include "struct.h"
  14. #include "io.h"
  15. #include "misc.h"
  16. #define RAY_HITC 1
  17. #include "ray.h"
  18.  
  19. extern OptionType Option;
  20.  
  21. /**********************************************************************/
  22. /* Reset hit data. Set not object hit, and maximum distance for ray   */
  23. /**********************************************************************/
  24. void Reset_Hit(hit, max_distance)
  25.      HitData *hit;
  26.      double max_distance;
  27. {
  28.   hit->obj = (Objectt *)NULL;
  29.   hit->poly = (Polygon *)NULL;
  30.   hit->mesh = (Mesh *)NULL;
  31.   if (Option.visibility == RAY_TRACE ||
  32.       Option.visibility == RAY_CAST) {
  33.     hit->distance= 4.0 * UNIVERSE;          /* Drawing scene          */
  34.   } else if (Option.visibility == FORM_FACTOR) {
  35.     hit->distance = max_distance;           /* Computing form-factors */
  36.   }
  37. }
  38.  
  39. /**********************************************************************/
  40. /* Update hit intersection information */
  41. /**********************************************************************/
  42. void Store_HitInter(hit,optr,t,x,y,z)
  43.      register HitData *hit;
  44.      register Objectt *optr;
  45.      double t,x,y,z;
  46. {
  47.   hit->obj = optr;
  48.   hit->distance= t;
  49.   hit->intersect.x= x;
  50.   hit->intersect.y= y;
  51.   hit->intersect.z= z;
  52. }
  53.  
  54. /**********************************************************************/
  55. /* Update hit intersection normal information */
  56. /**********************************************************************/
  57. void Store_HitNorm(hit,x,y,z)
  58.      register HitData *hit;
  59.      double x,y,z;
  60. {
  61.   hit->normal.x= x;
  62.   hit->normal.y= y;
  63.   hit->normal.z= z;
  64. }
  65.  
  66.