Add orthographic & window cameras
This commit is contained in:
parent
fd26d8a3a3
commit
4d6f5d6f85
2 changed files with 40 additions and 0 deletions
|
|
@ -3,6 +3,7 @@
|
|||
#include <psemek/geom/vector.hpp>
|
||||
#include <psemek/geom/point.hpp>
|
||||
#include <psemek/geom/matrix.hpp>
|
||||
#include <psemek/geom/box.hpp>
|
||||
|
||||
namespace psemek::geom
|
||||
{
|
||||
|
|
@ -31,6 +32,24 @@ namespace psemek::geom
|
|||
virtual ~camera() = default;
|
||||
};
|
||||
|
||||
struct window_camera
|
||||
: camera
|
||||
{
|
||||
float width, height;
|
||||
|
||||
matrix<float, 4, 4> view() const override;
|
||||
matrix<float, 4, 4> projection() const override;
|
||||
};
|
||||
|
||||
struct orthographic_camera
|
||||
: camera
|
||||
{
|
||||
geom::box<float_t, 3> box;
|
||||
|
||||
matrix<float, 4, 4> view() const override;
|
||||
matrix<float, 4, 4> projection() const override;
|
||||
};
|
||||
|
||||
struct perspective_camera
|
||||
: camera
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
#include <psemek/geom/camera.hpp>
|
||||
#include <psemek/geom/gauss.hpp>
|
||||
#include <psemek/geom/orthographic.hpp>
|
||||
#include <psemek/geom/perspective.hpp>
|
||||
#include <psemek/geom/translation.hpp>
|
||||
#include <psemek/geom/rotation.hpp>
|
||||
|
|
@ -68,6 +69,26 @@ namespace psemek::geom
|
|||
return p;
|
||||
}
|
||||
|
||||
matrix<float, 4, 4> window_camera::view() const
|
||||
{
|
||||
return matrix<float, 4, 4>::identity();
|
||||
}
|
||||
|
||||
matrix<float, 4, 4> window_camera::projection() const
|
||||
{
|
||||
return orthographic<float, 3>({{ {0.f, width}, {height, 0.f}, {-1.f, 1.f} }}).homogeneous_matrix();
|
||||
}
|
||||
|
||||
matrix<float, 4, 4> orthographic_camera::view() const
|
||||
{
|
||||
return matrix<float, 4, 4>::identity();
|
||||
}
|
||||
|
||||
matrix<float, 4, 4> orthographic_camera::projection() const
|
||||
{
|
||||
return orthographic<float, 3>(box).homogeneous_matrix();
|
||||
}
|
||||
|
||||
matrix<float, 4, 4> perspective_camera::projection() const
|
||||
{
|
||||
return perspective<float, 3>(fov_x, fov_y, near_clip, far_clip).homogeneous_matrix();
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue