diff options
author | Stijn Buys <ingar@osirion.org> | 2007-10-21 15:16:27 +0000 |
---|---|---|
committer | Stijn Buys <ingar@osirion.org> | 2007-10-21 15:16:27 +0000 |
commit | 783545505aa51e4f908932fffb1f8362ad898d44 (patch) | |
tree | 84bb8738254d65057dd34f173a708ea0f3ef2fc3 /src/client/camera.cc | |
parent | f936192f3689e58f9c72e19dd6f736f6b2449906 (diff) |
Fixed camera
Added alpha blending to background
Diffstat (limited to 'src/client/camera.cc')
-rw-r--r-- | src/client/camera.cc | 61 |
1 files changed, 27 insertions, 34 deletions
diff --git a/src/client/camera.cc b/src/client/camera.cc index 1b4255f..42d686a 100644 --- a/src/client/camera.cc +++ b/src/client/camera.cc @@ -1,11 +1,9 @@ -/* camera.cc +/* client/camera.cc This file is part of the Osirion project and is distributed under the terms and conditions of the GNU General Public License version 2 */ #include "common/functions.h" -#include "common/osirion.h" - #include "game/game.h" #include "gl/osiriongl.h" @@ -14,51 +12,40 @@ namespace camera enum Mode {Free, Track}; Mode mode = Track; -const float track_pitch = 15.0f; // default tracking pitch +const float track_pitch = -15.0f; // default tracking pitch const float offset_inc = 5.0f; // default offset increment -float yaw = 90; // current yaw, angle in XZ plane -float yaw_offset = 0; // target offset, relative to target yaw +float yaw = 0; // current yaw, angle in XZ plane, positive is looking left +float yaw_target = 0; // target yaw -float pitch = -90; // current pitch, angle in XY -float pitch_offset = track_pitch; // target offset, relative to target pitch +float pitch = -45.0f; // current pitch, angle in XY, positive is looking up +float pitch_target = track_pitch; // target pitch -float distance = 2.0f; // distance from the eye to the target +float distance = 0.4f; // distance from the eye to the target void draw(float elapsed) { - float yaw_target; if (mode == Track) { - // track the target - yaw_target = game::ship.yaw - yaw_offset; - } else { - yaw_target = - yaw_offset; + yaw_target = game::ship.yaw; } // adjust yaw float d = degreesf(yaw - yaw_target); yaw = degreesf( yaw - d * elapsed) ; - + // adjust pitch target - float pitch_target = 0.0f - pitch_offset; d = degreesf(pitch - pitch_target); pitch = degreesf( pitch - d *elapsed); - /* - gl::translate(distance, 0.0, 0.0); - gl::rotate(-pitch,0, 0, 1.0 ); - gl::rotate(-yaw, 0, 1.0f, 0); - */ switch (mode) { case Free: - gl::translate(1+distance * GAMESCALE, 0.0f, 0.0f); + gl::translate(1.0f+distance, -distance, 0.0f); gl::rotate(-pitch, 0, 0, 1.0f); gl::rotate(-yaw, 0, 1.0f, 0); break; case Track: - //gl::translate(1+distance* GAMESCALE, -0.5f* GAMESCALE, 0.0f); - gl::translate(1+ 2* GAMESCALE, -0.5f* GAMESCALE, 0.0f); + gl::translate(1.0f+distance, -distance , 0.0f); gl::rotate(-pitch, 0, 0, 1.0f); gl::rotate(-yaw, 0, 1.0f, 0); break; @@ -70,44 +57,50 @@ void draw(float elapsed) void rotate_right() { if (mode == Free ) { - yaw_offset = degreesf( yaw_offset - offset_inc); + yaw_target = degreesf( yaw_target + offset_inc); } } void rotate_left() { if (mode == Free ) { - yaw_offset = degreesf( yaw_offset + offset_inc); + yaw_target = degreesf( yaw_target - offset_inc); } } void rotate_up() { if (mode == Free ) { - pitch_offset = pitch_offset + offset_inc; - if (pitch_offset > 90.0f) pitch_offset = 90.0f; + pitch_target = pitch_target + offset_inc; + if (pitch_target > 90.0f) pitch_target = 90.0f; } } void rotate_down() { if (mode == Free ) { - pitch_offset = pitch_offset - offset_inc; - if (pitch_offset < -90.0f) pitch_offset = -90.0f; + pitch_target = pitch_target - offset_inc; + if (pitch_target < -90.0f) pitch_target = -90.0f; } } void nextmode() { switch(mode) { case Free: + // switch camera to Track mode mode = Track; - yaw_offset = 0; - yaw = game::ship.yaw; - pitch_offset = track_pitch; + yaw_target = game::ship.yaw; + yaw = yaw_target; + pitch_target = track_pitch; + pitch = pitch_target; break; case Track: + // switch camera to Free mode mode = Free; - yaw_offset = 0; + yaw_target = game::ship.yaw; + yaw = yaw_target; + pitch_target = track_pitch; + pitch = pitch_target; break; default: break; |