diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/render/draw.cc | 60 | ||||
-rw-r--r-- | src/render/draw.h | 4 | ||||
-rw-r--r-- | src/render/state.cc | 2 |
3 files changed, 63 insertions, 3 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) { diff --git a/src/render/draw.h b/src/render/draw.h index f814168..a477d35 100644 --- a/src/render/draw.h +++ b/src/render/draw.h @@ -21,8 +21,12 @@ void pass_reset_lights(); /// draw the world void draw(float seconds); +/// draws model docks, used when targetting an entity void draw_target(const core::Entity *entity); +/// draws entity weapon slots +void draw_slots(const core::Entity *entity); + /// reset void reset(); diff --git a/src/render/state.cc b/src/render/state.cc index 8d1f3b0..06156a1 100644 --- a/src/render/state.cc +++ b/src/render/state.cc @@ -222,7 +222,7 @@ void State::use_material(const model::Material * material) { return; } - // Decal macro + // material has the decal flag set if (material->flags() & model::Material::Decal) { gl::enable(GL_POLYGON_OFFSET_FILL); gl::enable(GL_ALPHA_TEST); |