diff options
author | Stijn Buys <ingar@osirion.org> | 2008-11-16 18:47:01 +0000 |
---|---|---|
committer | Stijn Buys <ingar@osirion.org> | 2008-11-16 18:47:01 +0000 |
commit | 44158ccfbe943b832c0e0bf9ce547212aa6c2b8b (patch) | |
tree | 3749d855271779b65283f86599c0faebdfdf4318 /src/render/camera.cc | |
parent | 315a8c2dff9b76ac5e1ebbef265f13ac19d65e3d (diff) |
camera zoom
Diffstat (limited to 'src/render/camera.cc')
-rw-r--r-- | src/render/camera.cc | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/render/camera.cc b/src/render/camera.cc index c136375..f97ea96 100644 --- a/src/render/camera.cc +++ b/src/render/camera.cc @@ -43,6 +43,7 @@ float Camera::pitch_target; float Camera::target_pitch; float Camera::distance; +float Camera::camera_zoom; void Camera::init() { @@ -59,6 +60,7 @@ void Camera::init() target_direction = 0.0f; distance = 0.4f; + camera_zoom = 1.0f; camera_mode = Overview; camera_previous_mode = Track; @@ -192,6 +194,13 @@ void Camera::view_previous() break; } } + +void Camera::set_zoom(float zoom) +{ + camera_zoom += zoom; + math::clamp(camera_zoom, 1.0f, 10.0f); +} + void Camera::frame(float seconds) { math::Axis target_axis; @@ -245,6 +254,8 @@ void Camera::frame(float seconds) if (mode() == Track) { + distance *= camera_zoom; + float cosangle; // cosine of an angle float angle; // angle in radians math::Vector3f n; // normal of a plane @@ -297,7 +308,7 @@ void Camera::frame(float seconds) pitch_current = degrees360f(pitch_current - d * seconds); camera_axis.change_pitch(pitch_current); - distance = 1.5f * core::localcontrol()->radius(); + distance = 1.5f * core::localcontrol()->radius() * camera_zoom; } else if (mode() == Cockpit) { |