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