diff options
author | Stijn Buys <ingar@osirion.org> | 2008-03-24 23:10:55 +0000 |
---|---|---|
committer | Stijn Buys <ingar@osirion.org> | 2008-03-24 23:10:55 +0000 |
commit | 5e6ff388cff8d967667f97c611e5d2463239dcd3 (patch) | |
tree | 1d4b420b16718b1e7ed940e4f2e94d27e4a538f7 /src/client | |
parent | 78572764acf68b94b9992f488a725bc4be96a5b3 (diff) |
camera distance matches model radius
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; |