1 #ifndef MSP_GAME_CAMERA_H_
2 #define MSP_GAME_CAMERA_H_
4 #include <msp/geometry/angle.h>
5 #include <msp/linal/vector.h>
7 #include "mspgame_api.h"
14 Geometry::Angle<float> fov_y;
15 LinAl::Vector<float, 2> size;
20 bool is_orthographic() const { return fov_y==Geometry::Angle<float>::zero(); }
21 Geometry::Angle<float> get_fov_horizontal() const { return Geometry::atan(tan(fov_y/2.0f)*get_aspect())*2.0f; }
22 float get_aspect() const { return size.x/size.y; }
25 class MSPGAME_API Camera: public BufferedComponent<CameraData>
28 using Setup = CameraSetup;
34 Camera(Handle<Entity>, const Setup &);
36 void set_field_of_view(Geometry::Angle<float>, float);
37 void set_size(const LinAl::Vector<float, 2> &);
38 bool is_orthographic() const { return read().is_orthographic(); }
39 Geometry::Angle<float> get_fov_vertical() const { return read().fov_y; }
40 Geometry::Angle<float> get_fov_horizontal() const { return read().get_fov_horizontal(); }
41 const LinAl::Vector<float, 2> &get_size() const { return read().size; }
42 float get_aspect() const { return read().get_aspect(); }
43 float get_near_clip() const { return read().near_clip; }
44 float get_far_clip() const { return read().far_clip; }
45 CameraScaling get_scaling() const { return setup.scaling; }
46 const std::string &get_sequence_name() const { return setup.sequence_name; }
49 } // namespace Msp::Game