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. 2
      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,11 +406,13 @@ 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());
if(materialContext.getTexturesCount()>0) {
UVCoordinatesGenerator.generateUVCoordinates(materialContext.getUvCoordinatesType(), UVCoordinatesGenerator.generateUVCoordinates(materialContext.getUvCoordinatesType(),
materialContext.getProjectionType(), materialContext.getProjectionType(),
materialContext.getTextureDimension(), entry.getValue()); materialContext.getTextureDimension(), entry.getValue());
} }
} }
}
dataRepository.addLoadedFeatures(structure.getOldMemoryAddress(), structure.getName(), structure, geometries); dataRepository.addLoadedFeatures(structure.getOldMemoryAddress(), structure.getName(), structure, geometries);
return geometries; return geometries;

Loading…
Cancel
Save