Panda3D
|
00001 // Filename: geometricBoundingVolume.h 00002 // Created by: drose (07Oct99) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 #ifndef GEOMETRICBOUNDINGVOLUME_H 00016 #define GEOMETRICBOUNDINGVOLUME_H 00017 00018 #include "pandabase.h" 00019 00020 #include "boundingVolume.h" 00021 00022 #include "luse.h" 00023 #include "lmatrix.h" 00024 00025 //////////////////////////////////////////////////////////////////// 00026 // Class : GeometricBoundingVolume 00027 // Description : This is another abstract class, for a general class 00028 // of bounding volumes that actually enclose points in 00029 // 3-d space, such as BSP's and bounding spheres. 00030 //////////////////////////////////////////////////////////////////// 00031 class EXPCL_PANDA_MATHUTIL GeometricBoundingVolume : public BoundingVolume { 00032 public: 00033 INLINE_MATHUTIL GeometricBoundingVolume(); 00034 00035 PUBLISHED: 00036 INLINE_MATHUTIL bool extend_by(const GeometricBoundingVolume *vol); 00037 INLINE_MATHUTIL bool extend_by(const LPoint3f &point); 00038 00039 // It might be nice to make these template member functions so we 00040 // could have true STL-style first/last iterators, but that's 00041 // impossible for virtual functions. 00042 INLINE_MATHUTIL bool around(const GeometricBoundingVolume **first, 00043 const GeometricBoundingVolume **last); 00044 INLINE_MATHUTIL bool around(const LPoint3f *first, 00045 const LPoint3f *last); 00046 00047 INLINE_MATHUTIL int contains(const GeometricBoundingVolume *vol) const; 00048 INLINE_MATHUTIL int contains(const LPoint3f &point) const; 00049 INLINE_MATHUTIL int contains(const LPoint3f &a, const LPoint3f &b) const; 00050 00051 virtual LPoint3f get_approx_center() const=0; 00052 virtual void xform(const LMatrix4f &mat)=0; 00053 00054 public: 00055 virtual const GeometricBoundingVolume *as_geometric_bounding_volume() const; 00056 00057 protected: 00058 // Some virtual functions to implement fundamental bounding 00059 // operations on points in 3-d space. 00060 00061 virtual bool extend_by_point(const LPoint3f &point); 00062 virtual bool around_points(const LPoint3f *first, 00063 const LPoint3f *last); 00064 virtual int contains_point(const LPoint3f &point) const; 00065 virtual int contains_lineseg(const LPoint3f &a, const LPoint3f &b) const; 00066 00067 00068 public: 00069 static TypeHandle get_class_type() { 00070 return _type_handle; 00071 } 00072 static void init_type() { 00073 BoundingVolume::init_type(); 00074 register_type(_type_handle, "GeometricBoundingVolume", 00075 BoundingVolume::get_class_type()); 00076 } 00077 virtual TypeHandle get_type() const { 00078 return get_class_type(); 00079 } 00080 virtual TypeHandle force_init_type() {init_type(); return get_class_type();} 00081 00082 private: 00083 static TypeHandle _type_handle; 00084 }; 00085 00086 #include "geometricBoundingVolume.I" 00087 00088 #endif