diff options
Diffstat (limited to 'src/client/camera.cc')
-rw-r--r-- | src/client/camera.cc | 40 |
1 files changed, 33 insertions, 7 deletions
diff --git a/src/client/camera.cc b/src/client/camera.cc index 754cbad..585aafc 100644 --- a/src/client/camera.cc +++ b/src/client/camera.cc @@ -5,6 +5,7 @@ */ #include "math/mathlib.h" +#include "math/matrix4f.h" #include "core/core.h" #include "client/client.h" #include "client/camera.h" @@ -84,7 +85,9 @@ void set_mode(Mode newmode) { case Track: // switch camera to Track mode mode = Track; - yaw_target = core::localcontrol()->direction(); + // FIXME + //yaw_target = core::localcontrol()->direction(); + yaw_target = 0; yaw_current = yaw_target; pitch_target = pitch_track; pitch_current = pitch_target; @@ -93,7 +96,9 @@ void set_mode(Mode newmode) { case Free: // switch camera to Free mode mode = Free; - yaw_target = core::localcontrol()->direction(); + // FIXME + //yaw_target = core::localcontrol()->direction(); + yaw_target = 0; yaw_current = yaw_target; pitch_target = pitch_track; pitch_current = pitch_target; @@ -150,7 +155,9 @@ void draw(float elapsed) } if (mode == Track) { - yaw_target = core::localcontrol()->direction(); + // FIXME + //yaw_target = core::localcontrol()->direction(); + yaw_target = 0; } if ((mode == Free) || (mode == Track)) { @@ -167,21 +174,40 @@ void draw(float elapsed) gl::rotate(90.0f, 0, 1.0, 0); gl::rotate(-90.0f, 1.0f , 0, 0); + math::Matrix4f matrix; + // map camera coordinates to opengl coordinates switch (mode) { case Free: case Track: if (core::localcontrol()->model()) - distance = core::localcontrol()->model()->radius(); + distance = 1+core::localcontrol()->model()->radius(); else - distance = 0.5f; - + distance = 1.5f; + + target = core::localcontrol()->location(); + matrix = core::localcontrol()->axis(); + + // apply the transpose of the axis transformation (the axis is orhtonormal) + gl::multmatrix(matrix.transpose()); + + // match the camera with the current target + gl::translate(-1.0f * target); + + // draw the local camera transformation + gl::translate(distance * core::localcontrol()->axis().forward()); + gl::translate((distance-1)/-2.0f * core::localcontrol()->axis().up()); + + /* // draw the camera transformation gl::translate(0.0f, 0.0f, -3*distance/4); gl::translate(1.2+distance, 0.0f, 0.0f); gl::rotate(-pitch_current, 0.0f, 1.0f, 0.0f); gl::rotate(-yaw_current, 0.0f, 0.0f, 1.0f); - gl::translate(-1*target); + */ + + // reposition, the engine will draw relative to 0,0,0 + //gl::translate(-1 * target); break; case Overview: |