Panda3D
 All Classes Functions Variables Enumerations
boundingBox.h
1 // Filename: boundingBox.h
2 // Created by: drose (31May07)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef BOUNDINGBOX_H
16 #define BOUNDINGBOX_H
17 
18 #include "pandabase.h"
19 
20 #include "finiteBoundingVolume.h"
21 #include "plane.h"
22 
23 ////////////////////////////////////////////////////////////////////
24 // Class : BoundingBox
25 // Description : An axis-aligned bounding box; that is, a minimum and
26 // maximum coordinate triple.
27 //
28 // This box is always axis-aligned. If you need a more
29 // general bounding box, try BoundingHexahedron.
30 ////////////////////////////////////////////////////////////////////
31 class EXPCL_PANDA_MATHUTIL BoundingBox : public FiniteBoundingVolume {
32 PUBLISHED:
33  INLINE_MATHUTIL BoundingBox();
34  INLINE_MATHUTIL BoundingBox(const LPoint3 &min, const LPoint3 &max);
35  ALLOC_DELETED_CHAIN(BoundingBox);
36 
37 public:
38  virtual BoundingVolume *make_copy() const;
39 
40  virtual LPoint3 get_min() const;
41  virtual LPoint3 get_max() const;
42  virtual PN_stdfloat get_volume() const;
43 
44  virtual LPoint3 get_approx_center() const;
45  virtual void xform(const LMatrix4 &mat);
46 
47  virtual void output(ostream &out) const;
48 
49 PUBLISHED:
50  INLINE_MATHUTIL int get_num_points() const;
51  INLINE_MATHUTIL LPoint3 get_point(int n) const;
52  MAKE_SEQ(get_points, get_num_points, get_point);
53  INLINE_MATHUTIL int get_num_planes() const;
54  INLINE_MATHUTIL LPlane get_plane(int n) const;
55  MAKE_SEQ(get_planes, get_num_planes, get_plane);
56 
57 public:
58  // Inline accessors for speed.
59  INLINE_MATHUTIL const LPoint3 &get_minq() const;
60  INLINE_MATHUTIL const LPoint3 &get_maxq() const;
61 
62 public:
63  virtual const BoundingBox *as_bounding_box() const;
64 
65 protected:
66  virtual bool extend_other(BoundingVolume *other) const;
67  virtual bool around_other(BoundingVolume *other,
68  const BoundingVolume **first,
69  const BoundingVolume **last) const;
70  virtual int contains_other(const BoundingVolume *other) const;
71 
72 
73  virtual bool extend_by_point(const LPoint3 &point);
74  virtual bool extend_by_box(const BoundingBox *box);
75  virtual bool extend_by_finite(const FiniteBoundingVolume *volume);
76 
77  virtual bool around_points(const LPoint3 *first,
78  const LPoint3 *last);
79  virtual bool around_finite(const BoundingVolume **first,
80  const BoundingVolume **last);
81 
82  virtual int contains_point(const LPoint3 &point) const;
83  virtual int contains_lineseg(const LPoint3 &a, const LPoint3 &b) const;
84  virtual int contains_hexahedron(const BoundingHexahedron *hexahedron) const;
85  virtual int contains_box(const BoundingBox *box) const;
86  virtual int contains_line(const BoundingLine *line) const;
87  virtual int contains_plane(const BoundingPlane *plane) const;
88  virtual int contains_finite(const FiniteBoundingVolume *volume) const;
89 
90 private:
91  LPoint3 _min;
92  LPoint3 _max;
93 
94  static const int plane_def[6][3];
95 
96 public:
97  static TypeHandle get_class_type() {
98  return _type_handle;
99  }
100  static void init_type() {
101  FiniteBoundingVolume::init_type();
102  register_type(_type_handle, "BoundingBox",
103  FiniteBoundingVolume::get_class_type());
104  }
105  virtual TypeHandle get_type() const {
106  return get_class_type();
107  }
108  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
109 
110 private:
111  static TypeHandle _type_handle;
112 
113  friend class BoundingSphere;
114 };
115 
116 #include "boundingBox.I"
117 
118 #endif
An axis-aligned bounding box; that is, a minimum and maximum coordinate triple.
Definition: boundingBox.h:31
virtual const BoundingBox * as_bounding_box() const
Virtual downcast method.
This defines a bounding sphere, consisting of a center and a radius.
This is a three-component point in space (as opposed to a three-component vector, which represents a ...
Definition: lpoint3.h:99
This funny bounding volume is an infinite plane that divides space into two regions: the part behind ...
Definition: boundingPlane.h:31
This is an abstract class for any volume in any sense which can be said to define the locality of ref...
This is a 4-by-4 transform matrix.
Definition: lmatrix.h:451
A special kind of GeometricBoundingVolume that is known to be finite.
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85
This defines a bounding convex hexahedron.
This funny bounding volume is an infinite line with no thickness and extending to infinity in both di...
Definition: boundingLine.h:33