support normal map now,
support "glow" now, update preview.jpg
This commit is contained in:
@@ -5,7 +5,6 @@
|
||||
#include "..\Header\OutputDevice.h"
|
||||
#include <QRegExp>
|
||||
|
||||
#include "..\Header\Profiler.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// constructor/destructor
|
||||
@@ -119,11 +118,11 @@ void GeometryEngine::drawGeometry(QOpenGLShaderProgram *program)
|
||||
float maxExtent = std::max(std::max(m_boundings.extents[0], m_boundings.extents[1]), m_boundings.extents[2]);
|
||||
normMatrix.scale(1 / maxExtent);
|
||||
normMatrix.translate(-m_boundings.center[0], -m_boundings.center[1], -m_boundings.center[2]);
|
||||
program->setUniformValue("norm_matrix", normMatrix);
|
||||
program->setUniformValue("normalizeModel", normMatrix);
|
||||
|
||||
// Allways use texture unit 0 and 1
|
||||
program->setUniformValue("texture", 0);
|
||||
program->setUniformValue("secondTexture", 1);
|
||||
program->setUniformValue("tx0", 0);
|
||||
program->setUniformValue("tx1", 1);
|
||||
|
||||
//setup the pipeline
|
||||
setupPipeline(program);
|
||||
@@ -135,6 +134,7 @@ void GeometryEngine::drawGeometry(QOpenGLShaderProgram *program)
|
||||
bool tmp_transparent(false);
|
||||
bool tmp_specular(false);
|
||||
bool tmp_normalmap(false);
|
||||
bool tmp_glow(false);
|
||||
float shininess(0.0);
|
||||
QVector3D specularColor;
|
||||
|
||||
@@ -155,6 +155,9 @@ void GeometryEngine::drawGeometry(QOpenGLShaderProgram *program)
|
||||
m_materials->at(it.textureIndex).texture1->bind(1);
|
||||
}
|
||||
}
|
||||
|
||||
if (m_materials->at(it.textureIndex).flags[0] || m_materials->at(it.textureIndex).flags[1] || m_materials->at(it.textureIndex).rendertype == 1)
|
||||
tmp_glow = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -163,19 +166,18 @@ void GeometryEngine::drawGeometry(QOpenGLShaderProgram *program)
|
||||
}
|
||||
|
||||
// Set model matrix
|
||||
program->setUniformValue("m_matrix", it.modelMatrix);
|
||||
program->setUniformValue("modelMatrix", it.modelMatrix);
|
||||
|
||||
// Set normal matrix
|
||||
program->setUniformValue("n_matrix", (normMatrix * it.modelMatrix).normalMatrix());
|
||||
|
||||
// set some more values
|
||||
program->setUniformValue("b_transparent", tmp_transparent);
|
||||
program->setUniformValue("b_specular", tmp_specular);
|
||||
program->setUniformValue("b_normalmap", tmp_normalmap);
|
||||
program->setUniformValue("normalMatrix", (normMatrix * it.modelMatrix).normalMatrix());
|
||||
|
||||
// set some material attributes
|
||||
program->setUniformValue("materialShininess", shininess);
|
||||
program->setUniformValue("materialSpecularColor", specularColor);
|
||||
program->setUniformValue("material.shininess", shininess);
|
||||
program->setUniformValue("material.specularColor", specularColor);
|
||||
program->setUniformValue("material.isTransparent", tmp_transparent);
|
||||
program->setUniformValue("material.hasSpecularmap", tmp_specular);
|
||||
program->setUniformValue("material.hasNormalmap", tmp_normalmap);
|
||||
program->setUniformValue("material.isGlow", tmp_glow);
|
||||
|
||||
// Draw cube geometry using indices from VBO 1
|
||||
glDrawElements(GL_TRIANGLES, it.size, GL_UNSIGNED_INT, (void*)(it.offset * sizeof(GLuint)));
|
||||
@@ -185,7 +187,6 @@ void GeometryEngine::drawGeometry(QOpenGLShaderProgram *program)
|
||||
|
||||
void GeometryEngine::loadFile(QString filePath)
|
||||
{
|
||||
TIC("Start");
|
||||
// cleanup old stuff and recreate buffers
|
||||
clearData();
|
||||
m_arrayBuf.create();
|
||||
@@ -260,7 +261,5 @@ void GeometryEngine::loadFile(QString filePath)
|
||||
clearData();
|
||||
OutputDevice::getInstance()->print(QString(e.what()), 2);
|
||||
}
|
||||
|
||||
TOC("End");
|
||||
}
|
||||
|
||||
|
@@ -921,7 +921,7 @@ void MshFile::loadTexture(QOpenGLTexture *& destination, QString filepath, QStri
|
||||
if (!loadSuccess)
|
||||
{
|
||||
OutputDevice::getInstance()->print("WARNING: texture not found or corrupted: " + filename, 1);
|
||||
|
||||
//TODO: use the correct diffuse color or return with null
|
||||
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));
|
||||
filename += " *";
|
||||
|
@@ -143,10 +143,10 @@ void OglViewerWidget::paintGL()
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
// Set view-projection matrix
|
||||
m_program.setUniformValue("vp_matrix", m_projection * m_camera->getMatrix());
|
||||
m_program.setUniformValue("viewProjection", m_projection * m_camera->getMatrix());
|
||||
|
||||
// Set Light values
|
||||
m_program.setUniformValue("b_light", m_lightOn);
|
||||
m_program.setUniformValue("useLight", 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);
|
||||
|
Reference in New Issue
Block a user