X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Frender%2Fcamera.h;h=ed81a9511b3fcd9640fa4170f5adf28c23091a34;hb=9e63512930bc7dace6dc169c65161961e5dcfcf6;hp=0dd599298b3baed315f6d647cd932150feaa2511;hpb=38712d8ecc57d043a2419ffbaeeb57f7a6586f14;p=libs%2Fgl.git diff --git a/source/render/camera.h b/source/render/camera.h index 0dd59929..ed81a951 100644 --- a/source/render/camera.h +++ b/source/render/camera.h @@ -8,6 +8,20 @@ namespace Msp { namespace GL { +/** +Represents a point of view in 3D space. + +A Camera provides two matrices. The view matrix is the inverse of the camera's +model matrix and transforms coordinates from world space to eye space (the +camera's object space). The projection matrix transforms coordinates from eye +space to clip space. + +Orientation of the Camera is determined by look direction and up direction. +Look direction corresponds to the negative Z axis direction in eye space. The +YZ plane of eye space is aligned to the plane formed by the look and up +directions. Setting the up direction to the opposite of gravity direction is +an easy way to keep the camera upright. +*/ class Camera: public Placeable { public: @@ -47,12 +61,26 @@ private: public: Camera(); + /** Sets the camera projection to perspective, characterised by the vertical + field of view. Horizontal FoV is computed with the aspect ratio. */ void set_field_of_view(const Geometry::Angle &); + + /** Sets the camera projection to orthogonal, characterized by the size of + the projection region. */ void set_orthographic(float, float); + void set_aspect_ratio(float); void set_depth_clip(float, float); + + /** Sets the direction of the frustum axis, which corresponds to the center + of the screen. The offset is expressed in terms of the neutral frustum such + that -1 is the left or bottom edge and 1 is the right or top edge. */ void set_frustum_axis(float, float); + + /** Apply a rotation to the view frustum after projection. This can be used + with rotated displayes without affecting the camera's orientation. */ void set_frustum_rotation(const Geometry::Angle &); + const Geometry::Angle &get_field_of_view() const { return fov; } bool is_orthographic() const { return fov==Geometry::Angle::zero(); } float get_orthographic_width() const { return height*aspect; } @@ -91,6 +119,7 @@ public: Vector4 unproject(const Vector4 &) const; Vector3 unproject(const Vector3 &) const; + /** Returns a ProgramData object containing the camera matrices. */ const ProgramData &get_shader_data() const { return shdata; } private: