Bugfix: fixed a bug that caused vertex colors to be improperly assigned

after temporal mesh triangulation.
experimental
jmekaelthas 10 years ago
parent 6e05304d26
commit 13b433e434
  1. 2
      jme3-blender/src/main/java/com/jme3/scene/plugins/blender/meshes/Face.java
  2. 20
      jme3-blender/src/main/java/com/jme3/scene/plugins/blender/meshes/MeshHelper.java
  3. 2
      jme3-blender/src/main/java/com/jme3/scene/plugins/blender/meshes/TemporalMesh.java

@ -180,7 +180,7 @@ public class Face implements Comparator<Integer> {
}
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));
}

@ -341,6 +341,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<byte[]> selectVertexColorSubset(Face face, Integer... indexesSublist) {
List<byte[]> result = null;
List<byte[]> vertexColors = face.getVertexColors();
if (vertexColors != null) {
result = new ArrayList<byte[]>(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
* renders it.

@ -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<Float, Integer> boneBuffersForVertex = new HashMap<Float, Integer>();

Loading…
Cancel
Save