aboutsummaryrefslogtreecommitdiff
path: root/src/drone.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/drone.cc')
-rw-r--r--src/drone.cc18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/drone.cc b/src/drone.cc
index 0be11a6..2c0fad8 100644
--- a/src/drone.cc
+++ b/src/drone.cc
@@ -4,6 +4,7 @@
#include "opengl_widget.hh"
#include <QJsonArray>
+#include <QDebug>
bool Drone::mesh_initialized = false;
@@ -11,14 +12,15 @@ OpenGLMesh *Drone::mesh = nullptr;
Drone::Drone(int id)
:id(id) {
+ OpenGLWidget *glw = OpenGLWidget::instance;
if (!mesh_initialized) {
+ glw->makeCurrent();
QVector<GLfloat> verts = load_obj(":/mdl/dji600.obj", LOAD_OBJ_NORMALS | LOAD_OBJ_UVS);
QOpenGLTexture *texture = new QOpenGLTexture(QImage(":/img/dji600.jpg").mirrored());
- mesh = new OpenGLMesh(verts, texture);
+ mesh = new OpenGLMesh(verts, texture, glw->getMainProgram());
mesh_initialized = true;
+ glw->doneCurrent();
}
- OpenGLWidget::instance->meshes.append(*mesh);
- mesh_id = OpenGLWidget::instance->meshes.size() - 1;
}
@@ -51,8 +53,6 @@ void Drone::setTo(int frame) {
break;
}
}
- OpenGLMesh &mesh = OpenGLWidget::instance->meshes[mesh_id];
- mesh.mat = QMatrix4x4();
if (next > -1 && prev == -1) {
pos = next_wp->pos;
} else if (prev > -1 && next == -1) {
@@ -60,11 +60,10 @@ void Drone::setTo(int frame) {
} else {
pos = lerp(prev_wp->pos, next_wp->pos, (double) (frame-prev) / (next-prev));
}
- mesh.mat.translate(pos);
}
-QVector3D Drone::getPos() const {
+const QVector3D Drone::getPos() const {
return pos;
}
@@ -72,3 +71,8 @@ QVector3D Drone::getPos() const {
int Drone::getId() const {
return id;
}
+
+
+const OpenGLMesh *Drone::getMesh() const {
+ return mesh;
+}