From c0116528a7b618d185ac688b31e0fa8752924375 Mon Sep 17 00:00:00 2001 From: ccolin Date: Tue, 22 Dec 2020 18:15:19 +0100 Subject: use Qt resources for the drone model --- src/drone_controller.cc | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/drone_controller.cc b/src/drone_controller.cc index 406a031..c625ca0 100644 --- a/src/drone_controller.cc +++ b/src/drone_controller.cc @@ -6,6 +6,7 @@ #include #include +#include Waypoint::Waypoint(unsigned frame, QVector3D pos) @@ -25,12 +26,19 @@ OpenGLMesh *Drone::mesh = nullptr; Drone::Drone() { if (!mesh_initialized) { - tinyobj::ObjReaderConfig reader_config; - reader_config.mtl_search_path = "../mdl/"; // Path to material files + QFile obj_file(":/mdl/dji600.obj"); + QFile mtl_file(":/mdl/dji600.mtl"); + obj_file.open(QIODevice::ReadOnly | QIODevice::Text); + mtl_file.open(QIODevice::ReadOnly | QIODevice::Text); + std::string obj = obj_file.readAll().toStdString(); + std::string mtl = mtl_file.readAll().toStdString(); + tinyobj::ObjReaderConfig cfg; + cfg.triangulate = true; + cfg.vertex_color = false; tinyobj::ObjReader reader; - if (!reader.ParseFromFile("../mdl/dji600.obj", reader_config)) { + if (!reader.ParseFromString(obj, mtl, cfg)) { if (!reader.Error().empty()) { - qWarning() << "Erreur lors de la lecture de ../mdl/dji600.obj"; + qWarning() << "Erreur lors de la lecture de du modèle"; } exit(1); } -- cgit v1.2.3-70-g09d2