当前位置: 首页>>代码示例>>C++>>正文


C++ Importer::GetErrorString方法代码示例

本文整理汇总了C++中assimp::Importer::GetErrorString方法的典型用法代码示例。如果您正苦于以下问题:C++ Importer::GetErrorString方法的具体用法?C++ Importer::GetErrorString怎么用?C++ Importer::GetErrorString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在assimp::Importer的用法示例。


在下文中一共展示了Importer::GetErrorString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: fin

bool sa::MeshHandler::importModelsFromScene(const std::string& fileName)
{
	Assimp::Importer importer;

	std::ifstream fin(fileName.c_str());
	if (!fin.fail()) {
		fin.close();
	}
	else {
		LOG("Couldn't open file: %s", fileName.c_str());
		LOG("%s", importer.GetErrorString());
		return false;
	}

	const aiScene* scene = importer.ReadFile(fileName, aiProcessPreset_TargetRealtime_Quality);

	// If the import failed, report it
	if (!scene)
	{
		ASSERT(false, "%s", importer.GetErrorString());
		return false;
	}

	// Everything will be cleaned up by the importer destructor
	loadMeshesFromScene(scene);
	LOG("Import of scene %s succeeded.", fileName.c_str());
	return true;
}
开发者ID:Apodus,项目名称:game_one,代码行数:28,代码来源:meshhandler.cpp

示例2: loadAssets

void loadAssets() {
    // Read in an asset file, and do some post-processing.  There is much
    // more you can do with this asset loader, including load textures.
    // More info is here:
    // http://assimp.sourceforge.net/lib_html/usage.html
    cathedralScene = cathedralImporter.ReadFile(CATHEDRAL_MODEL_PATH,
                     aiProcess_CalcTangentSpace |
                     aiProcess_Triangulate |
                     aiProcess_JoinIdenticalVertices |
                     aiProcessPreset_TargetRealtime_Quality);

    if (!cathedralScene || cathedralScene->mNumMeshes <= 0) {
        std::cerr << cathedralImporter.GetErrorString() << std::endl;
        exit(-1);
    }

    armadilloScene = armadilloImporter.ReadFile(ARMADILLO_MODEL_PATH,
                     aiProcess_CalcTangentSpace |
                     aiProcess_Triangulate |
                     aiProcess_JoinIdenticalVertices |
                     aiProcessPreset_TargetRealtime_Quality);

    if (!armadilloScene || armadilloScene->mNumMeshes <= 0) {
        std::cerr << armadilloImporter.GetErrorString() << std::endl;
        exit(-1);
    }

    //////////////////////////////////////////////////////////////////////////
    // TODO: LOAD YOUR SHADERS/TEXTURES
    //////////////////////////////////////////////////////////////////////////

    // Load the vertex shader
    phongShader = new Shader("Shaders/phong");
    if (!phongShader->loaded()) {
        std::cerr << "Shader failed to load" << std::endl;
        std::cerr << phongShader->errors() << std::endl;
        exit(-1);
    }

    simpleShader = new Shader("Shaders/simple");
    if (!simpleShader->loaded()) {
        std::cerr << "Shader failed to load" << std::endl;
        std::cerr << simpleShader->errors() << std::endl;
        exit(-1);
    }

    envMapShader = new Shader("Shaders/envmap");
    if (!envMapShader->loaded()) {
        std::cerr << "Shader failed to load" << std::endl;
        std::cerr << envMapShader->errors() << std::endl;
        exit(-1);
    }

    loadTexturesAndMeshIndices(cathedralScene);
    loadTexturesAndMeshIndices(armadilloScene);

    whiteImage = sf::Image(1, 1, sf::Color::White);

    generateCubeMap();
}
开发者ID:mrotondo,项目名称:ccrma,代码行数:60,代码来源:Main.cpp

示例3: Import3DFromFile

bool Import3DFromFile( const std::string& pFile)
{
	//check if file exists
	std::ifstream fin(pFile.c_str());
	if(!fin.fail())
	{
		fin.close();
	}
	else
	{
		MessageBox(NULL, ("Couldn't open file: " + pFile).c_str() , "ERROR", MB_OK | MB_ICONEXCLAMATION);
		logInfo( importer.GetErrorString());
		return false;
	}

	scene = importer.ReadFile( pFile, aiProcessPreset_TargetRealtime_Quality);

	// If the import failed, report it
	if( !scene)
	{
		logInfo( importer.GetErrorString());
		return false;
	}

	// Now we can access the file's contents.
	logInfo("Import of scene " + pFile + " succeeded.");

	// We're done. Everything will be cleaned up by the importer destructor
	return true;
}
开发者ID:EeroHeikkinen,项目名称:cinderworkshop,代码行数:30,代码来源:model_loading.cpp

示例4: fin

SharedPointer< Group > SceneImporter::import( std::string filename )
{
	// check if file exists
	std::ifstream fin( filename );
	bool exists = !fin.fail();
	fin.close();
	if ( !exists ) {
		// Is it ok to throw exceptions?
		throw FileNotFoundException( filename );
	}

	Assimp::Importer importer;
	importer.SetPropertyInteger( AI_CONFIG_PP_SLM_VERTEX_LIMIT, 15000 );
	const aiScene* importedScene = importer.ReadFile( filename, aiProcessPreset_TargetRealtime_MaxQuality );
	if ( importedScene == nullptr ) {
		Log::error( CRIMILD_CURRENT_CLASS_NAME, "Error importing file ", filename, "\n", importer.GetErrorString() );
	 	return nullptr;
	}

	auto skinnedMesh = crimild::alloc< SkinnedMesh >();
	loadAnimations( importedScene, skinnedMesh );

	auto root = crimild::alloc< Group >( filename );
	auto basePath = FileSystem::getInstance().extractDirectory( filename ) + "/";
	recursiveSceneBuilder( root, importedScene, importedScene->mRootNode, basePath, skinnedMesh );

	if ( _skeleton != nullptr ) {
		Transformation globalInverseTransform;
		computeTransform( importedScene->mRootNode->mTransformation.Inverse(), globalInverseTransform );
		_skeleton->setGlobalInverseTransform( globalInverseTransform );
		root->attachComponent( _skeleton );
	}

	return root;
}
开发者ID:hhsaez,项目名称:crimild,代码行数:35,代码来源:SceneImporter.cpp

示例5: Init

//Init 
bool cScene::Init(const std::string &lacNameId, const std::string &lacFile)
{
  macFile = lacFile;
  mbLoaded = false;

  //Create an instance of the importer class
  Assimp::Importer lImporter;

  //Load the scene
  const aiScene* lpScene = lImporter.ReadFile( macFile.c_str(),
  aiProcess_CalcTangentSpace |
  aiProcess_Triangulate      |
  aiProcess_JoinIdenticalVertices |
  aiProcess_SortByPType);

  // If the import failed, report it
  if (!lpScene)
  {
    printf( lImporter.GetErrorString() );
    return false;
  }

  
  ProcessScene(lpScene);
  lImporter.FreeScene();
  mbLoaded = true;
  return true;
}
开发者ID:carlixyz,项目名称:engin3d,代码行数:29,代码来源:Scene.cpp

示例6: makeConvex

std::vector<PQP_Model *> Convexer::loadScenario(const std::string& file, bool make_convex)
{
  const aiScene* scene = NULL;
  std::vector<PQP_Model *> ret_val;
  // Create an instance of the Importer class
  Assimp::Importer importer;
  // And have it read the given file with some example postprocessing
  // Usually - if speed is not the most important aspect for you - you'll 
  // propably to request more postprocessing than we do in this example.
  scene = importer.ReadFile( file, 
        aiProcess_CalcTangentSpace       | 
        aiProcess_Triangulate            |
        aiProcess_JoinIdenticalVertices  |
        aiProcess_SortByPType);
  
  // If the import failed, report it
  if( !scene)
  {
    std::cerr << "Convexer::loadScenario --> " <<  importer.GetErrorString() << std::endl;
  } else {
    std::cout << "Convexer::loadScenario --> Scene loaded successfully. Num meshes: ";
    std::cout << scene->mNumMeshes << std::endl;
    if (make_convex) {
      cout << "\nConvexer::loadScenario --> Making convex the mesh.\n";
      ret_val = makeConvex(scene);
    } else {
      ret_val = fromaiScene(scene);
    }
  }
  
  cout << "Convexer::loadScenario --> Scene loaded contains " << ret_val.size() << " different obstacles.\n";
  
  // We're done. Everything will be cleaned up by the importer destructor
  return ret_val;
}
开发者ID:jacobano,项目名称:arcas_ws,代码行数:35,代码来源:Convexer.cpp

示例7: importModel

bool ModelImporter::importModel(std::string file)
{
	std::cout << " Loading model: " << file << std::endl;

	Assimp::Importer importer;
		
	model = importer.ReadFile(file,
		aiProcess_Triangulate |
		aiProcess_JoinIdenticalVertices |
		aiProcess_FlipWindingOrder
	);
		
	if(!model)
	{
		std::cout << "Error importing '" << file
			<< "': " << importer.GetErrorString() << std::endl;
		return false;
	}
		
	this->printModelInfo();
		
	/* Create the VAOs for the model */
	this->extractTriangles();
		
	return true;
}
开发者ID:Manycv,项目名称:RigidBodyMV,代码行数:26,代码来源:ModelImporter.cpp

示例8: LoadMesh

bool Mesh::LoadMesh ( const std::string& filename )
{
  // Удаляем данные предыдущей модели (если она была загружена)
  Clear ( );

  Assimp::Importer importer;

  const aiScene* pScene = importer.ReadFile ( filename.c_str ( ), 
    aiPostProcessSteps::aiProcess_Triangulate |
    aiPostProcessSteps::aiProcess_GenSmoothNormals |
    aiPostProcessSteps::aiProcess_FlipUVs |
    aiPostProcessSteps::aiProcess_CalcTangentSpace );
  
  bool returnResult = false;

  if ( pScene ) 
  {
    returnResult = InitFromScene ( pScene, filename );
  }
  else 
  {
    printf ( "Error parsing '%s': '%s'\n", filename.c_str ( ), importer.GetErrorString ( ) );
  }

  return returnResult;
}
开发者ID:Kirill71,项目名称:OpenGL,代码行数:26,代码来源:mesh.cpp

示例9: load

	// load model if not yet cached
	void Model::load(const std::string& path)
	{
		m_pMeshes = std::make_shared<std::vector<Mesh>>();
		m_ShaderID = ShaderLoader::Instance().getProgram("Default");
		m_MVPMatrixLocation = glGetUniformLocation(m_ShaderID, "mvpMatrix");
		m_TextureFrontSamplerLocation = glGetUniformLocation(m_ShaderID, "textureFrontSampler");
		m_TextureSideSamplerLocation = glGetUniformLocation(m_ShaderID, "textureSideSampler");			
		m_ChinVerticalPosLocation = glGetUniformLocation(m_ShaderID, "chinVerticalPos");
		m_EyeVerticalPosLocation = glGetUniformLocation(m_ShaderID, "eyeVerticalPos");
		m_LEyeTexVerticalPosLocation = glGetUniformLocation(m_ShaderID, "LEyeVerticalTexPos");
		m_REyeTexVerticalPosLocation = glGetUniformLocation(m_ShaderID, "REyeVerticalTexPos");
		m_ChinTexVerticalPosLocation = glGetUniformLocation(m_ShaderID, "ChinTexVerticalPos");

		// Create an instance of the importer class
		Assimp::Importer importer;
		// Read in the given file into a scene and set some (example) postprocessing
		const aiScene *scene = importer.ReadFile(path, aiProcess_Triangulate | aiProcess_GenNormals);// | aiProcess_FlipUVs);

		if (!scene || scene->mFlags == AI_SCENE_FLAGS_INCOMPLETE || !scene->mRootNode)
		{
			std::string error = importer.GetErrorString();
			throw std::exception("Failed to load model. ASSIMP-ERROR");
		}
		// Start processing nodes
		processNode(scene->mRootNode, scene);
	}
开发者ID:tpinetz,项目名称:Visualisierung,代码行数:27,代码来源:Model.cpp

示例10: exception

AnimatedMesh tiny::mesh::io::readAnimatedMesh(const std::string &fileName, const std::string &meshName)
{
    //Use AssImp to read all data from the file.
    Assimp::Importer importer;
    const aiScene *scene = importer.ReadFile(fileName.c_str(), aiProcessPreset_TargetRealtime_Quality);
    
    if (!scene)
    {
        std::cerr << "Unable to read '" << fileName << "' from disk:" << importer.GetErrorString() << "!" << std::endl;
        throw std::exception();
    }
    
    const aiMesh *sourceMesh = detail::getAiMesh(scene, meshName);
    AnimatedMesh mesh;
    
    assert(sourceMesh);
    detail::copyAiMeshVertices<AnimatedMesh, AnimatedMeshVertex>(sourceMesh, mesh, aiMatrix4x4());
    detail::copyAiMeshIndices(sourceMesh, mesh);
    detail::copyAiMeshBones(sourceMesh, mesh);
    
    //Copy animations if available.
    if (scene->HasAnimations())
    {
        detail::copyAiAnimations(scene, sourceMesh, mesh.skeleton);
    }
    
    std::cerr << "Read mesh '" << meshName << "' with " << mesh.vertices.size() << " vertices, " << mesh.indices.size()/3 << " triangles, " << mesh.skeleton.bones.size() << " bones, and " << mesh.skeleton.animations.size() << " animations from '" << fileName << "'." << std::endl;
    
    //importer will go out of scope, which will free all read data automatically.
    return mesh;
}
开发者ID:BasFaggingerAuer,项目名称:tiny-game-engine,代码行数:31,代码来源:animatedmesh.cpp

示例11: LoadScene

	int LoadScene(tchar const *filename, aiScene const **scene)
	{
		if(scene == null || filename == null)
		{
			return E_POINTER;
		}

		Assimp::Importer *importer = new Assimp::Importer();
		importer->SetIOHandler(new MyIOSystem());
		importer->SetPropertyInteger(AI_CONFIG_PP_SBP_REMOVE, aiPrimitiveType_LINE | aiPrimitiveType_POINT);

#if defined(_DEBUG)
		DefaultLogger::create("", Logger::VERBOSE, aiDefaultLogStream_DEBUGGER);
#endif
		importer->ReadFile(filename, aiProcess_Triangulate | aiProcess_SortByPType);

#if defined(_DEBUG)
		DefaultLogger::kill();
#endif
		if(importer->GetScene() == null)
		{
			TRACE("Error loading %s: %s\n", filename, importer->GetErrorString());
			return HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND);
		}
		*scene = importer->GetScene();
		return S_OK;
	}
开发者ID:cskilbeck,项目名称:ShaderProcessor,代码行数:27,代码来源:Importer.cpp

示例12: loadMeshdata

void Mesh::loadMeshdata(const std::string& a_Filepath)
{
	Assimp::Importer importer;
	const auto scene = importer.ReadFile(a_Filepath, aiPostProcessSteps::aiProcess_CalcTangentSpace |
		aiPostProcessSteps::aiProcess_Triangulate |
		aiPostProcessSteps::aiProcess_JoinIdenticalVertices |
		aiPostProcessSteps::aiProcess_SortByPType);
	auto error = importer.GetErrorString();
	auto mesh = scene->mMeshes[0];

	m_Vertices.reserve(mesh->mNumVertices);
	for (auto i = 0u; i < mesh->mNumVertices; i++)
	{
		m_Vertices.emplace_back(toXMFloat3(mesh->mVertices[i]),
			mesh->HasVertexColors(i) ? toXMFloat4(mesh->mColors[0][i]) : XMFLOAT4(1.0f, 1.0f, 1.0f, 1.0f),
			mesh->HasTextureCoords(i) ? toXMFloat2(mesh->mTextureCoords[0][i]) : XMFLOAT2(0.0f, 0.0f));
	}
	m_Indices.reserve(mesh->mNumFaces * 3);
	for (auto i = 0u; i < mesh->mNumFaces; ++i)
	{
		aiFace currentFace = mesh->mFaces[i];
		for (auto j = 0u; j < currentFace.mNumIndices; ++j)
		{
			m_Indices.push_back(currentFace.mIndices[j]);
		}
	}
}
开发者ID:NickyW,项目名称:BUAssignments,代码行数:27,代码来源:BoxDemo.cpp

示例13: printf

Scene::Scene(int argc, char ** argv)
{
	dist = -6.0f;
	    Assimp::Importer importer;
		(importer.ReadFile( "C:\\Users\\abrajoe\\Documents\\Visual Studio 2010\\Projects\\Piano-Scene\\Debug\\lung.blend", 
        aiProcess_CalcTangentSpace       | 
        aiProcess_Triangulate            |
        aiProcess_JoinIdenticalVertices  |
        aiProcess_SortByPType));
  scene  = importer.GetOrphanedScene();
  // If the import failed, report it
  if( !scene)
  {
    printf( importer.GetErrorString());
    return;
  }
  glutInit(&argc, argv);  
  dir = argv[0];
  glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_ALPHA | GLUT_DEPTH);  
  glutInitWindowSize(640, 480);  
  glutInitWindowPosition(0, 0);  
  window = glutCreateWindow("foo");  
  glutDisplayFunc(&display);  
  glutReshapeFunc(&resize);
  glutKeyboardFunc(&keyPressed); 



}
开发者ID:abrajoe,项目名称:Piano-Scene,代码行数:29,代码来源:Scene.cpp

示例14: Load

ModelScene* ModelImporter_Impl::Load(const char* path)
{
	Assimp::Importer importer;

	const aiScene* scene = importer.ReadFile(path, aiProcess_CalcTangentSpace | aiProcess_Triangulate | aiProcess_JoinIdenticalVertices | aiProcess_SortByPType);
	
	if (!scene)
	{
		std::string error = importer.GetErrorString();
		return NULL;
	}

	std::string strPath = std::string(path);
	std::stringstream fileName;

	char ch;
	for (uint32_t i = 0; i < strPath.length(); ++i)
	{
		ch = strPath.at(i);
		if (ch == '/' || ch == '\\')
			fileName.str("");
		else if (ch == '.')
			break;
		else
			fileName << ch;			
	}

	ModelScene* myScene = _LoadScene(fileName.str().c_str(), scene);
	_CalculateModelCenter(myScene);

	return myScene;
}
开发者ID:qpHalcy0n,项目名称:Quad2012,代码行数:32,代码来源:qmodelimporter.cpp

示例15: loadMesh

bool Mesh::loadMesh(const std::string& fileName)
{
    // Release the previously loaded mesh (if it exists)
    this->textures.clear();
    this->entries.clear();

    bool res = false;
    Assimp::Importer importer;

    const aiScene* pScene = importer.ReadFile(fileName.c_str(), aiProcess_Triangulate | aiProcess_GenSmoothNormals | aiProcess_FlipUVs);

    if (pScene) 
    {
        res = this->initFromScene(pScene, fileName);
    }
    else 
    {
        printf("Error parsing '%s': '%s'\n", fileName.c_str(), importer.GetErrorString());
    }

    // print debug info
    printf("Loaded %i verticies\n", this->numVerticies);
    printf("Loaded %i faces\n", this->numFaces);

    return res;
}
开发者ID:kmclarnon,项目名称:Tranquility,代码行数:26,代码来源:Mesh.cpp


注:本文中的assimp::Importer::GetErrorString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。