more information for the InfoWindow,
set correct values for cloth material, enable specular map
This commit is contained in:
parent
5f104e46f2
commit
91488c55b2
|
@ -6,8 +6,8 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>200</width>
|
<width>320</width>
|
||||||
<height>300</height>
|
<height>400</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
|
@ -101,8 +101,8 @@ Triangles: -</string>
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>180</width>
|
<width>300</width>
|
||||||
<height>222</height>
|
<height>322</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||||
|
|
|
@ -12,10 +12,12 @@ space - reset view
|
||||||
L - set light to current position
|
L - set light to current position
|
||||||
esc - close
|
esc - close
|
||||||
|
|
||||||
using the X, Y, Z Button you can activate/deactivate the rotating directions
|
using the X, Y, Z buttons you can activate/deactivate the rotating directions.
|
||||||
|
|
||||||
tipp: do round movement to rotate the object in z-direction, when all directions are acitvated
|
tipp: do round movement to rotate the object in z-direction, when all directions are acitvated
|
||||||
|
|
||||||
|
textures marked with a '*' couldn't be open.
|
||||||
|
|
||||||
===============================================================
|
===============================================================
|
||||||
Credits:
|
Credits:
|
||||||
ANDEWEGET
|
ANDEWEGET
|
||||||
|
|
|
@ -12,6 +12,7 @@ uniform float materialShininess;
|
||||||
uniform vec3 materialSpecularColor;
|
uniform vec3 materialSpecularColor;
|
||||||
|
|
||||||
uniform bool b_transparent;
|
uniform bool b_transparent;
|
||||||
|
uniform bool b_specular;
|
||||||
uniform bool b_light;
|
uniform bool b_light;
|
||||||
|
|
||||||
uniform struct Light {
|
uniform struct Light {
|
||||||
|
@ -34,8 +35,6 @@ void main()
|
||||||
|
|
||||||
vec4 surfaceColor = vec4(texture2D(texture, v_surfaceUV));
|
vec4 surfaceColor = vec4(texture2D(texture, v_surfaceUV));
|
||||||
surfaceColor.rgb = pow(surfaceColor.rgb, vec3(2.2));
|
surfaceColor.rgb = pow(surfaceColor.rgb, vec3(2.2));
|
||||||
if(!b_transparent)
|
|
||||||
surfaceColor.a = 1.0f;
|
|
||||||
|
|
||||||
vec3 surfaceToLight;
|
vec3 surfaceToLight;
|
||||||
float attenuation;
|
float attenuation;
|
||||||
|
@ -67,6 +66,8 @@ void main()
|
||||||
float specularCoefficient = 0.0;
|
float specularCoefficient = 0.0;
|
||||||
if(diffuseCoefficient > 0.0)
|
if(diffuseCoefficient > 0.0)
|
||||||
specularCoefficient = pow(max(0.0, dot(surfaceToCamera, reflect(-surfaceToLight, normalWorld))), materialShininess);
|
specularCoefficient = pow(max(0.0, dot(surfaceToCamera, reflect(-surfaceToLight, normalWorld))), materialShininess);
|
||||||
|
if(b_specular)
|
||||||
|
materialSpecularColor = vec3(surfaceColor.a);
|
||||||
vec3 specular = specularCoefficient * materialSpecularColor * light.intensities;
|
vec3 specular = specularCoefficient * materialSpecularColor * light.intensities;
|
||||||
|
|
||||||
// linear color before gamma correction)
|
// linear color before gamma correction)
|
||||||
|
@ -74,6 +75,8 @@ void main()
|
||||||
|
|
||||||
// final color after gama correction
|
// final color after gama correction
|
||||||
vec3 gamma = vec3(1.0/2.2);
|
vec3 gamma = vec3(1.0/2.2);
|
||||||
|
if(!b_transparent)
|
||||||
|
surfaceColor.a = 1.0f;
|
||||||
gl_FragColor = vec4(pow(linearColor, gamma), surfaceColor.a);
|
gl_FragColor = vec4(pow(linearColor, gamma), surfaceColor.a);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -177,6 +177,7 @@ void GeometryEngine::drawGeometry(QOpenGLShaderProgram *program, bool wireframe)
|
||||||
for (auto& it : m_drawList)
|
for (auto& it : m_drawList)
|
||||||
{
|
{
|
||||||
bool tmp_transparent(false);
|
bool tmp_transparent(false);
|
||||||
|
bool tmp_specular(false);
|
||||||
float shininess;
|
float shininess;
|
||||||
QVector3D specularColor;
|
QVector3D specularColor;
|
||||||
|
|
||||||
|
@ -185,6 +186,7 @@ void GeometryEngine::drawGeometry(QOpenGLShaderProgram *program, bool wireframe)
|
||||||
{
|
{
|
||||||
m_materials->at(it.textureIndex).texture->bind();
|
m_materials->at(it.textureIndex).texture->bind();
|
||||||
tmp_transparent = m_materials->at(it.textureIndex).transparent;
|
tmp_transparent = m_materials->at(it.textureIndex).transparent;
|
||||||
|
tmp_specular = m_materials->at(it.textureIndex).flags[7];
|
||||||
shininess = m_materials->at(it.textureIndex).shininess;
|
shininess = m_materials->at(it.textureIndex).shininess;
|
||||||
specularColor = m_materials->at(it.textureIndex).specularColor.toVector3D();
|
specularColor = m_materials->at(it.textureIndex).specularColor.toVector3D();
|
||||||
}
|
}
|
||||||
|
@ -199,8 +201,9 @@ void GeometryEngine::drawGeometry(QOpenGLShaderProgram *program, bool wireframe)
|
||||||
// Set normal matrix
|
// Set normal matrix
|
||||||
program->setUniformValue("n_matrix", (normMatrix * it.modelMatrix).normalMatrix());
|
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_transparent", tmp_transparent);
|
||||||
|
program->setUniformValue("b_specular", tmp_specular);
|
||||||
|
|
||||||
// set some material attributes
|
// set some material attributes
|
||||||
program->setUniformValue("materialShininess", shininess);
|
program->setUniformValue("materialShininess", shininess);
|
||||||
|
|
|
@ -210,16 +210,68 @@ void MainWindow::setFileInfo(QString name, QVector<Material>* materials, int ver
|
||||||
m_fileInfo += QByteArray::number(triangle);
|
m_fileInfo += QByteArray::number(triangle);
|
||||||
m_fileInfo += "<detail>";
|
m_fileInfo += "<detail>";
|
||||||
|
|
||||||
int count(0);
|
|
||||||
//TODO: mark not opened textures
|
//TODO: mark not opened textures
|
||||||
//TODO: add more information
|
//TODO: add more information
|
||||||
for (auto& it : *materials)
|
for (auto& it : *materials)
|
||||||
{
|
{
|
||||||
m_fileInfo += "Material ";
|
|
||||||
m_fileInfo += QByteArray::number(count++);
|
|
||||||
m_fileInfo += " - ";
|
|
||||||
m_fileInfo += it.name;
|
m_fileInfo += it.name;
|
||||||
m_fileInfo += "\n";
|
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>")));
|
m_output->setText(m_fileInfo.left(m_fileInfo.indexOf("<detail>")));
|
||||||
|
|
|
@ -572,7 +572,6 @@ void MshFile::analyseClthChunks(Model * dataDestination, std::list<ChunkHeader*>
|
||||||
for (auto& it : chunkList)
|
for (auto& it : chunkList)
|
||||||
{
|
{
|
||||||
// texture name
|
// texture name
|
||||||
//TODO: change this
|
|
||||||
if (!strcmp("CTEX", it->name))
|
if (!strcmp("CTEX", it->name))
|
||||||
{
|
{
|
||||||
// read the texture name
|
// read the texture name
|
||||||
|
@ -581,26 +580,17 @@ void MshFile::analyseClthChunks(Model * dataDestination, std::list<ChunkHeader*>
|
||||||
*buffer = { 0 };
|
*buffer = { 0 };
|
||||||
m_file.read(buffer, it->size);
|
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!tmp_found)
|
m_materials->push_back(Material());
|
||||||
{
|
m_materials->back().name = "Cloth Material";
|
||||||
m_materials->push_back(Material());
|
m_materials->back().textureName = QString(buffer);
|
||||||
m_materials->back().name = QString(buffer);
|
|
||||||
|
|
||||||
loadTexture(m_materials->back().texture, m_filepath + "/" + m_materials->back().name);
|
m_materials->back().shininess = 10;
|
||||||
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;
|
delete[] buffer;
|
||||||
}
|
}
|
||||||
|
@ -688,21 +678,13 @@ void MshFile::loadTexture(QOpenGLTexture *& destination, QString filepath)
|
||||||
bool loadSuccess(false);
|
bool loadSuccess(false);
|
||||||
QImage img = loadTga(filepath, loadSuccess);
|
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)
|
if (!loadSuccess)
|
||||||
{
|
{
|
||||||
emit sendMessage("WARNING: texture not found or corrupted: " + m_materials->back().name, 1);
|
emit sendMessage("WARNING: texture not found or corrupted: " + m_materials->back().name, 1);
|
||||||
|
|
||||||
img = QImage(1, 1, QImage::Format_RGB32);
|
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));
|
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
|
// Load image to OglTexture
|
||||||
|
|
Loading…
Reference in New Issue