more information for the InfoWindow,
set correct values for cloth material, enable specular map
This commit is contained in:
@@ -572,7 +572,6 @@ void MshFile::analyseClthChunks(Model * dataDestination, std::list<ChunkHeader*>
|
||||
for (auto& it : chunkList)
|
||||
{
|
||||
// texture name
|
||||
//TODO: change this
|
||||
if (!strcmp("CTEX", it->name))
|
||||
{
|
||||
// read the texture name
|
||||
@@ -581,26 +580,17 @@ void MshFile::analyseClthChunks(Model * dataDestination, std::list<ChunkHeader*>
|
||||
*buffer = { 0 };
|
||||
m_file.read(buffer, it->size);
|
||||
|
||||
// search if it is already known
|
||||
bool tmp_found(false);
|
||||
for (unsigned int index = 0; index < m_materials->size(); index++)
|
||||
{
|
||||
if (m_materials->at(index).name == QString(buffer))
|
||||
{
|
||||
tmp_found = true;
|
||||
new_segment->textureIndex = index;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
m_materials->push_back(Material());
|
||||
m_materials->back().name = "Cloth Material";
|
||||
m_materials->back().textureName = QString(buffer);
|
||||
|
||||
if(!tmp_found)
|
||||
{
|
||||
m_materials->push_back(Material());
|
||||
m_materials->back().name = QString(buffer);
|
||||
m_materials->back().shininess = 10;
|
||||
|
||||
loadTexture(m_materials->back().texture, m_filepath + "/" + m_materials->back().name);
|
||||
new_segment->textureIndex = m_materials->size() - 1;
|
||||
}
|
||||
if (!m_materials->back().textureName.isEmpty())
|
||||
loadTexture(m_materials->back().texture, m_filepath + "/" + m_materials->back().textureName);
|
||||
|
||||
new_segment->textureIndex = m_materials->size() - 1;
|
||||
|
||||
delete[] buffer;
|
||||
}
|
||||
@@ -688,21 +678,13 @@ void MshFile::loadTexture(QOpenGLTexture *& destination, QString filepath)
|
||||
bool loadSuccess(false);
|
||||
QImage img = loadTga(filepath, loadSuccess);
|
||||
|
||||
if (filepath.isEmpty())
|
||||
{
|
||||
loadSuccess = true;
|
||||
img = QImage(1, 1, QImage::Format_RGB32);
|
||||
img.fill(Qt::red);
|
||||
}
|
||||
else
|
||||
img = loadTga(filepath, loadSuccess);
|
||||
|
||||
if (!loadSuccess)
|
||||
{
|
||||
emit sendMessage("WARNING: texture not found or corrupted: " + m_materials->back().name, 1);
|
||||
|
||||
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));
|
||||
m_materials->back().textureName += " *";
|
||||
}
|
||||
|
||||
// Load image to OglTexture
|
||||
|
||||
Reference in New Issue
Block a user