From cdd6ace701442fffa541150624107d6ddbb31056 Mon Sep 17 00:00:00 2001 From: Anakin Date: Sun, 22 Jan 2017 15:41:08 +0100 Subject: [PATCH] save rendertype, evaluate rednertype specular, changed info window always on top --- QtMeshViewer/Form Files/FileInfoWindow.ui | 67 ----------------------- QtMeshViewer/Header/FileInterface.h | 2 + QtMeshViewer/Source/FileInfoWindow.cpp | 4 +- QtMeshViewer/Source/MainWindow.cpp | 12 ++-- QtMeshViewer/Source/MshFile.cpp | 15 +++-- 5 files changed, 22 insertions(+), 78 deletions(-) diff --git a/QtMeshViewer/Form Files/FileInfoWindow.ui b/QtMeshViewer/Form Files/FileInfoWindow.ui index 912e070..8c4793b 100644 --- a/QtMeshViewer/Form Files/FileInfoWindow.ui +++ b/QtMeshViewer/Form Files/FileInfoWindow.ui @@ -26,73 +26,6 @@ Triangles: - - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - - false - true diff --git a/QtMeshViewer/Header/FileInterface.h b/QtMeshViewer/Header/FileInterface.h index ba7c12f..6368109 100644 --- a/QtMeshViewer/Header/FileInterface.h +++ b/QtMeshViewer/Header/FileInterface.h @@ -50,6 +50,8 @@ struct Material { float shininess = 80; bool flags[8] = { false }; bool transparent = false; + std::uint8_t rendertype = 0; + std::uint8_t dataValues[2] = { 0 }; }; class FileInterface : public QObject diff --git a/QtMeshViewer/Source/FileInfoWindow.cpp b/QtMeshViewer/Source/FileInfoWindow.cpp index 598b497..62c758d 100644 --- a/QtMeshViewer/Source/FileInfoWindow.cpp +++ b/QtMeshViewer/Source/FileInfoWindow.cpp @@ -7,7 +7,9 @@ FileInfoWindow::FileInfoWindow(QWidget *parent) { ui->setupUi(this); - setWindowFlags(Qt::Tool | Qt::WindowStaysOnTopHint | Qt::NoDropShadowWindowHint); + setWindowFlags(Qt::Tool | Qt::NoDropShadowWindowHint); + + ui->scrollArea->setStyleSheet("background-color: #ffffff"); } diff --git a/QtMeshViewer/Source/MainWindow.cpp b/QtMeshViewer/Source/MainWindow.cpp index ea4f651..4382ba5 100644 --- a/QtMeshViewer/Source/MainWindow.cpp +++ b/QtMeshViewer/Source/MainWindow.cpp @@ -20,7 +20,7 @@ MainWindow::MainWindow(QWidget *parent) , ui(new Ui::MainWindowClass) , m_curSeverity(0) , m_output(new QLabel(this)) - , m_infoWindow(new FileInfoWindow()) + , m_infoWindow(new FileInfoWindow(this)) { ui->setupUi(this); @@ -233,12 +233,16 @@ void MainWindow::setFileInfo(QString name, QVector* materials, int ver } m_fileInfo += "\n"; - m_fileInfo += "Rendertype:\t-"; - //TODO: rendertype + m_fileInfo += "Rendertype:\t"; + m_fileInfo += QByteArray::number(it.rendertype); m_fileInfo += "\n"; - m_fileInfo += "Shininess:\t"; + m_fileInfo += "Gloss:\t"; m_fileInfo += QByteArray::number(it.shininess); + m_fileInfo += "\tData0:\t"; + m_fileInfo += QByteArray::number(it.dataValues[0]); + m_fileInfo += "\tData1:\t"; + m_fileInfo += QByteArray::number(it.dataValues[1]); m_fileInfo += "\n"; m_fileInfo += "Diffusecolor:\tR: "; diff --git a/QtMeshViewer/Source/MshFile.cpp b/QtMeshViewer/Source/MshFile.cpp index 2ea6893..e42918c 100644 --- a/QtMeshViewer/Source/MshFile.cpp +++ b/QtMeshViewer/Source/MshFile.cpp @@ -253,13 +253,16 @@ void MshFile::analyseMatdChunks(std::list& chunkList) // attributes else if (!strcmp("ATRB", it->name)) { + // get pointer to current material + Material* curMat = &m_materials->back(); + // read the attributes m_file.seekg(it->position); - std::uint8_t flag, render, data[2]; + std::uint8_t flag; m_file.read(F2V(flag), sizeof(flag)); - m_file.read(F2V(render), sizeof(render)); - m_file.read(F2V(data[0]), sizeof(data[0])); - m_file.read(F2V(data[1]), sizeof(data[1])); + m_file.read(F2V(curMat->rendertype), sizeof(std::uint8_t)); + m_file.read(F2V(curMat->dataValues[0]), sizeof(std::uint8_t)); + m_file.read(F2V(curMat->dataValues[1]), sizeof(std::uint8_t)); // flags // 0: emissive @@ -272,9 +275,9 @@ void MshFile::analyseMatdChunks(std::list& chunkList) // 7: specular for (unsigned int i = 0; i < 8; i++) - m_materials->back().flags[i] = (std::uint8_t)(flag << (7 - i)) >> 7; + curMat->flags[i] = (std::uint8_t)(flag << (7 - i)) >> 7; - m_materials->back().transparent = m_materials->back().flags[2] || m_materials->back().flags[3] || m_materials->back().flags[4] || m_materials->back().flags[6]; + curMat->transparent = curMat->flags[2] || curMat->flags[3] || curMat->flags[4] || curMat->flags[6] || curMat->rendertype == 4; }