This commit is contained in:
Kim Kulling
2015-08-30 15:21:53 +02:00
parent 9708a4db93
commit e4510c26ba
6 changed files with 197 additions and 41 deletions

View File

@@ -133,15 +133,16 @@ void ObjFileImporter::InternReadFile( const std::string& pFile, aiScene* pScene,
TextFileToBuffer(file.get(),m_Buffer);
// Get the model name
std::string strModelName;
std::string modelName, folderName;
std::string::size_type pos = pFile.find_last_of( "\\/" );
if ( pos != std::string::npos )
{
strModelName = pFile.substr(pos+1, pFile.size() - pos - 1);
}
else
{
strModelName = pFile;
if ( pos != std::string::npos ) {
modelName = pFile.substr(pos+1, pFile.size() - pos - 1);
folderName = pFile.substr( 0, pos );
if ( folderName.empty() ) {
pIOHandler->PushDirectory( folderName );
}
} else {
modelName = pFile;
}
// process all '\'
@@ -161,13 +162,18 @@ void ObjFileImporter::InternReadFile( const std::string& pFile, aiScene* pScene,
}
// parse the file into a temporary representation
ObjFileParser parser(m_Buffer, strModelName, pIOHandler);
ObjFileParser parser(m_Buffer, modelName, pIOHandler);
// And create the proper return structures out of it
CreateDataFromImport(parser.GetModel(), pScene);
// Clean up allocated storage for the next import
m_Buffer.clear();
// Pop directory stack
if ( pIOHandler->StackSize() > 0 ) {
pIOHandler->PopDirectory();
}
}
// ------------------------------------------------------------------------------------------------