Commit 2996ce3e authored by Jan Möbius's avatar Jan Möbius
Browse files

Added prefix to texture dir to avoid overwriting existing texture files

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@11125 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 17a55b9f
......@@ -110,7 +110,9 @@ bool FileOBJPlugin::writeMaterial(QString _filename, MeshT& _mesh, int _objId )
// Use file path in target folder (relative)
QFileInfo file(mat.map_Kd().c_str());
if(optionCreateTexFolder) {
matStream << "map_Kd textures" << QDir::separator().toAscii()
QFileInfo materialFilename(_filename);
matStream << "map_Kd " << materialFilename.baseName().toStdString() << "_textures" << QDir::separator().toAscii()
<< file.fileName().toStdString() << std::endl;
} else {
matStream << "map_Kd " << file.fileName().toStdString() << std::endl;
......@@ -402,12 +404,12 @@ bool FileOBJPlugin::writeMesh(std::ostream& _out, QString _filename, MeshT& _mes
if(optionCreateTexFolder) {
// Create folder
QDir dir(fi.absolutePath());
if(!testedOnce && dir.exists(fi.absolutePath() + QDir::separator() + "textures")) {
if(!testedOnce && dir.exists(fi.absolutePath() + QDir::separator() + fi.baseName() + "_textures")) {
emit log(LOGERR, tr("The specified target folder already contains a subfolder called textures. Skipping!"));
continue;
} else {
dir.mkdir("textures");
img.save(fi.absolutePath() + QDir::separator() + "textures" + QDir::separator() + img_f.fileName());
dir.mkdir(fi.baseName() + "_textures");
img.save(fi.absolutePath() + QDir::separator() + fi.baseName() + "_textures" + QDir::separator() + img_f.fileName());
testedOnce = true;
}
......@@ -427,4 +429,4 @@ bool FileOBJPlugin::writeMesh(std::ostream& _out, QString _filename, MeshT& _mes
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment