| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495 |
- /*
- * Copyright (C) 2022 The V-Gears Team
- *
- * This file is part of V-Gears
- *
- * V-Gears is free software: you can redistribute it and/or modify it under
- * terms of the GNU General Public License as published by the Free Software
- * Foundation, version 3.0 (GPLv3) of the License.
- *
- * V-Gears is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- */
- #pragma once
- #include "common/TypeDefine.h"
- #include "data/QGearsSerializer.h"
- namespace QGears {
- class WorldMapFile;
- /**
- * Handles map file serialization.
- */
- class MapFileSerializer : public Serializer{
- public:
- /**
- * Block header of map files.
- */
- struct BlockHeader{
- /**
- * Offset in this block of the compressed data.
- *
- * At the compressed data offset we have another uint32 which
- * is the size of the uncompressed data.
- */
- uint32 compressed_data_offsets[16];
- };
- /**
- * Block header of a mesh section in map files.
- */
- struct BlockMeshHeader{
- /**
- * Number of BlockTriangle's in the mesh.
- */
- uint16 triengle_count;
- /**
- * Number of vertices and normals.
- */
- uint16 vertex_count;
- };
- /**
- * A vertex.
- */
- struct Vertex{
- /**
- * X coordinate.
- */
- sint16 x;
- /**
- * Y coordinate.
- */
- sint16 y;
- /**
- * Z coordinate.
- */
- sint16 z;
- /**
- * Fill space to fit the structure in 32 bit.
- */
- uint16 unused;
- };
- /**
- * A normal.
- */
- struct Normal{
- /**
- * X coordinate.
- */
- sint16 x;
- /**
- * Y coordinate.
- */
- sint16 y;
- /**
- * Z coordinate.
- */
- sint16 z;
- /**
- * Fill space to fit the structure in 32 bit.
- */
- uint16 unused;
- };
- /**
- * A triangle block in a map file.
- */
- struct BlockTriangle{
- /**
- * Index of the first vertex of the triangle.
- */
- uint8 vertex_0_index;
- /**
- * Index of the second vertex of the triangle.
- */
- uint8 vertex_1_index;
- /**
- * Index of the third vertex of the triangle.
- */
- uint8 vertex_2_index;
- /**
- * Triangle walkability.
- *
- * Only 5 bits are valid.
- *
- * @todo Document walkability modes.
- */
- uint8 walkability_info_;
- /**
- * Unknown data.
- *
- * Only 3 bits are valid.
- *
- * @todo Find out what this is for.
- */
- uint8 unknown;
- /**
- * First side vector U component.
- */
- uint8 vertex_0_u;
- /**
- * First side vector V component.
- */
- uint8 vertex_0_v;
- /**
- * Second side vector U component.
- */
- uint8 vertex_1_u;
- /**
- * Second side vector V component.
- */
- uint8 vertex_1_v;
- /**
- * Third side vector U component.
- */
- uint8 vertex_2_u;
- /**
- * Third side vector V component.
- */
- uint8 vertex_2_v;
- /**
- * Triangle texture info.
- *
- * Only 9 bits are valid.
- */
- uint16 TextureInfo;
- /**
- * Triangle location.
- *
- * Only 7 bits are valid.
- */
- uint16 Location;
- };
- /**
- * Type of walkmesh triangle.
- *
- * Determines the triangle walkability under different conditions.
- */
- enum TriangleWalkMapTypes{
- /**
- * Grass.
- *
- * Most things can go here.
- */
- GRASS = 0,
- /**
- * Forest.
- *
- * No landing here, but anything else goes.
- */
- FOREST = 1,
- /**
- * Mountain.
- *
- * Chocobos and flying machines only.
- */
- MOUNTAIN = 2,
- /**
- * Deep water.
- *
- * Only gold chocobo and submarine can go here.
- */
- SEA_DEEP_WATER = 3,
- /**
- * River crossing.
- *
- * Buggy, Tiny Bronco and water-capable chocobos.
- */
- RIVER_CROSSING = 4,
- /**
- * River.
- *
- * Tiny Bronco and chocobos.
- */
- RIVER = 5,
- /**
- * Shallow water.
- *
- * Only Tiny Bronco and chocobos.
- */
- WATER = 6,
- /**
- * Swamp.
- *
- * The Midgar zolom can only move in swamp areas.
- */
- SWAMP = 7,
- /**
- * Desert.
- *
- * No landing.
- */
- DESERT = 8,
- /**
- * Wasteland.
- *
- * Found around Midgar, Wutai and misc other. No landing.
- */
- WASTELAND = 9,
- /**
- * Snow.
- *
- * Leaves footprints, no landing.
- */
- SNOW = 10,
- /**
- * Riverside.
- *
- * Beach-like area where river and land meet.
- */
- RIVERSIDE = 11,
- /**
- * Cliff.
- *
- * Sharp drop, usually where the player can be on either side.
- */
- CLIFF = 12,
- /**
- * Corel bridge.
- *
- * Tiny bridge over the waterfall from Costa del Sol to Corel.
- */
- COREL_BRIDGE = 13,
- /**
- * Bridges in Wutai.
- *
- * Rickety rope bridges south of Wutai.
- */
- WUTAI_BRIDGE = 14,
- /**
- * Unused.
- *
- * It doesn't seem to be used anywhere in the original data.
- */
- UNUSED_1 = 15,
- /**
- * Hill side.
- *
- * This is the tiny walkable part at the foot of a mountain.
- */
- HILL_SIDE = 16,
- /**
- * Beach.
- *
- * Where land and shallow water meet.
- */
- BEACH = 17,
- /**
- * Submarine pens.
- *
- * The only place where the submarine can be boarded.
- */
- SUBMARINE_PEN = 18,
- /**
- * Cosmo Canyon area.
- *
- * The ground in cosmo canyon has this type, walkability seems
- * to be the same as {@see Wasteland} (no landing).
- */
- CANYON = 19,
- /**
- * Mountain pass.
- *
- * The small path through the mountains connecting Costa del
- * Sol and Corel.
- */
- MOUNTAIN_PASS = 20,
- /**
- * Unknown.
- *
- * Present around bridges, may have some special meaning.
- */
- UNKNOWN_1 = 21,
- /**
- * Waterfall.
- *
- * River type where the Tiny Bronco can't go.
- */
- WATERFALL = 22,
- /**
- * Unused.
- *
- * It doesn't seem to be used anywhere in the original data.
- */
- UNUSED_2 = 23,
- /**
- * Gold Saucer desert.
- *
- * Special desert type for the Gold Saucer desert.
- */
- GOLD_SAUCER_DESERT = 24,
- /**
- * Jungle.
- *
- * Same walkability as {@see FOREST}, used in southern parts of
- * the map.
- */
- JUNGLE = 25,
- /**
- * Deep sea.
- *
- * Special type of deep water, only used in one small spot next
- * to HP-MP cave, possibly related to the underwater
- * map/submarine.
- */
- SEA = 26,
- /**
- * The northernd cave.
- *
- * Inside part of the crater, where the Highwind can descend.
- */
- NORTHERND_CAVE = 27,
- /**
- * Borders of the Gold Saucer desert.
- *
- * Narrow strip of land surrounding the golden saucer desert.
- * Probably related to the "quicksand" script.
- */
- GOLD_SAUCER_DESERT_BORDER = 28,
- /**
- * Bridge heads.
- *
- * Small area at both ends of every bridge. May have some
- * special meaning.
- */
- BRIDGE_HEAD = 29,
- /**
- * Entrances.
- *
- * Special type that can be set unwalkable from the script.
- */
- BACK_ENTRANCE = 30,
- /**
- * Unused.
- *
- * It doesn't seem to be used anywhere in the original data.
- */
- UNUSED_3 = 31
- };
- /**
- * Constructor.
- */
- MapFileSerializer();
- /**
- * Destructor.
- */
- virtual ~MapFileSerializer();
- /**
- * Imports and parses a map file.
- *
- * @param stream[in] Map file contents.
- * @param dest[in] Unused
- */
- void ImportMapFile(Ogre::DataStreamPtr& stream, WorldMapFile& dest);
- /**
- * Part of a file block.
- */
- struct BlockPart{
- /**
- * Block part header.
- */
- BlockMeshHeader header;
- /**
- * List of triangles in the block part.
- */
- std::vector<BlockTriangle> triangles;
- /**
- * List of vertices in the block part.
- */
- std::vector<Vertex> vertices;
- /**
- * List of normals in the block part.
- */
- std::vector<Normal> normals;
- };
- /**
- * A file block.
- */
- struct Block{
- /**
- * List of meshes in the block.
- */
- std::vector<BlockPart> meshes;
- };
- /**
- * The list of file blocks.
- */
- std::vector<Block> blocks;
- };
- }
|