00001 00002 /*************************************************************************** 00003 * Copyright (C) 1998-2008 by authors (see AUTHORS.txt ) * 00004 * * 00005 * This file is part of LuxRender. * 00006 * * 00007 * Lux Renderer is free software; you can redistribute it and/or modify * 00008 * it under the terms of the GNU General Public License as published by * 00009 * the Free Software Foundation; either version 3 of the License, or * 00010 * (at your option) any later version. * 00011 * * 00012 * Lux Renderer is distributed in the hope that it will be useful, * 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00015 * GNU General Public License for more details. * 00016 * * 00017 * You should have received a copy of the GNU General Public License * 00018 * along with this program. If not, see <http://www.gnu.org/licenses/>. * 00019 * * 00020 * This project is based on PBRT ; see http://www.pbrt.org * 00021 * Lux Renderer website : http://www.luxrender.net * 00022 ***************************************************************************/ 00023 00024 #ifndef LUX_RAY_H 00025 #define LUX_RAY_H 00026 00027 #include <iostream> 00028 #include "vector.h" 00029 #include "point.h" 00030 00031 namespace lux 00032 { 00033 00034 class Ray { 00035 public: 00036 // Ray Public Methods 00037 Ray(): mint(RAY_EPSILON), maxt(INFINITY), time(0.f) {} 00038 Ray(const Point &origin, const Vector &direction, 00039 float start = RAY_EPSILON, float end = INFINITY, float t = 0.f) 00040 : o(origin), d(direction), mint(start), maxt(end), time(t) { } 00041 Point operator()(float t) const { return o + d * t; } 00042 // Ray Public Data 00043 Point o; 00044 Vector d; 00045 mutable float mint, maxt; 00046 float time; 00047 }; 00048 00049 inline ostream &operator<<(ostream &os, Ray &r) { 00050 os << "org: " << r.o << "dir: " << r.d << " range [" << 00051 r.mint << "," << r.maxt << "] time = " << 00052 r.time; 00053 return os; 00054 } 00055 00056 }//namespace lux 00057 00058 #endif //LUX_RAY_H