Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualEndurion

Posted 06 May 2012 - 11:41 PM

I'd start with setting

float ambiant[4];
float diffuse[4];
float specular[4];
float shininess;

to zero or something.

The lines

if (line.length() > 2)
{
if (line.substr(0,6)=="newmtl" && specular[2] >= 0)
{
material mat = {{ambiant[0],ambiant[1],ambiant[2],ambiant[3]},{diffuse[0],diffuse[1],diffuse[2],diffuse[3]},{specular[0],specular[1],specular[2],specular[3]},shininess};
Mat.push_back(mat);
}

could already access specular[2] (and all other color variables) without having been initialized properly and pointing to random garbage.

#1Endurion

Posted 06 May 2012 - 11:41 PM

I'd start with setting

float ambiant[4];
float diffuse[4];
float specular[4];
float shininess;

to zero or something.

The lines

if (line.length() > 2)
{
if (line.substr(0,6)=="newmtl" && specular[2] >= 0)
{
material mat = {{ambiant[0],ambiant[1],ambiant[2],ambiant[3]},{diffuse[0],diffuse[1],diffuse[2],diffuse[3]},{specular[0],specular[1],specular[2],specular[3]},shininess};
Mat.push_back(mat);
}

could already access specular[2] without it having been initialized properly and pointing to random garbage.

PARTNERS