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>2009-01-10 15:36:38 +0000
committerStijn Buys <ingar@osirion.org>2009-01-10 15:36:38 +0000
commit34d0dd66aa8dfe57199c5f3ac316bbcd46cdccf7 (patch)
tree6c2d02bf2b476db3cc191fe0a6e19e5477d3a055
parent272d229094309bc5875287a5063f818c58c5f4f8 (diff)
hud drawing code reorganization
-rw-r--r--src/render/draw.cc62
-rw-r--r--src/render/draw.h2
2 files changed, 64 insertions, 0 deletions
diff --git a/src/render/draw.cc b/src/render/draw.cc
index 1b964b2..fbf5058 100644
--- a/src/render/draw.cc
+++ b/src/render/draw.cc
@@ -1037,4 +1037,66 @@ void draw(float seconds)
// GL_BLEND must be enabled for the GUI
}
+void draw_target(core::Entity *entity)
+{
+ model::Model *model = entity->model();
+ if (!model)
+ return;
+
+ if (!model->docks().size())
+ return;
+
+ 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->location());
+ gl::multmatrix(entity->axis());
+
+ gl::color(0, 1.0f, 1.0f, 1.0f);
+
+ for (model::Model::Docks::iterator dit = model->docks().begin(); dit != model->docks().end(); dit++) {
+ model::Dock *dock = (*dit);
+ math::Vector3f maxbox(dock->location());
+ math::Vector3f minbox(dock->location());
+
+ for (size_t i=0; i < 3; i++) {
+ maxbox[i] += 0.025;
+ minbox[i] -= 0.025;
+ }
+
+ // top
+ gl::begin(gl::LineLoop);
+ gl::vertex(maxbox.x, maxbox.y, maxbox.z);
+ gl::vertex(minbox.x, maxbox.y, maxbox.z);
+ gl::vertex(minbox.x, minbox.y, maxbox.z);
+ gl::vertex(maxbox.x, minbox.y, maxbox.z);
+ gl::end();
+
+ // bottom
+ gl::begin(gl::LineLoop);
+ gl::vertex(maxbox.x, maxbox.y, minbox.z);
+ gl::vertex(minbox.x, maxbox.y, minbox.z);
+ gl::vertex(minbox.x, minbox.y, minbox.z);
+ gl::vertex(maxbox.x, minbox.y, minbox.z);
+ gl::end();
+
+ gl::begin(gl::Lines);
+ gl::vertex(maxbox.x, maxbox.y, maxbox.z);
+ gl::vertex(maxbox.x, maxbox.y, minbox.z);
+ gl::vertex(minbox.x, maxbox.y, maxbox.z);
+ gl::vertex(minbox.x, maxbox.y, minbox.z);
+ gl::vertex(minbox.x, minbox.y, maxbox.z);
+ gl::vertex(minbox.x, minbox.y, minbox.z);
+ gl::vertex(maxbox.x, minbox.y, maxbox.z);
+ gl::vertex(maxbox.x, minbox.y, minbox.z);
+ gl::end();
+ }
+
+ gl::pop();
+ gl::disable(GL_DEPTH_TEST);
+}
+
}
diff --git a/src/render/draw.h b/src/render/draw.h
index 89c5ea7..14ad2fa 100644
--- a/src/render/draw.h
+++ b/src/render/draw.h
@@ -16,6 +16,8 @@ namespace render
/// draw the world
void draw(float seconds);
+void draw_target(core::Entity *entity);
+
/// reset
void reset();