From a9cf6a348fc3a3d4ff1bb8787bdce71fc8424da7 Mon Sep 17 00:00:00 2001 From: NemesisMate Date: Thu, 27 Apr 2017 13:32:14 +0100 Subject: [PATCH] Fix #646 Ignoring the alpha influencer (mapping) if the color one was found first. --- .../plugins/blender/textures/TextureHelper.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/jme3-blender/src/main/java/com/jme3/scene/plugins/blender/textures/TextureHelper.java b/jme3-blender/src/main/java/com/jme3/scene/plugins/blender/textures/TextureHelper.java index 8913f5864..8bd1a2503 100644 --- a/jme3-blender/src/main/java/com/jme3/scene/plugins/blender/textures/TextureHelper.java +++ b/jme3-blender/src/main/java/com/jme3/scene/plugins/blender/textures/TextureHelper.java @@ -614,8 +614,15 @@ public class TextureHelper extends AbstractBlenderHelper { int texflag = ((Number) textureData.mtex.getFieldValue("texflag")).intValue(); boolean negateTexture = (texflag & 0x04) != 0; + boolean colorSet = false; for (int i = 0; i < mappings.length; ++i) { if ((mappings[i] & mapto.intValue()) != 0) { + if(mappings[i] == MaterialContext.MTEX_COL) { + colorSet = true; + } else if(colorSet && mappings[i] == MaterialContext.MTEX_ALPHA) { + continue; + } + CombinedTexture combinedTexture = new CombinedTexture(mappings[i], !skyTexture); int blendType = ((Number) textureData.mtex.getFieldValue("blendtype")).intValue(); float[] color = new float[] { ((Number) textureData.mtex.getFieldValue("r")).floatValue(), ((Number) textureData.mtex.getFieldValue("g")).floatValue(), ((Number) textureData.mtex.getFieldValue("b")).floatValue() }; @@ -646,8 +653,16 @@ public class TextureHelper extends AbstractBlenderHelper { Map> result = new HashMap>(); for (TextureData data : textures) { Number mapto = (Number) data.mtex.getFieldValue("mapto"); + + boolean colorSet = false; for (int i = 0; i < mappings.length; ++i) { if ((mappings[i] & mapto.intValue()) != 0) { + if(mappings[i] == MaterialContext.MTEX_COL) { + colorSet = true; + } else if(colorSet && mappings[i] == MaterialContext.MTEX_ALPHA) { + continue; + } + List datas = result.get(mappings[i]); if (datas == null) { datas = new ArrayList(); @@ -668,4 +683,4 @@ public class TextureHelper extends AbstractBlenderHelper { /** The name of the user's UV coordinates that are used for this texture. */ public String uvCoordinatesName; } -} \ No newline at end of file +}