save more material information,

hold default material in geometry separated,
load diffuse color if texture cannot be opened,
fixed gamma correction on the texture,
This commit is contained in:
Anakin
2017-01-20 16:26:58 +01:00
parent abd9070e90
commit 9808cd03c0
5 changed files with 77 additions and 59 deletions

View File

@@ -14,11 +14,15 @@ GeometryEngine::GeometryEngine(QObject *parent)
, m_indexBuf(QOpenGLBuffer::IndexBuffer)
{
initializeOpenGLFunctions();
m_defaultMaterial = FileInterface::getDefaultMaterial();
}
GeometryEngine::~GeometryEngine()
{
clearData();
delete m_defaultMaterial->texture;
delete m_defaultMaterial;
}
@@ -113,9 +117,6 @@ void GeometryEngine::loadFile(QString filePath)
m_indexBuf.bind();
m_indexBuf.allocate(indexData.data(), indexData.size() * sizeof(GLuint));
//pushback a default material
m_materials->push_back(FileInterface::getDefaultMaterial());
emit requestUpdate();
emit sendMessage("done..", 0);
emit sendFileInfo(filePath.right(filePath.size() - filePath.lastIndexOf(QRegExp("/|\\\\")) - 1), m_materials, vertexData.size(), indexData.size() / 3);
@@ -185,12 +186,12 @@ void GeometryEngine::drawGeometry(QOpenGLShaderProgram *program, bool wireframe)
m_materials->at(it.textureIndex).texture->bind();
tmp_transparent = m_materials->at(it.textureIndex).transparent;
shininess = m_materials->at(it.textureIndex).shininess;
specularColor = m_materials->at(it.textureIndex).specularColor;
specularColor = m_materials->at(it.textureIndex).specularColor.toVector3D();
}
else
{
m_materials->last().texture->bind();
tmp_transparent = m_materials->last().transparent;
m_defaultMaterial->texture->bind();
tmp_transparent = m_defaultMaterial->transparent;
}
// Set model matrix
program->setUniformValue("m_matrix", it.modelMatrix);