From 6bb951a5bb76749a182cf39dd699cafb6d9c6e33 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Sun, 31 Aug 2003 22:17:15 +0000 Subject: [PATCH] From Alberto Farre, fixes to the file path handling of internally referenced files. --- src/osgPlugins/flt/flt2osg.cpp | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/src/osgPlugins/flt/flt2osg.cpp b/src/osgPlugins/flt/flt2osg.cpp index 39c701bd2..b045d378f 100644 --- a/src/osgPlugins/flt/flt2osg.cpp +++ b/src/osgPlugins/flt/flt2osg.cpp @@ -1854,13 +1854,30 @@ osg::Group* ConvertFromFLT::visitMatrix(osg::Group& osgParent, const osg::Group& return transform; } - osg::Group* ConvertFromFLT::visitExternal(osg::Group& osgParent, ExternalRecord* rec) { // SExternalReference *pSExternal = (SExternalReference*)rec->getData(); - osgDB::PushAndPopDataPath tmpfile(osgDB::getFilePath(rec->getFilename())); - + std::string filePath = osgDB::getFilePath(rec->getFilename()); + std::string pushAndPopPath; + //If absolute path + if( (filePath.length()>0 && filePath.find_first_of("/\\")==0) || + (filePath.length()>2 && filePath.substr(1,1)==":" && filePath.find_first_of("/\\")==2) ) + { + pushAndPopPath = filePath; + } + else + { + osgDB::FilePathList fpl = osgDB::getDataFilePathList(); + pushAndPopPath = fpl.empty() ? "." : fpl.front(); + if(pushAndPopPath.empty()) pushAndPopPath = "."; + pushAndPopPath += "/" + filePath; + } + + osgDB::PushAndPopDataPath tmpfile(pushAndPopPath); + //osgDB::PushAndPopDataPath tmpfile(osgDB::getFilePath(rec->getFilename())); + + FltFile* pFile = rec->getExternal(); osg::Group* external = NULL; if (pFile)