Bläddra i källkod

Bugfix: fixed a bug that caused some models to be half-transparent when
it was not needed.

jmekaelthas 9 år sedan
förälder
incheckning
93080f506a

+ 19 - 12
jme3-blender/src/main/java/com/jme3/scene/plugins/blender/materials/MaterialContext.java

@@ -46,6 +46,8 @@ public final class MaterialContext implements Savable {
     public static final int                  MTEX_ALPHA = 0x80;
     public static final int                  MTEX_AMB   = 0x800;
 
+    public static final int                  FLAG_TRANSPARENT   = 0x10000;
+    
     /* package */final String                name;
     /* package */final List<CombinedTexture> loadedTextures;
 
@@ -96,20 +98,25 @@ public final class MaterialContext implements Savable {
         TextureHelper textureHelper = blenderContext.getHelper(TextureHelper.class);
         loadedTextures = textureHelper.readTextureData(structure, new float[] { diffuseColor.r, diffuseColor.g, diffuseColor.b, diffuseColor.a }, false);
 
-        // veryfying if the transparency is present
-        // (in blender transparent mask is 0x10000 but its better to verify it because blender can indicate transparency when
-        // it is not required
-        boolean transparent = false;
-        if (diffuseColor != null) {
-            transparent = diffuseColor.a < 1.0f;
-            if (loadedTextures.size() > 0) {// texutre covers the material color
-                diffuseColor.set(1, 1, 1, 1);
+        long flag = ((Number)structure.getFieldValue("flag")).longValue();
+        if((flag & FLAG_TRANSPARENT) != 0) {
+            // veryfying if the transparency is present
+            // (in blender transparent mask is 0x10000 but its better to verify it because blender can indicate transparency when
+            // it is not required
+            boolean transparent = false;
+            if (diffuseColor != null) {
+                transparent = diffuseColor.a < 1.0f;
+                if (loadedTextures.size() > 0) {// texutre covers the material color
+                    diffuseColor.set(1, 1, 1, 1);
+                }
             }
+            if (specularColor != null) {
+                transparent = transparent || specularColor.a < 1.0f;
+            }
+            this.transparent = transparent;
+        } else {
+            transparent = false;
         }
-        if (specularColor != null) {
-            transparent = transparent || specularColor.a < 1.0f;
-        }
-        this.transparent = transparent;
     }
 
     /**

+ 0 - 1
jme3-blender/src/main/java/com/jme3/scene/plugins/blender/modifiers/SubdivisionSurfaceModifier.java

@@ -209,7 +209,6 @@ public class SubdivisionSurfaceModifier extends Modifier {
      * @param temporalMesh
      *            the mesh to be subdivided
      */
-    @SuppressWarnings("unchecked")
     private void subdivideSimple(TemporalMesh temporalMesh) {
         Map<Edge, Integer> edgePoints = new HashMap<Edge, Integer>();
         Map<Face, Integer> facePoints = new HashMap<Face, Integer>();