QGearsAFile.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*
  2. -----------------------------------------------------------------------------
  3. Copyright (c) 15.1.2013 Tobias Peters <tobias.peters@kreativeffekt.at>
  4. This file is part of Q-Gears
  5. Q-Gears is free software: you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation, version 2.0 (GPLv2) of the License.
  8. Q-Gears is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. -----------------------------------------------------------------------------
  13. */
  14. #ifndef __QGearsAFile_H__
  15. #define __QGearsAFile_H__
  16. #include <OgreSkeleton.h>
  17. #include <Ogre.h>
  18. #include "common/TypeDefine.h"
  19. #include "common/QGearsResource.h"
  20. namespace QGears
  21. {
  22. class AFile : public Resource
  23. {
  24. public:
  25. AFile( Ogre::ResourceManager *creator, const String &name
  26. ,Ogre::ResourceHandle handle, const String &group
  27. ,bool isManual = false, Ogre::ManualResourceLoader *loader = NULL );
  28. virtual ~AFile();
  29. static const Ogre::Real FRAME_DURATION;
  30. static const String RESOURCE_TYPE;
  31. void addTo( Ogre::SkeletonPtr skeleton, const String &name ) const;
  32. typedef std::vector<Ogre::Vector3> BoneRotationList;
  33. struct Frame
  34. {
  35. Ogre::Vector3 root_rotation;
  36. Ogre::Vector3 root_translation;
  37. BoneRotationList bone_rotations;
  38. };
  39. typedef std::vector<Frame> FrameList;
  40. FrameList& getFrames() { return m_frames; }
  41. void setBoneCount( const uint32 bone_count );
  42. protected:
  43. virtual void loadImpl() override final;
  44. virtual void unloadImpl() override final;
  45. size_t calculateSize() const;
  46. void setFrameRotation( Ogre::TransformKeyFrame *key_frame
  47. ,const Ogre::Vector3 &rotation ) const;
  48. private:
  49. uint32 m_bone_count;
  50. FrameList m_frames;
  51. };
  52. typedef Ogre::SharedPtr<AFile> AFilePtr;
  53. }
  54. #endif // __QGearsAFile_H__