Fix to a bug that caused loader to crach when loading an object without textures.

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@8098 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
Kae..pl 13 years ago
parent 3667531f90
commit 87ba2fcb11
  1. 10
      engine/src/blender/com/jme3/scene/plugins/blender/materials/MaterialContext.java
  2. 8
      engine/src/blender/com/jme3/scene/plugins/blender/meshes/MeshHelper.java

@ -109,6 +109,16 @@ public final class MaterialContext {
return this.textureType == Type.TwoDimensional ? 2 : 3; return this.textureType == Type.TwoDimensional ? 2 : 3;
} }
/**
* This method returns the amount of textures applied for the current
* material.
*
* @return the amount of textures applied for the current material
*/
public int getTexturesCount() {
return textures == null ? 0 : textures.size();
}
/** /**
* This method determines the type of the texture. * This method determines the type of the texture.
* @param texType texture type (from blender) * @param texType texture type (from blender)

@ -406,9 +406,11 @@ public class MeshHelper extends AbstractBlenderHelper {
} }
for(Entry<Material, List<Geometry>> entry : materialMap.entrySet()) { for(Entry<Material, List<Geometry>> entry : materialMap.entrySet()) {
MaterialContext materialContext = dataRepository.getMaterialContext(entry.getKey()); MaterialContext materialContext = dataRepository.getMaterialContext(entry.getKey());
UVCoordinatesGenerator.generateUVCoordinates(materialContext.getUvCoordinatesType(), if(materialContext.getTexturesCount()>0) {
materialContext.getProjectionType(), UVCoordinatesGenerator.generateUVCoordinates(materialContext.getUvCoordinatesType(),
materialContext.getTextureDimension(), entry.getValue()); materialContext.getProjectionType(),
materialContext.getTextureDimension(), entry.getValue());
}
} }
} }

Loading…
Cancel
Save