Ignoring textures when their UV coordinates type is not supported. This will prevent from unexpected exceptions to occur.
git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@9690 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
This commit is contained in:
parent
c6bc0bf79b
commit
0fd34d3535
@ -7,6 +7,7 @@ import java.awt.image.BufferedImage;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import jme3tools.converters.ImageToAwt;
|
||||
|
||||
@ -39,6 +40,8 @@ import com.jme3.texture.Texture2D;
|
||||
* @author Marcin Roguski (Kaelthas)
|
||||
*/
|
||||
public class CombinedTexture {
|
||||
private static final Logger LOGGER = Logger.getLogger(CombinedTexture.class.getName());
|
||||
|
||||
/** The mapping type of the texture. Defined bu MaterialContext.MTEX_COL, MTEX_NOR etc. */
|
||||
private final int mappingType;
|
||||
/** The data for each of the textures. */
|
||||
@ -81,17 +84,21 @@ public class CombinedTexture {
|
||||
if (!(texture instanceof GeneratedTexture) && !(texture instanceof Texture2D)) {
|
||||
throw new IllegalArgumentException("Unsupported texture type: " + (texture == null ? "null" : texture.getClass()));
|
||||
}
|
||||
TextureData textureData = new TextureData();
|
||||
textureData.texture = texture;
|
||||
textureData.textureBlender = textureBlender;
|
||||
textureData.uvCoordinatesType = UVCoordinatesType.valueOf(uvCoordinatesType);
|
||||
textureData.projectionType = UVProjectionType.valueOf(projectionType);
|
||||
textureData.textureStructure = textureStructure;
|
||||
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);
|
||||
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() + "'.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -236,6 +236,39 @@ public class UVCoordinatesGenerator {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method should be used to determine if the texture will ever be
|
||||
* computed. If the texture coordinates are not supported then the try of
|
||||
* flattening the texture might result in runtime exceptions occurence.
|
||||
*
|
||||
* @param texco
|
||||
* the texture coordinates type
|
||||
* @return <b>true</b> if the type is supported and false otherwise
|
||||
*/
|
||||
public static boolean isTextureCoordinateTypeSupported(UVCoordinatesType texco) {
|
||||
switch (texco) {
|
||||
case TEXCO_ORCO:
|
||||
case TEXCO_UV:
|
||||
case TEXCO_NORM:
|
||||
return true;
|
||||
case TEXCO_REFL:
|
||||
case TEXCO_GLOB:
|
||||
case TEXCO_TANGENT:
|
||||
case TEXCO_STRESS:
|
||||
case TEXCO_LAVECTOR:
|
||||
case TEXCO_OBJECT:
|
||||
case TEXCO_OSA:
|
||||
case TEXCO_PARTICLE_OR_STRAND:
|
||||
case TEXCO_SPEED:
|
||||
case TEXCO_STICKY:
|
||||
case TEXCO_VIEW:
|
||||
case TEXCO_WINDOW:
|
||||
return false;
|
||||
default:
|
||||
throw new IllegalStateException("Unknown texture coordinates value: " + texco);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This method returns the bounding box of the given geometries.
|
||||
|
Loading…
x
Reference in New Issue
Block a user