include/crbn/basic/ray.hpp

00001 
00002 #ifndef __ray_hpp__
00003 #define __ray_hpp__
00004 
00005 #include <crbn/basic/vec3.hpp>
00006 
00007 struct ray {
00008   vec3 origin, direction;
00009 
00010   float index; // Index of the vacuum where the ray is
00011 
00012   int bounce; //
00013 
00014   ray() : origin(0.0), direction(0.0, 0.0, 1.0), index(1.0), bounce(0) {}
00015   ray( const vec3& o, const vec3& d, const float& i=1.0, const int& b=0 ) : 
00016     origin(o),
00017     direction(d),
00018     index(i),
00019     bounce(b)
00020   {}
00021 
00022   ray( const ray& r ) : 
00023     origin(r.origin),
00024     direction(r.direction),
00025     index(r.index),
00026     bounce(r.bounce)
00027   {}
00028 
00029   ray& operator= (const ray& r) {
00030     origin    = r.origin;
00031     direction = r.direction;
00032     index     = r.index;
00033     bounce    = r.bounce;
00034 
00035     return *this;
00036   }
00037 };
00038 
00039 // p = p.o + f * p.d
00040 inline void on( vec3& p, ray& r, float f )
00041 {
00042   vaddfmul( p, r.origin, f, r.direction );
00043 }
00044 
00045 #endif // __ray_hpp__

Generated on Tue Nov 14 15:40:08 2006 for libcrbn by  doxygen 1.5.0