From 5d166c464a2441c4baa1ce1dbc090b4c695a85d6 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sat, 20 Oct 2007 11:03:53 +0000 Subject: Modified free camera behaviour --- src/client/camera.cc | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) (limited to 'src/client') diff --git a/src/client/camera.cc b/src/client/camera.cc index ca60d18..1b4255f 100644 --- a/src/client/camera.cc +++ b/src/client/camera.cc @@ -28,16 +28,23 @@ float distance = 2.0f; // distance from the eye to the target void draw(float elapsed) { - // adjust yaw target - float yaw_target = game::ship.yaw - yaw_offset; + float yaw_target; + if (mode == Track) { + // track the target + yaw_target = game::ship.yaw - yaw_offset; + } else { + yaw_target = - yaw_offset; + } + + // adjust yaw float d = degreesf(yaw - yaw_target); - yaw = degreesf( yaw - d * elapsed); + yaw = degreesf( yaw - d * elapsed) ; // adjust pitch target float pitch_target = 0.0f - pitch_offset; - d= degreesf(pitch - pitch_target); + d = degreesf(pitch - pitch_target); pitch = degreesf( pitch - d *elapsed); - + /* gl::translate(distance, 0.0, 0.0); gl::rotate(-pitch,0, 0, 1.0 ); @@ -50,7 +57,8 @@ void draw(float elapsed) gl::rotate(-yaw, 0, 1.0f, 0); break; case Track: - gl::translate(1+distance* GAMESCALE, -0.5f* GAMESCALE, 0.0f); + //gl::translate(1+distance* GAMESCALE, -0.5f* GAMESCALE, 0.0f); + gl::translate(1+ 2* GAMESCALE, -0.5f* GAMESCALE, 0.0f); gl::rotate(-pitch, 0, 0, 1.0f); gl::rotate(-yaw, 0, 1.0f, 0); break; @@ -76,14 +84,16 @@ void rotate_left() void rotate_up() { if (mode == Free ) { - pitch_offset = degreesf( pitch_offset + offset_inc); + pitch_offset = pitch_offset + offset_inc; + if (pitch_offset > 90.0f) pitch_offset = 90.0f; } } void rotate_down() { if (mode == Free ) { - pitch_offset = degreesf( pitch_offset - offset_inc); + pitch_offset = pitch_offset - offset_inc; + if (pitch_offset < -90.0f) pitch_offset = -90.0f; } } -- cgit v1.2.3