read tx1d tx2d tx3d texture names and print to info window
This commit is contained in:
@@ -249,7 +249,6 @@ void MshFile::analyseMatdChunks(std::list<ChunkHeader*>& chunkList)
|
||||
m_file.read(F2V(m_materials->back().shininess), sizeof(float));
|
||||
}
|
||||
|
||||
// TODO: evaluate specular, gloss,.. and save values
|
||||
// attributes
|
||||
else if (!strcmp("ATRB", it->name))
|
||||
{
|
||||
@@ -281,7 +280,7 @@ void MshFile::analyseMatdChunks(std::list<ChunkHeader*>& chunkList)
|
||||
|
||||
}
|
||||
|
||||
// texture zero
|
||||
// texture 0
|
||||
else if (!strcmp("TX0D", it->name))
|
||||
{
|
||||
// get the texture name
|
||||
@@ -289,12 +288,50 @@ void MshFile::analyseMatdChunks(std::list<ChunkHeader*>& chunkList)
|
||||
char* buffer = new char[it->size + 1];
|
||||
*buffer = { 0 };
|
||||
m_file.read(buffer, it->size);
|
||||
m_materials->back().textureName = buffer;
|
||||
m_materials->back().tx0d = buffer;
|
||||
delete[] buffer;
|
||||
|
||||
// load the texture if the name is not empty
|
||||
if (!m_materials->back().textureName.isEmpty())
|
||||
loadTexture(m_materials->back().texture, m_filepath + "/" + m_materials->back().textureName);
|
||||
if (!m_materials->back().tx0d.isEmpty())
|
||||
loadTexture(m_materials->back().texture0, m_filepath + "/" + m_materials->back().tx0d);
|
||||
}
|
||||
|
||||
// texture 1
|
||||
else if (!strcmp("TX1D", it->name))
|
||||
{
|
||||
// get the texture name
|
||||
m_file.seekg(it->position);
|
||||
char* buffer = new char[it->size + 1];
|
||||
*buffer = { 0 };
|
||||
m_file.read(buffer, it->size);
|
||||
m_materials->back().tx1d = buffer;
|
||||
delete[] buffer;
|
||||
|
||||
// TODO: load texture to slot 1, need to change loadTexutre function
|
||||
}
|
||||
|
||||
// texture 2
|
||||
else if (!strcmp("TX2D", it->name))
|
||||
{
|
||||
// get the texture name
|
||||
m_file.seekg(it->position);
|
||||
char* buffer = new char[it->size + 1];
|
||||
*buffer = { 0 };
|
||||
m_file.read(buffer, it->size);
|
||||
m_materials->back().tx2d = buffer;
|
||||
delete[] buffer;
|
||||
}
|
||||
|
||||
// texture 3
|
||||
else if (!strcmp("TX3D", it->name))
|
||||
{
|
||||
// get the texture name
|
||||
m_file.seekg(it->position);
|
||||
char* buffer = new char[it->size + 1];
|
||||
*buffer = { 0 };
|
||||
m_file.read(buffer, it->size);
|
||||
m_materials->back().tx3d = buffer;
|
||||
delete[] buffer;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -586,12 +623,12 @@ void MshFile::analyseClthChunks(Model * dataDestination, std::list<ChunkHeader*>
|
||||
|
||||
m_materials->push_back(Material());
|
||||
m_materials->back().name = "Cloth Material";
|
||||
m_materials->back().textureName = QString(buffer);
|
||||
m_materials->back().tx0d = QString(buffer);
|
||||
|
||||
m_materials->back().shininess = 10;
|
||||
|
||||
if (!m_materials->back().textureName.isEmpty())
|
||||
loadTexture(m_materials->back().texture, m_filepath + "/" + m_materials->back().textureName);
|
||||
if (!m_materials->back().tx0d.isEmpty())
|
||||
loadTexture(m_materials->back().texture0, m_filepath + "/" + m_materials->back().tx0d);
|
||||
|
||||
new_segment->textureIndex = m_materials->size() - 1;
|
||||
|
||||
@@ -687,7 +724,7 @@ void MshFile::loadTexture(QOpenGLTexture *& destination, QString filepath)
|
||||
|
||||
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));
|
||||
m_materials->back().textureName += " *";
|
||||
m_materials->back().tx0d += " *";
|
||||
}
|
||||
|
||||
// Load image to OglTexture
|
||||
|
||||
Reference in New Issue
Block a user