#ifndef __C_SKINNED_MESH_H_INCLUDED__
#define __C_SKINNED_MESH_H_INCLUDED__
#include "ISkinnedMesh.h"
#include "SMeshBuffer.h"
#include "S3DVertex.h"
#include "irrString.h"
#include "matrix4.h"
#include "quaternion.h"
namespace irr
{
namespace scene
{
class IAnimatedMeshSceneNode;
class IBoneSceneNode;
class CSkinnedMesh: public ISkinnedMesh
{
public:
CSkinnedMesh();
virtual ~CSkinnedMesh();
virtual u32 getFrameCount() const;
virtual f32 getAnimationSpeed() const;
virtual void setAnimationSpeed(f32 fps);
virtual IMesh* getMesh(s32 frame, s32 detailLevel=255, s32 startFrameLoop=-1, s32 endFrameLoop=-1);
virtual void animateMesh(f32 frame, f32 blend);
virtual void skinMesh();
virtual u32 getMeshBufferCount() const;
virtual IMeshBuffer* getMeshBuffer(u32 nr) const;
virtual IMeshBuffer* getMeshBuffer( const video::SMaterial &material) const;
virtual const core::aabbox3d<f32>& getBoundingBox() const;
virtual void setBoundingBox( const core::aabbox3df& box);
virtual void setMaterialFlag(video::E_MATERIAL_FLAG flag, bool newvalue);
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 E_ANIMATED_MESH_TYPE getMeshType() const;
virtual u32 getJointCount() const;
virtual const c8* getJointName(u32 number) const;
virtual s32 getJointNumber(const c8* name) const;
virtual bool useAnimationFrom(const ISkinnedMesh *mesh);
virtual void updateNormalsWhenAnimating(bool on);
virtual void setInterpolationMode(E_INTERPOLATION_MODE mode);
virtual void convertMeshToTangents();
virtual bool isStatic();
virtual bool setHardwareSkinning(bool on);
virtual core::array<SSkinMeshBuffer*> &getMeshBuffers();
virtual core::array<SJoint*> &getAllJoints();
virtual const core::array<SJoint*> &getAllJoints() const;
virtual void finalize();
virtual SSkinMeshBuffer *addMeshBuffer();
virtual SJoint *addJoint(SJoint *parent=0);
virtual SPositionKey *addPositionKey(SJoint *joint);
virtual SRotationKey *addRotationKey(SJoint *joint);
virtual SScaleKey *addScaleKey(SJoint *joint);
virtual SWeight *addWeight(SJoint *joint);
virtual void updateBoundingBox(void);
void recoverJointsFromMesh(core::array<IBoneSceneNode*> &jointChildSceneNodes);
void transferJointsToMesh(const core::array<IBoneSceneNode*> &jointChildSceneNodes);
void transferOnlyJointsHintsToMesh(const core::array<IBoneSceneNode*> &jointChildSceneNodes);
void addJoints(core::array<IBoneSceneNode*> &jointChildSceneNodes,
IAnimatedMeshSceneNode* node,
ISceneManager* smgr);
private:
void checkForAnimation();
void normalizeWeights();
void buildAllLocalAnimatedMatrices();
void buildAllGlobalAnimatedMatrices(SJoint *Joint=0, SJoint *ParentJoint=0);
void getFrameData(f32 frame, SJoint *Node,
core::vector3df &position, s32 &positionHint,
core::vector3df &scale, s32 &scaleHint,
core::quaternion &rotation, s32 &rotationHint);
void calculateGlobalMatrices(SJoint *Joint,SJoint *ParentJoint);
void skinJoint(SJoint *Joint, SJoint *ParentJoint);
void calculateTangents(core::vector3df& normal,
core::vector3df& tangent, core::vector3df& binormal,
core::vector3df& vt1, core::vector3df& vt2, core::vector3df& vt3,
core::vector2df& tc1, core::vector2df& tc2, core::vector2df& tc3);
core::array<SSkinMeshBuffer*> *SkinningBuffers;
core::array<SSkinMeshBuffer*> LocalBuffers;
core::array<SJoint*> AllJoints;
core::array<SJoint*> RootJoints;
core::array< core::array<bool> > Vertices_Moved;
core::aabbox3d<f32> BoundingBox;
f32 AnimationFrames;
f32 FramesPerSecond;
f32 LastAnimatedFrame;
E_INTERPOLATION_MODE InterpolationMode:8;
bool HasAnimation;
bool PreparedForSkinning;
bool AnimateNormals;
bool HardwareSkinning;
};
}
}
#endif