don't copy existing texture files
parent
378833cefd
commit
fa452311f8
|
@ -629,28 +629,32 @@ void loadImage(GeometryConverter *cvt, std::ostream &os, const std::string &text
|
||||||
fileToId[filename] = image.getId();
|
fileToId[filename] = image.getId();
|
||||||
|
|
||||||
boost::filesystem::path path = boost::filesystem::path(filename, boost::filesystem::native);
|
boost::filesystem::path path = boost::filesystem::path(filename, boost::filesystem::native);
|
||||||
ref<FileResolver> fRes = FileResolver::getInstance();
|
std::string targetPath = textureDir + path.leaf();
|
||||||
std::string resolved = fRes->resolve(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' "
|
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.");
|
"utility found in the Maya binary directory can be used to do this.");
|
||||||
|
|
||||||
if (!FileStream::exists(filename)) {
|
if (!FileStream::exists(targetPath)) {
|
||||||
if (!FileStream::exists(resolved)) {
|
ref<FileResolver> fRes = FileResolver::getInstance();
|
||||||
SLog(EWarn, "Found neither \"%s\" nor \"%s\"!", filename.c_str(), resolved.c_str());
|
std::string resolved = fRes->resolve(path.leaf());
|
||||||
filename = cvt->locateResource(filename);
|
if (!FileStream::exists(filename)) {
|
||||||
if (filename == "")
|
if (!FileStream::exists(resolved)) {
|
||||||
SLog(EError, "Unable to locate a resource -- aborting conversion.");
|
SLog(EWarn, "Found neither \"%s\" nor \"%s\"!", filename.c_str(), resolved.c_str());
|
||||||
} else {
|
filename = cvt->locateResource(filename);
|
||||||
filename = resolved;
|
if (filename == "")
|
||||||
|
SLog(EError, "Unable to locate a resource -- aborting conversion.");
|
||||||
|
} else {
|
||||||
|
filename = resolved;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
ref<FileStream> input = new FileStream(filename, FileStream::EReadOnly);
|
||||||
|
ref<FileStream> output = new FileStream(targetPath, FileStream::ETruncReadWrite);
|
||||||
|
input->copyTo(output);
|
||||||
|
input->close();
|
||||||
|
output->close();
|
||||||
}
|
}
|
||||||
|
|
||||||
ref<FileStream> input = new FileStream(filename, FileStream::EReadOnly);
|
|
||||||
ref<FileStream> output = new FileStream(textureDir + path.leaf(), FileStream::ETruncReadWrite);
|
|
||||||
input->copyTo(output);
|
|
||||||
|
|
||||||
os << "\t<texture id=\"" << image.getId() << "\" type=\"ldrtexture\">" << endl;
|
os << "\t<texture id=\"" << image.getId() << "\" type=\"ldrtexture\">" << endl;
|
||||||
os << "\t\t<string name=\"filename\" value=\"" << textureDir + path.leaf() << "\"/>" << endl;
|
os << "\t\t<string name=\"filename\" value=\"" << textureDir + path.leaf() << "\"/>" << endl;
|
||||||
os << "\t</texture>" << endl << endl;
|
os << "\t</texture>" << endl << endl;
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
|
|
||||||
std::string copyTexture(GeometryConverter *cvt, const std::string &textureDir, std::string filename) {
|
std::string copyTexture(GeometryConverter *cvt, const std::string &textureDir, std::string filename) {
|
||||||
SLog(EInfo, "Copying texture \"%s\" ..", filename.c_str());
|
SLog(EInfo, "Copying texture \"%s\" ..", filename.c_str());
|
||||||
|
|
||||||
#if defined(WIN32)
|
#if defined(WIN32)
|
||||||
for (size_t i=0; i<filename.length(); ++i)
|
for (size_t i=0; i<filename.length(); ++i)
|
||||||
if (filename[i] == '/')
|
if (filename[i] == '/')
|
||||||
|
@ -20,28 +21,30 @@ std::string copyTexture(GeometryConverter *cvt, const std::string &textureDir, s
|
||||||
if (filename[i] == '\\')
|
if (filename[i] == '\\')
|
||||||
filename[i] = '/';
|
filename[i] = '/';
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
boost::filesystem::path path = boost::filesystem::path(filename, boost::filesystem::native);
|
boost::filesystem::path path = boost::filesystem::path(filename, boost::filesystem::native);
|
||||||
ref<FileResolver> 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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
std::string targetPath = textureDir + path.leaf();
|
std::string targetPath = textureDir + path.leaf();
|
||||||
|
|
||||||
ref<FileStream> input = new FileStream(filename, FileStream::EReadOnly);
|
if (!FileStream::exists(targetPath)) {
|
||||||
ref<FileStream> output = new FileStream(targetPath, FileStream::ETruncReadWrite);
|
ref<FileResolver> fRes = FileResolver::getInstance();
|
||||||
input->copyTo(output);
|
std::string resolved = fRes->resolve(path.leaf());
|
||||||
output->close();
|
if (!FileStream::exists(filename)) {
|
||||||
input->close();
|
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<FileStream> input = new FileStream(filename, FileStream::EReadOnly);
|
||||||
|
ref<FileStream> output = new FileStream(targetPath, FileStream::ETruncReadWrite);
|
||||||
|
input->copyTo(output);
|
||||||
|
output->close();
|
||||||
|
input->close();
|
||||||
|
}
|
||||||
|
|
||||||
return targetPath;
|
return targetPath;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue