Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2008-08-06 14:40:36 +0000
committerStijn Buys <ingar@osirion.org>2008-08-06 14:40:36 +0000
commit668026125ae19b9bd800004ae9ec0510f20753ad (patch)
tree27a8c540bd3ef68f2f5a0b653246adc4dd180a21 /src/client
parent18f21c931e6e071b6616a1c0a07026af9b185ad5 (diff)
improved target drawing
Diffstat (limited to 'src/client')
-rw-r--r--src/client/targets.cc59
-rw-r--r--src/client/view.cc10
2 files changed, 57 insertions, 12 deletions
diff --git a/src/client/targets.cc b/src/client/targets.cc
index 8dc5c07..e140df2 100644
--- a/src/client/targets.cc
+++ b/src/client/targets.cc
@@ -10,6 +10,7 @@
#include <iomanip>
#include "audio/audio.h"
+#include "auxiliary/functions.h"
#include "audio/sources.h"
#include "client/input.h"
#include "client/view.h"
@@ -18,6 +19,7 @@
#include "core/entity.h"
#include "core/func.h"
#include "core/gameinterface.h"
+#include "math/axis.h"
#include "math/vector3f.h"
#include "render/gl.h"
#include "render/render.h"
@@ -347,6 +349,8 @@ void draw_target()
core::Entity *entity = current_target;
+
+
// if target is in visible space
Vector3f v(entity->state()->location() - render::Camera::eye());
v.normalize();
@@ -364,17 +368,58 @@ void draw_target()
+ plane_normal.y * (entity->state()->location().y - render::Camera::eye().y)
+ plane_normal.z * (entity->state()->location().z - render::Camera::eye().z);
- Vector3f intersection = render::Camera::eye() + (entity->state()->location() - render::Camera::eye()) * t;
+ //Vector3f intersection = render::Camera::eye() + (entity->state()->location() - render::Camera::eye()) * t;
+ //intersection -= render::Camera::eye()
+ Vector3f intersection = (entity->state()->location() - render::Camera::eye()) * t;
+
+ Vector3f center(render::Camera::axis().transpose()*intersection);
+
+ float cx = video::width * (0.5 - center.y);
+ float cy = video::height * (0.5 - center.z * render::Camera::aspect());
+
+ const float pointer_size = 48.0f;
+ const float r = pointer_size;
+
+ render::gl::disable(GL_TEXTURE_2D);
+
+ render::gl::color(0, 0, 0, 1);
+ render::gl::begin(render::gl::LineLoop);
+ glVertex3f(cx+r, cy+2, 0);
+ glVertex3f(cx, cy+r+2, 0);
+ glVertex3f(cx-r, cy+2, 0);
+ glVertex3f(cx, cy-r+2, 0);
+ render::gl::end();
- // draw the target cursor in the frustum front plane, but in real world coordinates
- const float r = 0.05;
render::gl::color(1, 1, 1, 1);
render::gl::begin(render::gl::LineLoop);
- render::gl::vertex(intersection + render::Camera::axis().up() * r);
- render::gl::vertex(intersection + render::Camera::axis().left() * r);
- render::gl::vertex(intersection - render::Camera::axis().up() * r);
- render::gl::vertex(intersection - render::Camera::axis().left() * r);
+ glVertex3f(cx+r, cy, 0);
+ glVertex3f(cx, cy+r, 0);
+ glVertex3f(cx-r, cy, 0);
+ glVertex3f(cx, cy-r, 0);
render::gl::end();
+
+ render::gl::enable(GL_TEXTURE_2D);
+
+ std::stringstream str;
+
+ // entity name
+ render::Text::setcolor('B');
+ render::Text::draw(cx-aux::text_length(entity->name()) * render::Text::fontwidth()*0.5f, cy-r-4- render::Text::fontheight(), entity->name());
+
+
+ d = math::distance(core::localcontrol()->location(), entity->state()->location()) - entity->radius() - core::localcontrol()->radius();
+ if (d > 0 ) {
+ if (d > 100) {
+ str << roundf(d * 0.1f) << "km";
+ } else {
+ str << roundf(d * 100.0f) << "m";
+ }
+ } else {
+ str << "--";
+ }
+ render::Text::setcolor('B');
+ render::Text::draw(cx - aux::text_length(str.str()) * render::Text::fontwidth() * 0.5f, cy - render::Text::fontheight() * 0.5f, str);
+
}
}
diff --git a/src/client/view.cc b/src/client/view.cc
index 6c792d6..4fe7a33 100644
--- a/src/client/view.cc
+++ b/src/client/view.cc
@@ -214,7 +214,7 @@ void draw_cursor()
return;
float angle = 0;
- float pointer_size = 48.0f;
+ const float pointer_size = 48.0f;
float x = (float) input::mouse_position_x() - (pointer_size / 2.0f);
float y = (float) input::mouse_position_y() - (pointer_size / 2.0f);
bool cursor_animated = false;
@@ -392,9 +392,6 @@ void frame(float seconds)
if (core::application()->connected() && core::game()->serverframetime()) {
render::draw(seconds); // draw the world
targets::frame();
- if (draw_ui->value()) {
- targets::draw_target();
- }
}
// switch to orthographic projection to draw the GUI
@@ -423,7 +420,10 @@ void frame(float seconds)
// draw text elements
if (draw_ui->value()) {
Text::setfont("bitmaps/fonts/gui", 12, 18);
-
+
+ // draw the current target selection
+ targets::draw_target();
+
// draw the player status
draw_status();