use Qt resources for the drone model
This commit is contained in:
parent
1026231bb4
commit
c0116528a7
@ -4,6 +4,8 @@ TEMPLATE = app
|
||||
DEFINES += QT_DEPRECATED_WARNINGS
|
||||
CONFIG += qt debug
|
||||
|
||||
RESOURCES += resources.qrc
|
||||
|
||||
SOURCES += src/main.cc
|
||||
SOURCES += src/main_window.cc
|
||||
SOURCES += src/opengl_mesh.cc
|
||||
|
7
resources.qrc
Normal file
7
resources.qrc
Normal file
@ -0,0 +1,7 @@
|
||||
<!DOCTYPE RCC>
|
||||
<RCC version="1.0">
|
||||
<qresource>
|
||||
<file>mdl/dji600.obj</file>
|
||||
<file>mdl/dji600.mtl</file>
|
||||
</qresource>
|
||||
</RCC>
|
@ -6,6 +6,7 @@
|
||||
|
||||
#include <QJsonArray>
|
||||
#include <QDebug>
|
||||
#include <QFile>
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user