diff options
Diffstat (limited to 'src/drone_controller.cc')
-rw-r--r-- | src/drone_controller.cc | 32 |
1 files changed, 14 insertions, 18 deletions
diff --git a/src/drone_controller.cc b/src/drone_controller.cc index f6edfb6..0be9844 100644 --- a/src/drone_controller.cc +++ b/src/drone_controller.cc @@ -3,6 +3,7 @@ #include <QJsonArray> #include <QDebug> +#include <QOpenGLShaderProgram> DroneController::DroneController(const QJsonObject &json) @@ -19,33 +20,26 @@ DroneController::DroneController(const QJsonObject &json) } } - OpenGLWidget::instance->makeCurrent(); - QOpenGLTexture *ground_tex = new QOpenGLTexture(QImage(":/img/ground.jpg").mirrored()); - ground_tex->setMagnificationFilter(QOpenGLTexture::LinearMipMapLinear); - ground_tex->setMinificationFilter(QOpenGLTexture::LinearMipMapLinear); - ground_tex->setWrapMode(QOpenGLTexture::MirroredRepeat); - OpenGLMesh *ground = new OpenGLMesh({ - -1000, 0, -1000, 0, 1000, 0, 0, 0, - 1000, 0, -1000, 0, 1000, 0, 1000, 0, - -1000, 0, 1000, 0, 1000, 0, 0, 1000, - 1000, 0, -1000, 0, 1000, 0, 1000, 0, - -1000, 0, 1000, 0, 1000, 0, 0, 1000, - 1000, 0, 1000, 0, 1000, 0, 1000, 1000, - }, ground_tex); - OpenGLWidget::instance->meshes.append(*ground); - OpenGLWidget::instance->doneCurrent(); - connect(&timer, &QTimer::timeout, this, &DroneController::step); } +void DroneController::draw(QOpenGLExtraFunctions *f) const { + for (const Drone &d : drones) { + QMatrix4x4 mat; + mat.translate(d.getPos()); + d.getMesh()->draw(f, mat); + } +} + + int DroneController::getDuration() const { return duration; } void DroneController::step() { - for (Drone d : drones) { + for (Drone &d : drones) { d.setTo(frame); } OpenGLWidget::instance->update(); @@ -111,7 +105,9 @@ void DroneController::computeCollisions(double sphere_radius) { } } } - seek(frame); + for (Drone &d : drones) { + d.setTo(frame); + } } |