Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/client')
-rw-r--r--src/client/hud.cc109
1 files changed, 71 insertions, 38 deletions
diff --git a/src/client/hud.cc b/src/client/hud.cc
index e0e0d89..18b00af 100644
--- a/src/client/hud.cc
+++ b/src/client/hud.cc
@@ -66,66 +66,99 @@ void HUD::resize()
}
+/*
+ * This function is called to draw off-screen target indicators
+ * */
void HUD::draw_offscreen_target(core::Entity *entity, bool is_active_target)
{
math::Vector3f target(entity->location() - render::Camera::eye());
target = render::Camera::axis().transpose() * target;
- float cx = 0;
- float cy = 0;
+ math::Vector2f screen_edge;
if (target.y() * target.y() + target.z() * target.z() < 0.0001) {
// X - bound, behind (front is visible)
- cx = 0.0f;
- cy = -0.5f;
-
+ screen_edge.assign(0.0f, -0.5f);
} else if (fabs(target.y()) > fabs(target.z())) {
// Y-bound
- cx = math::sgnf(target.y()) * 0.5f;
- cy = 0.5f * target.z() / fabs(target.y());
+ screen_edge.assign(math::sgnf(target.y()) * 0.5f, 0.5f * target.z() / fabs(target.y()));
} else {
// Z-bound
- cx = 0.5f * target.y() / fabs(target.z());
- cy = math::sgnf(target.z()) * 0.5f;
+ screen_edge.assign(0.5f * target.y() / fabs(target.z()), math::sgnf(target.z()) * 0.5f);
+ }
+
+ screen_edge[0] = (0.5f - screen_edge[0]) * ((float) render::State::width());
+ screen_edge[1] = (0.5f - screen_edge[1]) * ((float) render::State::height());
+
+ const float bitmap_margin = 24.0f;
+ float bitmap_radius = 32.0f;
+
+ if (!is_active_target) {
+ bitmap_radius = 24.0f;
+ }
+
+ math::Vector2f screen_center((float) render::State::width() * 0.5f, (float) render::State::height() * 0.5f);
+ math::Vector2f bitmap_up((screen_edge - screen_center));
+ bitmap_up /= bitmap_up.length();
+ math::Vector2f bitmap_left(-bitmap_up.y(), bitmap_up.x());
+ math::Vector2f bitmap_center(screen_edge - (bitmap_up * (bitmap_margin + bitmap_radius)));
+
+ // popup effect
+ if (is_active_target && (hud_splash_time > 0.0f)) {
+ bitmap_radius *= (core::application()->time() - hud_splash_time) / SPLASH_POPUP_DELAY;
}
- const float r = 16;
- const float margin = 24;
- cx = (0.5f - cx) * ((float) render::State::width() - margin * 2);
- cx += margin;
- cy = (0.5f - cy) * ((float) render::State::height() - margin * 2);
- cy += margin;
-
- gl::disable(GL_TEXTURE_2D);
- gl::color(0, 0, 0, 1);
- gl::begin(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);
- gl::end();
+ bitmap_up *= bitmap_radius;
+ bitmap_left *= bitmap_radius;
- if (entity == core::localplayer()->mission_target()) {
- gl::color(palette()->mission());
- } else if (entity->type() == core::Entity::Controlable) {
- gl::color(0, 1, 0, 1); // FIXME allegiance color
+ //math::Vector2f bitmap_location(bitmap_center[0] - bitmap_radius, bitmap_center[1] - bitmap_radius);
+ //math::Vector2f bitmap_size(2.0f * bitmap_radius, 2.0f * bitmap_radius);
+
+ math::Color bitmap_color;
+ std:: string bitmap_material("bitmaps/hud/offscreen_default");
+
+ if (entity->type() == core::Entity::Controlable) {
+ //bitmap_material.assign("bitmaps/hud/offscreen_controlable");
+ bitmap_color.assign(palette()->fancy());
+
+ } else if (entity->has_flag(core::Entity::Dockable)) {
+ //bitmap_material.assign("bitmaps/hud/offscreen_dockable");
+ bitmap_color.assign(palette()->foreground());
+
} else {
- gl::color(1, 1, 1, 1); // FIXME neutral color
+ //bitmap_material.assign("bitmaps/hud/offscreen_default");
+ bitmap_color.assign(palette()->text());
}
-
- gl::begin(gl::LineLoop);
- glVertex3f(cx + r, cy, 0);
- glVertex3f(cx, cy + r, 0);
- glVertex3f(cx - r, cy, 0);
- glVertex3f(cx, cy - r, 0);
- gl::end();
+
+ if (entity == core::localplayer()->mission_target()) {
+ bitmap_color.assign(palette()->mission());
+ }
+
+ render::Textures::bind(bitmap_material.c_str());
+ gl::color(bitmap_color);
gl::enable(GL_TEXTURE_2D);
+ gl::begin(gl::Quads);
+
+ gl::texcoord(0.0f, 0.0f);
+ gl::vertex(bitmap_center + bitmap_up - bitmap_left);
+
+ gl::texcoord(1.0f, 0.0f);
+ gl::vertex(bitmap_center + bitmap_up + bitmap_left);
+
+ gl::texcoord(1.0f, 1.0f);
+ gl::vertex(bitmap_center - bitmap_up + bitmap_left);
+
+ gl::texcoord(0.0f, 1.0f);
+ gl::vertex(bitmap_center - bitmap_up - bitmap_left);
+
+ gl::end();
+ gl::disable(GL_TEXTURE_2D);
}
/*
- * This function is called to draw on-screen targets
- * if is_active_target is set, the target is the currently selected target
+ * This function is called to draw on-screen target indicators
+ * If is_active_target is set, the target is the currently selected HUD target
* */
void HUD::draw_target(core::Entity *entity, bool is_active_target)
{