From 6c2f7288b7110cdb5934734cad3bb08e2ed033f5 Mon Sep 17 00:00:00 2001 From: "Kae..pl" Date: Tue, 28 Aug 2012 13:46:16 +0000 Subject: [PATCH] Material assignation fix when blender does not fully assigns the materials. Proper warning is generated and default material is used. git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@9693 75d07b2b-3a1a-0410-a2c5-0572b91ccdca --- .../com/jme3/scene/plugins/blender/meshes/MeshHelper.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/meshes/MeshHelper.java b/engine/src/blender/com/jme3/scene/plugins/blender/meshes/MeshHelper.java index 45851bc7f..736c1c29c 100644 --- a/engine/src/blender/com/jme3/scene/plugins/blender/meshes/MeshHelper.java +++ b/engine/src/blender/com/jme3/scene/plugins/blender/meshes/MeshHelper.java @@ -34,6 +34,7 @@ package com.jme3.scene.plugins.blender.meshes; import java.util.ArrayList; import java.util.List; import java.util.Map.Entry; +import java.util.logging.Logger; import com.jme3.asset.BlenderKey.FeaturesToLoad; import com.jme3.math.Vector2f; @@ -62,6 +63,8 @@ import com.jme3.util.BufferUtils; * @author Marcin Roguski (Kaelthas) */ public class MeshHelper extends AbstractBlenderHelper { + private static final Logger LOGGER = Logger.getLogger(MeshHelper.class.getName()); + /** * This constructor parses the given blender version and stores the result. Some functionalities may differ in different blender * versions. @@ -213,6 +216,11 @@ public class MeshHelper extends AbstractBlenderHelper { List uvCoordinates = meshBuilder.getUVCoordinates(materialNumber); MaterialContext materialContext = materials[materialNumber]; materialContext.applyMaterial(geometry, structure.getOldMemoryAddress(), uvCoordinates, blenderContext); + } else { + geometry.setMaterial(blenderContext.getDefaultMaterial()); + LOGGER.warning("The importer came accross mesh that points to a null material. Default material is used to prevent loader from crashing, " + + "but the model might look not the way it should. Sometimes blender does not assign materials properly. " + + "Enter the edit mode and assign materials once more to your faces."); } } } else {