diff --git a/QtMeshViewer/Header/GeometryEngine.h b/QtMeshViewer/Header/GeometryEngine.h index db265b8..631e52f 100644 --- a/QtMeshViewer/Header/GeometryEngine.h +++ b/QtMeshViewer/Header/GeometryEngine.h @@ -29,7 +29,7 @@ private: QVector m_drawList; BoundingBox m_boundings; - void loadTexture(const char* filePath); + void loadTexture(const char* filePath, const char* fileName); void clearData(); public slots: diff --git a/QtMeshViewer/Source/GeometryEngine.cpp b/QtMeshViewer/Source/GeometryEngine.cpp index 49ccbbd..b30fff2 100644 --- a/QtMeshViewer/Source/GeometryEngine.cpp +++ b/QtMeshViewer/Source/GeometryEngine.cpp @@ -98,7 +98,7 @@ void GeometryEngine::loadFile(const char* filePath) emit sendMessage("loading textures..", 0); // load the textures for(auto& it : *textureNames) - loadTexture(std::string(path + it).c_str()); + loadTexture(path.c_str(), it.c_str()); emit requestUpdate(); emit sendMessage("done..", 0); @@ -109,11 +109,26 @@ void GeometryEngine::loadFile(const char* filePath) } } -void GeometryEngine::loadTexture(const char* filePath) +void GeometryEngine::loadTexture(const char* filePath, const char* fileName) { - bool loadSuccess; - QImage img = loadTga(filePath, loadSuccess); + bool loadSuccess(false); + QImage img; + //if (!strcmp(fileName, "")) + //{ + // img = QImage(1, 1, QImage::Format_RGB32); + // img.fill(Qt::red); + //} + //else + img = loadTga((std::string(filePath) + std::string(fileName)).c_str(), loadSuccess); + + //TODO: emit if not successfull + if (!loadSuccess) + { + QString msg = "WARNING: texture not found or corrupted: "; + msg += QString(fileName); + emit sendMessage(msg, 1); + } // Load image to OglTexture QOpenGLTexture* new_texture = new QOpenGLTexture(img.mirrored()); diff --git a/README.md b/README.md index cedcab4..47eed0b 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,9 @@ Feel free to use my code the way you like. But remember i used some public libra licence, too. ### To Do -- tga with RLE cannot be opend +- loading 2 corrupted tga files => crash +- every mesh has empty tga => corrupted +- add default texture at the end - optional display bones, shadow, collision,... - integrate into a software: -> list all msh under a directory,