]> Dogcows Code - chaz/yoink/blob - src/moof/frustum.hh
pch support
[chaz/yoink] / src / moof / frustum.hh
1
2 /*] Copyright (c) 2009-2011, Charles McGarvey [*****************************
3 **] All rights reserved.
4 *
5 * Distributable under the terms and conditions of the 2-clause BSD license;
6 * see the file COPYING for a complete text of the license.
7 *
8 *****************************************************************************/
9
10 #ifndef _MOOF_FRUSTUM_HH_
11 #define _MOOF_FRUSTUM_HH_
12
13 #include <moof/math.hh>
14 #include <moof/plane.hh>
15
16
17 /**
18 * \file frustum.hh
19 * All things related to frustums!
20 */
21
22 namespace moof {
23
24
25 template <int D> class aabb;
26 template <int D> class sphere;
27
28 /**
29 * A six-sided volume for representing the space visible by a position looking
30 * outward.
31 */
32 class frustum
33 {
34 public:
35
36 enum collision
37 {
38 outside = 0,
39 inside = 1,
40 intersecting = 2
41 };
42
43 frustum() {}
44 frustum(const matrix4& modelview, const matrix4& projection)
45 {
46 init(modelview, projection);
47 }
48 frustum(const matrix4& modelview, scalar fovy, scalar aspect,
49 scalar abutting, scalar distant)
50 {
51 init(modelview, fovy, aspect, abutting, distant);
52 }
53
54 void init(const matrix4& modelview, const matrix4& projection);
55 void init(const matrix4& modelview, scalar fovy, scalar aspect,
56 scalar abutting, scalar distant);
57
58 collision contains(const aabb<3>& aabb) const;
59 collision contains(const sphere<3>& sphere) const;
60
61 private:
62
63 plane planes_[6]; // left, right, bottom, top, near, far
64 };
65
66
67 } // namespace moof
68
69 #endif // _MOOF_FRUSTUM_HH_
70
This page took 0.031372 seconds and 4 git commands to generate.