Stellarium  0.16.1
Frustum.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 _FRUSTUM_HPP_
22 #define _FRUSTUM_HPP_
23 
24 #include <vector>
25 #include "Plane.hpp"
26 #include "GeomMath.hpp"
27 
28 class Frustum
29 {
30 public:
31  enum Corner
32  {
33  NBL = 0, NBR, NTR, NTL,
34  FBL, FBR, FTR, FTL,
35  CORNERCOUNT
36  };
37 
38  enum FrustumPlane
39  {
40  NEARP = 0, FARP,
41  LEFT, RIGHT,
42  BOTTOM, TOP,
43  PLANECOUNT
44  };
45 
46  enum
47  {
48  OUTSIDE, INTERSECT, INSIDE
49  };
50 
51  Frustum();
52  ~Frustum();
53 
54  void setCamInternals(float fov, float aspect, float zNear, float zFar)
55  {
56  this->fov = fov;
57  this->aspect = aspect;
58  this->zNear = zNear;
59  this->zFar = zFar;
60  }
61 
62  void calcFrustum(Vec3d p, Vec3d l, Vec3d u);
63  const Vec3f &getCorner(Corner corner) const;
64  const Plane &getPlane(FrustumPlane plane) const;
65  int pointInFrustum(const Vec3f &p);
66  int boxInFrustum(const AABBox &bbox);
67 
68  void drawFrustum() const;
69  void saveDrawingCorners();
70  void resetCorners();
71  float fov;
72  float aspect;
73  float zNear;
74  float zFar;
75  Mat4d m;
76  AABBox bbox;
77 
78  std::vector<Vec3f> drawCorners;
79  AABBox drawBbox;
80 
81  std::vector<Vec3f> corners;
82  std::vector<Plane*> planes;
83 
84 private:
85 
86 
87 };
88 
89 #endif
Definition: Plane.hpp:27
An axis-aligned bounding-box class.
Definition: GeomMath.hpp:31
This header contains useful classes for common geometric operations that are useful for 3D rendering...