00001 /* 00002 toxic - A Global Illumination Renderer 00003 Copyright (C) 2003-2004 Francois Beaune 00004 Contact: http://toxicengine.sourceforge.net/ 00005 00006 This file is part of toxic. 00007 00008 toxic is free software; you can redistribute it and/or modify 00009 it under the terms of the GNU General Public License as published by 00010 the Free Software Foundation; either version 2 of the License, or 00011 (at your option) any later version. 00012 00013 toxic is distributed in the hope that it will be useful, 00014 but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 GNU General Public License for more details. 00017 00018 You should have received a copy of the GNU General Public License 00019 along with toxic; if not, write to the Free Software 00020 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00021 */ 00022 00023 #ifndef TOXIC_RENDERER_RAY_H 00024 #define TOXIC_RENDERER_RAY_H 00025 00026 #include "common/math/real.h" 00027 #include "common/math/point3.h" 00028 #include "common/math/vector3.h" 00029 #include "globals.h" 00030 00031 #include <cassert> 00032 00033 namespace toxic { 00034 00035 class Ray { 00036 public: 00037 // A ray can be expressed in world space or object space. 00038 00039 // If you alter this enumeration, don't forget to update IObject::IntersectionMask 00040 // (in file iobject.h) accordingly. 00041 enum Type { 00042 VISIBILITY_RAY = 1, 00043 PRIMARY_RAY = 2, 00044 REFLECTED_RAY = 4, 00045 SHADOW_RAY = 8, 00046 PHOTON_RAY = 16, 00047 PRIMARY_FG_RAY = 32, 00048 SECONDARY_FG_RAY = 64, 00049 AUTOFOCUS_RAY = 128 00050 }; 00051 00052 sheep::Point3 m_origin; //!< World space or object space. 00053 sheep::Vector3 m_direction; //!< World space or object space. 00054 00055 Ray(Type type); 00056 Ray(const Ray &r); 00057 Ray(Type type, const sheep::Point3 &origin, const sheep::Vector3 &direction); 00058 00059 Type GetType() const; 00060 00061 //! Returns an invalid ray id (useful for mailbox mechanisms). 00062 static int GetInvalidId(); 00063 00064 //! Returns id of this ray, which lies in range [0..infinity). 00065 int GetId() const; 00066 00067 //! Assigns a new id to this ray. 00068 void NewId(); 00069 00070 //! t lies in the interval [0..infinity[. Warning! Be careful to take 00071 //! into account the fact that the ray direction may not be unit-length. 00072 sheep::Point3 GetPointAt(sheep::Real t) const; 00073 00074 private: 00075 static int m_next_id; 00076 00077 Type m_type; 00078 int m_id; 00079 }; 00080 00081 #include "ray.inl" 00082 00083 } 00084 00085 #endif // !TOXIC_RENDERER_RAY_H
1.3.6