///////////////////////////////////////////////////////////////////////////////
/// @file deAnimatedMesh_priv.hpp
///
/// @brief private header for animated mesh loading code
///
/// @author Assassin
///
/// This file is the intellectual property of Novus Delta, LLC.. Usage of the
/// contents of this file is subject to the Destiny3D Member License which
/// can be found at http://www.destiny3d.com.  Any other usage is prohibited.
///
/// This file is distributed "AS IS" without warranty of any kind.  Novus
/// Delta, LLC. does not guarantee the fitness of the contents of this file
/// for any particular purpose.
///
/// Copyright (C) 2001-2003 Novus Delta, LLC. All Rights Reserved.
///
/// <hr>
///                                 Change History
/// <hr>
///
/// @date June 2002
/// @author Assassin
/// @remarks Creation
///
///////////////////////////////////////////////////////////////////////////////

//Destiny 3D Actor Class
//A simple MD2 loader to start.  Maybe we could build off this later.
#ifndef DEANIMATEDMESH_PRIV_H
#define DEANIMATEDMESH_PRIV_H

#include "deAnimatedMesh.hpp"
#include "deString.hpp"
#include "deResource_Helper.hpp"

typedef struct MD2Header						MD2Header;
typedef struct MD2FrameData						MD2FrameData;
typedef struct MD2Face							MD2Face;
typedef struct MD2Frame							MD2Frame;
typedef struct MD2TexCoord						MD2TexCoord;
typedef struct MD2Triangle						MD2Triangle;
typedef struct MD2TriangleVertex				MD2TriangleVertex;

typedef char									MD2Skin[64];

class deAnimatedMesh : public deResourceBase, public IdeAnimatedMesh
{
public:
	deAnimatedMesh();
	deAnimatedMesh(const char *filename);
	~deAnimatedMesh();
	void * GetRscInterface(long interface_id);

	static long					s_AnimatedMeshInterfaceID;

private:
	int							m_NumTriangles;
	int							m_NumFrames;
	int							m_NumVertices;
	int							m_NumTexCoords;
	int							m_NumSkins;

	MD2Face						*m_pTriangles;
	MD2Skin						*m_pSkins;
	MD2Frame					*m_pFrames;

	MD2TexCoord					*m_pTexCoords;

	IdeBitmapProxy				*m_pBitmap;
	IdeRenderTexture			*m_pTexture;
	IdeVertexBuffer				*m_pVBuffer;
	deVertex					**m_pVertices;
	deVertex					**m_pNormals;

	deTransform					m_Transform;

	int							m_CurrentFrame;
	int							m_NextFrame;

	struct MD2Anim
	{
		deString AnimName;
		int Start,Stop;
	};
	
	float						m_Interpolation;
	float						m_AnimSpeed;
	deTArray <MD2Anim>			m_Anims;
	int							m_CurrentAnim;
	void InitVars();

public:
	deBoolean					LoadFromFile(const char *filename);
	void						Destroy();

	IdeVertexBuffer*			GetVBuffer();
	IdeVertexBuffer*			GetVBuffer(float Time);
	IdeRenderTexture*			GetTexture(IdeDriver * pDriver);

	int							GetNumFrames();
	int							GetNumVerts();
	int							GetNumTriangles();
	int							GetNumSkins();
	int							GetFrameSize();
	int							GetNumTexCoords();

	int							GetCurrentFrame();
	int							GetNextFrame();
	float						GetInterpolation();

	char						*GetSkinName(int index);

	void						SetAnimSpeed(float FramesPerSec);
	deBoolean					SetCurrentAnim(const char* AnimName);
	deBoolean					SetCurrentAnim(int AnimNum);
	float						GetAnimSpeed();
	int							GetCurrentAnim();

	void						SetCurrentFrame(int frame);
	void						SetNextFrame(int frame);
	
	void						SetTexture(const char *filename);
	void						SetTexture(IdeBitmapProxy *tex);

	bool						LoadMD2(const char *filename);
	IdeResourceBase				*MakeCopy();
};



#endif // DEANIMATEDMESH_PRIV_H
