1package com.jme3.scene.plugins.blender.textures.blending;
2
3import java.util.logging.Level;
4import java.util.logging.Logger;
5
6import com.jme3.scene.plugins.blender.BlenderContext;
7import com.jme3.texture.Texture;
8import com.jme3.texture.Image.Format;
9
10/**
11 * This class creates the texture blending class depending on the texture type.
12 *
13 * @author Marcin Roguski (Kaelthas)
14 */
15public class TextureBlenderFactory {
16	private static final Logger	LOGGER	= Logger.getLogger(TextureBlenderFactory.class.getName());
17
18	/**
19	 * This method creates the blending class.
20	 *
21	 * @param format
22	 *            the texture format
23	 * @returntexture blending class
24	 */
25	public static TextureBlender createTextureBlender(Format format) {
26		switch (format) {
27			case Luminance8:
28			case Luminance8Alpha8:
29			case Luminance16:
30			case Luminance16Alpha16:
31			case Luminance16F:
32			case Luminance16FAlpha16F:
33			case Luminance32F:
34				return new TextureBlenderLuminance();
35			case RGBA8:
36			case ABGR8:
37			case BGR8:
38			case RGB8:
39			case RGB10:
40			case RGB111110F:
41			case RGB16:
42			case RGB16F:
43			case RGB16F_to_RGB111110F:
44			case RGB16F_to_RGB9E5:
45			case RGB32F:
46			case RGB565:
47			case RGB5A1:
48			case RGB9E5:
49			case RGBA16:
50			case RGBA16F:
51			case RGBA32F:
52				return new TextureBlenderAWT();
53			case DXT1:
54			case DXT1A:
55			case DXT3:
56			case DXT5:
57				return new TextureBlenderDDS();
58			case Alpha16:
59			case Alpha8:
60			case ARGB4444:
61			case Depth:
62			case Depth16:
63			case Depth24:
64			case Depth32:
65			case Depth32F:
66			case Intensity16:
67			case Intensity8:
68			case LATC:
69			case LTC:
70				LOGGER.log(Level.WARNING, "Image type not yet supported for blending: {0}. Returning a blender that does not change the texture.", format);
71				return new TextureBlender() {
72					@Override
73					public Texture blend(float[] materialColor, Texture texture, float[] color, float affectFactor, int blendType, boolean neg, BlenderContext blenderContext) {
74						return texture;
75					}
76				};
77			default:
78				throw new IllegalStateException("Unknown image format type: " + format);
79		}
80	}
81}
82