Improve OBJ mesh export in case output format is not explicitly specified

This commit is contained in:
wmayer
2019-07-05 12:23:13 +02:00
parent 9826c2c2ae
commit 8b0ee4c4a2

View File

@@ -362,13 +362,18 @@ void MeshObject::save(const char* file, MeshCore::MeshIO::Format f,
aWriter.Transform(this->_Mtrx);
if (aWriter.SaveAny(file, f)) {
if (mat && mat->binding == MeshCore::MeshIO::PER_FACE && f == MeshCore::MeshIO::OBJ) {
Base::FileInfo fi(file);
std::string fn = fi.dirPath() + "/" + mat->library;
fi.setFile(fn);
Base::ofstream str(fi, std::ios::out | std::ios::binary);
aWriter.SaveMTL(str);
str.close();
if (mat && mat->binding == MeshCore::MeshIO::PER_FACE) {
if (f == MeshCore::MeshIO::Undefined)
f = MeshCore::MeshOutput::GetFormat(file);
if (f == MeshCore::MeshIO::OBJ) {
Base::FileInfo fi(file);
std::string fn = fi.dirPath() + "/" + mat->library;
fi.setFile(fn);
Base::ofstream str(fi, std::ios::out | std::ios::binary);
aWriter.SaveMTL(str);
str.close();
}
}
}
}