Hi guys,
I’m using this OBJ file, which has a comment of 0 length, as follows:
[java]
Max2Obj Version 4.0 Mar 10th, 2001
#
object Plane01 to come …
#
v -0.085781 0.378683 0.720427
v -0.089537 0.369320 0.726735
[/java]
When trying to parse this file, the OBJLoader skipped the first line right after the 0 length comment. The culprit turns out to be in the line skipping logic, which is in the nextStatement() method:
[java]
protected void nextStatement(){
scan.useDelimiter(nl);
scan.next();
scan.useDelimiter(ws);
}
[/java]
If the pointer is at the end of line already, this will skip the next line entirely. To fix this, we can use the following regular expression instead:
[java]
protected void nextStatement(){
scan.skip(".*n");
}
[/java]
Here is my diff patch:
[patch]
This patch file was generated by NetBeans IDE
It uses platform neutral UTF-8 encoding and n newlines.
— Base (BASE)
+++ Locally Modified (Based On LOCAL)
@@ -334,13 +334,8 @@
}
}
- private static final Pattern nl = Pattern.compile("n");
- private static final Pattern ws = Pattern.compile("\p{javaWhitespace}+");
-
protected void nextStatement(){
-
scan.useDelimiter(nl);<br />
-
scan.next();<br />
-
scan.useDelimiter(ws);<br />
-
scan.skip(".*n");<br />
}
protected boolean readLine() throws IOException{
[/patch]