FF7ModelListFileSerializer.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /*
  2. * Copyright (C) 2022 The V-Gears Team
  3. *
  4. * This file is part of V-Gears
  5. *
  6. * V-Gears is free software: you can redistribute it and/or modify it under
  7. * terms of the GNU General Public License as published by the Free Software
  8. * Foundation, version 3.0 (GPLv3) of the License.
  9. *
  10. * V-Gears is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. */
  15. #pragma once
  16. #include "common/TypeDefine.h"
  17. #include "formats/VGearsSerializer.h"
  18. #include "FF7ModelListFile.h"
  19. namespace VGears{
  20. /**
  21. * Handles the serialization of model list files.
  22. */
  23. class ModelListFileSerializer : public Serializer{
  24. public:
  25. /**
  26. * Constructor.
  27. */
  28. ModelListFileSerializer();
  29. /**
  30. * Destructor.
  31. */
  32. virtual ~ModelListFileSerializer();
  33. /**
  34. * Imports a model list file.
  35. *
  36. * @param[in] stream The contents of the model list file.
  37. * @param[out] dest The formed model list file.
  38. */
  39. virtual void ImportModelListFile(Ogre::DataStreamPtr &stream, ModelListFile *dest);
  40. typedef ModelListFile::AnimationDescription AnimationDescription;
  41. typedef ModelListFile::ModelDescription ModelDescription;
  42. /**
  43. * Data sizes in the file.
  44. */
  45. enum {
  46. /**
  47. * Length of the name of the HRC file assigned to a model.
  48. */
  49. HRC_NAME_LENGTH = 8,
  50. /**
  51. * Scale data length.
  52. */
  53. SCALE_LENGTH = 4
  54. };
  55. protected:
  56. /**
  57. * Reads an object as an animation description.
  58. *
  59. * @param[in] stream Input data.
  60. * @param[out] dest The formed animation description data.
  61. */
  62. virtual void readObject(Ogre::DataStreamPtr &stream, AnimationDescription &dest);
  63. /**
  64. * Reads an object as a model description.
  65. *
  66. * @param[in] stream Input data.
  67. * @param[out] dest The formed model description data.
  68. */
  69. virtual void readObject(Ogre::DataStreamPtr &stream, ModelDescription &dest);
  70. using Serializer::readObject;
  71. /**
  72. * Reads an object as a vector.
  73. *
  74. * @param[in] stream Input data.
  75. * @param[out] dest The formed vector data.
  76. * @param[in] count The size of the data to read.
  77. */
  78. template<typename ValueType> void ReadVector(
  79. Ogre::DataStreamPtr &stream, std::vector<ValueType> &dest, size_t count
  80. );
  81. };
  82. }