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>2012-04-22 19:51:45 +0000
committerStijn Buys <ingar@osirion.org>2012-04-22 19:51:45 +0000
commit4762531e81fc694008c2a3d2b3818d8972916ca5 (patch)
treea9ac7bdcf1418951d5a7552092cd8aedeb8a47c8 /src/render/draw.cc
parent130682a299e202c4a02521c05ab11054fc0ba6b3 (diff)
Draw weapon slot placeholder boxes.
Diffstat (limited to 'src/render/draw.cc')
-rw-r--r--src/render/draw.cc60
1 files changed, 58 insertions, 2 deletions
diff --git a/src/render/draw.cc b/src/render/draw.cc
index ed9c6a6..efdbd84 100644
--- a/src/render/draw.cc
+++ b/src/render/draw.cc
@@ -87,8 +87,7 @@ int add_light(const math::Vector3f & location, float attenuation, const math::Co
if (!glIsEnabled(GL_LIGHT0 + i)) {
gllight = GL_LIGHT0 + i;
break;
- }
- else {
+ } else {
gllight = GL_LIGHT0;
return gllight;
}
@@ -833,6 +832,9 @@ void draw_pass_model_fragments()
ext_render(entity)->thrust()
);
+ if (entity->slots())
+ draw_slots(entity);
+
if (r_bbox->value()) {
gl::color(entity->color());
draw_model_bbox(entity->model());
@@ -1294,6 +1296,60 @@ void draw(float seconds)
pass_reset_lights();
}
+// draw weapon slots
+// weapons are drawn in model space coordinate, model transformations
+void draw_slots(const core::Entity *entity)
+{
+ assert(entity->slots() && entity->model());
+
+ gl::disable(GL_DEPTH_TEST);
+
+ //const float modelscale = entity->radius() / entity->model()->radius();
+
+ gl::color(1.0f, 0.0f, 0.0f, 1.0f);
+
+ for(core::Slots::iterator it = entity->slots()->begin(); it != entity->slots()->end(); ++it) {
+ core::Slot *slot = (*it);
+
+ math::Vector3f maxbox(slot->location());
+ math::Vector3f minbox(slot->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::enable(GL_DEPTH_TEST);
+}
+
// draw HUD target world space geometry, like dock indicators
void draw_target(const core::Entity *entity)
{