Пример #1
0
// ------------------------------------------------------------------------------------------------
const aiScene* aiImportFileExWithProperties( const char* pFile, unsigned int pFlags, 
	aiFileIO* pFS,
	const aiPropertyStore* props)
{
	ai_assert(NULL != pFile);

	const aiScene* scene = NULL;
	ASSIMP_BEGIN_EXCEPTION_REGION();

	// create an Importer for this file
	Assimp::Importer* imp = new Assimp::Importer();

	// copy properties
	if(props) {
		const PropertyMap* pp = reinterpret_cast<const PropertyMap*>(props);
		ImporterPimpl* pimpl = imp->Pimpl();
		pimpl->mIntProperties = pp->ints;
		pimpl->mFloatProperties = pp->floats;
		pimpl->mStringProperties = pp->strings;
		pimpl->mMatrixProperties = pp->matrices;
	}
	// setup a custom IO system if necessary
	if (pFS)	{
		imp->SetIOHandler( new CIOSystemWrapper (pFS) );
	}

	// and have it read the file
	scene = imp->ReadFile( pFile, pFlags);

	// if succeeded, store the importer in the scene and keep it alive
	if( scene)	{
		ScenePrivateData* priv = const_cast<ScenePrivateData*>( ScenePriv(scene) );
		priv->mOrigImporter = imp;
	} 
	else	{
		// if failed, extract error code and destroy the import
		gLastErrorString = imp->GetErrorString();
		delete imp;
	}

	// return imported data. If the import failed the pointer is NULL anyways
	ASSIMP_END_EXCEPTION_REGION(const aiScene*);
	return scene;
}
Пример #2
0
// ------------------------------------------------------------------------------------------------
const aiScene* aiImportFileFromMemoryWithProperties(
    const char* pBuffer,
    unsigned int pLength,
    unsigned int pFlags,
    const char* pHint,
    const aiPropertyStore* props)
{
    ai_assert( NULL != pBuffer );
    ai_assert( 0 != pLength );

    const aiScene* scene = NULL;
    ASSIMP_BEGIN_EXCEPTION_REGION();

    // create an Importer for this file
    Assimp::Importer* imp = new Assimp::Importer();

    // copy properties
    if(props) {
        const PropertyMap* pp = reinterpret_cast<const PropertyMap*>(props);
        ImporterPimpl* pimpl = imp->Pimpl();
        pimpl->mIntProperties = pp->ints;
        pimpl->mFloatProperties = pp->floats;
        pimpl->mStringProperties = pp->strings;
        pimpl->mMatrixProperties = pp->matrices;
    }

    // and have it read the file from the memory buffer
    scene = imp->ReadFileFromMemory( pBuffer, pLength, pFlags,pHint);

    // if succeeded, store the importer in the scene and keep it alive
    if( scene)  {
         ScenePrivateData* priv = const_cast<ScenePrivateData*>( ScenePriv(scene) );
         priv->mOrigImporter = imp;
    }
    else    {
        // if failed, extract error code and destroy the import
        gLastErrorString = imp->GetErrorString();
        delete imp;
    }
    // return imported data. If the import failed the pointer is NULL anyways
    ASSIMP_END_EXCEPTION_REGION(const aiScene*);
    return scene;
}