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