more information for the InfoWindow,

set correct values for cloth material,
enable specular map
This commit is contained in:
Anakin
2017-01-22 14:37:06 +01:00
parent 5f104e46f2
commit 91488c55b2
6 changed files with 82 additions and 40 deletions

View File

@@ -177,6 +177,7 @@ void GeometryEngine::drawGeometry(QOpenGLShaderProgram *program, bool wireframe)
for (auto& it : m_drawList)
{
bool tmp_transparent(false);
bool tmp_specular(false);
float shininess;
QVector3D specularColor;
@@ -185,6 +186,7 @@ void GeometryEngine::drawGeometry(QOpenGLShaderProgram *program, bool wireframe)
{
m_materials->at(it.textureIndex).texture->bind();
tmp_transparent = m_materials->at(it.textureIndex).transparent;
tmp_specular = m_materials->at(it.textureIndex).flags[7];
shininess = m_materials->at(it.textureIndex).shininess;
specularColor = m_materials->at(it.textureIndex).specularColor.toVector3D();
}
@@ -199,8 +201,9 @@ void GeometryEngine::drawGeometry(QOpenGLShaderProgram *program, bool wireframe)
// Set normal matrix
program->setUniformValue("n_matrix", (normMatrix * it.modelMatrix).normalMatrix());
// decide if this is transparent
// set some more values
program->setUniformValue("b_transparent", tmp_transparent);
program->setUniformValue("b_specular", tmp_specular);
// set some material attributes
program->setUniformValue("materialShininess", shininess);

View File

@@ -210,16 +210,68 @@ void MainWindow::setFileInfo(QString name, QVector<Material>* materials, int ver
m_fileInfo += QByteArray::number(triangle);
m_fileInfo += "<detail>";
int count(0);
//TODO: mark not opened textures
//TODO: add more information
for (auto& it : *materials)
{
m_fileInfo += "Material ";
m_fileInfo += QByteArray::number(count++);
m_fileInfo += " - ";
m_fileInfo += it.name;
m_fileInfo += "\n";
m_fileInfo += "TX0D:\t\t";
if (it.texture == NULL)
m_fileInfo += "-";
m_fileInfo += it.textureName;
m_fileInfo += "\n";
m_fileInfo += "Flags:\t\t";
for (int i = 0; i < 8; i++)
{
if (it.flags[i])
m_fileInfo += "1";
else
m_fileInfo += "0";
}
m_fileInfo += "\n";
m_fileInfo += "Rendertype:\t-";
//TODO: rendertype
m_fileInfo += "\n";
m_fileInfo += "Shininess:\t";
m_fileInfo += QByteArray::number(it.shininess);
m_fileInfo += "\n";
m_fileInfo += "Diffusecolor:\tR: ";
m_fileInfo += QByteArray::number(it.diffuseColor.x());
m_fileInfo += "\tG: ";
m_fileInfo += QByteArray::number(it.diffuseColor.y());
m_fileInfo += "\tB: ";
m_fileInfo += QByteArray::number(it.diffuseColor.z());
m_fileInfo += "\tA: ";
m_fileInfo += QByteArray::number(it.diffuseColor.w());
m_fileInfo += "\n";
m_fileInfo += "Ambientcolor:\tR: ";
m_fileInfo += QByteArray::number(it.ambientColor.x());
m_fileInfo += "\tG: ";
m_fileInfo += QByteArray::number(it.ambientColor.y());
m_fileInfo += "\tB: ";
m_fileInfo += QByteArray::number(it.ambientColor.z());
m_fileInfo += "\tA: ";
m_fileInfo += QByteArray::number(it.ambientColor.w());
m_fileInfo += "\n";
m_fileInfo += "Specularcolor:\tR: ";
m_fileInfo += QByteArray::number(it.specularColor.x());
m_fileInfo += "\tG: ";
m_fileInfo += QByteArray::number(it.specularColor.y());
m_fileInfo += " \tB: ";
m_fileInfo += QByteArray::number(it.specularColor.z());
m_fileInfo += " \tA: ";
m_fileInfo += QByteArray::number(it.specularColor.w());
m_fileInfo += "\n";
m_fileInfo += "-----------------------------------------------------------------\n";
}
m_output->setText(m_fileInfo.left(m_fileInfo.indexOf("<detail>")));

View File

@@ -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