MapFileSerializer.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. #ifndef _MAP_FILE_SERIALIZER_H_
  2. #define _MAP_FILE_SERIALIZER_H_
  3. #include "common/TypeDefine.h"
  4. #include "data/QGearsSerializer.h"
  5. namespace QGears {
  6. class WorldMapFile;
  7. class MapFileSerializer : public Serializer
  8. {
  9. public:
  10. struct BlockHeader
  11. {
  12. // Offset in this block of the compressed data
  13. uint32 mCompressedDataOffsets[16];
  14. // At the compressed data offset we have another uint32 which
  15. // is the size of the uncompressed data
  16. };
  17. struct BlockMeshHeader
  18. {
  19. // Number of BlockTriangle's
  20. uint16 NumberOfTriangles;
  21. // Number of Vertex's and Normal's
  22. uint16 NumberOfVertices;
  23. };
  24. struct Vertex
  25. {
  26. sint16 X, Y, Z;
  27. uint16 Unused; // fill to fit structure to 32bit boundry
  28. };
  29. struct Normal
  30. {
  31. sint16 X, Y, Z;
  32. uint16 Unused; // fill to fit structure to 32bit boundry
  33. };
  34. struct BlockTriangle
  35. {
  36. uint8 Vertex0Index;
  37. uint8 Vertex1Index;
  38. uint8 Vertex2Index;
  39. // Only 5 bits are valid
  40. uint8 WalkabilityInfo;//:5;
  41. // Only 3 bits are valid
  42. uint8 Unknown;//:3;
  43. uint8 uVertex0, vVertex0;
  44. uint8 uVertex1, vVertex1;
  45. uint8 uVertex2, vVertex2;
  46. // Only 9 bits are valid
  47. uint16 TextureInfo;//:9;
  48. // Only 7 bits are valid
  49. uint16 Location;//:7;
  50. };
  51. enum eTriangleWalkMapTypes
  52. {
  53. // Most things can go here.
  54. eGrass = 0,
  55. // No landing here, but anything else goes.
  56. eForest = 1,
  57. // Chocobos and flying machines only.
  58. eMountain = 2,
  59. // Only gold chocobo and submarine can go here.
  60. eSeaDeepWater = 3,
  61. // Buggy, tiny bronco and water-capable chocobos.
  62. eRiverCrossing = 4,
  63. // Tiny bronco and chocobos.
  64. eRiver = 5,
  65. // Shallow water, same as above.
  66. eWater = 6,
  67. // Midgar zolom can only move in swamp areas.
  68. eSwamp = 7,
  69. // No landing.
  70. eDesert = 8,
  71. // Found around Midgar, Wutai and misc other. No landing.
  72. eWasteland = 9,
  73. // Leaves footprints, no landing.
  74. eSnow = 10,
  75. // Beach-like area where river and land meet.
  76. eRiverside = 11,
  77. // Sharp drop, usually where the player can be on either side.
  78. eCliff = 12,
  79. // Tiny bridge over the waterfall from Costa del Sol to Corel.
  80. eCorelBridge = 13,
  81. // Rickety rope bridges south of Wutai.
  82. eWutaiBridge = 14,
  83. // Doesn't seem to be used anywhere in the original data.
  84. eUnused1 = 15,
  85. // This is the tiny walkable part at the foot of a mountain.
  86. eHillSide = 16,
  87. // Where land and shallow water meets.
  88. eBeach = 17,
  89. // Only place where you can enter/exit the submarine.
  90. eSubmarinePen = 18,
  91. // The ground in cosmo canyon has this type, walkability seems to be the same as wasteland.
  92. eCanyon = 19,
  93. // The small path through the mountains connecting Costa del Sol and Corel.
  94. eMountainPass = 20,
  95. // Present around bridges, may have some special meaning.
  96. eUnknown1 = 21,
  97. // River type where the tiny bronco can't go.
  98. eWaterfall = 22,
  99. // Doesn't seem to be used anywhere in the original data.
  100. eUnused2 = 23,
  101. // Special desert type for the golden saucer.
  102. eGoldSaucerDesert = 24,
  103. // Walkability same as forest, used in southern parts of the map.
  104. eJungle = 25,
  105. // Special type of deep water, only used in one small spot next to HP-MP cave,
  106. // possibly related to the underwater map/submarine.
  107. eSea = 26,
  108. // Inside part of the crater, where you can land the highwind.
  109. eNorthernCave = 27,
  110. // Narrow strip of land surrounding the golden saucer desert. Probably related to the "quicksand" script.
  111. eGoldSaucerDesertBorder = 28,
  112. // Small area at both ends of every bridge. May have some special meaning.
  113. eBridgehead = 29,
  114. // Special type that can be set unwalkable from the script.
  115. eBackEntrance = 30,
  116. // oesn't seem to be used anywhere in the original data.
  117. eUnused3 = 31
  118. };
  119. MapFileSerializer();
  120. virtual ~MapFileSerializer();
  121. void importMapFile( Ogre::DataStreamPtr& stream, WorldMapFile& dest );
  122. struct SBlockPart
  123. {
  124. BlockMeshHeader mHeader;
  125. std::vector<BlockTriangle> mTris;
  126. std::vector<Vertex> mVertices;
  127. std::vector<Normal> mNormal;
  128. };
  129. struct SBlock
  130. {
  131. std::vector<SBlockPart> mMeshes;
  132. };
  133. std::vector<SBlock> mBlocks;
  134. };
  135. } // namespace QGears
  136. #endif // _MAP_FILE_SERIALIZER_H_