From a6d3f3d779b031f8ca70510abe90fade909a8d0d Mon Sep 17 00:00:00 2001 From: ccolin Date: Sat, 26 Dec 2020 01:21:28 +0100 Subject: textures and whatnot i forgot to commit for a while lol --- src/drone_controller.cc | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'src/drone_controller.cc') 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(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); } -- cgit v1.2.3-70-g09d2