Beispiel #1
0
// Load mesh from PLY file
bool Mesh::loadFromFile(char* filename)
{
    FILE* inFile = fopen(filename, "rt");
    if (inFile == NULL)
    {
        char pszError[_MAX_FNAME + 1];
		sprintf(pszError, "%s does not exist!\n", filename);
        MessageBox(NULL, pszError, NULL, MB_ICONEXCLAMATION);
		return FALSE;
    }

	// read header to PLY file
	if (!readPlyHeader(inFile))
	{
		return false;
	}

	// read vertex data from PLY file
	if (!readPlyVerts(inFile))
	{
		return false;
	}

	// read triangle data from PLY file
	if (!readPlyTris(inFile))
	{
		return false;
	}

    fclose(inFile); // close the file

	calcVertNormals();

	return true;
}
Beispiel #2
0
 bool Mesh::loadFromPlyFile(char *filename)
 {
     FILE* inFile = fopen(filename, "rt");
     if (inFile == NULL) {
         std::cerr << filename << " does not exist." << std::endl;
         return false;
     }
     
     if (!readPlyHeader(inFile)) { return false;}
     if (!readPlyVertexList(inFile)) { return false; }
     if (!readPlyFaceList(inFile)) {return false; }
     
     fclose(inFile); // close the file
     
     return true;
 }