Ver Fonte

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
Kae..pl há 13 anos atrás
pai
commit
0e24cf969b

+ 16 - 9
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
 	 * @return a map with sorted and filtered textures
 	 */
 	 */
 	private Map<Number, List<TextureData>> sortAndFilterTextures(List<TextureData> textures) {
 	private Map<Number, List<TextureData>> sortAndFilterTextures(List<TextureData> textures) {
+		int[] mappings = new int[] { MTEX_COL, MTEX_NOR, MTEX_EMIT, MTEX_SPEC, MTEX_ALPHA };
 		Map<Number, List<TextureData>> result = new HashMap<Number, List<TextureData>>();
 		Map<Number, List<TextureData>> result = new HashMap<Number, List<TextureData>>();
 		for (TextureData data : textures) {
 		for (TextureData data : textures) {
 			Number mapto = (Number) data.mtex.getFieldValue("mapto");
 			Number mapto = (Number) data.mtex.getFieldValue("mapto");
-			List<TextureData> datas = result.get(mapto);
-			if(datas==null) {
-				datas = new ArrayList<TextureData>();
-				result.put(mapto, datas);
+			for (int i = 0; i < mappings.length; ++i) {
+				if((mappings[i] & mapto.intValue()) != 0) {
+					List<TextureData> datas = result.get(mappings[i]);
+					if (datas == null) {
+						datas = new ArrayList<TextureData>();
+						result.put(mappings[i], datas);
+					}
+					datas.add(data);
+				}
 			}
 			}
-			datas.add(data);
 		}
 		}
 		return result;
 		return result;
 	}
 	}