diff --git a/src/osgPlugins/obj/obj.cpp b/src/osgPlugins/obj/obj.cpp index 8e4d90a28..1310ff958 100644 --- a/src/osgPlugins/obj/obj.cpp +++ b/src/osgPlugins/obj/obj.cpp @@ -12,7 +12,9 @@ */ #include +#include #include +#include #include #include "obj.h" @@ -24,6 +26,13 @@ using namespace obj; +std::string strip( const std::string& ss ) +{ + std::string result; + result.assign( ss.begin() + ss.find_first_not_of( ' ' ), ss.begin() + 1 + ss.find_last_not_of( ' ' ) ); + return( result ); +} + bool Model::readline(std::istream& fin, char* line, const int LINE_SIZE) { if (LINE_SIZE<1) return false; @@ -347,15 +356,18 @@ bool Model::readMTL(std::istream& fin) } else if (strncmp(line,"map_Kd ",7)==0) { - material->map_Kd = lastComponent(line+7); + material->map_Kd = strip(line+7); + osg::notify(osg::INFO)<< "map_Kd:\'" << material->map_Kd << "\'" << std::endl; } else if (strncmp(line,"map_Ks ",7)==0) { - material->map_Ks = lastComponent(line+7); + material->map_Ks = strip(line+7); + osg::notify(osg::INFO)<< "map_Ks:\'" << material->map_Kd << "\'" << std::endl; } else if (strncmp(line,"map_opacity ",7)==0) { - material->map_opacity = lastComponent(line+7); + material->map_opacity = strip(line+7); + osg::notify(osg::INFO)<< "map_opacity:\'" << material->map_Kd << "\'" << std::endl; } else if (strcmp(line,"refl")==0 || strncmp(line,"refl ",5)==0) {