FF7WalkmeshFileSerializer.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*
  2. -----------------------------------------------------------------------------
  3. Copyright (c) 2013-09-05 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 __FF7WalkmeshFileSerializer_H__
  15. #define __FF7WalkmeshFileSerializer_H__
  16. #include "common/TypeDefine.h"
  17. #include "data/QGearsSerializer.h"
  18. #include "map/QGearsWalkmeshFile.h"
  19. namespace QGears
  20. {
  21. namespace FF7
  22. {
  23. class WalkmeshFileSerializer : public Serializer
  24. {
  25. public:
  26. WalkmeshFileSerializer();
  27. virtual ~WalkmeshFileSerializer();
  28. virtual void importWalkmeshFile( Ogre::DataStreamPtr &stream, WalkmeshFile *pDest );
  29. typedef WalkmeshFile::Triangle WalkmeshTriangle;
  30. typedef WalkmeshFile::TriangleList WalkmeshTriangleList;
  31. enum {
  32. VERTEX_PADDING_COUNT = 1
  33. ,VERTEX_COMPONENT_COUNT = 3 + VERTEX_PADDING_COUNT
  34. ,ACCESS_COMPONENT_COUNT = 3
  35. };
  36. struct Triangle
  37. {
  38. Ogre::Vector3 a, b, c;
  39. };
  40. struct Access
  41. {
  42. sint16 a, b, c;
  43. };
  44. typedef std::vector<Triangle> TriangleList;
  45. typedef std::vector<Access> AccessList;
  46. protected:
  47. virtual void readObject( Ogre::DataStreamPtr &stream, Triangle &pDest );
  48. virtual void readObject( Ogre::DataStreamPtr &stream, Ogre::Vector3 &pDest );
  49. virtual void readObject( Ogre::DataStreamPtr &stream, Access &pDest );
  50. using Serializer::readObject;
  51. template<typename ValueType>
  52. void readVector( Ogre::DataStreamPtr &stream
  53. ,std::vector<ValueType> &pDest
  54. ,size_t count );
  55. private:
  56. };
  57. }
  58. }
  59. #endif // __FF7WalkmeshFileSerializer_H__