From 17e9ce54ee3972b9804174b874652ec0856efcd0 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sat, 10 May 2008 21:44:58 +0000 Subject: interpolation & oscilating debugging --- TODO | 10 +++++++++- osirion.kdevelop.pcs | Bin 656442 -> 655486 bytes osirion.kdevses | 33 ++++++++++++--------------------- src/client/camera.cc | 48 ++++++++++++++++++++++++++++-------------------- src/game/ship.cc | 33 ++++++++++++++++++++++++--------- src/render/draw.cc | 2 +- 6 files changed, 74 insertions(+), 52 deletions(-) diff --git a/TODO b/TODO index c93629e..61f2736 100644 --- a/TODO +++ b/TODO @@ -8,13 +8,18 @@ milestone 1: camera frustum clip keyboard binds +milestone 2: + server-client event system, hit-once lightweight entities + explosion events + weapons fire events + filesystem: write a filesystem based on streams write handlers for zip model: split map loader from model - support map classes (e.g. func_rotate) + support map classes (e.g. func_rotate), requires class VertexData engine flare key core: @@ -58,6 +63,9 @@ render: add small camera light, fix lighting without sun +sound: + sound would be nice + win32 port: network not functional (ok) texture loading is broken (ok) diff --git a/osirion.kdevelop.pcs b/osirion.kdevelop.pcs index c7807ad..96a6daf 100644 Binary files a/osirion.kdevelop.pcs and b/osirion.kdevelop.pcs differ diff --git a/osirion.kdevses b/osirion.kdevses index 287f188..20dfedd 100644 --- a/osirion.kdevses +++ b/osirion.kdevses @@ -1,37 +1,28 @@ - - + + - - + + - - + + - + - + - - + + - - + + - - - - - - - - - diff --git a/src/client/camera.cc b/src/client/camera.cc index 28f60c5..c4a60b0 100644 --- a/src/client/camera.cc +++ b/src/client/camera.cc @@ -178,28 +178,43 @@ void draw(float seconds) } if (mode == Track) { - if (core::localcontrol()->state() && core::localcontrol()->model()) - target += core::localcontrol()->model()->maxbbox().x * core::localcontrol()->state()->axis().forward(); + if (core::localcontrol()->state() && core::localcontrol()->model()) { + target -= (core::localcontrol()->model()->maxbbox().x + 0.1f) * core::localcontrol()->state()->axis().forward(); + + target += (core::localcontrol()->model()->maxbbox().z + 0.3f ) * + core::localcontrol()->state()->axis().up(); + } // make the camera swing while turning target_direction = core::localcontrol()->target_direction; - pitch_target = core::localcontrol()->target_pitch; + target_pitch = core::localcontrol()->target_pitch; + + yaw_target = - 30 * target_direction; + pitch_target = - 30 * target_pitch; + //pitch_target = pitch_track - 30 * target_pitch; - yaw_target = - 25 * target_direction; - pitch_target = pitch_track - 25 * target_pitch; + distance = 0.0f; } else if (mode == Free) { yaw_target = yaw_current - 90 * target_direction; pitch_target = pitch_current - 90 * target_pitch; + + if (core::localcontrol()->model()) { + distance = core::localcontrol()->model()->radius(); + } else { + distance = 1.0f; + } } else if (mode == Cockpit) { if (core::localcontrol()->state() && core::localcontrol()->model()) - target += core::localcontrol()->model()->maxbbox().x * core::localcontrol()->state()->axis().forward(); + target += core::localcontrol()->model()->maxbbox().x * + core::localcontrol()->state()->axis().forward(); + + distance = 0.0f; } - if (mode != Cockpit) { // adjust direction d = degrees180f(yaw_current - yaw_target); @@ -210,11 +225,6 @@ void draw(float seconds) d = degrees180f(pitch_current - pitch_target); pitch_current = degrees360f(pitch_current - d *seconds); axis.change_pitch(pitch_current); - - if (core::localcontrol()->model()) - distance = 1+core::localcontrol()->model()->radius(); - else - distance = 1.5f; } } @@ -231,15 +241,13 @@ void draw(float seconds) // match the camera with the current target gl::translate(-1.0f * target); - if (mode != Cockpit) { - // apply camera offset - gl::translate((1.0f+distance) * axis.forward()); + // apply camera offset + gl::translate((1.0 + distance) * axis.forward()); + + // calculate eye position + eye = target - ((1.0f+distance) * axis.forward()); + eye.assign(target); - // calculate eye position - eye = target - ((1.0f+distance) * axis.forward()); - } else { - eye.assign(target); - } } void set_direction(float direction) diff --git a/src/game/ship.cc b/src/game/ship.cc index 525bf71..5c36205 100644 --- a/src/game/ship.cc +++ b/src/game/ship.cc @@ -47,12 +47,17 @@ void Ship::frame(float seconds) // update pitch math::clamp(target_pitch, -1.0f, 1.0f); - if (current_target_pitch - target_pitch < 0) { + if (current_target_pitch < target_pitch) { current_target_pitch += direction_change_speed * seconds; - } else if (current_target_pitch - target_pitch > 0) { + if (current_target_pitch > target_pitch) + current_target_pitch = target_pitch; + } else if (current_target_pitch > target_pitch) { current_target_pitch -= direction_change_speed * seconds; + if (current_target_pitch < target_pitch) + current_target_pitch = target_pitch; } - if (fabs(current_target_pitch) < direction_change_speed * seconds) { + + if (fabs(seconds*current_target_pitch) < 0.00005f) { current_target_pitch = 0.0f; } else { math::clamp(current_target_pitch, -1.0f, 1.0f); @@ -62,12 +67,18 @@ void Ship::frame(float seconds) // update direction math::clamp(target_direction, -1.0f, 1.0f); - if (current_target_direction - target_direction < 0) { + if (current_target_direction < target_direction) { current_target_direction += direction_change_speed * seconds; - } else if (current_target_direction - target_direction > 0) { + if (current_target_direction > target_direction) { + current_target_direction = target_direction; + } + } else if (current_target_direction > target_direction) { current_target_direction -= direction_change_speed * seconds; + if (current_target_direction < target_direction) { + current_target_direction = target_direction; + } } - if (fabs(current_target_direction) < direction_change_speed * seconds) { + if (fabs(seconds*current_target_direction) < 0.00005f) { current_target_direction = 0.0f; } else { math::clamp(current_target_direction, -1.0f, 1.0f); @@ -77,12 +88,16 @@ void Ship::frame(float seconds) // update roll math::clamp(target_roll, -1.0f, 1.0f); - if (current_target_roll - target_roll < 0) { + if (current_target_roll < target_roll) { current_target_roll += direction_change_speed * seconds; - } else if (current_target_roll - target_roll > 0) { + if (current_target_roll > target_roll) + current_target_roll = target_roll; + } else if (current_target_roll > target_roll) { current_target_roll -= direction_change_speed * seconds; + if (current_target_roll < target_roll) + current_target_roll = target_roll; } - if (fabs(current_target_roll) < direction_change_speed * seconds) { + if (fabs(current_target_roll) < 0.00005f) { current_target_roll = 0.0f; } else { math::clamp(current_target_roll, -1.0f, 1.0f); diff --git a/src/render/draw.cc b/src/render/draw.cc index 7a780bf..e2037e2 100644 --- a/src/render/draw.cc +++ b/src/render/draw.cc @@ -515,7 +515,7 @@ void draw_pass_model_corona() for (std::map::iterator it=core::Entity::registry.begin(); it != core::Entity::registry.end(); it++) { core::Entity *entity = (*it).second; - if ((entity->shape() != core::Entity::Sphere) && entity->state() && entity->state()->visible()) { + if (entity->model() && entity->state() && entity->state()->visible()) { gl::push(); gl::translate(entity->state()->location()); math::Color color = entity->color(); -- cgit v1.2.3