Commit 2e974673 authored by hybrid's avatar hybrid

Fix .mtl writing which did not use the correct path, thanks to hendu for pointing this out

Also fixed texture names, which could have spaces and thus fail immediately upon loading. Now the path is given relative to the .mtl file, which often works, and in case of spaces in the path no path at all is used.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@4467 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 695abde4
......@@ -64,7 +64,8 @@ bool COBJMeshWriter::writeMesh(io::IWriteFile* file, scene::IMesh* mesh, s32 fla
// write OBJ MESH header
const core::stringc name(FileSystem->getFileBasename(SceneManager->getMeshCache()->getMeshName(mesh), false)+".mtl");
core::stringc name;
core::cutFilenameExtension(name,file->getFileName()) += ".mtl";
file->write("# exported by Irrlicht\n",23);
file->write("mtllib ",7);
file->write(name.c_str(),name.size());
......@@ -192,7 +193,11 @@ bool COBJMeshWriter::writeMesh(io::IWriteFile* file, scene::IMesh* mesh, s32 fla
if (mat[i]->getTexture(0))
{
file->write("map_Kd ", 7);
file->write(mat[i]->getTexture(0)->getName().getPath().c_str(), mat[i]->getTexture(0)->getName().getPath().size());
io::path tname = FileSystem->getRelativeFilename(mat[i]->getTexture(0)->getName(),
FileSystem->getFileDir(file->getFileName()));
if (tname.findFirst(' ') != -1)
tname = FileSystem->getFileBasename(tname);
file->write(tname.c_str(), tname.size());
file->write("\n",1);
}
file->write("\n",1);
......
Markdown is supported
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