]> git.tdb.fi Git - libs/gl.git/blob - source/camera.h
Remove some methods that have been deprecated for a long while
[libs/gl.git] / source / camera.h
1 #ifndef MSP_GL_CAMERA_H_
2 #define MSP_GL_CAMERA_H_
3
4 #include "matrix.h"
5 #include "vector.h"
6
7 namespace Msp {
8 namespace GL {
9
10 class Camera
11 {
12 private:
13         Geometry::Angle<float> fov;
14         float height;
15         float aspect;
16         // Some compilers have "near" and "far" keywords
17         float clip_near;
18         float clip_far;
19         float frustum_x;
20         float frustum_y;
21         Geometry::Angle<float> rotate;
22         Vector3 position;
23         Vector3 look_dir;
24         Vector3 up_dir;
25         Matrix view_matrix;
26         Matrix object_matrix;
27         Matrix proj_matrix;
28
29 public:
30         Camera();
31
32         void set_field_of_view(const Geometry::Angle<float> &);
33         void set_orthographic(float, float);
34         void set_aspect(float);
35         void set_depth_clip(float, float);
36         void set_frustum_axis(float, float);
37         void set_frustum_rotation(const Geometry::Angle<float> &);
38         const Geometry::Angle<float> &get_field_of_view() const { return fov; }
39         bool is_orthographic() const { return fov==Geometry::Angle<float>::zero(); }
40         float get_orthographic_width() const { return height*aspect; }
41         float get_orthographic_height() const { return height; }
42         float get_aspect() const { return aspect; }
43         float get_near_clip() const { return clip_near; }
44         float get_far_clip() const { return clip_far; }
45         const Geometry::Angle<float> &get_frustum_rotation() const { return rotate; }
46
47         void set_position(const Vector3 &);
48         void set_look_direction(const Vector3 &);
49         void look_at(const Vector3 &);
50         void set_up_direction(const Vector3 &);
51         const Vector3 &get_position() const { return position; }
52         const Vector3 &get_look_direction() const { return look_dir; }
53         const Vector3 &get_up_direction() const { return up_dir; }
54
55         /** Returns the view matrix, used to transform coordinates from world space
56         to eye space. */
57         const Matrix &get_view_matrix() const { return view_matrix; }
58
59         /** Returns the object matrix, used to transform coordinates from eye space
60         to world space. */
61         const Matrix &get_object_matrix() const { return object_matrix; }
62
63         /** Returns the projection matrix. */
64         const Matrix &get_projection_matrix() const { return proj_matrix; }
65
66         Vector3 project(const Vector4 &) const;
67         Vector3 project(const Vector3 &) const;
68         Vector4 unproject(const Vector4 &) const;
69         Vector3 unproject(const Vector3 &) const;
70
71         void apply() const;
72
73 private:
74         void update_projection_matrix();
75         void update_object_matrix();
76 };
77
78 } // namespace GL
79 } // namespcae Msp
80
81 #endif