diff options
Diffstat (limited to 'src/render')
-rw-r--r-- | src/render/draw.cc | 62 | ||||
-rw-r--r-- | src/render/draw.h | 2 |
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(); |