title: Simple Model Loader Issues
body: <p>We've been creating a very basic model loader. The code itself is below; the main problem is when the stringstream detects an 'f' as a first character. The code has been overly simplified (it was a bit more complicated at first) for the sake of debugging. At the moment, cout &lt;&lt; ind3; is giving 0. It should read either a 2 or a 5, depending on which line the reader is on. The two vector parameters are used to write to for drawing, but at the minute I've removed this operation. </p>
  
  <p>The two 'f' lines are:
  f 0 1 2
  f 3 4 5</p>
  
  <p>The program reads the v (vertex) lines in just fine; it won't read in f lines. </p>
  
  <pre><code>bool modelLoader(string fileName,vector&lt;GLfloat&gt;&amp; vertices, vector&lt;GLushort&gt;&amp; indices)
  {
  vector&lt;GLfloat&gt; localVertices;
  ifstream objFile;
  string line,testline;
  stringstream ss;
  
  GLfloat x, y, z;
  //GLushort ind1, ind2, ind3; Excluded for testing
  int ind1=0, ind2=0, ind3=0; 
  objFile.open(fileName);
  if (!objFile.is_open())
  {
      cout &lt;&lt; "FAILED TO LOAD: OBJ FILE\n";
  
      return false;
  }
  
  while ( objFile.good() )
  {
      getline(objFile, line);
      ss.str(line);
  
      if (line == "")
      {
          continue;
      }
  
      else if(line[0] == 'v')
      {
          ss.ignore(2);
          ss &gt;&gt; x &gt;&gt; y &gt;&gt; z;
          localVertices.push_back(x);
          localVertices.push_back(y);
          localVertices.push_back(z);
      }
  
      else if (line[0] == 'f')
      {
          cout&lt;&lt;ss.str()&lt;&lt;endl; // for debug
          ss.ignore(6); // To skip 'f 0 1 ' and get purely a 2. Was originally
                      // set to ss.ignore(2) when reading in all 3 values.
          cout&lt;&lt;ss.str()&lt;&lt;endl; // for debug
          ss &gt;&gt; ind3;
          cout &lt;&lt; ind3 &lt;&lt; endl; 
      }
  }
  objFile.close();
  cout &lt;&lt; "Reader success.\n";
  return true;
  }
  </code></pre>
  
  <p>Does anyone have any idea why the three inds are being read in as flat 0's? It's not that I've initialised them to 0 either - before they all read a large negative number depending on the type used so that doesn't indicate much.</p>