示例#1
0
void Object::loadObject( const std::string& filename )
{
	Assimp::Importer Importer;

	/* Import file
	   Options:

	   aiProcess_Triangulate -> translate models which are made from non-triangle polys
							 into triangle based meshes
	   aiProcess_GenSmoothNormals -> automatically generate normals, in case the model
							 doesn't already contain them
	*/

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

	if( pScene )
	{
		initFromScene( pScene, filename );
		initMaterials( pScene, filename );
	}
	else
	{
		std::cerr << "Could not load model\n";
	}

}
示例#2
0
bool Model::loadModel(const std::string& Filename)
{
	bool ret = false;

	const aiScene* _scene = aiImportFile(Filename.c_str(), aiProcess_Triangulate | aiProcess_GenSmoothNormals | aiProcess_FlipUVs);

	if (_scene)
		ret = initFromScene(_scene, Filename);
	return ret;
}
示例#3
0
bool Mesh::loadMesh(const std::string & filename)
{
	clear();
	
	bool Ret = false;
	Assimp::Importer importer;

	const aiScene* pScene = importer.ReadFile(filename.c_str(), aiProcessPreset_TargetRealtime_Quality);

	if(pScene)
		Ret = initFromScene(pScene, filename);
	else
		std::cout << "Error passing " << filename << " : " << importer.GetErrorString() << std::endl;

	return Ret;
}
示例#4
0
文件: Mesh.cpp 项目: NCCA/NGL6Demos
bool Mesh::load(const aiScene *_scene)
{
  bool success=false;
  m_scene=_scene;
  // we have already forced the load to be trinagles so no need to check
  m_vao = ngl::VertexArrayObject::createVOA(GL_TRIANGLES);
  // if we have a valid scene load and init
  if (m_scene)
  {
    // grab the inverse global transform
    m_globalInverseTransform = AIU::aiMatrix4x4ToNGLMat4(m_scene->mRootNode->mTransformation);
    m_globalInverseTransform.inverse();
    // now load the bones etc
    initFromScene(m_scene);
    success=true;
  }
  else
  {
    std::cerr<<"Error parsing "<<_scene<<"\n";
  }
  return success;
}