BcxFile.cpp 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. #include <Ogre.h>
  2. #include <math.h>
  3. #include <vector>
  4. #include "../../common/Logger.h"
  5. #include "AnimationFile.h"
  6. #include "BcxFile.h"
  7. #include "MeshFile.h"
  8. #include "SkeletonFile.h"
  9. BcxFile::BcxFile(const Ogre::String& file):
  10. LzsFile(file)
  11. {
  12. }
  13. BcxFile::BcxFile(File *file, const u32 offset, const u32 length):
  14. LzsFile(file, offset, length)
  15. {
  16. }
  17. BcxFile::BcxFile(u8* buffer, const u32 offset, const u32 length):
  18. LzsFile(buffer, offset, length)
  19. {
  20. }
  21. BcxFile::BcxFile(File *file):
  22. LzsFile(file)
  23. {
  24. }
  25. BcxFile::~BcxFile()
  26. {
  27. }
  28. void
  29. BcxFile::GetModel( std::vector< s16 >& skeleton_length, const Unit& unit, Ogre::MeshPtr mesh, Ogre::SkeletonPtr skeleton, VectorTexForGenBsx& textures )
  30. {
  31. u32 offset_to_model_info = GetU32LE(0x04);
  32. u8 number_of_bones = GetU8(offset_to_model_info + 0x02);
  33. u8 number_of_parts = GetU8(offset_to_model_info + 0x03);
  34. u8 number_of_animations = GetU8(offset_to_model_info + 0x04);
  35. //////////////////////////
  36. // mesh
  37. //////////////////////////
  38. u16 offset_to_parts = GetU16LE(offset_to_model_info + 0x1c) + number_of_bones * 4;
  39. MeshFile file_m(this);
  40. file_m.GetData(unit.name, offset_to_parts, number_of_parts, mesh, textures);
  41. //////////////////////////
  42. //////////////////////////
  43. // skeleton
  44. //////////////////////////
  45. u16 offset_to_bones = GetU16LE(offset_to_model_info + 0x1C);
  46. SkeletonFile file_s(this);
  47. file_s.GetData( skeleton_length, offset_to_bones, number_of_bones, skeleton );
  48. //////////////////////////
  49. ///////////////////////////////////////////////////
  50. // animations
  51. ///////////////////////////////////////////////////
  52. u32 offset_to_animations = GetU32LE(offset_to_model_info + 0x1C) - 0x80000000 + number_of_bones * 4 + number_of_parts * 0x20;
  53. AnimationFile afile(this);
  54. afile.GetData( skeleton_length, unit, offset_to_animations, number_of_animations, 0, skeleton );
  55. }
  56. void
  57. BcxFile::GetSkeleton( std::vector< s16 >& skeleton_length )
  58. {
  59. u32 offset_to_model_info = GetU32LE(0x04);
  60. u8 number_of_bones = GetU8(offset_to_model_info + 0x02);
  61. u16 offset_to_bones = GetU16LE(offset_to_model_info + 0x1C);
  62. SkeletonFile file_s(this);
  63. Ogre::SkeletonPtr skeleton;
  64. skeleton.setNull();
  65. file_s.GetData( skeleton_length, offset_to_bones, number_of_bones, skeleton);
  66. }