X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fgame%2Fcamera.h;h=e981afcd3b2e85dfaf4d34d8d5f6ce65413e27b8;hb=239cd38de0ddbb5931151523530a5e7272e16f7f;hp=1e8efdd5e85527b536e6d9d87bbcca1f8afedf59;hpb=f298027c2042b63cec903c98dfc97e792a4f923f;p=libs%2Fgame.git diff --git a/source/game/camera.h b/source/game/camera.h index 1e8efdd..e981afc 100644 --- a/source/game/camera.h +++ b/source/game/camera.h @@ -4,52 +4,44 @@ #include #include #include "component.h" +#include "mspgame_api.h" +#include "setups.h" namespace Msp::Game { -enum class CameraScaling +struct CameraData { - ORIGINAL_SIZE, - SCALE_TO_FIT, - SCALE_TO_COVER, - STRETCH_TO_FIT -}; + Geometry::Angle fov_y; + LinAl::Vector size; + float height; + float near_clip; + float far_clip; -struct CameraSetup -{ - Geometry::Angle field_of_view_y = Geometry::Angle::from_degrees(60); - LinAl::Vector size = { 16.0f/9.0f, 1.0f }; - float near_clip = 0.1f; - float far_clip = 100.0f; - CameraScaling scaling = CameraScaling::SCALE_TO_FIT; - std::string sequence_name; + bool is_orthographic() const { return fov_y==Geometry::Angle::zero(); } + Geometry::Angle get_fov_horizontal() const { return Geometry::atan(tan(fov_y/2.0f)*get_aspect())*2.0f; } + float get_aspect() const { return size.x/size.y; } }; -class Camera: public Component +class MSPGAME_API Camera: public BufferedComponent { public: using Setup = CameraSetup; private: const Setup &setup; - Geometry::Angle fov_y; - LinAl::Vector size; - float height; - float near_clip; - float far_clip; public: Camera(Handle, const Setup &); void set_field_of_view(Geometry::Angle, float); void set_size(const LinAl::Vector &); - bool is_orthographic() const { return fov_y==Geometry::Angle::zero(); } - Geometry::Angle get_fov_vertical() const { return fov_y; } - Geometry::Angle get_fov_horizontal() const { return Geometry::atan(tan(fov_y/2.0f)*get_aspect())*2.0f; } - const LinAl::Vector &get_size() const { return size; } - float get_aspect() const { return size.x/size.y; } - float get_near_clip() const { return near_clip; } - float get_far_clip() const { return far_clip; } + bool is_orthographic() const { return read().is_orthographic(); } + Geometry::Angle get_fov_vertical() const { return read().fov_y; } + Geometry::Angle get_fov_horizontal() const { return read().get_fov_horizontal(); } + const LinAl::Vector &get_size() const { return read().size; } + float get_aspect() const { return read().get_aspect(); } + float get_near_clip() const { return read().near_clip; } + float get_far_clip() const { return read().far_clip; } CameraScaling get_scaling() const { return setup.scaling; } const std::string &get_sequence_name() const { return setup.sequence_name; } };