diff options
Diffstat (limited to 'src/client')
-rw-r--r-- | src/client/camera.cc | 57 |
1 files changed, 8 insertions, 49 deletions
diff --git a/src/client/camera.cc b/src/client/camera.cc index b9fa1b5..c7982f4 100644 --- a/src/client/camera.cc +++ b/src/client/camera.cc @@ -167,61 +167,20 @@ void draw(float elapsed) gl::rotate(90.0f, 0, 1.0, 0); gl::rotate(-90.0f, 1.0f , 0, 0); - float x,y,z; - // map camera coordinates to opengl coordinates switch (mode) { case Free: - // calculate the position of the eye - x = -distance; - y = 0; - z = distance/2; - - eye.x = x * cos(-pitch_current / 180.0f * M_PI) - z * sin(-pitch_current / 180.0f * M_PI); - eye.y = y; - eye.z = x * sin(-pitch_current / 180.0f * M_PI) + z * cos(-pitch_current / 180.0f * M_PI); - - x = eye.x; - y = eye.y; - z = eye.z; - - eye.x = x * cos(yaw_current / 180.0f * M_PI) - y * sin(yaw_current / 180.0f * M_PI); - eye.y = x * sin(yaw_current / 180.0f * M_PI) + y * cos(yaw_current / 180.0f * M_PI); - eye.z = z; - - eye = eye + target; - - // draw the camera transformation - gl::translate(1.0f+distance, 0.0f, -distance/2); - gl::rotate(-pitch_current, 0, 1.0f, 0 ); - gl::rotate(-yaw_current, 0, 0, 1.0f); - gl::translate(-1*target); - break; - case Track: - // calculate the position of the eye - x = -distance; - y = 0; - z = distance; - - eye.x = z * sin(pitch_current / 180.0f * M_PI) + x * cos(pitch_current / 180.0f * M_PI); - eye.y = y; - eye.z = z * sin(pitch_current / 180.0f * M_PI) - x * cos(pitch_current / 180.0f * M_PI); - - x = eye.x; - y = eye.y; - z = eye.z; - - eye.x = x * cos(yaw_current / 180.0f * M_PI) - y * sin(yaw_current / 180.0f * M_PI); - eye.y = x * sin(yaw_current / 180.0f * M_PI) + y * cos(yaw_current / 180.0f * M_PI); - eye.z = z; - - eye = eye + target; + if (core::localcontrol()->model()) + distance = core::localcontrol()->model()->radius(); + else + distance = 0.5f; // draw the camera transformation - gl::translate(1.0f+distance, 0.0f, -distance); - gl::rotate(-pitch_current, 0, 1.0f, 0); - gl::rotate(-yaw_current, 0, 0, 1.0f); + 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); break; |