00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef BOUNDINGSPHERE_H
00020 #define BOUNDINGSPHERE_H
00021
00022 #include <pandabase.h>
00023
00024 #include "finiteBoundingVolume.h"
00025
00026
00027
00028
00029
00030
00031
00032 class EXPCL_PANDA BoundingSphere : public FiniteBoundingVolume {
00033 PUBLISHED:
00034 INLINE_MATHUTIL BoundingSphere();
00035 INLINE_MATHUTIL BoundingSphere(const LPoint3f ¢er, float radius);
00036
00037 public:
00038 virtual BoundingVolume *make_copy() const;
00039
00040 virtual LPoint3f get_min() const;
00041 virtual LPoint3f get_max() const;
00042
00043 virtual LPoint3f get_approx_center() const;
00044 virtual void xform(const LMatrix4f &mat);
00045
00046 virtual void output(ostream &out) const;
00047
00048 PUBLISHED:
00049 INLINE_MATHUTIL const LPoint3f &get_center() const;
00050 INLINE_MATHUTIL float get_radius() const;
00051
00052 protected:
00053 virtual bool extend_other(BoundingVolume *other) const;
00054 virtual bool around_other(BoundingVolume *other,
00055 const BoundingVolume **first,
00056 const BoundingVolume **last) const;
00057 virtual int contains_other(const BoundingVolume *other) const;
00058
00059
00060 virtual bool extend_by_point(const LPoint3f &point);
00061 virtual bool extend_by_sphere(const BoundingSphere *sphere);
00062 virtual bool extend_by_hexahedron(const BoundingHexahedron *hexahedron);
00063 bool extend_by_finite(const FiniteBoundingVolume *volume);
00064
00065 virtual bool around_points(const LPoint3f *first,
00066 const LPoint3f *last);
00067 virtual bool around_spheres(const BoundingVolume **first,
00068 const BoundingVolume **last);
00069 virtual bool around_hexahedrons(const BoundingVolume **first,
00070 const BoundingVolume **last);
00071 bool around_finite(const BoundingVolume **first,
00072 const BoundingVolume **last);
00073
00074 virtual int contains_point(const LPoint3f &point) const;
00075 virtual int contains_lineseg(const LPoint3f &a, const LPoint3f &b) const;
00076 virtual int contains_hexahedron(const BoundingHexahedron *hexahedron) const;
00077 virtual int contains_sphere(const BoundingSphere *sphere) const;
00078 virtual int contains_line(const BoundingLine *line) const;
00079
00080 private:
00081 LPoint3f _center;
00082 float _radius;
00083
00084
00085 public:
00086 static TypeHandle get_class_type() {
00087 return _type_handle;
00088 }
00089 static void init_type() {
00090 FiniteBoundingVolume::init_type();
00091 register_type(_type_handle, "BoundingSphere",
00092 FiniteBoundingVolume::get_class_type());
00093 }
00094 virtual TypeHandle get_type() const {
00095 return get_class_type();
00096 }
00097 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00098
00099 private:
00100 static TypeHandle _type_handle;
00101
00102 friend class BoundingHexahedron;
00103 };
00104
00105 #include "boundingSphere.I"
00106
00107 #endif