From 1e33d2b0f3ec833e149efab3a692b46bf31be202 Mon Sep 17 00:00:00 2001 From: "Kae..pl" Date: Mon, 25 Nov 2013 13:26:05 +0000 Subject: [PATCH] Bugfix: allowing to use vertex colors when mesh has no material defined in blender. git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@10916 75d07b2b-3a1a-0410-a2c5-0572b91ccdca --- .../jme3/scene/plugins/blender/meshes/MeshHelper.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) 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 7d32c59b2..8b96df307 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 @@ -48,6 +48,7 @@ import com.jme3.scene.Mesh; import com.jme3.scene.Mesh.Mode; import com.jme3.scene.VertexBuffer; import com.jme3.scene.VertexBuffer.Format; +import com.jme3.scene.VertexBuffer.Type; import com.jme3.scene.VertexBuffer.Usage; import com.jme3.scene.plugins.blender.AbstractBlenderHelper; import com.jme3.scene.plugins.blender.BlenderContext; @@ -120,7 +121,7 @@ public class MeshHelper extends AbstractBlenderHelper { materials = materialHelper.getMaterials(structure, blenderContext); } - LOGGER.fine("Reading vertices and their colors."); + LOGGER.fine("Reading vertices."); MeshBuilder meshBuilder = new MeshBuilder(structure, materials, blenderContext); if (meshBuilder.isEmpty()) { LOGGER.fine("The geometry is empty."); @@ -201,7 +202,12 @@ public class MeshHelper extends AbstractBlenderHelper { if (mode != Mode.Triangles && mode != Mode.TriangleFan && mode != Mode.TriangleStrip) { geometry.setMaterial(this.getBlackUnshadedMaterial(blenderContext)); } else { - geometry.setMaterial(blenderContext.getDefaultMaterial()); + Material defaultMaterial = blenderContext.getDefaultMaterial(); + if(geometry.getMesh().getBuffer(Type.Color) != null) { + defaultMaterial = defaultMaterial.clone(); + defaultMaterial.setBoolean("VertexColor", true); + } + geometry.setMaterial(defaultMaterial); } if (uvCoordsBuffer != null) { for (VertexBuffer buffer : uvCoordsBuffer) {