From Gino van den Bergen, "AFAICS, OSG's OBJ loader correctly handles backslash-newlines that are used for continuation of lines. However, I recently ran into a problem with OBJs that where converted from another source using Right Hemisphere Deep Exploration. In these OBJs newlines are escaped in the following way:

f  15939/9999/16177 15941/10000/16178 15940/10001/16179\
15938/10002/16180

In the OBJ loader the newline would be interpreted as follows

f  15939/9999/16177 15941/10000/16178 15940/10001/1617915938/10002/16180

However, for correctly loading the model it should be interpreted as

f  15939/9999/16177 15941/10000/16178 15940/10001/16179 15938/10002/16180

Thus, the escaped newline should be interpreted as a space.

I tried to lookup what the correct interpretation for a backslash-newline was in the OBJ spec but did not find anything useful. Nevertheless, my suggestion would be to adopt replacing the escaped newline by a space in order to avoid problems as stated above. I cannot imagine a meaningful usage of a newline within a numerical literal so I do not foresee cases where replacing a backslash-newline by a space would be harmful. The fixed obj.cpp is zipped and attached to this mail."
This commit is contained in:
Robert Osfield
2009-06-19 14:14:26 +00:00
parent 4d19bed7f2
commit 6dbb6dc0ae

View File

@@ -137,6 +137,7 @@ bool Model::readline(std::istream& fin, char* line, const int LINE_SIZE)
if (skipNewline)
{
skipNewline = false;
*ptr++ = ' ';
continue;
}
else break;
@@ -146,6 +147,7 @@ bool Model::readline(std::istream& fin, char* line, const int LINE_SIZE)
if (skipNewline)
{
skipNewline = false;
*ptr++ = ' ';
continue;
}
else break;
@@ -156,7 +158,7 @@ bool Model::readline(std::istream& fin, char* line, const int LINE_SIZE)
// osg::notify(osg::NOTICE)<<"We have unix line ending"<<std::endl;
if (skipNewline)
{
skipNewline = false;
*ptr++ = ' ';
continue;
}
else break;