J'essaie de charger un fichier en analysant ses données textes, mais à chaque fois ça met un temps énorme que je ne suis jamais arrivé au bout... Bizzare surtout que le fichier est pas gros, enfin voilà mon code, si vous pouviez m'aider:
class CMaterial
{
public:
unsigned short ambient[3];
unsigned short diffuse[3];
unsigned short specular[3];
};
unsigned int nMaterials;
CMaterial* pMaterials;
unsigned int nVertices;
unsigned int nFaces;
unsigned int nMaterialRef;
CVertex* pVertices;
ifstream file(szPath);
string buffer;
unsigned int nCurrentMaterial;
unsigned int nCurrentVertex;
float x, y, z;
while (!file.eof())
{
file >> buffer;
//Chargement des informations sur les materials
if (buffer == "*MATERIAL_COUNT" )
{
file >> nMaterials;
pMaterials = new CMaterial[nMaterials];
}
if (buffer == "*MATERIAL" )
{
file >> nCurrentMaterial;
}
if (buffer == "*MATERIAL_AMBIENT" )
{
file >> pMaterials[nCurrentMaterial].ambient[0];
file >> pMaterials[nCurrentMaterial].ambient[1];
file >> pMaterials[nCurrentMaterial].ambient[2];
}
if (buffer == "*MATERIAL_DIFFUSE" )
{
file >> pMaterials[nCurrentMaterial].diffuse[0];
file >> pMaterials[nCurrentMaterial].diffuse[1];
file >> pMaterials[nCurrentMaterial].diffuse[2];
}
if (buffer == "*MATERIAL_SPECULAR" )
{
file >> pMaterials[nCurrentMaterial].specular[0];
file >> pMaterials[nCurrentMaterial].specular[1];
file >> pMaterials[nCurrentMaterial].specular[2];
}
//Chargement des informations sur les objects
if (buffer == "*MESH_NUMVERTEX" )
{
file >> nVertices;
pVertices = new CVertex[nVertices];
}
if (buffer == "*MESH_NUMFACES" )
{
file >> nFaces;
}
if (buffer == "*MESH_VERTEX" )
{
file >> nCurrentVertex;
file >> x;
file >> y;
file >> z;
pVertices[nCurrentVertex].Set( x, y, z,
pMaterials[0].diffuse[0],
pMaterials[0].diffuse[1],
pMaterials[0].diffuse[2]);
}
}
file.close();