From 0e4f115e84eaafa381a204137039ed2d72bdc47a Mon Sep 17 00:00:00 2001 From: "Kae..pl" Date: Thu, 8 Dec 2011 17:37:58 +0000 Subject: [PATCH] FIXED: Issue 430: Blender loader sets blend mode = alpha on material that is not really transparent git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@8900 75d07b2b-3a1a-0410-a2c5-0572b91ccdca --- .../blender/materials/MaterialContext.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/materials/MaterialContext.java b/engine/src/blender/com/jme3/scene/plugins/blender/materials/MaterialContext.java index 3dff16b70..e44bbc386 100644 --- a/engine/src/blender/com/jme3/scene/plugins/blender/materials/MaterialContext.java +++ b/engine/src/blender/com/jme3/scene/plugins/blender/materials/MaterialContext.java @@ -63,7 +63,6 @@ public final class MaterialContext { int mode = ((Number) structure.getFieldValue("mode")).intValue(); shadeless = (mode & 0x4) != 0; vertexColor = (mode & 0x80) != 0; - transparent = (mode & 0x10000) != 0; vTangent = (mode & 0x4000000) != 0; // NOTE: Requires tangents int diff_shader = ((Number) structure.getFieldValue("diff_shader")).intValue(); @@ -90,6 +89,7 @@ public final class MaterialContext { float shininess = ((Number) structure.getFieldValue("emit")).floatValue(); this.shininess = shininess > 0.0f ? shininess : MaterialHelper.DEFAULT_SHININESS; } + float[] diffuseColorArray = new float[] {diffuseColor.r, diffuseColor.g, diffuseColor.b, diffuseColor.a};//TODO: czy trzeba wstawiac te dane? mTexs = new ArrayList(); @@ -161,6 +161,21 @@ public final class MaterialContext { this.texturesCount = mTexs.size(); this.textureType = firstTextureType; + + //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(specularColor != null) { + transparent = transparent || specularColor.a < 1.0f; + } + if(ambientColor != null) { + transparent = transparent || ambientColor.a < 1.0f; + } + this.transparent = transparent; } /**