From 28ba97bdd8fb6ca352dc49dba01a66bd155ad523 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sat, 15 Nov 2008 19:24:55 +0000 Subject: entity extensions --- src/client/view.cc | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) (limited to 'src/client/view.cc') diff --git a/src/client/view.cc b/src/client/view.cc index 90a30ef..0f981ca 100644 --- a/src/client/view.cc +++ b/src/client/view.cc @@ -77,7 +77,7 @@ void DevInfo::draw() << "^Nspeed ^B" << core::localcontrol()->speed() << '\n'; if (target) { - d = math::distance(core::localcontrol()->location(), target->state()->location()) - target->radius() - core::localcontrol()->radius(); + d = math::distance(core::localcontrol()->location(), target->location()) - target->radius() - core::localcontrol()->radius(); textstream << "^Ndist ^B" << d << '\n'; } } @@ -298,14 +298,14 @@ void draw_entity_world_target(core::Entity *entity) if (!model->docks().size()) return; - float d = math::distance(core::localcontrol()->location(), entity->state()->location()) - entity->radius() - core::localcontrol()->radius(); + float d = math::distance(core::localcontrol()->location(), entity->location()) - entity->radius() - core::localcontrol()->radius(); if (d > 100.0f) return; gl::enable(GL_DEPTH_TEST); gl::push(); - gl::translate(entity->state()->location()); - gl::multmatrix(entity->state()->axis()); + gl::translate(entity->location()); + gl::multmatrix(entity->axis()); gl::color(0, 1.0f, 1.0f, 1.0f); @@ -355,7 +355,7 @@ void draw_entity_world_target(core::Entity *entity) void draw_entity_offscreen_target(core::Entity *entity, bool is_active_target) { - math::Vector3f target(entity->state()->location() - render::Camera::eye()); + math::Vector3f target(entity->location() - render::Camera::eye()); target = render::Camera::axis().transpose() * target; float cx = 0; @@ -414,11 +414,11 @@ void draw_entity_target(core::Entity *entity, bool is_active_target) using math::Vector3f; // don't draw target if we're very close to it - if (entity->state()->distance() < 0.001f) + if (ext_render(entity)->distance() < 0.001f) return; // don't draw target if it is outside the visible cone - Vector3f target(entity->state()->location() - render::Camera::eye()); + Vector3f target(entity->location() - render::Camera::eye()); if (math::dotproduct(render::Camera::axis().forward(), Vector3f::normalized(target)) < 0.75 ) { draw_entity_offscreen_target(entity, is_active_target); return; @@ -492,7 +492,7 @@ void draw_entity_target(core::Entity *entity, bool is_active_target) if (is_active_target) { // entity name and distance std::stringstream strdistance; - float d = math::distance(core::localcontrol()->location(), entity->state()->location()) - entity->radius() - core::localcontrol()->radius(); + float d = math::distance(core::localcontrol()->location(), entity->location()) - entity->radius() - core::localcontrol()->radius(); if (d > 0 ) { if (d > 100.0f) { strdistance << roundf(d * 0.1f) << "km"; @@ -572,7 +572,7 @@ void draw_hud() std::stringstream strtarget; strtarget << "^B" << target->name() << "\n^B"; - d = math::distance(core::localcontrol()->location(), target->state()->location()) + d = math::distance(core::localcontrol()->location(), target->location()) - target->radius() - core::localcontrol()->radius(); if (d > 0 ) { @@ -582,12 +582,23 @@ void draw_hud() } else { strtarget << roundf(d * 100.0f) << "m"; } + + if (core::localcontrol()->speed() > 0.1f) { + strtarget << "^N eta:^B "; + float eta = floorf(d / core::localcontrol()->speed() ); + if (eta > 60.0f) { + float etamin = floorf(eta / 60.0f); + strtarget << etamin << "min "; + eta -= etamin * 60; + } + strtarget << eta << "sec"; + } } else { strtarget << " --"; } strtarget << '\n'; Text::draw(render::State::width() - 4-Text::fontwidth()*32, render::State::height() - Text::fontheight()*2 -4, strtarget); - y = 3.0f; + y += 2.0f; } Text::setcolor('N'); //set normal color -- cgit v1.2.3