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. 11
      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,15 +126,12 @@ public final class MaterialContext {
TextureHelper textureHelper = blenderContext.getHelper(TextureHelper.class); TextureHelper textureHelper = blenderContext.getHelper(TextureHelper.class);
for(Entry<Number, List<TextureData>> entry : textureDataMap.entrySet()) { for(Entry<Number, List<TextureData>> entry : textureDataMap.entrySet()) {
if(entry.getValue().size()>0) { if(entry.getValue().size()>0) {
CombinedTexture combinedTexture = loadedTextures.get(entry.getKey()); CombinedTexture combinedTexture = new CombinedTexture();
if(combinedTexture == null) {
combinedTexture = new CombinedTexture();
loadedTextures.put(entry.getKey(), combinedTexture);
}
for(TextureData textureData : entry.getValue()) { for(TextureData textureData : entry.getValue()) {
int texflag = ((Number) textureData.mtex.getFieldValue("texflag")).intValue(); int texflag = ((Number) textureData.mtex.getFieldValue("texflag")).intValue();
boolean negateTexture = (texflag & 0x04) != 0; boolean negateTexture = (texflag & 0x04) != 0;
Texture texture = textureHelper.getTexture(textureData.textureStructure, textureData.mtex, blenderContext); Texture texture = textureHelper.getTexture(textureData.textureStructure, textureData.mtex, blenderContext);
if(texture != null) {
int blendType = ((Number) textureData.mtex.getFieldValue("blendtype")).intValue(); int blendType = ((Number) textureData.mtex.getFieldValue("blendtype")).intValue();
float[] color = new float[] { ((Number) textureData.mtex.getFieldValue("r")).floatValue(), float[] color = new float[] { ((Number) textureData.mtex.getFieldValue("r")).floatValue(),
((Number) textureData.mtex.getFieldValue("g")).floatValue(), ((Number) textureData.mtex.getFieldValue("g")).floatValue(),
@ -145,6 +142,10 @@ public final class MaterialContext {
combinedTexture.add(texture, textureBlender, textureData.uvCoordinatesType, textureData.projectionType, textureData.textureStructure, blenderContext); combinedTexture.add(texture, textureBlender, textureData.uvCoordinatesType, textureData.projectionType, textureData.textureStructure, blenderContext);
} }
} }
if(combinedTexture.getTexturesCount() > 0) {
loadedTextures.put(entry.getKey(), combinedTexture);
}
}
} }
//veryfying if the transparency is present //veryfying if the transparency is present

@ -211,6 +211,13 @@ public class CombinedTexture {
return resultUVS; 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 * This method merges two given textures. The result is stored in the
* 'target' texture. * 'target' texture.

Loading…
Cancel
Save