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
parent18f21c931e6e071b6616a1c0a07026af9b185ad5 (diff)
improved target drawing
-rw-r--r--osirion-doc.webprj14
-rw-r--r--osirion.kdevelop2
-rw-r--r--src/client/targets.cc59
-rw-r--r--src/client/view.cc10
-rw-r--r--src/math/axis.cc8
-rw-r--r--src/math/axis.h3
6 files changed, 71 insertions, 25 deletions
diff --git a/osirion-doc.webprj b/osirion-doc.webprj
index aa4a641..bb11a5c 100644
--- a/osirion-doc.webprj
+++ b/osirion-doc.webprj
@@ -6,13 +6,13 @@
<email>ingar@telenet.be</email>
<defaultDTD>-//W3C//DTD HTML 4.01//EN</defaultDTD>
<item url="doc/" uploadstatus="1" />
- <item url="doc/assets.html" uploadstatus="1" />
- <item url="doc/index.html" uploadstatus="1" />
- <item url="doc/license.html" uploadstatus="1" />
- <item url="doc/manual.html" uploadstatus="1" />
- <item url="doc/models.html" uploadstatus="1" />
- <item url="doc/style.css" uploadstatus="1" />
- <item url="doc/world.html" uploadstatus="1" />
+ <item modified_time="1217287896" url="doc/assets.html" uploadstatus="1" />
+ <item modified_time="1217008503" url="doc/index.html" uploadstatus="1" />
+ <item modified_time="1216035705" url="doc/license.html" uploadstatus="1" />
+ <item modified_time="1217944621" url="doc/manual.html" uploadstatus="1" />
+ <item modified_time="1217009100" url="doc/models.html" uploadstatus="1" />
+ <item modified_time="1216214171" url="doc/style.css" uploadstatus="1" />
+ <item modified_time="1217289882" url="doc/world.html" uploadstatus="1" />
<item url="" uploadstatus="1" />
<templates>templates/</templates>
<toolbars>toolbars/</toolbars>
diff --git a/osirion.kdevelop b/osirion.kdevelop
index d40c050..58a8bfc 100644
--- a/osirion.kdevelop
+++ b/osirion.kdevelop
@@ -21,7 +21,7 @@
</general>
<kdevautoproject>
<general>
- <activetarget>src/core/libcore.la</activetarget>
+ <activetarget>src/client/libclient.la</activetarget>
<useconfiguration>debug</useconfiguration>
</general>
<run>
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();
diff --git a/src/math/axis.cc b/src/math/axis.cc
index aa35d92..e6442eb 100644
--- a/src/math/axis.cc
+++ b/src/math/axis.cc
@@ -91,17 +91,15 @@ void Axis::rotate(Vector3f const &normal, float angle)
}
}
-/*
-Axis const Axis::transpose()
+Axis Axis::transpose() const
{
- Axis` t;
+ Axis t;
for (size_t i = 0; i < 3; i++)
for (size_t j = 0; j < 3; j++)
- t.axis_vector[j][i] = axis_vector[j][i];
+ t.axis_vector[i][j] = axis_vector[j][i];
return t;
}
-*/
// write an axis to a std::ostream
std::ostream &operator<<(std::ostream & os, Axis const & axis)
diff --git a/src/math/axis.h b/src/math/axis.h
index 1422564..1396521 100644
--- a/src/math/axis.h
+++ b/src/math/axis.h
@@ -51,6 +51,9 @@ public:
/// rotation about an arbitrary axis
void rotate(Vector3f const &normal, float angle);
+ /// return the transpose of this matrix
+ Axis transpose() const;
+
private:
Vector3f axis_vector[3];
};