diff options
Diffstat (limited to 'src/client')
-rw-r--r-- | src/client/camera.cc | 26 | ||||
-rw-r--r-- | src/client/camera.h | 6 |
2 files changed, 25 insertions, 7 deletions
diff --git a/src/client/camera.cc b/src/client/camera.cc index 03eff83..c195d20 100644 --- a/src/client/camera.cc +++ b/src/client/camera.cc @@ -18,6 +18,7 @@ namespace client Camera::Camera() { + pitch_overview = -60.0f; pitch_track = -15.0f; offset_inc = 5.0f; @@ -61,6 +62,11 @@ void Camera::draw(float elapsed) gl::rotate(-pitch_current, 0, 0, 1.0f); gl::rotate(-yaw_current, 0, 1.0f, 0); break; + case Overview: + gl::translate(-distance/2, -distance, 0.0f); + gl::rotate(-pitch_current, 0, 0, 1.0f); + gl::rotate(-yaw_current, 0, 1.0f, 0); + break; default: break; } @@ -68,21 +74,21 @@ void Camera::draw(float elapsed) void Camera::rotate_right() { - if (mode == Free ) { + if (mode == Free || mode == Overview) { yaw_target = degrees360f( yaw_target + offset_inc); } } void Camera::rotate_left() { - if (mode == Free ) { + if (mode == Free || mode == Overview) { yaw_target = degrees360f( yaw_target - offset_inc); } } void Camera::rotate_up() { - if (mode == Free ) { + if (mode == Free) { pitch_target = pitch_target - offset_inc; if (pitch_target < -90.0f) pitch_target = -90.0f; } @@ -90,7 +96,7 @@ void Camera::rotate_up() void Camera::rotate_down() { - if (mode == Free ) { + if (mode == Free) { pitch_target = pitch_target + offset_inc; if (pitch_target > 90.0f) pitch_target = 90.0f; } @@ -98,13 +104,14 @@ void Camera::rotate_down() void Camera::nextmode() { switch(mode) { - case Free: + case Overview: // switch camera to Track mode mode = Track; yaw_target = game::ship.yaw(); yaw_current = yaw_target; pitch_target = pitch_track; pitch_current = pitch_target; + distance = 0.4f; break; case Track: // switch camera to Free mode @@ -113,7 +120,16 @@ void Camera::nextmode() { yaw_current = yaw_target; pitch_target = pitch_track; pitch_current = pitch_target; + distance = 0.4f; break; + case Free: + // switch camera to Overview mode + mode = Overview; + yaw_target = 0; + yaw_current = 0; + pitch_target = pitch_overview; + pitch_current = pitch_target; + distance = 10.0f; default: break; } diff --git a/src/client/camera.h b/src/client/camera.h index c363f91..ec8d4d6 100644 --- a/src/client/camera.h +++ b/src/client/camera.h @@ -22,7 +22,7 @@ public: ~Camera(); /// enum indicating the camera mode - enum Mode {Free, Track}; + enum Mode {Free, Track, Overview}; /// draw the OpenGL camera transformation void draw(float elapsed); @@ -57,8 +57,10 @@ protected: float yaw_current; /// current pitch, angle in XY, positive is looking up float pitch_current; - /// default tracking pitch + /// default pitch in mode::Track float pitch_track; + /// default pitch in mode::Overview + float pitch_overview; /// default offset increment float offset_inc; }; |