1 #ifndef MSP_GL_CAMERA_H_
2 #define MSP_GL_CAMERA_H_
4 #include <msp/datafile/objectloader.h>
10 class Camera: public Placeable
13 class Loader: public DataFile::ObjectLoader<Camera>
19 void aspect_ratio(float);
20 void depth_clip(float, float);
21 void field_of_view(float);
22 void look_at(float, float, float);
23 void look_direction(float, float, float);
24 void orthographic(float, float);
25 void position(float, float, float);
26 void up_direction(float, float, float);
30 Geometry::Angle<float> fov;
33 // Some compilers have "near" and "far" keywords
38 Geometry::Angle<float> rotate;
48 void set_field_of_view(const Geometry::Angle<float> &);
49 void set_orthographic(float, float);
50 void set_aspect_ratio(float);
51 void set_depth_clip(float, float);
52 void set_frustum_axis(float, float);
53 void set_frustum_rotation(const Geometry::Angle<float> &);
54 const Geometry::Angle<float> &get_field_of_view() const { return fov; }
55 bool is_orthographic() const { return fov==Geometry::Angle<float>::zero(); }
56 float get_orthographic_width() const { return height*aspect; }
57 float get_orthographic_height() const { return height; }
58 float get_aspect_ratio() const { return aspect; }
59 float get_near_clip() const { return clip_near; }
60 float get_far_clip() const { return clip_far; }
61 const Geometry::Angle<float> &get_frustum_rotation() const { return rotate; }
63 void set_position(const Vector3 &);
64 void set_look_direction(const Vector3 &);
65 void look_at(const Vector3 &);
66 void set_up_direction(const Vector3 &);
67 const Vector3 &get_position() const { return position; }
68 const Vector3 &get_look_direction() const { return look_dir; }
69 const Vector3 &get_up_direction() const { return up_dir; }
71 virtual void set_matrix(const Matrix &m) { set_object_matrix(m); }
73 /** Sets the position and orientation of the camera from an object matrix. */
74 void set_object_matrix(const Matrix &);
76 /** Returns the view matrix, used to transform coordinates from world space
78 const Matrix &get_view_matrix() const { return view_matrix; }
80 /** Returns the object matrix, used to transform coordinates from eye space
82 const Matrix &get_object_matrix() const { return matrix; }
84 /** Returns the projection matrix. */
85 const Matrix &get_projection_matrix() const { return proj_matrix; }
87 Vector3 project(const Vector4 &) const;
88 Vector3 project(const Vector3 &) const;
89 Vector4 unproject(const Vector4 &) const;
90 Vector3 unproject(const Vector3 &) const;
93 void update_projection_matrix();
94 void update_object_matrix();