diff options
Diffstat (limited to 'src/client')
-rw-r--r-- | src/client/camera.cc | 58 | ||||
-rw-r--r-- | src/client/draw.cc | 21 |
2 files changed, 47 insertions, 32 deletions
diff --git a/src/client/camera.cc b/src/client/camera.cc index 45cd65a..2def781 100644 --- a/src/client/camera.cc +++ b/src/client/camera.cc @@ -40,18 +40,26 @@ Mode mode; float yaw_current; // current pitch, angle in XY, positive is looking up float pitch_current; -// default pitch in mode::Track -float pitch_track; + // default pitch in mode::Overview float pitch_overview; -// default offset increment -float offset_inc; + + +// current x offset +float x_offset; +// current z offset +float z_offset; + +// default pitch in mode::Track +const float pitch_track = -15.0f; +// default rotate offset increase/decrease +float rotate_offset_inc; +// default translate offset increase/decrease +const float translate_offset_inc = 0.1; void init() { - pitch_overview = -60.0f; - pitch_track = -15.0f; - offset_inc = 5.0f; + rotate_offset_inc = 5.0f; yaw_current = 0; yaw_target = 0; @@ -96,10 +104,10 @@ void draw(float elapsed) gl::rotate(-yaw_current, 0, 1.0f, 0); gl::translate(-1*target); break; - case Overview: - gl::translate(-distance/2, -distance, 0.0f); - gl::rotate(-pitch_current, 0, 0, 1.0f); - gl::rotate(-yaw_current, 0, 1.0f, 0); + case Overview: + gl::rotate(75.0f, 0.0f, 0.0f, 1.0f); + gl::translate(0.0f, -distance, 0.0f); + //gl::translate(x_offset, 0.0f, z_offset); gl::translate(-1*target); break; default: @@ -109,31 +117,39 @@ void draw(float elapsed) void key_right() { - if (mode == Free || mode == Overview) { - yaw_target = degrees360f( yaw_target + offset_inc); + if (mode == Free) { + yaw_target = degrees360f( yaw_target + rotate_offset_inc); + } else if (mode == Overview) { + z_offset += translate_offset_inc; } } void key_left() { - if (mode == Free || mode == Overview) { - yaw_target = degrees360f( yaw_target - offset_inc); + if (mode == Free) { + yaw_target = degrees360f( yaw_target - rotate_offset_inc); + } else if (mode == Overview) { + z_offset -= translate_offset_inc; } } void key_up() { if (mode == Free) { - pitch_target = pitch_target - offset_inc; + 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; } } void key_down() { if (mode == Free) { - pitch_target = pitch_target + offset_inc; + 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; } } @@ -160,11 +176,9 @@ void next_mode() { case Free: // switch camera to Overview mode mode = Overview; - yaw_target = 0; - yaw_current = 0; - pitch_target = pitch_overview; - pitch_current = pitch_target; - distance = 10.0f; + x_offset = 0; + z_offset = 0; + distance = 20.0f; default: break; } diff --git a/src/client/draw.cc b/src/client/draw.cc index 1e3e5b0..8d83ba8 100644 --- a/src/client/draw.cc +++ b/src/client/draw.cc @@ -20,16 +20,16 @@ render::Box cube(math::Vector3f(0.5f, 0.5f, 0.5f), math::Vector3f(-0.5f, -0.5f, void draw_entity_sphere(core::Entity *entity) { - render::gl::color(entity->base_color); - sphere.radius = entity->base_radius; + render::gl::color(entity->core_color); + sphere.radius = entity->core_radius; sphere.draw(); } void draw_entity_cube(core::Entity *entity) { - cube.topcolor = entity->base_color; - cube.bottomcolor = entity->base_color * 0.7f; - cube.radius = entity->base_radius; + cube.topcolor = entity->core_color; + cube.bottomcolor = entity->core_color * 0.7f; + cube.radius = entity->core_radius; cube.draw(); } @@ -37,11 +37,11 @@ void draw_entity_cube(core::Entity *entity) void draw_entity_diamond(core::Entity *entity) { using namespace render; - float r = entity->base_radius; + float r = entity->core_radius; gl::begin(gl::Lines); gl::color(1.0f, 0.0f, 0.0f); gl::vertex(r,0.0f,0.0f); - gl::color(entity->base_color); + gl::color(entity->core_color); gl::vertex(-r,0.0f,0.0f); gl::vertex(0.0f,0.0f,r/2); @@ -52,13 +52,13 @@ void draw_entity_diamond(core::Entity *entity) gl::end(); } -// draw an entity of type core::entity::Default +// draw an entity of core_type core::entity::Default void draw_entity_default(core::Entity *entity) { render::gl::push(); render::gl::translate(entity->location); - switch(entity->base_shape) { + switch(entity->core_shape) { case core::entity::Sphere: draw_entity_sphere(entity); break; @@ -194,6 +194,7 @@ void draw_spacegrid() void draw_world(float elapsed) { + // used for animations angle += 180.0f * elapsed; if( angle > 360.0f ) { angle -= 360.0f; @@ -203,7 +204,7 @@ void draw_world(float elapsed) using namespace render; std::vector<core::Entity *>::iterator it; for (it=core::entity::registry.begin(); it != core::entity::registry.end(); it++) { - switch ( (*it)->type) { + switch ( (*it)->core_type()) { case core::entity::Default: draw_entity_default((*it)); break; |