#ifndef __C_ANIMATED_MESH_MD3_H_INCLUDED__
#define __C_ANIMATED_MESH_MD3_H_INCLUDED__
#include "IAnimatedMeshMD3.h"
#include "IReadFile.h"
#include "IFileSystem.h"
#include "irrArray.h"
#include "irrString.h"
#include "SMesh.h"
#include "SMeshBuffer.h"
#include "IQ3Shader.h"
namespace irr
{
namespace scene
{
class CAnimatedMeshMD3 : public IAnimatedMeshMD3
{
public:
CAnimatedMeshMD3( );
virtual ~CAnimatedMeshMD3();
virtual bool loadModelFile( u32 modelIndex, io::IReadFile* file,
io::IFileSystem* fs, video::IVideoDriver * driver
);
virtual void setInterpolationShift ( u32 shift, u32 loopMode );
virtual SMD3Mesh * getOriginalMesh ();
virtual SMD3QuaternionTagList *getTagList(s32 frame, s32 detailLevel, s32 startFrameLoop, s32 endFrameLoop);
virtual u32 getFrameCount() const;
virtual IMesh* getMesh(s32 frame, s32 detailLevel, s32 startFrameLoop, s32 endFrameLoop);
virtual const core::aabbox3d<f32>& getBoundingBox() const;
virtual E_ANIMATED_MESH_TYPE getMeshType() const;
virtual u32 getMeshBufferCount() const
{
return 0;
}
virtual IMeshBuffer* getMeshBuffer(u32 nr) const
{
return 0;
}
virtual IMeshBuffer* getMeshBuffer( const video::SMaterial &material) const
{
return 0;
}
virtual void setMaterialFlag(video::E_MATERIAL_FLAG flag, bool newvalue)
{
return;
}
virtual void setHardwareMappingHint(E_HARDWARE_MAPPING newMappingHint, E_BUFFER_TYPE buffer=EBT_VERTEX_AND_INDEX);
virtual void setDirty(E_BUFFER_TYPE buffer=EBT_VERTEX_AND_INDEX);
virtual void setBoundingBox(const core::aabbox3df& box)
{
return;
}
private:
inline void Animate (u32 frame);
video::SMaterial Material;
SMD3Mesh *Mesh;
u32 IPolShift;
u32 LoopMode;
f32 Scaling;
struct SCacheInfo
{
SCacheInfo ( s32 frame = -1, s32 start = -1, s32 end = -1 )
: Frame ( frame ), startFrameLoop ( start ),
endFrameLoop ( end ) {}
bool operator == ( const SCacheInfo &other ) const
{
return 0 == memcmp ( this, &other, sizeof ( SCacheInfo ) );
}
s32 Frame;
s32 startFrameLoop;
s32 endFrameLoop;
};
SCacheInfo Current;
SMesh MeshIPol;
SMD3QuaternionTagList TagListIPol;
IMeshBuffer * createMeshBuffer ( const SMD3MeshBuffer *source, io::IFileSystem* fs, video::IVideoDriver * driver );
void buildVertexArray ( u32 frameA, u32 frameB, f32 interpolate,
const SMD3MeshBuffer * source,
SMeshBufferLightMap * dest
);
void buildTagArray ( u32 frameA, u32 frameB, f32 interpolate );
};
}
}
#endif