#ifndef THMD2Object
#define THMD2Object
#include <ThCore.h>
#include "ThGeometry.h"
#include "ThRTTI.h"
namespace Th {
class MD2Object : public Geometry
{
DECLARE_RTTI
DECLARE_IS_DERIVED_FROM
public:
static struct MD2Header
{
int iMagic;
int iVersion;
int iSkinWidth;
int iSkinHeight;
int iFrameSize;
int iNumSkins;
int iNumVertices;
int iNumTexCoords;
int iNumTriangles;
int iNumGlCommands;
int iNumFrames;
int iOffsetSkins;
int iOffsetTexCoords;
int iOffsetTriangles;
int iOffsetFrames;
int iOffsetGlCommands;
int iOffsetEnd;
};
static struct MD2Triangle
{
short iVertexIndex[3];
short iTextureIndex[3];
};
static struct MD2Vertex
{
unsigned char abVertex[3];
unsigned char abLightNormalIndex;
};
static struct MD2TextureCoord
{
short sU,sV;
};
static struct MD2CommandVertex
{
float fU;
float fV;
int iVertexIndex;
};
static struct MD2Frame
{
float afScale[3];
float afTranslate[3];
char acName[16];
MD2Vertex akVertices[1];
};
public:
virtual ~MD2Object();
MD2Object();
MD2Object(const String& akFilename);
bool LoadObject(const String& rkFilename);
virtual void Draw(Renderer& rkRenderer);
const MD2Header& Header() const;
const MD2Triangle* Triangles() const;
const MD2CommandVertex* Commands() const;
const MD2TextureCoord* TextureCoords() const;
char *m_akFrames;
MD2Header m_kHeader;
//indices
MD2Triangle* m_akTriangle;
MD2TextureCoord* m_akTextureCoords;
MD2CommandVertex** m_akTriangleFans;
MD2CommandVertex** m_akTriangleStrips;
unsigned int m_uiNumFans;
unsigned int m_uiNumStrips;
};
}
#endif //THMD2Object