package min3d.parser;

import android.content.Context;
import android.content.res.Resources;

import java.io.InputStream;

/**
 * Parser factory class. Specify the parser type and the corresponding
 * specialized class will be returned.
 * @author dennis.ippel
 *
 */
public class Parser {
	/**
	 * Parser types enum
	 * @author dennis.ippel
	 *
	 */
	public static enum Type { OBJ, MAX_3DS, MD2 };
	
	/**
	 * Create a parser of the specified type.
	 * @param type
	 * @param resources
	 * @param resourceID
	 * @return
	 */
	public static IParser createParser(Context c, Type type, Resources resources, String resourceID, boolean generateMipMap)
	{
		switch(type)
		{
			case OBJ:
				return new ObjParser(c,resources, resourceID, generateMipMap);
			case MAX_3DS:
				return new Max3DSParser(c,resources, resourceID, generateMipMap);
			case MD2:
				return new MD2Parser(c,resources, resourceID, generateMipMap);
		}
		
		return null;
	}

	public static IParser createParser(Context c, Type type, String is, boolean generateMipMap)
	{
		switch(type)
		{
			case OBJ:
				return new ObjParser(c,is, generateMipMap);
			case MAX_3DS:
				return new Max3DSParser(c,is, generateMipMap);
			case MD2:
				return new MD2Parser(c,is, generateMipMap);
		}

		return null;
	}
}
