textures and whatnot i forgot to commit for a while lol

This commit is contained in:
2020-12-26 01:21:28 +01:00
parent c0116528a7
commit a6d3f3d779
12 changed files with 59 additions and 18 deletions

View File

@ -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);
}