// ------------------------------------------------------------------------------------------------ // Default constructor ObjFileImporter::ObjFileImporter() : m_Buffer() , m_pRootObject( nullptr ) , m_strAbsPath( "" ) { DefaultIOSystem io; m_strAbsPath = io.getOsSeparator(); }
// ------------------------------------------------------------------------------------------------ // Default constructor ObjFileImporter::ObjFileImporter() : m_pRootObject(NULL) { DefaultIOSystem io; m_strAbsPath = io.getOsSeparator(); }
// ------------------------------------------------------------------------------------------------ // Default constructor MTLImporter::MTLImporter() : m_Buffer(), m_pRootObject( NULL ), m_strAbsPath( "" ) { DefaultIOSystem io; m_strAbsPath = io.getOsSeparator(); }
// ------------------------------------------------------------------------------------------------ // Obj-file import implementation void ObjFileImporter::InternReadFile( const std::string& pFile, aiScene* pScene, IOSystem* pIOHandler) { DefaultIOSystem io; // Read file into memory const std::string mode = "rb"; boost::scoped_ptr<IOStream> file( pIOHandler->Open( pFile, mode)); if (NULL == file.get()) throw new ImportErrorException( "Failed to open file " + pFile + "."); // Get the filesize and vaslidate it, throwing an exception when failes size_t fileSize = file->FileSize(); if( fileSize < 16) throw new ImportErrorException( "OBJ-file is too small."); // Allocate buffer and read file into it m_Buffer.resize( fileSize ); const size_t readsize = file->Read(&m_Buffer.front(), sizeof(char), fileSize); assert (readsize == fileSize); // std::string strDirectory(1,io.getOsSeparator()), strModelName; std::string::size_type pos = pFile.find_last_of(io.getOsSeparator()); if (pos != std::string::npos) { strDirectory = pFile.substr(0, pos); strModelName = pFile.substr(pos+1, pFile.size() - pos - 1); } else { strModelName = pFile; } // parse the file into a temporary representation ObjFileParser parser(m_Buffer, strDirectory, strModelName, pIOHandler); // And create the proper return structures out of it CreateDataFromImport(parser.GetModel(), pScene); }