diff options
Diffstat (limited to 'src/client/camera.cc')
-rw-r--r-- | src/client/camera.cc | 103 |
1 files changed, 58 insertions, 45 deletions
diff --git a/src/client/camera.cc b/src/client/camera.cc index 85929cc..f274e12 100644 --- a/src/client/camera.cc +++ b/src/client/camera.cc @@ -77,18 +77,71 @@ void shutdown() { } +void set_mode(Mode newmode) { + switch(newmode) { + case Track: + // switch camera to Track mode + mode = Track; + yaw_target = core::localplayer.controled->direction; + yaw_current = yaw_target; + pitch_target = pitch_track; + pitch_current = pitch_target; + distance = 0.4f; + break; + case Free: + // switch camera to Free mode + mode = Free; + yaw_target = core::localplayer.controled->direction; + yaw_current = yaw_target; + pitch_target = pitch_track; + pitch_current = pitch_target; + distance = 0.4f; + break; + case Overview: + // switch camera to Overview mode + mode = Overview; + x_offset = 0; + z_offset = 0; + distance = 20.0f; + default: + break; + } + +} + +void next_mode() +{ + + if (!core::localplayer.controled) { + set_mode(Overview); + return; + } + + switch(mode) { + case Free: + // switch camera to Track mode + set_mode(Track); + break; + case Track: + // switch camera to Free mode + set_mode(Free); + break; + default: + break; + } +} + void draw(float elapsed) { if (!core::localplayer.controled) { // switch the camera to Overview of the player is not controling anything if (mode != Overview) { - mode = Overview; - target = math::Vector3f(0,0,0); - x_offset = 0; - z_offset = 0; - distance = 20.0f; + set_mode(Overview); } } else { + if (mode == Overview) + set_mode(Track); + camera::target = core::localplayer.controled->location; } @@ -168,46 +221,6 @@ void key_down() } } -void next_mode() { - - if (!core::localplayer.controled) { - mode = Overview; - target = math::Vector3f(0,0,0); - x_offset = 0; - z_offset = 0; - distance = 20.0f; - } - - switch(mode) { - case Overview: - // switch camera to Track mode - mode = Track; - yaw_target = core::localplayer.controled->direction; - yaw_current = yaw_target; - pitch_target = pitch_track; - pitch_current = pitch_target; - distance = 0.4f; - break; - case Track: - // switch camera to Free mode - mode = Free; - yaw_target = core::localplayer.controled->direction; - 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; - x_offset = 0; - z_offset = 0; - distance = 20.0f; - default: - break; - } -} - } // namespace camera } // namespace client |