From Ulrich Hertlein, "ttached are some tweaks to the Obj loader that allows a program supplied osgDB::Options object to be passed through the code. This allows for caching to be used with images.

The patched loader also complains more loudly if a material library file wasn't found or if a referenced material wasn't found in the material library."
This commit is contained in:
Robert Osfield
2009-11-19 12:54:52 +00:00
parent 72b3ce7ac6
commit 74f7ffcd32
2 changed files with 31 additions and 20 deletions

View File

@@ -645,16 +645,22 @@ bool Model::readOBJ(std::istream& fin, const osgDB::ReaderWriter::Options* optio
{
std::string materialFileName = trim( line+7 );
std::string fullPathFileName = osgDB::findDataFile( materialFileName, options );
osg::notify(osg::INFO) << "--" << line+7 << "--" << std::endl;
osg::notify(osg::INFO) << "--" << materialFileName << "--" << std::endl;
osg::notify(osg::INFO) << "--" << fullPathFileName << "--" << std::endl;
if (!fullPathFileName.empty())
{
osgDB::ifstream mfin( fullPathFileName.c_str() );
if (mfin)
{
osg::notify(osg::INFO) << "Obj reading mtllib '" << fullPathFileName << "'\n";
readMTL(mfin);
}
else
{
osg::notify(osg::WARN) << "Obj unable to load mtllib '" << fullPathFileName << "'\n";
}
}
else
{
osg::notify(osg::WARN) << "Obj unable to find mtllib '" << materialFileName << "'\n";
}
}
else if (strncmp(line,"o ",2)==0)