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