/**
 * package for md2 models of characters
 */
package simogl.model.character;

import java.io.File;
import java.io.IOException;

import simogl.model.AbstractMD2Model;
import simogl.model.animation.Animation;
import simogl.model.modelloader.MD2Importer;

import com.sun.opengl.util.texture.TextureIO;

/**
 * This class represents the md2 model of a civilian
 * @author Frank Bruns
 *
 */
public class MD2Civilian extends AbstractMD2Model
{
	/**
	 * Creates a new md2 model for a civilian at the specified
	 * loaction
	 * @param x x-coordinate
	 * @param y y-coordinate
	 * @param z z-coordinate
	 */
	public MD2Civilian(float x, float y, float z)
	{
		super(x,y,z);
		
		this.texPath = "./resources/models/citizen/loggy/tris0.bmp";
		this.modFile = new File("./resources/models/citizen/loggy/tris.md2");
		this.scaleFactor = 0.05f;
		
		try
		{
			this.texture = TextureIO.newTexture(new File(texPath),true);
		}
		catch(IOException exc)
		{
			System.out.println("Civilian texture file not found.");
		}
		
		this.createAnimStand();
		this.createAnimWalk();
		
		this.setPosition(x, y, z);
	}

	@Override
	protected void createAnimStand()
	{
		this.animStand = new Animation();
		this.animStand.addAnimFrame(MD2Importer.importModel(this.modFile, 0, 0, this.texture,this.scaleFactor),70);
		this.animStand.addAnimFrame(MD2Importer.importModel(this.modFile, 1, 0, this.texture,this.scaleFactor),70);
		this.animStand.addAnimFrame(MD2Importer.importModel(this.modFile, 2, 0, this.texture,this.scaleFactor),70);
		this.animStand.addAnimFrame(MD2Importer.importModel(this.modFile, 3, 0, this.texture,this.scaleFactor),70);
		this.animStand.addAnimFrame(MD2Importer.importModel(this.modFile, 4, 0, this.texture,this.scaleFactor),70);
		this.animStand.addAnimFrame(MD2Importer.importModel(this.modFile, 5, 0, this.texture,this.scaleFactor),70);
	}

	@Override
	protected void createAnimWalk()
	{
		this.animWalk = new Animation();
		this.animWalk.addAnimFrame(MD2Importer.importModel(this.modFile, 15, 0, this.texture,this.scaleFactor),70);
		this.animWalk.addAnimFrame(MD2Importer.importModel(this.modFile, 16, 0, this.texture,this.scaleFactor),70);
		this.animWalk.addAnimFrame(MD2Importer.importModel(this.modFile, 17, 0, this.texture,this.scaleFactor),70);
		this.animWalk.addAnimFrame(MD2Importer.importModel(this.modFile, 18, 0, this.texture,this.scaleFactor),70);
		this.animWalk.addAnimFrame(MD2Importer.importModel(this.modFile, 19, 0, this.texture,this.scaleFactor),70);
		this.animWalk.addAnimFrame(MD2Importer.importModel(this.modFile, 20, 0, this.texture,this.scaleFactor),70);
		this.animWalk.addAnimFrame(MD2Importer.importModel(this.modFile, 21, 0, this.texture,this.scaleFactor),70);
		this.animWalk.addAnimFrame(MD2Importer.importModel(this.modFile, 22, 0, this.texture,this.scaleFactor),70);
		this.animWalk.addAnimFrame(MD2Importer.importModel(this.modFile, 23, 0, this.texture,this.scaleFactor),70);
		this.animWalk.addAnimFrame(MD2Importer.importModel(this.modFile, 24, 0, this.texture,this.scaleFactor),70);
	}
	
	@Override
	public void update(long elapsedTime)
	{
		super.update(elapsedTime);
	}
}
