www.pudn.com > Ray_Tracing_Materials.rar > Ray.h, change:2005-03-02,size:1080b


/* 
   File Name: 
 
      Ray.h 
 
   Created by: 
 
      Allen Sherrod (Programming Ace of www.UltimateGameProgramming.com). 
 
   Description: 
 
      This file holds two structures.  One represents a ray and the other is used to 
      hold the result of a ray trace test. 
*/ 
 
 
#ifndef RAY_H
#define RAY_H

 
#include"CVector.h" 
 

struct Ray
{
   CVector4 origin;     // Origin of the ray 
   CVector4 direction;  // Direction the ray is going. 
 
   // Overloaded = sign for the ray object. 
   void operator=(const Ray &r) 
   { 
      origin = r.origin; 
      direction = r.direction; 
   }
};
 

struct TraceResult
{
   bool hit;            // True if a ray hit an object.
   float distance;      // Distance to the intersection. 
 
   // Overloaded = sign for the tracing result object. 
   void operator=(const TraceResult &tr) 
   { 
      hit = tr.hit; 
      distance = tr.distance; 
   }
}; 

#endif 
 
 
// Copyright February 2005 
// All Rights Reserved! 
// Allen Sherrod 
// ProgrammingAce@UltimateGameProgramming.com 
// www.UltimateGameProgramming.com