* Fix OBJ/MTL parsing bug when using linux line breaks
git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7644 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
This commit is contained in:
parent
993b220922
commit
17af890e86
@ -87,6 +87,10 @@ public class MTLLoader implements AssetLoader {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void skipLine(){
|
||||||
|
scan.skip(".*\r{0,1}\n");
|
||||||
|
}
|
||||||
|
|
||||||
protected void resetMaterial(){
|
protected void resetMaterial(){
|
||||||
ambient.set(ColorRGBA.Black);
|
ambient.set(ColorRGBA.Black);
|
||||||
diffuse.set(ColorRGBA.Black);
|
diffuse.set(ColorRGBA.Black);
|
||||||
@ -173,7 +177,7 @@ public class MTLLoader implements AssetLoader {
|
|||||||
String cmd = scan.next().toLowerCase();
|
String cmd = scan.next().toLowerCase();
|
||||||
if (cmd.startsWith("#")){
|
if (cmd.startsWith("#")){
|
||||||
// skip entire comment until next line
|
// skip entire comment until next line
|
||||||
nextStatement();
|
skipLine();
|
||||||
}else if (cmd.equals("newmtl")){
|
}else if (cmd.equals("newmtl")){
|
||||||
String name = scan.next();
|
String name = scan.next();
|
||||||
startMaterial(name);
|
startMaterial(name);
|
||||||
@ -190,7 +194,7 @@ public class MTLLoader implements AssetLoader {
|
|||||||
transparent = true;
|
transparent = true;
|
||||||
}else if (cmd.equals("map_ka")){
|
}else if (cmd.equals("map_ka")){
|
||||||
// ignore it for now
|
// ignore it for now
|
||||||
nextStatement();
|
skipLine();
|
||||||
}else if (cmd.equals("map_kd")){
|
}else if (cmd.equals("map_kd")){
|
||||||
String path = nextStatement();
|
String path = nextStatement();
|
||||||
diffuseMap = loadTexture(path);
|
diffuseMap = loadTexture(path);
|
||||||
@ -233,10 +237,10 @@ public class MTLLoader implements AssetLoader {
|
|||||||
}else if (cmd.equals("ke") || cmd.equals("ni")){
|
}else if (cmd.equals("ke") || cmd.equals("ni")){
|
||||||
// Ni: index of refraction - unsupported in jME
|
// Ni: index of refraction - unsupported in jME
|
||||||
// Ke: emission color
|
// Ke: emission color
|
||||||
nextStatement();
|
skipLine();
|
||||||
}else{
|
}else{
|
||||||
System.out.println("Unknown statement in MTL! "+cmd);
|
System.out.println("Unknown statement in MTL! "+cmd);
|
||||||
nextStatement();
|
skipLine();
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -334,13 +334,8 @@ public final class OBJLoader implements AssetLoader {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Pattern nl = Pattern.compile("\n");
|
|
||||||
private static final Pattern ws = Pattern.compile("\\p{javaWhitespace}+");
|
|
||||||
|
|
||||||
protected void nextStatement(){
|
protected void nextStatement(){
|
||||||
scan.useDelimiter(nl);
|
scan.skip(".*\r{0,1}\n");
|
||||||
scan.next();
|
|
||||||
scan.useDelimiter(ws);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean readLine() throws IOException{
|
protected boolean readLine() throws IOException{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user