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 /* Ray-Triangle Intersection Test Routines */ 00024 /* Different optimizations of my and Ben Trumbore's */ 00025 /* code from journals of graphics tools (JGT) */ 00026 /* http://www.acm.org/jgt/ */ 00027 /* by Tomas Moller, May 2000 */ 00028 00029 #ifndef TOXIC_RENDERER_INTERSECTTRIANGLE_H 00030 #define TOXIC_RENDERER_INTERSECTTRIANGLE_H 00031 00032 #include "common/math/real.h" 00033 #include "common/math/vector3.h" 00034 #include "globals.h" 00035 00036 namespace toxic { 00037 00038 class Ray; 00039 00040 // A point, T(u, v), on a triangle is given by: 00041 // T(u, v) = (1.0 - u - v) * V[0] + u * V[1] + v * V[2] 00042 00043 //! The original jgt code. 00044 bool intersect_triangle( 00045 const Ray &ray, 00046 const sheep::Vector3 &vert0, const sheep::Vector3 &vert1, const sheep::Vector3 &vert2, 00047 sheep::Real *t, sheep::Real *u, sheep::Real *v); 00048 00049 //! Code rewritten to do tests on the sign of the determinant. 00050 //! The division is at the end in the code. 00051 bool intersect_triangle1( 00052 const Ray &ray, 00053 const sheep::Vector3 &vert0, const sheep::Vector3 &vert1, const sheep::Vector3 &vert2, 00054 sheep::Real *t, sheep::Real *u, sheep::Real *v); 00055 00056 //! Code rewritten to do tests on the sign of the determinant. 00057 //! The division is before the test of the sign of the determinant. 00058 bool intersect_triangle2( 00059 const Ray &ray, 00060 const sheep::Vector3 &vert0, const sheep::Vector3 &vert1, const sheep::Vector3 &vert2, 00061 sheep::Real *t, sheep::Real *u, sheep::Real *v); 00062 00063 //! Code rewritten to do tests on the sign of the determinant. 00064 //! The division is before the test of the sign of the determinant and 00065 //! one cross product has been moved out from the if-else if-else. 00066 bool intersect_triangle3( 00067 const Ray &ray, 00068 const sheep::Vector3 &vert0, const sheep::Vector3 &vert1, const sheep::Vector3 &vert2, 00069 sheep::Real *t, sheep::Real *u, sheep::Real *v); 00070 00071 } 00072 00073 #endif // !TOXIC_RENDERER_INTERSECTTRIANGLE_H
1.3.6