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.cc23
-rw-r--r--src/client/draw.cc38
-rw-r--r--src/client/view.cc3
3 files changed, 33 insertions, 31 deletions
diff --git a/src/client/camera.cc b/src/client/camera.cc
index d9aa16e..e8a6625 100644
--- a/src/client/camera.cc
+++ b/src/client/camera.cc
@@ -52,7 +52,7 @@ float x_offset;
float z_offset;
// default pitch in mode::Track
-const float pitch_track = -15.0f;
+const float pitch_track = 15.0f;
// default rotate offset increase/decrease
float rotate_offset_inc;
// default translate offset increase/decrease
@@ -161,22 +161,27 @@ void draw(float elapsed)
pitch_current = degrees360f( pitch_current - d *elapsed);
}
+ // map world coordinates to opengl coordinates
+ gl::rotate(90.0f, 0, 1.0, 0);
+ gl::rotate(-90.0f, 1.0f , 0, 0);
+
+ // map camera coordinates to opengl coordinates
switch (mode) {
case Free:
- gl::translate(1.0f+distance, -distance/2, 0.0f);
- gl::rotate(-pitch_current, 0, 0, 1.0f);
- gl::rotate(-yaw_current, 0, 1.0f, 0);
+ 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:
- gl::translate(1.0f+distance, -distance , 0.0f);
- gl::rotate(-pitch_current, 0, 0, 1.0f);
- gl::rotate(-yaw_current, 0, 1.0f, 0);
+ 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(-1*target);
break;
case Overview:
- gl::rotate(75.0f, 0.0f, 0.0f, 1.0f);
- gl::translate(0.0f, -distance, 0.0f);
+ gl::rotate(-75.0f, 0.0f, 1.0f, 0.0f);
+ gl::translate(0.0f, 0.0f, -distance);
//gl::translate(x_offset, 0.0f, z_offset);
gl::translate(-1*target);
break;
diff --git a/src/client/draw.cc b/src/client/draw.cc
index 76c55b3..cdf80c2 100644
--- a/src/client/draw.cc
+++ b/src/client/draw.cc
@@ -45,11 +45,11 @@ void draw_entity_diamond(core::Entity *entity)
gl::color(entity->color());
gl::vertex(-r,0.0f,0.0f);
- gl::vertex(0.0f,0.0f,r/2);
- gl::vertex(0.0f,0.0f,-r/2);
+ gl::vertex(0.0f,r/2,0.0f);
+ gl::vertex(0.0f,-r/2,0.0f);
- gl::vertex(0.0f,r,0.0f);
- gl::vertex(0.0f,-r, 0.0f);
+ gl::vertex(0.0f,0.0f,r);
+ gl::vertex(0.0f,0.0f,-r);
gl::end();
}
@@ -108,7 +108,7 @@ void draw_ship(core::EntityControlable *entity)
gl::push();
gl::translate(entity->location());
gl::scale(0.2f, 0.2f, 0.2f);
- gl::rotate(entity->direction(), 0.0f, 1.0f, 0.0f );
+ gl::rotate(entity->direction(), 0.0f, 0.0f, 1.0f );
Vector3f tl(0.25, 0.125, 0.125);
Vector3f br(-0.25, -0.125, -0.125);
@@ -151,25 +151,23 @@ void draw_ship(core::EntityControlable *entity)
}
// shield rotation
- gl::rotate(angle, 0.0f, 1.0f, 0.0f );
+ gl::rotate(angle, 0.0f, 0.0f, 1.0f );
// draw the shield
gl::color(Color(0.0f, 1.0f ,0.0f , 0.5f));
- gl::begin(gl::LineStrip);
+ gl::begin(gl::LineLoop);
gl::vertex(v0);
gl::vertex(v1);
gl::vertex(v2);
gl::vertex(v3);
- gl::vertex(v0);
gl::end();
- gl::begin(gl::LineStrip);
+ gl::begin(gl::LineLoop);
gl::vertex(v4);
gl::vertex(v5);
gl::vertex(v6);
gl::vertex(v7);
- gl::vertex(v4);
gl::end();
gl::pop();
@@ -183,28 +181,28 @@ void draw_spacegrid()
int gridsize = 32;
float s = 1.0f / gridsize;
- float y = -4.0f;
+ float z = -4.0f;
float dx = camera::target.x - floorf(camera::target.x);
- float dz = camera::target.z - floorf(camera::target.z);
+ float dy = camera::target.y - floorf(camera::target.y);
color(0,0, 1.0f);
begin(Lines);
for (int i=-gridsize; i <= gridsize; i++) {
color(0,0, 0, 0);
- vertex(i-dx, y, -gridsize-dz);
+ vertex(i-dx, -gridsize-dy, z);
color(0,0, (gridsize-abs(i))*s, (gridsize-abs(i))*s);
- vertex(i-dx, y, -dz);
- vertex(i-dx, y, -dz);
+ vertex(i-dx, -dy, z );
+ vertex(i-dx, -dy ,z );
color(0,0, 0, 0);
- vertex(i-dx, y, gridsize-dz);
+ vertex(i-dx, gridsize-dy, z);
- vertex(-gridsize-dx, y, i-dz);
+ vertex(-gridsize-dx, i-dy, z );
color(0,0, (gridsize-abs(i))*s, (gridsize-abs(i))*s);
- vertex(-dx, y, i-dz);
- vertex(-dx, y, i-dz);
+ vertex(-dx, i-dy, z);
+ vertex(-dx, i-dy, z);
color(0,0, 0, 0);
- vertex(gridsize-dx, y, i-dz);
+ vertex(gridsize-dx, i-dy, z);
}
end();
}
diff --git a/src/client/view.cc b/src/client/view.cc
index 96a0631..8ddd33c 100644
--- a/src/client/view.cc
+++ b/src/client/view.cc
@@ -174,8 +174,7 @@ void frame(float seconds)
gl::matrixmode(GL_MODELVIEW); // map world to screen coordinates
gl::loadidentity();
- gl::rotate(90.0f, 0, 1.0, 0);
-
+
camera::draw(seconds); // draw the current camera transformation
gl::enable(GL_DEPTH_TEST); // enable depth buffer writing