diff options
Diffstat (limited to 'src/drone_controller.cc')
-rw-r--r-- | src/drone_controller.cc | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/drone_controller.cc b/src/drone_controller.cc index dbe9a00..ffac66f 100644 --- a/src/drone_controller.cc +++ b/src/drone_controller.cc @@ -76,6 +76,25 @@ void DroneController::drawTrajectory(QOpenGLExtraFunctions *f, const Drone &d) c } +void DroneController::drawSupportLine(QOpenGLExtraFunctions *f, const Drone &d) const { + OpenGLWidget::instance->getLineProgram()->bind(); + OpenGLWidget::instance->getLineProgram()->setUniformValue("color", .2, .2, .2); + GLfloat data[6] = { + d.getPos().x(), 0, d.getPos().z(), + d.getPos().x(), d.getPos().y(), d.getPos().z(), + }; + f->glEnableVertexAttribArray(0); + f->glBindBuffer(GL_ARRAY_BUFFER, 0); + f->glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, data); + glLineWidth(2); + f->glDisable(GL_CULL_FACE); + f->glDrawArrays(GL_LINES, 0, 2); + f->glEnable(GL_CULL_FACE); + OpenGLWidget::instance->getLineProgram()->release(); + OpenGLWidget::instance->getMainProgram()->bind(); +} + + void DroneController::draw(QOpenGLExtraFunctions *f) const { const QVector<QPair<int, int>> &col = collisions[frame]; for (const Drone &d : drones) { @@ -95,6 +114,9 @@ void DroneController::draw(QOpenGLExtraFunctions *f) const { if (draw_trajectories) { drawTrajectory(f, d); } + if (draw_support_lines) { + drawSupportLine(f, d); + } } } @@ -196,3 +218,8 @@ void DroneController::setDrawTrajectories(bool enable) { draw_trajectories = enable; OpenGLWidget::instance->update(); } + +void DroneController::setDrawSupportLines(bool enable) { + draw_support_lines = enable; + OpenGLWidget::instance->update(); +} |