159b2e6871c65f58fdad78cd7229c292f6a177578Scott Bartapackage com.jme3.scene.plugins.blender.textures.blending;
259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta
359b2e6871c65f58fdad78cd7229c292f6a177578Scott Bartaimport java.util.logging.Level;
459b2e6871c65f58fdad78cd7229c292f6a177578Scott Bartaimport java.util.logging.Logger;
559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta
659b2e6871c65f58fdad78cd7229c292f6a177578Scott Bartaimport com.jme3.scene.plugins.blender.BlenderContext;
759b2e6871c65f58fdad78cd7229c292f6a177578Scott Bartaimport com.jme3.texture.Texture;
859b2e6871c65f58fdad78cd7229c292f6a177578Scott Bartaimport com.jme3.texture.Image.Format;
959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta
1059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta/**
1159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * This class creates the texture blending class depending on the texture type.
1259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta *
1359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta * @author Marcin Roguski (Kaelthas)
1459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta */
1559b2e6871c65f58fdad78cd7229c292f6a177578Scott Bartapublic class TextureBlenderFactory {
1659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta	private static final Logger	LOGGER	= Logger.getLogger(TextureBlenderFactory.class.getName());
1759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta
1859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta	/**
1959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta	 * This method creates the blending class.
2059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta	 *
2159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta	 * @param format
2259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta	 *            the texture format
2359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta	 * @returntexture blending class
2459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta	 */
2559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta	public static TextureBlender createTextureBlender(Format format) {
2659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta		switch (format) {
2759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta			case Luminance8:
2859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta			case Luminance8Alpha8:
2959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta			case Luminance16:
3059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta			case Luminance16Alpha16:
3159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta			case Luminance16F:
3259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta			case Luminance16FAlpha16F:
3359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta			case Luminance32F:
3459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta				return new TextureBlenderLuminance();
3559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta			case RGBA8:
3659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta			case ABGR8:
3759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta			case BGR8:
3859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta			case RGB8:
3959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta			case RGB10:
4059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta			case RGB111110F:
4159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta			case RGB16:
4259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta			case RGB16F:
4359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta			case RGB16F_to_RGB111110F:
4459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta			case RGB16F_to_RGB9E5:
4559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta			case RGB32F:
4659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta			case RGB565:
4759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta			case RGB5A1:
4859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta			case RGB9E5:
4959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta			case RGBA16:
5059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta			case RGBA16F:
5159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta			case RGBA32F:
5259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta				return new TextureBlenderAWT();
5359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta			case DXT1:
5459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta			case DXT1A:
5559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta			case DXT3:
5659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta			case DXT5:
5759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta				return new TextureBlenderDDS();
5859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta			case Alpha16:
5959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta			case Alpha8:
6059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta			case ARGB4444:
6159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta			case Depth:
6259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta			case Depth16:
6359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta			case Depth24:
6459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta			case Depth32:
6559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta			case Depth32F:
6659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta			case Intensity16:
6759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta			case Intensity8:
6859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta			case LATC:
6959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta			case LTC:
7059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta				LOGGER.log(Level.WARNING, "Image type not yet supported for blending: {0}. Returning a blender that does not change the texture.", format);
7159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta				return new TextureBlender() {
7259b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta					@Override
7359b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta					public Texture blend(float[] materialColor, Texture texture, float[] color, float affectFactor, int blendType, boolean neg, BlenderContext blenderContext) {
7459b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta						return texture;
7559b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta					}
7659b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta				};
7759b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta			default:
7859b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta				throw new IllegalStateException("Unknown image format type: " + format);
7959b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta		}
8059b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta	}
8159b2e6871c65f58fdad78cd7229c292f6a177578Scott Barta}
82