Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/client')
-rw-r--r--src/client/camera.cc57
-rw-r--r--src/client/view.cc2
2 files changed, 35 insertions, 24 deletions
diff --git a/src/client/camera.cc b/src/client/camera.cc
index dd49aa6..b9fa1b5 100644
--- a/src/client/camera.cc
+++ b/src/client/camera.cc
@@ -167,21 +167,27 @@ 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
- eye.x = -distance-1;
- eye.y = 0;
- eye.z = distance/2;
+ 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);
- eye.x = eye.z * sin(-pitch_current * M_1_PI * 0.5f) + eye.x * cos(-pitch_current * M_1_PI * 0.5f);
- eye.y = eye.y;
- eye.z = eye.z * sin(-pitch_current * M_1_PI * 0.5f) - eye.x * cos(-pitch_current * M_1_PI * 0.5f);
+ x = eye.x;
+ y = eye.y;
+ z = eye.z;
- eye.x = eye.x * cos(-yaw_current * M_1_PI * 0.5f) - eye.y * sin(-yaw_current * M_1_PI * 0.5f);
- eye.y = eye.x * sin(-yaw_current * M_1_PI * 0.5f) + eye.y * cos(-yaw_current * M_1_PI * 0.5f);
- eye.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;
@@ -194,17 +200,21 @@ void draw(float elapsed)
case Track:
// calculate the position of the eye
- eye.x = -distance-1;
- eye.y = 0;
- eye.z = distance;
+ 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);
- eye.x = eye.z * sin(-pitch_current * M_1_PI * 0.5f) + eye.x * cos(-pitch_current * M_1_PI * 0.5f);
- eye.y = eye.y;
- eye.z = eye.z * sin(-pitch_current * M_1_PI * 0.5f) - eye.x * cos(-pitch_current * M_1_PI * 0.5f);
+ x = eye.x;
+ y = eye.y;
+ z = eye.z;
- eye.x = eye.x * cos(-yaw_current * M_1_PI * 0.5f) - eye.y * sin(-yaw_current * M_1_PI * 0.5f);
- eye.y = eye.x * sin(-yaw_current * M_1_PI * 0.5f) + eye.y * cos(-yaw_current * M_1_PI * 0.5f);
- eye.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;
@@ -216,8 +226,9 @@ void draw(float elapsed)
break;
case Overview:
+
eye = target;
- eye.z = eye.z + distance;
+ eye.z = eye.z + distance-1;
gl::rotate(-75.0f, 0.0f, 1.0f, 0.0f);
gl::translate(0.0f, 0.0f, -distance);
@@ -250,8 +261,8 @@ void key_left()
void key_up()
{
if (mode == Free) {
- pitch_target = pitch_target - rotate_offset_inc;
- if (pitch_target < -90.0f) pitch_target = -90.0f;
+ pitch_target = pitch_target + rotate_offset_inc;
+ if (pitch_target > 90.0f) pitch_target = 90.0f;
} else if (mode == Overview) {
x_offset += translate_offset_inc;
}
@@ -260,8 +271,8 @@ void key_up()
void key_down()
{
if (mode == Free) {
- pitch_target = pitch_target + rotate_offset_inc;
- if (pitch_target > 90.0f) pitch_target = 90.0f;
+ pitch_target = pitch_target - rotate_offset_inc;
+ if (pitch_target < -90.0f) pitch_target = -90.0f;
} else if (mode == Overview) {
x_offset -= translate_offset_inc;
}
diff --git a/src/client/view.cc b/src/client/view.cc
index 8da7892..db7f3a3 100644
--- a/src/client/view.cc
+++ b/src/client/view.cc
@@ -210,7 +210,7 @@ void frame(float seconds)
camera::draw(seconds); // draw the current camera transformation
- render::draw(camera::target, seconds); // draw the world
+ render::draw(camera::eye, camera::target, seconds); // draw the world
}