From 20fade37c5ee2f055bc916a61bfbf5ff3bb82f41 Mon Sep 17 00:00:00 2001 From: "Kae..pl" Date: Sun, 17 Nov 2013 13:18:31 +0000 Subject: [PATCH] Bugfix: setting the right color for vertex colors for versions 2.62 and below (the color factors were misplaced in older blender versions) git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@10893 75d07b2b-3a1a-0410-a2c5-0572b91ccdca --- .../com/jme3/scene/plugins/blender/meshes/MeshHelper.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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 f5bade23b..a2fd878e8 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 @@ -488,6 +488,9 @@ public class MeshHelper extends AbstractBlenderHelper { private List getVerticesColors(Structure meshStructure, BlenderContext blenderContext) throws BlenderFileException { Pointer pMCol = (Pointer) meshStructure.getFieldValue(this.isBMeshCompatible(meshStructure) ? "mloopcol" : "mcol"); List verticesColors = null; + //it was likely a bug in blender untill version 2.63 (the blue and red factors were misplaced in their structure) + //so we need to put them right + boolean useBGRA = blenderContext.getBlenderVersion() < 263; if (pMCol.isNotNull()) { List mCol = pMCol.fetchData(blenderContext.getInputStream()); verticesColors = new ArrayList(mCol.size()); @@ -496,7 +499,7 @@ public class MeshHelper extends AbstractBlenderHelper { byte g = ((Number) color.getFieldValue("g")).byteValue(); byte b = ((Number) color.getFieldValue("b")).byteValue(); byte a = ((Number) color.getFieldValue("a")).byteValue(); - verticesColors.add(new byte[] { r, g, b, a }); + verticesColors.add(useBGRA ? new byte[] { b, g, r, a } : new byte[] { r, g, b, a }); } } return verticesColors;