SkeletonFile.cpp 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #include "SkeletonFile.h"
  2. #include "common/Logger.h"
  3. SkeletonFile::SkeletonFile(const Ogre::String& file):
  4. File( file )
  5. {
  6. }
  7. SkeletonFile::SkeletonFile(File* pFile):
  8. File(pFile)
  9. {
  10. }
  11. SkeletonFile::SkeletonFile(File* pFile, const u32 offset, const u32 length):
  12. File(pFile, offset, length)
  13. {
  14. }
  15. SkeletonFile::SkeletonFile(u8* pBuffer, const u32 offset, const u32 length):
  16. File(pBuffer, offset, length)
  17. {
  18. }
  19. SkeletonFile::~SkeletonFile()
  20. {
  21. }
  22. void
  23. SkeletonFile::GetData( std::vector< s16 >& skeleton_length, const int offset_to_bones, const int number_of_bones, Ogre::SkeletonPtr skeleton )
  24. {
  25. if (skeleton.isNull() == false)
  26. {
  27. Ogre::Bone* root = skeleton->createBone( "0", 0 );
  28. }
  29. for( int i = 0; i < number_of_bones; ++i )
  30. {
  31. s16 length = GetU16LE(offset_to_bones + i * 0x04 + 0x00);
  32. s8 parent_id = GetU8(offset_to_bones + i * 0x04 + 0x02);
  33. skeleton_length.push_back( length );
  34. if (skeleton.isNull() == false)
  35. {
  36. //LOGGER->Log(LOGGER_INFO, "Skeleton bone-%d length-%d parent-%d part-%d", i, length, parent_id, GetU8(offset_to_bones + i * 0x04 + 0x03));
  37. Ogre::Bone* bone1 = skeleton->createBone(Ogre::StringConverter::toString(i * 2 + 1), i * 2 + 1);
  38. Ogre::Bone* bone2 = skeleton->createBone(Ogre::StringConverter::toString(i * 2 + 2), i * 2 + 2);
  39. if (parent_id == -1)
  40. {
  41. skeleton->getBone(0)->addChild(bone1);
  42. }
  43. else
  44. {
  45. skeleton->getBone(parent_id * 2 + 2)->addChild(bone1);
  46. }
  47. bone1->addChild(bone2);
  48. }
  49. }
  50. }