mtllib fix
some tools do not add the mtllib line in the header, and simply call the mtl file like the main object file. Added a fall-back code to cover these cases
This commit is contained in:
parent
e5cdab35e4
commit
2fdad915cc
|
@ -615,6 +615,15 @@ namespace vcg {
|
||||||
}
|
}
|
||||||
else if ((header.compare("usemtl")==0) && (tokens.size() > 1)) // material usage
|
else if ((header.compare("usemtl")==0) && (tokens.size() > 1)) // material usage
|
||||||
{
|
{
|
||||||
|
// emergency check. If there are no materials, the materail library failed to load or was not specified
|
||||||
|
// but there are tools that save the material library with the same name of the file, but do not add the
|
||||||
|
// "mtllib" definition in the header. So, we can try to see if this is the case
|
||||||
|
if ((materials.size() == 1)&&(materials[0].materialName == "")){
|
||||||
|
std::string materialFileName(filename);
|
||||||
|
materialFileName.replace(materialFileName.end()-4, materialFileName.end(), ".mtl");
|
||||||
|
LoadMaterials(materialFileName.c_str(), materials, m.textures);
|
||||||
|
}
|
||||||
|
|
||||||
std::string materialName;
|
std::string materialName;
|
||||||
if (tokens.size() == 2)
|
if (tokens.size() == 2)
|
||||||
materialName = tokens[1]; //play it safe
|
materialName = tokens[1]; //play it safe
|
||||||
|
|
Loading…
Reference in New Issue