00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef SGRay_H
00019 #define SGRay_H
00020
00021 template<typename T>
00022 class SGRay {
00023 public:
00024 SGRay()
00025 { }
00026 SGRay(const SGVec3<T>& origin, const SGVec3<T>& dir) :
00027 _origin(origin), _direction(dir)
00028 { }
00029 template<typename S>
00030 explicit SGRay(const SGRay<S>& ray) :
00031 _origin(ray.getOrigin()), _direction(ray.getDirection())
00032 { }
00033
00034 void set(const SGVec3<T>& origin, const SGVec3<T>& dir)
00035 { _origin = origin; _direction = dir; }
00036
00037 void setOrigin(const SGVec3<T>& origin)
00038 { _origin = origin; }
00039 const SGVec3<T>& getOrigin() const
00040 { return _origin; }
00041
00042 void setDirection(const SGVec3<T>& direction)
00043 { _direction = direction; }
00044 const SGVec3<T>& getDirection() const
00045 { return _direction; }
00046
00047 SGVec3<T> getNormalizedDirection() const
00048 { return normalize(getDirection()); }
00049
00050 private:
00051 SGVec3<T> _origin;
00052 SGVec3<T> _direction;
00053 };
00054
00056 template<typename char_type, typename traits_type, typename T>
00057 inline
00058 std::basic_ostream<char_type, traits_type>&
00059 operator<<(std::basic_ostream<char_type, traits_type>& s,
00060 const SGRay<T>& ray)
00061 {
00062 return s << "ray: origin = " << ray.getOrigin()
00063 << ", direction = " << ray.getDirection();
00064 }
00065
00066 #endif