1 #ifndef MSP_GAME_CAMERA_H_
2 #define MSP_GAME_CAMERA_H_
4 #include <msp/geometry/angle.h>
5 #include <msp/linal/vector.h>
10 enum class CameraScaling
20 Geometry::Angle<float> field_of_view_y = Geometry::Angle<float>::from_degrees(60);
21 LinAl::Vector<float, 2> size = { 16.0f/9.0f, 1.0f };
22 float near_clip = 0.1f;
23 float far_clip = 100.0f;
24 CameraScaling scaling = CameraScaling::SCALE_TO_FIT;
25 std::string sequence_name;
28 class Camera: public Component
31 using Setup = CameraSetup;
35 Geometry::Angle<float> fov_y;
36 LinAl::Vector<float, 2> size;
42 Camera(Handle<Entity>, const Setup &);
44 void set_field_of_view(Geometry::Angle<float>, float);
45 void set_size(const LinAl::Vector<float, 2> &);
46 bool is_orthographic() const { return fov_y==Geometry::Angle<float>::zero(); }
47 Geometry::Angle<float> get_fov_vertical() const { return fov_y; }
48 Geometry::Angle<float> get_fov_horizontal() const { return Geometry::atan(tan(fov_y/2.0f)*get_aspect())*2.0f; }
49 const LinAl::Vector<float, 2> &get_size() const { return size; }
50 float get_aspect() const { return size.x/size.y; }
51 float get_near_clip() const { return near_clip; }
52 float get_far_clip() const { return far_clip; }
53 CameraScaling get_scaling() const { return setup.scaling; }
54 const std::string &get_sequence_name() const { return setup.sequence_name; }
57 } // namespace Msp::Game