diff options
author | Stijn Buys <ingar@osirion.org> | 2008-05-01 21:08:40 +0000 |
---|---|---|
committer | Stijn Buys <ingar@osirion.org> | 2008-05-01 21:08:40 +0000 |
commit | 36ce28a7557c4b2b73316621471558354024ca54 (patch) | |
tree | 3aeb4502b3a4f91a54df5d25bedfd262e61d1cec /src/client/camera.cc | |
parent | a22542f273de28d06ecaf2bd6fd741821e98512b (diff) |
roll control
Diffstat (limited to 'src/client/camera.cc')
-rw-r--r-- | src/client/camera.cc | 60 |
1 files changed, 41 insertions, 19 deletions
diff --git a/src/client/camera.cc b/src/client/camera.cc index e2dbacf..c2bbc83 100644 --- a/src/client/camera.cc +++ b/src/client/camera.cc @@ -43,6 +43,11 @@ float yaw_current; // current pitch, angle in XY, positive is looking up float pitch_current; +// current direction rotation speed +float current_direction_speed; +// current pitcj rotation speed +float current_pitch_speed; + // default pitch in mode::Overview float pitch_overview; @@ -55,6 +60,8 @@ float rotate_offset_inc; // default translate offset increase/decrease const float translate_offset_inc = 0.1; +void set_mode(Mode newmode); + void init() { rotate_offset_inc = 5.0f; @@ -67,7 +74,8 @@ void init() distance = 0.4f; - mode = Track; + set_mode(Track); + } void shutdown() @@ -75,25 +83,24 @@ void shutdown() } void set_mode(Mode newmode) { + + current_direction_speed = 0; + current_pitch_speed = 0; + yaw_target = 0; + yaw_current = yaw_target; + pitch_target = pitch_track; + pitch_current = pitch_target; + distance = 0.4f; + switch(newmode) { case Track: // switch camera to Track mode mode = Track; - yaw_target = 0; - 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 = 0; - yaw_current = yaw_target; - pitch_target = pitch_track; - pitch_current = pitch_target; - distance = 0.4f; break; case Overview: @@ -128,7 +135,7 @@ void next_mode() } } -void draw(float elapsed) +void draw(float seconds) { math::Matrix4f matrix; @@ -153,25 +160,34 @@ void draw(float elapsed) set_mode(Track); target.assign(core::localcontrol()->location()); - - axis.assign(core::localcontrol()->axis()); - + if (core::localcontrol()->model()) + target += core::localcontrol()->model()->maxbbox().z * core::localcontrol()->axis().up(); + if (mode == Track) { // make the camera swing while turning yaw_target = -25.0f * core::localcontrol()->target_direction; pitch_target = pitch_track - 25 * core::localcontrol()->target_pitch; - } + /* + d = -math::dotproduct(axis.forward(), core::localcontrol()->axis().forward()) + 1; + axis.change_direction(360.0f * d * seconds); + + //d = -math::dotproduct(axis.left(), core::localcontrol()->axis().left()) + 1; + // axis.change_pitch(360.0f * d * seconds); + */ + } + + axis.assign(core::localcontrol()->axis()); // adjust direction d = degrees180f(yaw_current - yaw_target); - yaw_current = degrees360f( yaw_current - d * elapsed); + yaw_current = degrees360f( yaw_current - d * seconds); axis.change_direction(yaw_current); // adjust pitch target d = degrees180f(pitch_current - pitch_target); - pitch_current = degrees360f(pitch_current - d *elapsed); + pitch_current = degrees360f(pitch_current - d *seconds); axis.change_pitch(pitch_current); - + if (core::localcontrol()->model()) distance = 1+core::localcontrol()->model()->radius(); else @@ -228,6 +244,12 @@ void key_up() } } + +void reset() +{ + set_mode(mode); +} + } // namespace camera } // namespace client |