Fixed NPE error when using a single 'None' texture type in the material definition.

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@9342 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
Kae..pl 13 years ago
parent 2e704987b9
commit f9593adee1
  1. 27
      engine/src/blender/com/jme3/scene/plugins/blender/materials/MaterialContext.java
  2. 7
      engine/src/blender/com/jme3/scene/plugins/blender/textures/CombinedTexture.java

@ -126,23 +126,24 @@ public final class MaterialContext {
TextureHelper textureHelper = blenderContext.getHelper(TextureHelper.class);
for(Entry<Number, List<TextureData>> entry : textureDataMap.entrySet()) {
if(entry.getValue().size()>0) {
CombinedTexture combinedTexture = loadedTextures.get(entry.getKey());
if(combinedTexture == null) {
combinedTexture = new CombinedTexture();
loadedTextures.put(entry.getKey(), combinedTexture);
}
CombinedTexture combinedTexture = new CombinedTexture();
for(TextureData textureData : entry.getValue()) {
int texflag = ((Number) textureData.mtex.getFieldValue("texflag")).intValue();
boolean negateTexture = (texflag & 0x04) != 0;
Texture texture = textureHelper.getTexture(textureData.textureStructure, textureData.mtex, blenderContext);
int blendType = ((Number) textureData.mtex.getFieldValue("blendtype")).intValue();
float[] color = new float[] { ((Number) textureData.mtex.getFieldValue("r")).floatValue(),
((Number) textureData.mtex.getFieldValue("g")).floatValue(),
((Number) textureData.mtex.getFieldValue("b")).floatValue() };
float colfac = ((Number) textureData.mtex.getFieldValue("colfac")).floatValue();
TextureBlender textureBlender = TextureBlenderFactory.createTextureBlender(texture.getImage().getFormat(),
texflag, negateTexture, blendType, diffuseColorArray, color, colfac);
combinedTexture.add(texture, textureBlender, textureData.uvCoordinatesType, textureData.projectionType, textureData.textureStructure, blenderContext);
if(texture != null) {
int blendType = ((Number) textureData.mtex.getFieldValue("blendtype")).intValue();
float[] color = new float[] { ((Number) textureData.mtex.getFieldValue("r")).floatValue(),
((Number) textureData.mtex.getFieldValue("g")).floatValue(),
((Number) textureData.mtex.getFieldValue("b")).floatValue() };
float colfac = ((Number) textureData.mtex.getFieldValue("colfac")).floatValue();
TextureBlender textureBlender = TextureBlenderFactory.createTextureBlender(texture.getImage().getFormat(),
texflag, negateTexture, blendType, diffuseColorArray, color, colfac);
combinedTexture.add(texture, textureBlender, textureData.uvCoordinatesType, textureData.projectionType, textureData.textureStructure, blenderContext);
}
}
if(combinedTexture.getTexturesCount() > 0) {
loadedTextures.put(entry.getKey(), combinedTexture);
}
}
}

@ -211,6 +211,13 @@ public class CombinedTexture {
return resultUVS;
}
/**
* @return the amount of added textures
*/
public int getTexturesCount() {
return textureDatas.size();
}
/**
* This method merges two given textures. The result is stored in the
* 'target' texture.

Loading…
Cancel
Save