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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user