Stellarium 0.14.3
AABB.hpp
1 /*
2  * Stellarium Scenery3d Plug-in
3  *
4  * Copyright (C) 2011-2015 Simon Parzer, Peter Neubauer, Georg Zotti, Andrei Borza, Florian Schaukowitsch
5  *
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.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
19  */
20 
21 #ifndef _AABB_HPP_
22 #define _AABB_HPP_
23 
24 #include <vector>
25 #include "VecMath.hpp"
26 
28 class Box
29 {
30 public:
31  Box();
32 
33  Vec3f vertices[8];
34 
36  void transform(const QMatrix4x4 &tf);
38  void render() const;
39 };
40 
42 class AABB
43 {
44 public:
45  enum Corner
46  {
47  MinMinMin = 0, MaxMinMin, MaxMaxMin, MinMaxMin,
48  MinMinMax, MaxMinMax, MaxMaxMax, MinMaxMax,
49  CORNERCOUNT
50  };
51 
52  enum Plane
53  {
54  Front = 0, Back, Bottom, Top, Left, Right,
55  PLANECOUNT
56  };
57 
58  Vec3f min, max;
59 
61  AABB();
62  AABB(Vec3f min, Vec3f max);
63  ~AABB();
64 
66  void reset();
68  void resetToZero();
69 
71  void expand(const Vec3f& vec);
72 
73  Vec3f getCorner(Corner corner) const;
74 
76  Vec3f positiveVertex(Vec3f& normal) const;
77  Vec3f negativeVertex(Vec3f& normal) const;
78 
79  void render() const;
80 
82  Vec4f getEquation(AABB::Plane p) const;
84  Box toBox();
85 };
86 
87 #endif
void transform(const QMatrix4x4 &tf)
Transforms the vertices.
void expand(const Vec3f &vec)
Updates the bounding box to include the specified vertex.
AABB()
Creates an AABB with minimum vertex set to infinity and maximum vertex set to -infinity.
Vec4f getEquation(AABB::Plane p) const
Return the plane equation for specified plane as Vec4f.
Box toBox()
Returns a box object that represents the AABB.
Vec3f positiveVertex(Vec3f &normal) const
Used for frustum culling.
Definition: Plane.hpp:27
void reset()
Resets minimum to infinity and maximum to -infinity.
An axis-aligned bounding-box class.
Definition: AABB.hpp:42
void resetToZero()
Resets minimum and maximum to zero vectors.
A simple "box" class with 8 arbitrary vertices.
Definition: AABB.hpp:28
void render() const
Renders the box.