* Fix issue with MTL map_** statements provided with arguments
git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7487 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
This commit is contained in:
parent
db62445d7e
commit
e55e17ba4b
@ -70,10 +70,11 @@ public class MTLLoader implements AssetLoader {
|
|||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void nextStatement(){
|
protected String nextStatement(){
|
||||||
scan.useDelimiter("\n");
|
scan.useDelimiter("\n");
|
||||||
scan.next();
|
String result = scan.next();
|
||||||
scan.useDelimiter("\\p{javaWhitespace}+");
|
scan.useDelimiter("\\p{javaWhitespace}+");
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void startMaterial(String name){
|
protected void startMaterial(String name){
|
||||||
@ -87,6 +88,11 @@ public class MTLLoader implements AssetLoader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected Texture loadTexture(String path){
|
protected Texture loadTexture(String path){
|
||||||
|
String[] split = path.trim().split("\\p{javaWhitespace}+");
|
||||||
|
|
||||||
|
// will crash if path is an empty string
|
||||||
|
path = split[split.length-1];
|
||||||
|
|
||||||
String name = new File(path).getName();
|
String name = new File(path).getName();
|
||||||
TextureKey key = new TextureKey(folderName + name);
|
TextureKey key = new TextureKey(folderName + name);
|
||||||
key.setGenerateMips(true);
|
key.setGenerateMips(true);
|
||||||
@ -139,12 +145,13 @@ public class MTLLoader implements AssetLoader {
|
|||||||
}
|
}
|
||||||
}else if (cmd.equals("map_ka")){
|
}else if (cmd.equals("map_ka")){
|
||||||
// ignore it for now
|
// ignore it for now
|
||||||
|
nextStatement();
|
||||||
}else if (cmd.equals("map_kd")){
|
}else if (cmd.equals("map_kd")){
|
||||||
String path = scan.next();
|
String path = nextStatement();
|
||||||
material.setTexture("DiffuseMap", loadTexture(path));
|
material.setTexture("DiffuseMap", loadTexture(path));
|
||||||
}else if (cmd.equals("map_bump") || cmd.equals("bump")){
|
}else if (cmd.equals("map_bump") || cmd.equals("bump")){
|
||||||
if (material.getParam("NormalMap") == null){
|
if (material.getParam("NormalMap") == null){
|
||||||
String path = scan.next();
|
String path = nextStatement();
|
||||||
Texture texture = loadTexture(path);
|
Texture texture = loadTexture(path);
|
||||||
if (texture != null){
|
if (texture != null){
|
||||||
material.setTexture("NormalMap", texture);
|
material.setTexture("NormalMap", texture);
|
||||||
@ -154,7 +161,7 @@ public class MTLLoader implements AssetLoader {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else if (cmd.equals("map_ks")){
|
}else if (cmd.equals("map_ks")){
|
||||||
String path = scan.next();
|
String path = nextStatement();
|
||||||
Texture texture = loadTexture(path);
|
Texture texture = loadTexture(path);
|
||||||
if (texture != null){
|
if (texture != null){
|
||||||
material.setTexture("SpecularMap", texture);
|
material.setTexture("SpecularMap", texture);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user