Example #1
0
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); 



}
Example #2
0
bool mesh::import_from_file(const std::string& filepath) {
    Assimp::Importer importer;

    const aiScene* scene = importer.ReadFile(filepath,
        aiProcess_Triangulate |
        aiProcess_JoinIdenticalVertices |
        aiProcess_GenNormals |
        aiProcess_PreTransformVertices | // TODO: figure out the node graph
        aiProcess_FixInfacingNormals |
        aiProcess_FindDegenerates
    );

    if(!scene)
    {
        std::cerr << importer.GetErrorString() << std::endl;
        return false;
    }

    this->scene = importer.GetOrphanedScene();

    if (scene->mNumMeshes != 1){
        std::cerr << "Scene contains does not contain exactly one mesh(" << scene->mNumMeshes << ")." << std::endl;
        return false;
    }

    return true;
}
/**
* Load an MD2 model from file.
*
* Note: MD2 format stores model's data in little-endian ordering.  On
* big-endian machines, you'll have to perform proper conversions.
*
* @params filename the name of the model to be loaded
* @params TransformationMatrix a Matrix with all the transformations to be made to the model
*
*/
void DynamicModelLoader::LoadModel(const char *filename, const glm::mat4 &TransformationMatrix)
{
	cout << "Loading " << filename << endl;

	Assimp::Importer importer;


	// Read file via ASSIMP
	importer.ReadFile(filename, aiProcess_Triangulate | aiProcess_FlipUVs | aiProcess_GenSmoothNormals);

	scene = importer.GetOrphanedScene();


	// Check for errors
	if (!scene || scene->mFlags == AI_SCENE_FLAGS_INCOMPLETE || !scene->mRootNode) // if is Not Zero
	{
		cout << "ERROR::ASSIMP:: " << importer.GetErrorString() << endl;
		return;
	}


	string pFile = filename;
	// Retrieve the directory path of the filepath
	m_directory = pFile.substr(0, pFile.find_last_of('/'));


	m_userTransform = TransformationMatrix;

	m_GlobalInverseTransform = aiMatrix4x4ToGlm(scene->mRootNode->mTransformation);
	m_GlobalInverseTransform = glm::inverse(m_GlobalInverseTransform);

	// Process ASSIMP's root node recursively
	ProcessNode(scene->mRootNode, scene, glm::mat4(1.0f));

	//init Vertex buffer object with the information
	for (GLuint i = 0; i < m_vMeshes.size(); ++i) m_vMeshes[i].setupMesh();

	//popullate the auxiliar array of transformations
	for (GLuint i = 0; i < m_originalBoneTransform.size(); ++i){
		glm::mat4 m = glm::mat4(1.0f);
		m_finalBoneTransforms.push_back(m);
	}

}