From 0e24cf969b5d90b0956fa026a18016d1060c4346 Mon Sep 17 00:00:00 2001 From: "Kae..pl" Date: Sun, 24 Jun 2012 19:49:15 +0000 Subject: [PATCH] Bugfix for textures loading: when one texture had several mappings it might not have appeared on the scene at all. git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@9520 75d07b2b-3a1a-0410-a2c5-0572b91ccdca --- .../blender/materials/MaterialContext.java | 25 ++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) 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 1f1910e6e..81e29d5cd 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 @@ -269,22 +269,29 @@ public final class MaterialContext { } /** - * This method sorts the textures by their mapping type. - * In each group only textures of one type are put (either two- or three-dimensional). - * If the mapping type is MTEX_COL then if the texture has no alpha channel then all textures before it are - * discarded and will not be loaded and merged because texture with no alpha will cover them anyway. + * This method sorts the textures by their mapping type. In each group only + * textures of one type are put (either two- or three-dimensional). If the + * mapping type is MTEX_COL then if the texture has no alpha channel then + * all textures before it are discarded and will not be loaded and merged + * because texture with no alpha will cover them anyway. + * * @return a map with sorted and filtered textures */ private Map> sortAndFilterTextures(List textures) { + int[] mappings = new int[] { MTEX_COL, MTEX_NOR, MTEX_EMIT, MTEX_SPEC, MTEX_ALPHA }; Map> result = new HashMap>(); for (TextureData data : textures) { Number mapto = (Number) data.mtex.getFieldValue("mapto"); - List datas = result.get(mapto); - if(datas==null) { - datas = new ArrayList(); - result.put(mapto, datas); + for (int i = 0; i < mappings.length; ++i) { + if((mappings[i] & mapto.intValue()) != 0) { + List datas = result.get(mappings[i]); + if (datas == null) { + datas = new ArrayList(); + result.put(mappings[i], datas); + } + datas.add(data); + } } - datas.add(data); } return result; }