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
This commit is contained in:
Kae..pl 2011-08-25 20:25:38 +00:00
parent 3667531f90
commit 87ba2fcb11
2 changed files with 15 additions and 3 deletions

View File

@ -109,6 +109,16 @@ public final class MaterialContext {
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.
* @param texType texture type (from blender)

View File

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