Stellarium  0.90.0
Polyhedron.hpp
1 /*
2  * Stellarium Scenery3d Plug-in
3  *
4  * Copyright (C) 2011 Simon Parzer, Peter Neubauer, Georg Zotti, Andrei Borza
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 
24 #ifndef _POLYHEDRON_HPP_
25 #define _POLYHEDRON_HPP_
26 
27 #include "Frustum.hpp"
28 #include "Plane.hpp"
29 #include "SPolygon.hpp"
30 
32 {
33 public:
34  Polyhedron();
35  ~Polyhedron();
36 
38  QVector<SPolygon> polygons;
39 
41  void add(const Frustum& f);
43  void add(const SPolygon& p);
45  void add(const QVector<Vec3f> &verts, const Vec3f &normal);
46 
48  void intersect(const AABBox &bb);
50  void intersect(const Plane &p);
52  void extrude(const Vec3f &dir, const AABBox &bb);
54  void clear();
56  int getVertCount() const;
58  const QVector<Vec3f> &getVerts() const;
60  void makeUniqueVerts();
61 
62  void render() const;
63 
66  //Box debugBox;
67 private:
69  QVector<Vec3f> uniqueVerts;
71  void addUniqueVert(const Vec3f &v);
73  void intersect(const Line &l, const Vec3f &min, const Vec3f &max, QVector<Vec3f> &vertices);
75  bool clip(float p, float q, float &u1, float &u2) const;
76 };
77 
78 #endif
void clear()
Clear up.
void makeUniqueVerts()
Makes the unique vertices vector.
QVector< SPolygon > polygons
Vector holding all polygons of this polyhedron.
Definition: Polyhedron.hpp:38
A simple line class, identified by a point and a direction vector.
Definition: GeomMath.hpp:99
void extrude(const Vec3f &dir, const AABBox &bb)
Extrude each point of this polyhedron towards direction until we hit the bounding box...
This implementation is based on Stingl&#39;s Robust Hard Shadows.
Definition: Polyhedron.hpp:31
Definition: Plane.hpp:27
void intersect(const AABBox &bb)
Intersect this polyhedron with the specified bounding box.
const QVector< Vec3f > & getVerts() const
Returns the unique vertices.
int getVertCount() const
Returns the unique vertices count.
void add(const Frustum &f)
Adds a frustum to this polyhedron.
A templatized 3d vector compatible with openGL.
Definition: VecMath.hpp:33
An axis-aligned bounding-box class.
Definition: GeomMath.hpp:31