]> Dogcows Code - chaz/yoink/blob - src/moof/camera.hh
43e547163d9a0ff8206a3a91475b75d85050e0a4
[chaz/yoink] / src / moof / camera.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_CAMERA_HH_
11 #define _MOOF_CAMERA_HH_
12
13 /**
14 * \file camera.hh
15 * Classes related to managing the modelview and perspective matrices.
16 */
17
18 #include <moof/event.hh>
19 #include <moof/frustum.hh>
20 #include <moof/math.hh>
21 #include <moof/rigid_body.hh>
22
23
24 namespace moof {
25
26
27 class camera : public rigid_body3
28 {
29 public:
30
31 camera()
32 {
33 state_.init();
34 prev_state_.init();
35
36 quaternion_rotation_world_y(state_.orientation, SCALAR(0.0));
37 }
38
39 void position(const vector3& position);
40 void rotation(const quaternion& rotation);
41
42 void look_at(const vector3& point);
43
44 void projection(const matrix4& projection);
45 void projection(scalar fovy, scalar aspect, scalar near, scalar far);
46
47 const matrix4& modelview() const
48 {
49 return modelview_;
50 }
51
52 const matrix4& projection() const
53 {
54 return projection_;
55 }
56
57 const class frustum& frustum() const
58 {
59 return frustum_;
60 }
61
62 void upload_to_gl(scalar alpha = 0) const;
63
64 void update(scalar t, scalar dt);
65 void draw(scalar alpha = 0) const;
66 void handle_event(const event& event);
67
68 private:
69
70 void calculate(scalar alpha) const;
71
72 mutable matrix4 modelview_;
73 matrix4 projection_;
74 mutable class frustum frustum_;
75 };
76
77
78 } // namespace moof
79
80 #endif // _MOOF_CAMERA_HH_
81
This page took 0.03052 seconds and 3 git commands to generate.