diff --git a/src/converter/collada.cpp b/src/converter/collada.cpp index 23fdeefb..68d82304 100644 --- a/src/converter/collada.cpp +++ b/src/converter/collada.cpp @@ -629,28 +629,32 @@ void loadImage(GeometryConverter *cvt, std::ostream &os, const std::string &text fileToId[filename] = image.getId(); boost::filesystem::path path = boost::filesystem::path(filename, boost::filesystem::native); - ref fRes = FileResolver::getInstance(); - std::string resolved = fRes->resolve(path.leaf()); + std::string targetPath = textureDir + path.leaf(); - if (endsWith(resolved, ".rgb")) + if (endsWith(filename, ".rgb")) SLog(EWarn, "Maya RGB images must be converted to PNG, EXR or JPEG! The 'imgcvt' " "utility found in the Maya binary directory can be used to do this."); - if (!FileStream::exists(filename)) { - if (!FileStream::exists(resolved)) { - SLog(EWarn, "Found neither \"%s\" nor \"%s\"!", filename.c_str(), resolved.c_str()); - filename = cvt->locateResource(filename); - if (filename == "") - SLog(EError, "Unable to locate a resource -- aborting conversion."); - } else { - filename = resolved; + if (!FileStream::exists(targetPath)) { + ref fRes = FileResolver::getInstance(); + std::string resolved = fRes->resolve(path.leaf()); + if (!FileStream::exists(filename)) { + if (!FileStream::exists(resolved)) { + SLog(EWarn, "Found neither \"%s\" nor \"%s\"!", filename.c_str(), resolved.c_str()); + filename = cvt->locateResource(filename); + if (filename == "") + SLog(EError, "Unable to locate a resource -- aborting conversion."); + } else { + filename = resolved; + } } + ref input = new FileStream(filename, FileStream::EReadOnly); + ref output = new FileStream(targetPath, FileStream::ETruncReadWrite); + input->copyTo(output); + input->close(); + output->close(); } - ref input = new FileStream(filename, FileStream::EReadOnly); - ref output = new FileStream(textureDir + path.leaf(), FileStream::ETruncReadWrite); - input->copyTo(output); - os << "\t" << endl; os << "\t\t" << endl; os << "\t" << endl << endl; diff --git a/src/converter/obj.cpp b/src/converter/obj.cpp index 2d56d4ac..f3536b91 100644 --- a/src/converter/obj.cpp +++ b/src/converter/obj.cpp @@ -11,6 +11,7 @@ std::string copyTexture(GeometryConverter *cvt, const std::string &textureDir, std::string filename) { SLog(EInfo, "Copying texture \"%s\" ..", filename.c_str()); + #if defined(WIN32) for (size_t i=0; i fRes = FileResolver::getInstance(); - std::string resolved = fRes->resolve(path.leaf()); - if (!FileStream::exists(filename)) { - if (!FileStream::exists(resolved)) { - SLog(EWarn, "Found neither \"%s\" nor \"%s\"!", filename.c_str(), resolved.c_str()); - filename = cvt->locateResource(filename); - if (filename == "") - SLog(EError, "Unable to locate a resource -- aborting conversion."); - } else { - filename = resolved; - } - } - + boost::filesystem::path path = boost::filesystem::path(filename, boost::filesystem::native); std::string targetPath = textureDir + path.leaf(); - ref input = new FileStream(filename, FileStream::EReadOnly); - ref output = new FileStream(targetPath, FileStream::ETruncReadWrite); - input->copyTo(output); - output->close(); - input->close(); + if (!FileStream::exists(targetPath)) { + ref fRes = FileResolver::getInstance(); + std::string resolved = fRes->resolve(path.leaf()); + if (!FileStream::exists(filename)) { + if (!FileStream::exists(resolved)) { + SLog(EWarn, "Found neither \"%s\" nor \"%s\"!", filename.c_str(), resolved.c_str()); + filename = cvt->locateResource(filename); + if (filename == "") + SLog(EError, "Unable to locate a resource -- aborting conversion."); + } else { + filename = resolved; + } + } + + ref input = new FileStream(filename, FileStream::EReadOnly); + ref output = new FileStream(targetPath, FileStream::ETruncReadWrite); + input->copyTo(output); + output->close(); + input->close(); + } return targetPath; }