aboutsummaryrefslogtreecommitdiff
path: root/src/drone_controller.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/drone_controller.cc')
-rw-r--r--src/drone_controller.cc23
1 files changed, 21 insertions, 2 deletions
diff --git a/src/drone_controller.cc b/src/drone_controller.cc
index c625ca0..2c956dd 100644
--- a/src/drone_controller.cc
+++ b/src/drone_controller.cc
@@ -62,16 +62,23 @@ Drone::Drone() {
tinyobj::real_t vx = attrib.vertices[3*idx.vertex_index+0];
tinyobj::real_t vy = attrib.vertices[3*idx.vertex_index+1];
tinyobj::real_t vz = attrib.vertices[3*idx.vertex_index+2];
+ tinyobj::real_t ts = attrib.texcoords[2*idx.texcoord_index+0];
+ tinyobj::real_t tt = attrib.texcoords[2*idx.texcoord_index+1];
verts.append(vx);
verts.append(vy);
verts.append(vz);
+ verts.append(ts);
+ verts.append(tt);
+ // qDebug() << "vert" << vx << vy << vz << "tex" << ts << tt;
}
index_offset += fv;
}
}
- mesh = new OpenGLMesh(verts);
- // mesh = new OpenGLMesh(QVector<float>(attrib.vertices.begin(), attrib.vertices.end()));
+ QOpenGLTexture *texture = new QOpenGLTexture(QImage(":/mdl/dji600.jpg").mirrored());
+ // texture->setMinificationFilter(QOpenGLTexture::LinearMipMapLinear);
+ // texture->setMagnificationFilter(QOpenGLTexture::Linear);
+ mesh = new OpenGLMesh(verts, texture);
mesh_initialized = true;
}
OpenGLWidget::instance->meshes.append(*mesh);
@@ -133,6 +140,18 @@ DroneController::DroneController(const QJsonObject &json)
}
}
+ OpenGLWidget::instance->makeCurrent();
+ QOpenGLTexture *ground_tex = new QOpenGLTexture(QImage(":/mdl/ground.jpg").mirrored());
+ OpenGLMesh *ground = new OpenGLMesh({
+ -100, 0, -100, 0, 0,
+ 100, 0, -100, 1, 0,
+ -100, 0, 100, 0, 1,
+ 100, 0, -100, 1, 0,
+ -100, 0, 100, 0, 1,
+ 100, 0, 100, 1, 1,
+ }, ground_tex);
+ OpenGLWidget::instance->meshes.append(*ground);
+ OpenGLWidget::instance->doneCurrent();
connect(&timer, &QTimer::timeout, this, &DroneController::step);
}