00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
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_)