Contents Functions Classes Topics User Forum CVS

Box.h

Go to the documentation of this file.
00001 
00016 #ifndef G3D_BOX_H
00017 #define G3D_BOX_H
00018 
00019 #include "G3D/platform.h"
00020 #include "G3D/Vector3.h"
00021 #include "G3D/Array.h"
00022 #include "G3D/Plane.h"
00023 
00024 namespace G3D {
00025 
00026 class CoordinateFrame;
00027 
00036 class Box {
00037 private:
00038 
00039     static int32 dummy;
00040 
00041     friend class CoordinateFrame;
00042 
00052     Vector3 _corner[8];
00053 
00057     Vector3 _axis[3];
00058    
00059     Vector3 _center;
00060 
00064     Vector3 _extent;
00065 
00066     float  _area;
00067     float  _volume;
00068 
00069     void init(
00070         const Vector3& min,
00071         const Vector3& max);
00072 
00073 public:
00074 
00078     Box();
00079 
00083     Box(
00084         const Vector3&      min,
00085         const Vector3&      max);
00086 
00087         Box(class BinaryInput& b);
00088 
00089     Box(const class AABox& b);
00090 
00091         void serialize(class BinaryOutput& b) const;
00092         void deserialize(class BinaryInput& b);
00093 
00101     CoordinateFrame localFrame() const;
00102 
00103     void getLocalFrame(CoordinateFrame& frame) const;
00104 
00108     inline Vector3 center() const {
00109         return _center;
00110     }
00111 
00112     inline Vector3 getCenter() const {
00113         return center();
00114     }
00115 
00120     inline Vector3 getCorner(int i) const {
00121         debugAssert(i < 8);
00122         return _corner[i];
00123     }
00124 
00125     inline Vector3 corner(int i) const {
00126         debugAssert(i < 8);
00127         return _corner[i];
00128     }
00129 
00133     inline Vector3 axis(int a) const {
00134         debugAssert(a < 3);
00135         return _axis[a];
00136     }
00137 
00142     inline float extent(int a) const {
00143         debugAssert(a < 3);
00144         return (float)_extent[a];
00145     }
00146 
00147     inline Vector3 extent() const {
00148         return _extent;
00149     }
00150 
00155     void getFaceCorners(
00156         int                 f,
00157         Vector3&            v0,
00158         Vector3&            v1,
00159         Vector3&            v2,
00160         Vector3&            v3) const;
00161 
00165     bool culledBy(
00166         const class Plane*  plane,
00167         int                 numPlanes,
00168                 int32&                          cullingPlaneIndex,
00169                 const uint32            testMask,
00170         uint32&             childMask) const;
00171 
00175     bool culledBy(
00176         const class Plane*  plane,
00177         int                 numPlanes,
00178                 int32&                          cullingPlaneIndex = dummy,
00179                 const uint32            testMask = -1) const;
00180 
00184         bool culledBy(
00185                 const Array<Plane>&             plane,
00186                 int32&                                  cullingPlaneIndex,
00187                 const uint32                    testMask,
00188         uint32&                 childMask) const;
00189 
00193         bool culledBy(
00194                 const Array<Plane>&             plane,
00195                 int32&                                  cullingPlaneIndex = dummy,
00196                 const uint32                    testMask                  = -1) const;
00197 
00198     bool contains(
00199         const Vector3&      point) const;
00200 
00202     float surfaceArea() const;
00203 
00204     inline float area() const {
00205         return surfaceArea();
00206     }
00207 
00208     float volume() const;
00209 
00210     void getRandomSurfacePoint(Vector3& P, Vector3& N = Vector3::dummy) const;
00211 
00216     inline Vector3 randomSurfacePoint() const {
00217         Vector3 V;
00218         getRandomSurfacePoint(V);
00219         return V;
00220     }
00221 
00225     Vector3 randomInteriorPoint() const;
00226 
00227     void getBounds(class AABox&) const;
00228 };
00229 
00230 }
00231 
00232 #endif

Generated on Mon Jul 17 11:50:41 2006 for G3D by doxygen 1.4.5
Hosted by SourceForge.net Logo