Aufgrund von Umarbeiten des s3 Storage wird es in GitLab, in nächster Zeit, mögliche Performance-Einbußen geben. Näheres dazu unter: https://maintenance.itc.rwth-aachen.de/ticket/status/messages/43/show_ticket/6670

Commit 10718f22 authored by Anakin's avatar Anakin

load tx1d texture

parent b2df84eb
...@@ -43,7 +43,7 @@ private: ...@@ -43,7 +43,7 @@ private:
void readVertex(Segment* dataDestination, std::streampos position); void readVertex(Segment* dataDestination, std::streampos position);
void readUV(Segment* dataDestination, std::streampos position); void readUV(Segment* dataDestination, std::streampos position);
void loadTexture(QOpenGLTexture*& destination, QString filepath); void loadTexture(QOpenGLTexture*& destination, QString filepath, QString& filename);
QMatrix4x4 getParentMatrix(std::string parent) const; QMatrix4x4 getParentMatrix(std::string parent) const;
QQuaternion getParentRotation(std::string parent) const; QQuaternion getParentRotation(std::string parent) const;
......
...@@ -39,7 +39,13 @@ void GeometryEngine::clearData() ...@@ -39,7 +39,13 @@ void GeometryEngine::clearData()
if (m_materials != Q_NULLPTR) if (m_materials != Q_NULLPTR)
{ {
for (auto it : *m_materials) for (auto it : *m_materials)
delete it.texture0; {
if (it.texture0 != Q_NULLPTR)
delete it.texture0;
if (it.texture1 != Q_NULLPTR)
delete it.texture1;
}
m_materials->clear(); m_materials->clear();
delete m_materials; delete m_materials;
} }
......
...@@ -293,7 +293,7 @@ void MshFile::analyseMatdChunks(std::list<ChunkHeader*>& chunkList) ...@@ -293,7 +293,7 @@ void MshFile::analyseMatdChunks(std::list<ChunkHeader*>& chunkList)
// load the texture if the name is not empty // load the texture if the name is not empty
if (!m_materials->back().tx0d.isEmpty()) if (!m_materials->back().tx0d.isEmpty())
loadTexture(m_materials->back().texture0, m_filepath + "/" + m_materials->back().tx0d); loadTexture(m_materials->back().texture0, m_filepath, m_materials->back().tx0d);
} }
// texture 1 // texture 1
...@@ -307,7 +307,9 @@ void MshFile::analyseMatdChunks(std::list<ChunkHeader*>& chunkList) ...@@ -307,7 +307,9 @@ void MshFile::analyseMatdChunks(std::list<ChunkHeader*>& chunkList)
m_materials->back().tx1d = buffer; m_materials->back().tx1d = buffer;
delete[] buffer; delete[] buffer;
// TODO: load texture to slot 1, need to change loadTexutre function if (!m_materials->back().tx1d.isEmpty())
loadTexture(m_materials->back().texture1, m_filepath, m_materials->back().tx1d);
} }
// texture 2 // texture 2
...@@ -628,7 +630,7 @@ void MshFile::analyseClthChunks(Model * dataDestination, std::list<ChunkHeader*> ...@@ -628,7 +630,7 @@ void MshFile::analyseClthChunks(Model * dataDestination, std::list<ChunkHeader*>
m_materials->back().shininess = 10; m_materials->back().shininess = 10;
if (!m_materials->back().tx0d.isEmpty()) if (!m_materials->back().tx0d.isEmpty())
loadTexture(m_materials->back().texture0, m_filepath + "/" + m_materials->back().tx0d); loadTexture(m_materials->back().texture0, m_filepath, m_materials->back().tx0d);
new_segment->textureIndex = m_materials->size() - 1; new_segment->textureIndex = m_materials->size() - 1;
...@@ -713,18 +715,18 @@ void MshFile::readUV(Segment * dataDestination, std::streampos position) ...@@ -713,18 +715,18 @@ void MshFile::readUV(Segment * dataDestination, std::streampos position)
m_file.read(F2V(dataDestination->vertices[i].texCoord[j]), sizeof(float)); m_file.read(F2V(dataDestination->vertices[i].texCoord[j]), sizeof(float));
} }
void MshFile::loadTexture(QOpenGLTexture *& destination, QString filepath) void MshFile::loadTexture(QOpenGLTexture *& destination, QString filepath, QString& filename)
{ {
bool loadSuccess(false); bool loadSuccess(false);
QImage img = loadTga(filepath, loadSuccess); QImage img = loadTga(filepath + "/" + filename, loadSuccess);
if (!loadSuccess) if (!loadSuccess)
{ {
emit sendMessage("WARNING: texture not found or corrupted: " + m_materials->back().name, 1); emit sendMessage("WARNING: texture not found or corrupted: " + filename, 1);
img = QImage(1, 1, QImage::Format_RGB32); img = QImage(1, 1, QImage::Format_RGB32);
img.fill(QColor(m_materials->back().diffuseColor[0] * 255, m_materials->back().diffuseColor[1] * 255, m_materials->back().diffuseColor[2] * 255)); img.fill(QColor(m_materials->back().diffuseColor[0] * 255, m_materials->back().diffuseColor[1] * 255, m_materials->back().diffuseColor[2] * 255));
m_materials->back().tx0d += " *"; filename += " *";
} }
// Load image to OglTexture // Load image to OglTexture
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment