Triangle.h

Go to the documentation of this file.
00001 ////////////////////////////////////////////////////////////////////////////////
00002 //    Scorched3D (c) 2000-2009
00003 //
00004 //    This file is part of Scorched3D.
00005 //
00006 //    Scorched3D is free software; you can redistribute it and/or modify
00007 //    it under the terms of the GNU General Public License as published by
00008 //    the Free Software Foundation; either version 2 of the License, or
00009 //    (at your option) any later version.
00010 //
00011 //    Scorched3D is distributed in the hope that it will be useful,
00012 //    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 //    GNU General Public License for more details.
00015 //
00016 //    You should have received a copy of the GNU General Public License
00017 //    along with Scorched3D; if not, write to the Free Software
00018 //    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019 ////////////////////////////////////////////////////////////////////////////////
00020 
00021 
00022 // Triangle.h: interface for the Triangle class.
00023 //
00024 //////////////////////////////////////////////////////////////////////
00025 
00026 #if !defined(AFX_TRIANGLE_H__B076B031_36ED_11D3_BE80_000000000000__INCLUDED_)
00027 #define AFX_TRIANGLE_H__B076B031_36ED_11D3_BE80_000000000000__INCLUDED_
00028 
00029 #include <common/Line.h>
00030 
00031 class Triangle
00032 {
00033 public:
00034         Triangle();
00035         virtual ~Triangle();
00036 
00037         Vector &getNormal() { return faceN_; }
00038 
00039         void setPointComponents(const float ptA1, const float ptA2, const float ptA3, 
00040                 Vector &normalA,
00041                 const float ptB1, const float ptB2, const float ptB3, 
00042                 Vector &normalB,
00043                 const float ptC1, const float ptC2, const float ptC3,
00044                 Vector &normalC);
00045 
00046         bool pointInBoundingBox(const Vector &pt);
00047         bool pointInTriangle(const Vector &pt);
00048 
00049         virtual bool rayIntersect(
00050                 const Line &ray, 
00051                 Vector &intersectPt, 
00052                 Vector &intersectN,
00053                 float &intersectDist,
00054                 const bool checkPtOnLine = true);
00055 
00056         virtual bool sphereIntersect(
00057                 Vector &sphereCentre, 
00058                 float &sphereRadius,
00059                 Vector &intersectPt,
00060                 Vector &intersectN,
00061                 float &intersectDist);
00062 
00063 protected:      
00064         enum largestNormalPart 
00065         { 
00066                 scalarX, 
00067                 scalarY, 
00068                 scalarZ 
00069         } largest_;
00070 
00071         Vector ptA_, ptB_, ptC_;
00072         Vector faceN_;
00073 
00074         void calcNormal();
00075         void calcLargest();
00076 };
00077 
00078 #endif // !defined(AFX_TRIANGLE_H__B076B031_36ED_11D3_BE80_000000000000__INCLUDED_)

Generated on Mon Feb 16 15:14:49 2009 for Scorched3D by  doxygen 1.5.3