Browse Source

* Forgot to commit proper exception for generated textures in MatParams
* OBJ/MTL loaders now use logger instead of System.out for warnings

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@8007 75d07b2b-3a1a-0410-a2c5-0572b91ccdca

sha..rd 14 years ago
parent
commit
2ddc537ddc

+ 5 - 1
engine/src/core-plugins/com/jme3/scene/plugins/MTLLoader.java

@@ -47,9 +47,13 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.util.Locale;
 import java.util.Scanner;
+import java.util.logging.Level;
+import java.util.logging.Logger;
 
 public class MTLLoader implements AssetLoader {
 
+    private static final Logger logger = Logger.getLogger(MTLLoader.class.getName());
+    
     protected Scanner scan;
     protected MaterialList matList;
     //protected Material material;
@@ -242,7 +246,7 @@ public class MTLLoader implements AssetLoader {
             // Ke: emission color
             skipLine();
         }else{
-            System.out.println("Unknown statement in MTL! "+cmd);
+            logger.log(Level.WARNING, "Unknown statement in MTL! {0}", cmd);
             skipLine();
         }
         

+ 4 - 2
engine/src/core-plugins/com/jme3/scene/plugins/OBJLoader.java

@@ -49,6 +49,7 @@ import com.jme3.scene.VertexBuffer.Type;
 import com.jme3.scene.mesh.IndexBuffer;
 import com.jme3.scene.mesh.IndexIntBuffer;
 import com.jme3.scene.mesh.IndexShortBuffer;
+import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
 import java.nio.FloatBuffer;
@@ -61,7 +62,6 @@ import java.util.Map.Entry;
 import java.util.Scanner;
 import java.util.logging.Level;
 import java.util.logging.Logger;
-import java.util.regex.Pattern;
 
 /**
  * Reads OBJ format models.
@@ -321,6 +321,8 @@ public final class OBJLoader implements AssetLoader {
         if (!name.toLowerCase().endsWith(".mtl"))
             throw new IOException("Expected .mtl file! Got: " + name);
 
+        // NOTE: Cut off any relative/absolute paths
+        name = new File(name).getName();
         matList = (MaterialList) assetManager.loadAsset(key.getFolder() + name);
 
         if (matList != null){
@@ -373,7 +375,7 @@ public final class OBJLoader implements AssetLoader {
             nextStatement();
         }else{
             // skip entire command until next line
-            System.out.println("Unknown statement in OBJ! "+cmd);
+            logger.log(Level.WARNING, "Unknown statement in OBJ! {0}", cmd);
             nextStatement();
         }     
 

+ 4 - 0
engine/src/core/com/jme3/material/MatParam.java

@@ -207,6 +207,10 @@ public class MatParam implements Savable, Cloneable {
             case TextureCubeMap:
                 Texture texVal = (Texture) value;
                 TextureKey texKey = (TextureKey) texVal.getKey();
+                if (texKey == null){
+                    throw new UnsupportedOperationException("The specified MatParam cannot be represented in J3M");
+                }
+                
                 String ret = "";
                 if (texKey.isFlipY()) {
                     ret += "Flip ";