/** SGX

The   sss    gggg x   x   
     s      g      x x    Engine
      sss   g  gg   x
         s  g   g  x x          Copyright 1995-2009.
     ssss    gggg x   x         Steven Goodwin. All Rights Reserved.
    
This version has been released under the GNU Public License v2.0.

Please see the license files for details.

File: sgx/include/sgx/graphics/mesh_md2.hpp

*/

#ifndef SGX_GFX_ANIM_MESH_MD2_HPP
#define SGX_GFX_ANIM_MESH_MD2_HPP	1


class sgxMD2Face {
public:
	tUINT32						m_iVertIndex[3];
	tUINT32						m_iCoordIndex[3];
};

class sgxMD2Object  {
public:
	sgxVector<sgxMD2Face>		m_FaceData;
	sgxVector<sgxVector3>		m_VertexData;
	sgxVector<sgxUV>			m_UVData;			// only u2/v2 are used here
};


class  sgxMD2Animation : public sgxAnimationKeyframes
{
public:
	tUINT32	m_iStartFrame;
	tUINT32	m_iEndFrame;
};


class CSGXAnimatedMeshMD2 : public CAnimatedMesh {
public:
	CSGXAnimatedMeshMD2(const sgxString &filename);
	virtual ~CSGXAnimatedMeshMD2();

	virtual void update(const tREAL32 telaps);
	virtual void draw(const sgxMatrix43 &transform) const;

	virtual void startAnimation(const tUINT32 animIndex);
	virtual void ParseAnimations(const tUINT32 numFrames);

	void ParseAnimations();
protected:

	CSGXTexture *				m_pTexture;

	sgxVector<sgxMD2Animation>	m_AnimationList;
	sgxVector<sgxMD2Object>		m_ObjectList;

	tUINT32		m_NextFrame;
	tUINT32		m_iCurrentFrame;
	tREAL32		m_fTime;
	tREAL32		m_fLastTime;
};


#endif /* SGX_GFX_ANIM_MESH_MD2_HPP */
