added specular, ambient light,...

need to fix the texutre gamma correction,
look at the todos
This commit is contained in:
Anakin
2017-01-19 17:57:50 +01:00
parent 4c177f2ddc
commit 9fb3ca03bd
6 changed files with 61 additions and 24 deletions

View File

@@ -176,12 +176,16 @@ void GeometryEngine::drawGeometry(QOpenGLShaderProgram *program, bool wireframe)
for (auto& it : m_drawList)
{
bool tmp_transparent(false);
float shininess;
QVector3D specularColor;
// bind the correct texture
if (it.textureIndex < m_materials->size() && m_materials->at(it.textureIndex).texture != Q_NULLPTR)
{
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;
}
else
{
@@ -197,6 +201,10 @@ void GeometryEngine::drawGeometry(QOpenGLShaderProgram *program, bool wireframe)
// decide if this is transparent
program->setUniformValue("b_transparent", tmp_transparent);
// set some material attributes
program->setUniformValue("materialShininess", shininess);
program->setUniformValue("materialSpecularColor", specularColor);
// Draw cube geometry using indices from VBO 1
if(wireframe)
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);

View File

@@ -217,6 +217,7 @@ void MshFile::analyseMatdChunks(std::list<ChunkHeader*>& chunkList)
{
for (auto& it : chunkList)
{
// TODO: don't load default texture, make it NULL
//TODO: get information from flags
// attributes
if (!strcmp("ATRB", it->name))

View File

@@ -234,6 +234,13 @@ void OglViewerWidget::paintGL()
m_program.setUniformValue("b_light", m_lightOn);
m_program.setUniformValue("light.position", m_light.position);
m_program.setUniformValue("light.intensities", m_light.intensities);
m_program.setUniformValue("light.attenuationFactor", m_light.attenuationFactor);
m_program.setUniformValue("light.ambientCoefficient", m_light.ambientCoefficient);
// Set camera position
QMatrix4x4 rotateBack;
rotateBack.rotate(m_rotation.inverted());
m_program.setUniformValue("cameraPosition", rotateBack * (-m_translation));
// Draw cube geometry
m_dataEngine->drawGeometry(&m_program, m_wireframe);