QGearsPFileSerializer.h 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*
  2. -----------------------------------------------------------------------------
  3. The MIT License (MIT)
  4. Copyright (c) 2013-08-10 Tobias Peters <tobias.peters@kreativeffekt.at>
  5. Permission is hereby granted, free of charge, to any person obtaining a copy
  6. of this software and associated documentation files (the "Software"), to deal
  7. in the Software without restriction, including without limitation the rights
  8. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  9. copies of the Software, and to permit persons to whom the Software is
  10. furnished to do so, subject to the following conditions:
  11. The above copyright notice and this permission notice shall be included in
  12. all copies or substantial portions of the Software.
  13. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  14. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  15. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  16. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  17. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  18. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  19. THE SOFTWARE.
  20. -----------------------------------------------------------------------------
  21. */
  22. #ifndef __QGearsPFileSerializer_H__
  23. #define __QGearsPFileSerializer_H__
  24. #include "common/TypeDefine.h"
  25. #include "QGearsPFile.h"
  26. #include "QGearsSerializer.h"
  27. namespace QGears
  28. {
  29. class PFileSerializer : public Serializer
  30. {
  31. public:
  32. PFileSerializer();
  33. virtual ~PFileSerializer();
  34. virtual void importPFile( Ogre::DataStreamPtr &stream, PFile* pDest );
  35. struct Header
  36. {
  37. uint32 version;
  38. uint32 unknown_04;
  39. uint32 vertex_type;
  40. uint32 num_vertices;
  41. uint32 num_normals;
  42. uint32 num_unknown1;
  43. uint32 num_texture_coordinates;
  44. uint32 num_vertex_colors;
  45. uint32 num_edges;
  46. uint32 num_polygons;
  47. uint32 num_unknown2;
  48. uint32 num_unknown3;
  49. uint32 num_materials;
  50. uint32 num_groups;
  51. uint32 num_bboxes;
  52. uint32 norm_index_table_flag;
  53. uint32 runtime_data[0x10];
  54. };
  55. typedef PFile::BBoxEntry BBoxEntry;
  56. typedef PFile::Edge Edge;
  57. typedef PFile::Group Group;
  58. typedef PFile::MaterialInformation MaterialInformation;
  59. typedef PFile::PolygonDefinition PolygonDefinition;
  60. typedef PFile::Colour Colour;
  61. protected:
  62. virtual void readFileHeader( Ogre::DataStreamPtr &stream );
  63. virtual void readObject( Ogre::DataStreamPtr &stream, Colour &pDest );
  64. virtual void readObject( Ogre::DataStreamPtr &stream, Edge &pDest );
  65. virtual void readObject( Ogre::DataStreamPtr &stream, PolygonDefinition &pDest );
  66. virtual void readObject( Ogre::DataStreamPtr &stream, Group &pDest );
  67. virtual void readObject( Ogre::DataStreamPtr &stream, BBoxEntry &pDest );
  68. using Serializer::readObject;
  69. template<typename ValueType>
  70. void readVector( Ogre::DataStreamPtr &stream
  71. ,std::vector<ValueType> &pDest
  72. ,size_t count );
  73. private:
  74. Header m_header;
  75. };
  76. }
  77. #endif // __QGearsPFileSerializer_H__