Added and entry to the blender key that allows to disable loading of generated textures. The value is set to false by default because generated textures need extra care when being loaded.

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@9694 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
Kae..pl 13 years ago
parent 6c2f7288b7
commit 1bad383be2
  1. 17
      engine/src/blender/com/jme3/asset/BlenderKey.java
  2. 30
      engine/src/blender/com/jme3/scene/plugins/blender/textures/CombinedTexture.java

@ -100,6 +100,8 @@ public class BlenderKey extends ModelKey {
protected boolean loadObjectProperties = true;
/** Maximum texture size. Might be dependant on the graphic card.*/
protected int maxTextureSize = -1;
/** Allows to toggle generated textures loading. Disabled by default because it very often takes too much memory and needs to be used wisely. */
protected boolean loadGeneratedTextures;
/**
* Constructor used by serialization mechanisms.
@ -205,6 +207,21 @@ public class BlenderKey extends ModelKey {
this.maxTextureSize = maxTextureSize;
}
/**
* This method sets the flag that toggles the generated textures loading.
* @param loadGeneratedTextures <b>true</b> if generated textures should be loaded and <b>false</b> otherwise
*/
public void setLoadGeneratedTextures(boolean loadGeneratedTextures) {
this.loadGeneratedTextures = loadGeneratedTextures;
}
/**
* @return tells if the generated textures should be loaded (<b>false</b> is the default value)
*/
public boolean isLoadGeneratedTextures() {
return loadGeneratedTextures;
}
/**
* This method sets the asset root path.
* @param assetRootPath

@ -84,21 +84,23 @@ public class CombinedTexture {
if (!(texture instanceof GeneratedTexture) && !(texture instanceof Texture2D)) {
throw new IllegalArgumentException("Unsupported texture type: " + (texture == null ? "null" : texture.getClass()));
}
if(UVCoordinatesGenerator.isTextureCoordinateTypeSupported(UVCoordinatesType.valueOf(uvCoordinatesType))) {
TextureData textureData = new TextureData();
textureData.texture = texture;
textureData.textureBlender = textureBlender;
textureData.uvCoordinatesType = UVCoordinatesType.valueOf(uvCoordinatesType);
textureData.projectionType = UVProjectionType.valueOf(projectionType);
textureData.textureStructure = textureStructure;
if (this.isWithoutAlpha(textureData, blenderContext)) {
textureDatas.clear();// clear previous textures, they will be covered anyway
if(!(texture instanceof GeneratedTexture) || blenderContext.getBlenderKey().isLoadGeneratedTextures()) {
if(UVCoordinatesGenerator.isTextureCoordinateTypeSupported(UVCoordinatesType.valueOf(uvCoordinatesType))) {
TextureData textureData = new TextureData();
textureData.texture = texture;
textureData.textureBlender = textureBlender;
textureData.uvCoordinatesType = UVCoordinatesType.valueOf(uvCoordinatesType);
textureData.projectionType = UVProjectionType.valueOf(projectionType);
textureData.textureStructure = textureStructure;
if (this.isWithoutAlpha(textureData, blenderContext)) {
textureDatas.clear();// clear previous textures, they will be covered anyway
}
textureDatas.add(textureData);
} else {
LOGGER.warning("The texture coordinates type is not supported: " + UVCoordinatesType.valueOf(uvCoordinatesType) + ". The texture '" + textureStructure.getName() + "'.");
}
textureDatas.add(textureData);
} else {
LOGGER.warning("The texture coordinates type is not supported: " + UVCoordinatesType.valueOf(uvCoordinatesType) + ". The texture '" + textureStructure.getName() + "'.");
}
}
}
/**

Loading…
Cancel
Save