diff --git a/jme3-blender/src/main/java/com/jme3/scene/plugins/blender/meshes/Face.java b/jme3-blender/src/main/java/com/jme3/scene/plugins/blender/meshes/Face.java index 6d94a4707..f4a417daa 100644 --- a/jme3-blender/src/main/java/com/jme3/scene/plugins/blender/meshes/Face.java +++ b/jme3-blender/src/main/java/com/jme3/scene/plugins/blender/meshes/Face.java @@ -180,7 +180,7 @@ public class Face implements Comparator { } if (detachedFaces.size() == 0 && path.size() < indexes.size()) { Integer[] indexesSublist = path.toArray(new Integer[path.size()]); - detachedFaces.add(new Face(indexesSublist, smooth, materialNumber, meshHelper.selectUVSubset(this, indexesSublist), vertexColors, temporalMesh)); + detachedFaces.add(new Face(indexesSublist, smooth, materialNumber, meshHelper.selectUVSubset(this, indexesSublist), meshHelper.selectVertexColorSubset(this, indexesSublist), temporalMesh)); for (int j = 0; j < path.size() - 1; ++j) { indexes.removeEdge(path.get(j), path.get(j + 1)); } diff --git a/jme3-blender/src/main/java/com/jme3/scene/plugins/blender/meshes/MeshHelper.java b/jme3-blender/src/main/java/com/jme3/scene/plugins/blender/meshes/MeshHelper.java index a69491a37..994ac23f3 100644 --- a/jme3-blender/src/main/java/com/jme3/scene/plugins/blender/meshes/MeshHelper.java +++ b/jme3-blender/src/main/java/com/jme3/scene/plugins/blender/meshes/MeshHelper.java @@ -340,6 +340,26 @@ public class MeshHelper extends AbstractBlenderHelper { } return result; } + + /** + * Selects the proper subsets of vertex colors for the given sublist of indexes. + * @param face + * the face with the original vertex colors + * @param indexesSublist + * the sub list of indexes + * @return a sublist of vertex colors + */ + public List selectVertexColorSubset(Face face, Integer... indexesSublist) { + List result = null; + List vertexColors = face.getVertexColors(); + if (vertexColors != null) { + result = new ArrayList(indexesSublist.length); + for (Integer index : indexesSublist) { + result.add(vertexColors.get(face.getIndexes().indexOf(index))); + } + } + return result; + } /** * Returns the black unshaded material. It is used for lines and points because that is how blender diff --git a/jme3-blender/src/main/java/com/jme3/scene/plugins/blender/meshes/TemporalMesh.java b/jme3-blender/src/main/java/com/jme3/scene/plugins/blender/meshes/TemporalMesh.java index da10c676d..4b9240680 100644 --- a/jme3-blender/src/main/java/com/jme3/scene/plugins/blender/meshes/TemporalMesh.java +++ b/jme3-blender/src/main/java/com/jme3/scene/plugins/blender/meshes/TemporalMesh.java @@ -402,7 +402,7 @@ public class TemporalMesh extends Geometry { int vertIndex = indexes.get(i); tempVerts[i] = vertices.get(vertIndex); tempNormals[i] = normals.get(vertIndex); - tempVertColors[i] = vertexColors != null ? vertexColors.get(i) : null; + tempVertColors[i] = vertexColors != null ? vertexColors.get(face.getIndexes().indexOf(vertIndex)) : null; if (boneIndexes.size() > 0) { Map boneBuffersForVertex = new HashMap();