From 84f8e3c68c31c73ed74eb77e0f77504d7c1e624e Mon Sep 17 00:00:00 2001 From: aramis_acg Date: Mon, 12 Jan 2009 00:00:13 +0000 Subject: [PATCH] Temporary fix: collada loader strips 'file://' from paths now. git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@289 67173fc5-114c-0410-ac8e-9d2fd5bffc1f --- code/ColladaLoader.cpp | 19 ++++++++++++++++++- code/ColladaLoader.h | 3 +++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/code/ColladaLoader.cpp b/code/ColladaLoader.cpp index 351efd340..2e630cebb 100644 --- a/code/ColladaLoader.cpp +++ b/code/ColladaLoader.cpp @@ -382,6 +382,23 @@ const aiString& ColladaLoader::FindFilenameForEffectTexture( const ColladaParser throw new ImportErrorException( boost::str( boost::format( "Unable to resolve effect texture entry \"%s\", ended up at ID \"%s\".") % pName % name)); static aiString result; - result.Set( imIt->second.mFileName); + result.Set( imIt->second.mFileName ); + ConvertPath(result); return result; } + +// ------------------------------------------------------------------------------------------------ +// Convert a path read from a collada file to the usual representation +void ColladaLoader::ConvertPath (aiString& ss) +{ + // TODO: collada spec, p 22. Handle URI correctly. + // For the moment we're just stripping the file:// away to make it work. + // Windoes doesn't seem to be able to find stuff like + // 'file://..\LWO\LWO2\MappingModes\earthSpherical.jpg' + if (0 == ::strncmp(ss.data,"file://",7)) + { + ss.length -= 7; + ::memmove(ss.data,ss.data+7,ss.length); + ss.data[ss.length] = '\0'; + } +} diff --git a/code/ColladaLoader.h b/code/ColladaLoader.h index d0ef2bc79..37f0ab656 100644 --- a/code/ColladaLoader.h +++ b/code/ColladaLoader.h @@ -121,6 +121,9 @@ protected: /** Resolves the texture name for the given effect texture entry */ const aiString& FindFilenameForEffectTexture( const ColladaParser& pParser, const Collada::Effect& pEffect, const std::string& pName); + /** Converts a path read from a collada file to the usual representation */ + void ConvertPath (aiString& ss); + protected: /** Filename, for a verbose error message */ std::string mFileName;