- // read a vertex
- for (int i=0; i<3; i++)
- if (stream->Read(&m_verts[m_numverts][i], sz).LastRead() != sz)
- {
- wxLogError("Cannot read the %d-th vertex in '%s'!",
- m_numverts, filename.c_str());
- delete stream;
- return;
- }
-
- // read its normal
- for (int i=0; i<3; i++)
- if (stream->Read(&m_norms[m_numverts][i], sz).LastRead() != sz)
- {
- wxLogError("Cannot read the %d-th vertex in '%s'!",
- m_numverts, filename.c_str());
- delete stream;
- return;
- }
-
- m_numverts++;
+ // we suppose to have in input a text file containing floating numbers
+ // space/newline-separed... first 3 numbers are the coordinates of a
+ // vertex and the following 3 are the relative vertex normal and so on...
+
+ wxTextInputStream inFile(*stream);
+ m_numverts = 0;
+
+ while (!stream->Eof() && m_numverts < MAXVERTS)// && m_numverts<MAXVERTS)
+ {
+ inFile >> m_verts[m_numverts][0] >> m_verts[m_numverts][1] >> m_verts[m_numverts][2];
+ inFile >> m_norms[m_numverts][0] >> m_norms[m_numverts][1] >> m_norms[m_numverts][2];
+
+ m_numverts++;
+ }
+
+ // discard last vertex; it is a zero caused by the EOF
+ m_numverts--;