X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fcamera.cpp;h=ba8ff718d136744dbff8261d73b887a21258ef76;hb=e3561c5c4d0b2caf00a0e50ce85c11a9fb62aa72;hp=6cbcf6f492680f537559206d311049f26af5f1db;hpb=50a0c7fd661fe6bfa3f929ad66e47cfab4a0fb87;p=libs%2Fgl.git diff --git a/source/camera.cpp b/source/camera.cpp index 6cbcf6f4..ba8ff718 100644 --- a/source/camera.cpp +++ b/source/camera.cpp @@ -56,6 +56,12 @@ void Camera::set_frustum_axis(float x, float y) update_projection_matrix(); } +void Camera::set_frustum_rotation(const Geometry::Angle &r) +{ + rotate = r; + update_projection_matrix(); +} + void Camera::set_position(const Vector3 &p) { position = p; @@ -105,7 +111,7 @@ void Camera::apply() const void Camera::update_projection_matrix() { - float frustum_h = tan(fov/2.0f)*clip_near; + float frustum_h = (fov!=Geometry::Angle::zero() ? tan(fov/2.0f)*clip_near : height/2); float frustum_w = frustum_h*aspect; float left = frustum_w*(frustum_x-1.0f); float right = frustum_w*(frustum_x+1.0f); @@ -115,6 +121,7 @@ void Camera::update_projection_matrix() proj_matrix = Matrix::frustum(left, right, bottom, top, clip_near, clip_far); else proj_matrix = Matrix::ortho(left, right, bottom, top, clip_near, clip_far); + proj_matrix = Matrix::rotation(rotate, Vector3(0, 0, 1))*proj_matrix; } void Camera::update_object_matrix()