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
experimental
Kae..pl 11 years ago
parent 5e4af7a4fe
commit 1e33d2b0f3
  1. 10
      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.Mesh.Mode;
import com.jme3.scene.VertexBuffer; import com.jme3.scene.VertexBuffer;
import com.jme3.scene.VertexBuffer.Format; import com.jme3.scene.VertexBuffer.Format;
import com.jme3.scene.VertexBuffer.Type;
import com.jme3.scene.VertexBuffer.Usage; import com.jme3.scene.VertexBuffer.Usage;
import com.jme3.scene.plugins.blender.AbstractBlenderHelper; import com.jme3.scene.plugins.blender.AbstractBlenderHelper;
import com.jme3.scene.plugins.blender.BlenderContext; import com.jme3.scene.plugins.blender.BlenderContext;
@ -120,7 +121,7 @@ public class MeshHelper extends AbstractBlenderHelper {
materials = materialHelper.getMaterials(structure, blenderContext); materials = materialHelper.getMaterials(structure, blenderContext);
} }
LOGGER.fine("Reading vertices and their colors."); LOGGER.fine("Reading vertices.");
MeshBuilder meshBuilder = new MeshBuilder(structure, materials, blenderContext); MeshBuilder meshBuilder = new MeshBuilder(structure, materials, blenderContext);
if (meshBuilder.isEmpty()) { if (meshBuilder.isEmpty()) {
LOGGER.fine("The geometry is empty."); 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) { if (mode != Mode.Triangles && mode != Mode.TriangleFan && mode != Mode.TriangleStrip) {
geometry.setMaterial(this.getBlackUnshadedMaterial(blenderContext)); geometry.setMaterial(this.getBlackUnshadedMaterial(blenderContext));
} else { } 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) { if (uvCoordsBuffer != null) {
for (VertexBuffer buffer : uvCoordsBuffer) { for (VertexBuffer buffer : uvCoordsBuffer) {

Loading…
Cancel
Save