removed crashes when a not well-formed mtl file has been opened.
This commit is contained in:
parent
f7d8e31056
commit
b75a2c77a0
|
@ -993,6 +993,8 @@ public:
|
|||
}
|
||||
else if (header.compare("Ka")==0)
|
||||
{
|
||||
if (tokens.size() < 4)
|
||||
return false;
|
||||
float r = (float) atof(tokens[1].c_str());
|
||||
float g = (float) atof(tokens[2].c_str());
|
||||
float b = (float) atof(tokens[3].c_str());
|
||||
|
@ -1001,6 +1003,8 @@ public:
|
|||
}
|
||||
else if (header.compare("Kd")==0)
|
||||
{
|
||||
if (tokens.size() < 4)
|
||||
return false;
|
||||
float r = (float) atof(tokens[1].c_str());
|
||||
float g = (float) atof(tokens[2].c_str());
|
||||
float b = (float) atof(tokens[3].c_str());
|
||||
|
@ -1009,6 +1013,8 @@ public:
|
|||
}
|
||||
else if (header.compare("Ks")==0)
|
||||
{
|
||||
if (tokens.size() < 4)
|
||||
return false;
|
||||
float r = (float) atof(tokens[1].c_str());
|
||||
float g = (float) atof(tokens[2].c_str());
|
||||
float b = (float) atof(tokens[3].c_str());
|
||||
|
@ -1018,20 +1024,28 @@ public:
|
|||
else if ( (header.compare("d")==0) ||
|
||||
(header.compare("Tr")==0) ) // alpha
|
||||
{
|
||||
if (tokens.size() < 2)
|
||||
return false;
|
||||
currentMaterial.Tr = (float) atof(tokens[1].c_str());
|
||||
}
|
||||
else if (header.compare("Ns")==0) // shininess
|
||||
{
|
||||
if (tokens.size() < 2)
|
||||
return false;
|
||||
currentMaterial.Ns = float(atoi(tokens[1].c_str()));
|
||||
}
|
||||
else if (header.compare("illum")==0) // specular illumination on/off
|
||||
{
|
||||
if (tokens.size() < 2)
|
||||
return false;
|
||||
int illumination = atoi(tokens[1].c_str());
|
||||
//currentMaterial.bSpecular = (illumination == 2);
|
||||
currentMaterial.illum = illumination;
|
||||
}
|
||||
else if( (header.compare("map_Kd")==0) || (header.compare("map_Ka")==0) ) // texture name
|
||||
{
|
||||
if (tokens.size() < 2)
|
||||
return false;
|
||||
std::string textureName = tokens[1];
|
||||
//strcpy(currentMaterial.textureFileName, textureName.c_str());
|
||||
currentMaterial.map_Kd=textureName;
|
||||
|
|
Loading…
Reference in New Issue