corrected issues in OBJ importer

- tabs now work as separators in vertices
- per-vertex color presence determination now works correctly
This commit is contained in:
Marco Callieri 2018-02-01 16:27:05 +01:00
parent a8227df267
commit 7ab64d844e
1 changed files with 15 additions and 5 deletions

View File

@ -887,6 +887,7 @@ namespace vcg {
oi.numNormals=0; oi.numNormals=0;
int lineCount=0; int lineCount=0;
int totRead=0; int totRead=0;
bool firstV = true;
std::string line; std::string line;
while (!stream.eof()) while (!stream.eof())
{ {
@ -899,11 +900,20 @@ namespace vcg {
{ {
if(line[0]=='v') if(line[0]=='v')
{ {
if(line[1]==' ') if ((line[1] == ' ') || (line[1] == '\t'))
{ {
oi.numVertices++; oi.numVertices++;
if(line.size()>=7) if (firstV)
{
int sepN = 0;
for (int lit = 0; lit < line.size(); lit++){
if ((line[lit] == ' ') || (line[lit] == '\t'))
sepN++;
}
if (sepN >= 6)
bHasPerVertexColor = true; bHasPerVertexColor = true;
firstV = false;
}
} }
if(line[1]=='t') oi.numTexCoords++; if(line[1]=='t') oi.numTexCoords++;
if(line[1]=='n') { if(line[1]=='n') {