I am trying to read in the following OBJ file
#--- ObjWriter ---
v -0.599972 -0.599972 -0.599972
v -0.304591 -0.834531 0.539150
.
.
.
f 1 2 6
f 1 6 5
f 1 5 7
.
.
.
I am trying to set up a function that will store the values of a vertex (3 values following the char v) to a vector of points (Pt being made up of a x, y, and z) and the values of a face (3 values following the char f) to another vector of faces (Face being made up of 3 ints). So far, I have attempted this with the following function:
void readFile(char *inFile)
{
ifstream inF(inFile);
string line;
while (getline(inF, line))
{
if (line[0] == 'v')
{
float x, y, z;
inF >> x >> y >> z;
// cout << x;
verts.push_back(Pt(x, y, z));
}
else if (line[0] == 'f')
{
int x, y, z;
inF >> x >> y >> z;
faces.push_back(Face(x, y, z));
}
else if (line[0] == '#')
continue;
}
}
Whenever I test this method by displaying the x value in the first if statement, I get the value "-858993460". How can I fix this function? Placement of the cout line is shown commented out.