Browse Source

Fix to a bug that caused loader to crach when loading an object without textures.

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@8098 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
Kae..pl 14 years ago
parent
commit
87ba2fcb11

+ 10 - 0
engine/src/blender/com/jme3/scene/plugins/blender/materials/MaterialContext.java

@@ -109,6 +109,16 @@ public final class MaterialContext {
 		return this.textureType == Type.TwoDimensional ? 2 : 3;
 	}
 	
+	/**
+	 * This method returns the amount of textures applied for the current
+	 * material.
+	 * 
+	 * @return the amount of textures applied for the current material
+	 */
+	public int getTexturesCount() {
+		return textures == null ? 0 : textures.size();
+	}
+	
 	/**
 	 * This method determines the type of the texture.
 	 * @param texType texture type (from blender)

+ 5 - 3
engine/src/blender/com/jme3/scene/plugins/blender/meshes/MeshHelper.java

@@ -406,9 +406,11 @@ public class MeshHelper extends AbstractBlenderHelper {
 			}
 			for(Entry<Material, List<Geometry>> entry : materialMap.entrySet()) {
 				MaterialContext materialContext = dataRepository.getMaterialContext(entry.getKey());
-				UVCoordinatesGenerator.generateUVCoordinates(materialContext.getUvCoordinatesType(), 
-						materialContext.getProjectionType(),
-						materialContext.getTextureDimension(), entry.getValue());
+				if(materialContext.getTexturesCount()>0) {
+					UVCoordinatesGenerator.generateUVCoordinates(materialContext.getUvCoordinatesType(), 
+							materialContext.getProjectionType(),
+							materialContext.getTextureDimension(), entry.getValue());
+				}
 			}
 		}