Prechádzať zdrojové kódy

Bugfix: making blender importer NOT to crash when coming accross Depth24Stencil8 image type.

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@10816 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
Kae..pl 12 rokov pred
rodič
commit
e2cc42e6f3

+ 4 - 3
engine/src/blender/com/jme3/scene/plugins/blender/textures/UVCoordinatesGenerator.java

@@ -55,9 +55,10 @@ public class UVCoordinatesGenerator {
     private static final Logger LOGGER = Logger.getLogger(UVCoordinatesGenerator.class.getName());
 
     public static enum UVCoordinatesType {
-        TEXCO_ORCO(1), TEXCO_REFL(2), TEXCO_NORM(4), TEXCO_GLOB(8), TEXCO_UV(16), TEXCO_OBJECT(32), TEXCO_LAVECTOR(64), TEXCO_VIEW(128), TEXCO_STICKY(256), TEXCO_OSA(512), TEXCO_WINDOW(1024), NEED_UV(2048), TEXCO_TANGENT(4096),
-        // still stored in vertex->accum, 1 D
-        TEXCO_PARTICLE_OR_STRAND(8192), TEXCO_STRESS(16384), TEXCO_SPEED(32768);
+        TEXCO_ORCO(1), TEXCO_REFL(2), TEXCO_NORM(4), TEXCO_GLOB(8), TEXCO_UV(16), TEXCO_OBJECT(32), TEXCO_LAVECTOR(64), TEXCO_VIEW(128), 
+        TEXCO_STICKY(256), TEXCO_OSA(512), TEXCO_WINDOW(1024), NEED_UV(2048), TEXCO_TANGENT(4096),
+        TEXCO_PARTICLE_OR_STRAND(8192), //TEXCO_PARTICLE (since blender 2.6x) has also the value of: 8192 but is used for halo materials instead of normal materials
+        TEXCO_STRESS(16384), TEXCO_SPEED(32768);
 
         public final int blenderValue;
 

+ 17 - 8
engine/src/blender/com/jme3/scene/plugins/blender/textures/blending/TextureBlenderFactory.java

@@ -34,6 +34,7 @@ package com.jme3.scene.plugins.blender.textures.blending;
 import com.jme3.scene.plugins.blender.BlenderContext;
 import com.jme3.texture.Image;
 import com.jme3.texture.Image.Format;
+
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
@@ -45,6 +46,19 @@ import java.util.logging.Logger;
 public class TextureBlenderFactory {
     private static final Logger LOGGER = Logger.getLogger(TextureBlenderFactory.class.getName());
 
+    /**
+     * A blender that does not change the image. Used for none supported image types.
+     */
+    private static final TextureBlender NON_CHANGING_BLENDER = new TextureBlender() {
+        @Override
+        public Image blend(Image image, Image baseImage, BlenderContext blenderContext) {
+            return image;
+        }
+
+        @Override
+        public void copyBlendingData(TextureBlender textureBlender) { }
+    };
+    
     /**
      * This method creates the blending class.
      * 
@@ -52,6 +66,7 @@ public class TextureBlenderFactory {
      *            the texture format
      * @return texture blending class
      */
+    @SuppressWarnings("deprecation")
     public static TextureBlender createTextureBlender(Format format, int flag, boolean negate, int blendType, float[] materialColor, float[] color, float colfac) {
         switch (format) {
             case Luminance8:
@@ -97,15 +112,9 @@ public class TextureBlenderFactory {
             case Intensity8:
             case LATC:
             case LTC:
+            case Depth24Stencil8:
                 LOGGER.log(Level.WARNING, "Image type not yet supported for blending: {0}. Returning a blender that does not change the texture.", format);
-                return new TextureBlender() {
-                    public Image blend(Image image, Image baseImage, BlenderContext blenderContext) {
-                        return image;
-                    }
-
-                    public void copyBlendingData(TextureBlender textureBlender) {
-                    }
-                };
+                return NON_CHANGING_BLENDER;
             default:
                 throw new IllegalStateException("Unknown image format type: " + format);
         }