/* ----------------------------------------------------------------------------- Copyright (c) 2010 Jacob 'jacmoe' Moen You may use this sample code for anything you like, it is public domain. ----------------------------------------------------------------------------- */ /* ----------------------------------------------------------------------------- Filename: AnimationSerializer.h Description: A serializer for keyframe animations ----------------------------------------------------------------------------- */ #ifndef __AnimationSerializer_h__ #define __AnimationSerializer_h__ #include "OgreSerializer.h" enum AnimationChunkID { AC_HEADER = 0x1000, AC_ANIMATION = 0x2000, AC_ANIMATION_TRACK = 0x3000, AC_ANIMATION_TRACK_KEYFRAME = 0x4000, }; class AnimationSerializer : public Ogre::Serializer { public: AnimationSerializer(); virtual ~AnimationSerializer(); void exportAnimation(const Ogre::Animation* pAnimation, const Ogre::String& filename, Endian endianMode = ENDIAN_NATIVE); Ogre::Animation* importAnimation(const Ogre::String& filename); Ogre::Animation* importAnimation(Ogre::DataStreamPtr& stream); protected: void writeAnimation(const Ogre::Animation* anim); void writeAnimationTrack(const Ogre::NodeAnimationTrack* track); void writeKeyFrame(const Ogre::TransformKeyFrame* key); Ogre::Animation* readAnimation(Ogre::DataStreamPtr& stream); void readAnimationTrack(Ogre::DataStreamPtr& stream, Ogre::Animation* anim); void readKeyFrame(Ogre::DataStreamPtr& stream, Ogre::NodeAnimationTrack* track); size_t calcAnimationSize(const Ogre::Animation* pAnim); size_t calcAnimationTrackSize(const Ogre::NodeAnimationTrack* pTrack); size_t calcKeyFrameSize(const Ogre::TransformKeyFrame* pKey); }; #endif