00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef FXRANGE_H
00025 #define FXRANGE_H
00026
00027 namespace FX {
00028
00029
00030
00031 class FXAPI FXRange {
00032 protected:
00033 FXfloat d[3][2];
00034 public:
00035
00036
00037 FXRange(){}
00038
00039
00040 FXRange(FXfloat xlo,FXfloat xhi,FXfloat ylo,FXfloat yhi,FXfloat zlo,FXfloat zhi){
00041 d[0][0]=xlo; d[0][1]=xhi;
00042 d[1][0]=ylo; d[1][1]=yhi;
00043 d[2][0]=zlo; d[2][1]=zhi;
00044 }
00045
00046
00047 FXfloat side(FXint i) const { return d[i][1]-d[i][0]; }
00048
00049
00050 FXfloat width() const { return d[0][1]-d[0][0]; }
00051
00052
00053 FXfloat height() const { return d[1][1]-d[1][0]; }
00054
00055
00056 FXfloat depth() const { return d[2][1]-d[2][0]; }
00057
00058
00059 FXfloat longest() const;
00060
00061
00062 FXfloat shortest() const;
00063
00064
00065 FXbool empty() const;
00066
00067
00068 FXbool overlap(const FXRange& box) const;
00069
00070
00071 FXbool contains(FXfloat x,FXfloat y,FXfloat z) const;
00072
00073
00074 FXfloat* operator[](FXint i){ return d[i]; }
00075
00076
00077 const FXfloat* operator[](FXint i) const { return d[i]; }
00078
00079
00080 FXRange& include(const FXRange& box);
00081
00082
00083 FXRange& include(FXfloat x,FXfloat y,FXfloat z);
00084
00085
00086 FXRange& include(const FXVec3f& v);
00087
00088
00089 FXRange& clipTo(const FXRange& box);
00090
00091
00092 friend FXAPI void boxCorners(FXVec3f* points,const FXRange& box);
00093
00094
00095 friend FXAPI FXbool boxIntersect(const FXRange& box,const FXVec3f& u,const FXVec3f& v);
00096
00097
00098 friend FXAPI FXVec3f boxCenter(const FXRange& box);
00099
00100
00101 friend FXAPI FXfloat boxDiagonal(const FXRange& box);
00102
00103
00104 friend FXAPI FXStream& operator<<(FXStream& store,const FXRange& box);
00105
00106
00107 friend FXAPI FXStream& operator>>(FXStream& store,FXRange& box);
00108 };
00109
00110 }
00111
00112 #endif