Bugfix: fixed a bug that caused importer to crash when the author of the

blend file assigned non existing UV coordinates group name to a mesh.
experimental
kaelthas 9 years ago
parent f1a0125dc2
commit 953a301d5e
  1. 8
      jme3-blender/src/main/java/com/jme3/scene/plugins/blender/materials/MaterialContext.java
  2. 3
      jme3-blender/src/main/java/com/jme3/scene/plugins/blender/textures/CombinedTexture.java

@ -168,9 +168,11 @@ public final class MaterialContext implements Savable {
this.setTexture(material, combinedTexture.getMappingType(), combinedTexture.getResultTexture()); this.setTexture(material, combinedTexture.getMappingType(), combinedTexture.getResultTexture());
List<Vector2f> uvs = combinedTexture.getResultUVS(); List<Vector2f> uvs = combinedTexture.getResultUVS();
VertexBuffer uvCoordsBuffer = new VertexBuffer(TextureHelper.TEXCOORD_TYPES[textureIndex++]); if(uvs != null && uvs.size() > 0) {
uvCoordsBuffer.setupData(Usage.Static, 2, Format.Float, BufferUtils.createFloatBuffer(uvs.toArray(new Vector2f[uvs.size()]))); VertexBuffer uvCoordsBuffer = new VertexBuffer(TextureHelper.TEXCOORD_TYPES[textureIndex++]);
geometry.getMesh().setBuffer(uvCoordsBuffer); uvCoordsBuffer.setupData(Usage.Static, 2, Format.Float, BufferUtils.createFloatBuffer(uvs.toArray(new Vector2f[uvs.size()])));
geometry.getMesh().setBuffer(uvCoordsBuffer);
}//uvs might be null if the user assigned non existing UV coordinates group name to the mesh (this should be fixed in blender file)
} else { } else {
LOGGER.log(Level.WARNING, "The texture could not be applied because JME only supports up to {0} different UV's.", TextureHelper.TEXCOORD_TYPES.length); LOGGER.log(Level.WARNING, "The texture could not be applied because JME only supports up to {0} different UV's.", TextureHelper.TEXCOORD_TYPES.length);
} }

@ -158,6 +158,9 @@ public class CombinedTexture {
} else { } else {
resultUVS = userDefinedUVCoordinates.get(textureData.uvCoordinatesName); resultUVS = userDefinedUVCoordinates.get(textureData.uvCoordinatesName);
} }
if(resultUVS == null && LOGGER.isLoggable(Level.WARNING)) {
LOGGER.warning("The texture " + textureData.texture.getName() + " has assigned non existing UV coordinates group: " + textureData.uvCoordinatesName + ".");
}
masterUserUVSetName = textureData.uvCoordinatesName; masterUserUVSetName = textureData.uvCoordinatesName;
} else { } else {
TemporalMesh temporalMesh = (TemporalMesh) blenderContext.getLoadedFeature(geometriesOMA, LoadedDataType.TEMPORAL_MESH); TemporalMesh temporalMesh = (TemporalMesh) blenderContext.getLoadedFeature(geometriesOMA, LoadedDataType.TEMPORAL_MESH);

Loading…
Cancel
Save