From 49ef41b373d19acfef337e0b62940853a98d4517 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Mon, 18 Feb 2008 15:17:42 +0000 Subject: [PATCH] From Bob Kuehne, "Subject: obj material parse fix this fix strips whitespace off externally referenced material files. fixes a bug where the obj listed something like: mtllib FR_PARIS_ESPACE_UNESCO_S.MTL and then that caused failures in the load later: FindFileInPath() : trying /Users/rpk/Downloads/ FR_PARIS_ESPACE_UNESCO_S.MTL ... this fix simply strips whitespace around that filename before passing it on to the remainder of the loader." Changes from Robert Osfield, change std::cout to osg::notify(osg::INFO) --- src/osgPlugins/obj/obj.cpp | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/src/osgPlugins/obj/obj.cpp b/src/osgPlugins/obj/obj.cpp index 9a2ce62e0..354e46d83 100644 --- a/src/osgPlugins/obj/obj.cpp +++ b/src/osgPlugins/obj/obj.cpp @@ -11,6 +11,7 @@ * OpenSceneGraph Public License for more details. */ +#include #include #include @@ -283,6 +284,17 @@ bool Model::readMTL(std::istream& fin) return true; } +std::string trim(const std::string& s) +{ + if(s.length() == 0) + return s; + int b = s.find_first_not_of(" \t"); + int e = s.find_last_not_of(" \t"); + if(b == -1) // No non-spaces + return ""; + return std::string(s, b, e - b + 1); +} + bool Model::readOBJ(std::istream& fin, const osgDB::ReaderWriter::Options* options) { osg::notify(osg::INFO)<<"Reading OBJ file"<