2
* $Id: SG_BBox.h,v 1.2 2004/05/21 09:21:15 kester Exp $
4
* ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
6
* This program is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License
8
* as published by the Free Software Foundation; either version 2
9
* of the License, or (at your option) any later version. The Blender
10
* Foundation also sells licenses for use in proprietary software under
11
* the Blender License. See http://www.blender.org/BL/ for information
14
* This program is distributed in the hope that it will be useful,
15
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
* GNU General Public License for more details.
19
* You should have received a copy of the GNU General Public License
20
* along with this program; if not, write to the Free Software Foundation,
21
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
24
* All rights reserved.
26
* The Original Code is: all of this file.
28
* Contributor(s): none yet.
30
* ***** END GPL/BL DUAL LICENSE BLOCK *****
37
#include "MT_Scalar.h"
38
#include "MT_Point3.h"
39
#include "MT_Vector3.h"
40
#include "MT_Transform.h"
48
* Holds the minimum and maximum axis aligned points of a node's bounding box,
49
* in world coordinates.
56
typedef enum { INSIDE, INTERSECT, OUTSIDE } intersect;
58
SG_BBox(const MT_Point3 &min, const MT_Point3 &max);
59
SG_BBox(const SG_BBox &other, const MT_Transform &world);
60
SG_BBox(const SG_BBox &other);
64
* Enlarges the bounding box to contain the specified point.
66
SG_BBox& operator +=(const MT_Point3 &point);
68
* Enlarges the bounding box to contain the specified bound box.
70
SG_BBox& operator +=(const SG_BBox &bbox);
72
SG_BBox operator + (const SG_BBox &bbox2) const;
75
* Translates the bounding box.
77
void translate(const MT_Vector3 &dx);
79
* Scales the bounding box about the optional point.
81
void scale(const MT_Vector3 &size, const MT_Point3 &point = MT_Point3(0., 0., 0.));
83
SG_BBox transform(const MT_Transform &world) const;
85
* Computes the volume of the bounding box.
87
MT_Scalar volume() const;
90
* Test if the given point is inside this bounding box.
92
bool inside(const MT_Point3 &point) const;
95
* Test if the given bounding box is inside this bounding box.
97
bool inside(const SG_BBox &other) const;
100
* Test if the given bounding box is outside this bounding box.
102
bool outside(const SG_BBox &other) const;
105
* Test if the given bounding box intersects this bounding box.
107
bool intersects(const SG_BBox &other) const;
110
* Test the given bounding box with this bounding box.
112
intersect test(const SG_BBox &other) const;
115
* Get the eight points that define this bounding box.
117
* @param world a world transform to apply to the produced points bounding box.
119
void get(MT_Point3 *box, const MT_Transform &world) const;
121
* Get the eight points that define this axis aligned bounding box.
122
* This differs from SG_BBox::get() in that the produced box will be world axis aligned.
123
* The maximum & minimum local points will be transformed *before* splitting to 8 points.
124
* @param world a world transform to be applied.
126
void getaa(MT_Point3 *box, const MT_Transform &world) const;
128
void split(SG_BBox &left, SG_BBox &right) const;
130
friend class SG_Tree;
134
#endif /* __SG_BBOX_H__ */