metaforce/DataSpec/DNACommon/MAPA.hpp

195 lines
5.9 KiB
C++
Raw Normal View History

#ifndef __DNACOMMON_MAPA_HPP__
#define __DNACOMMON_MAPA_HPP__
2015-10-26 02:31:09 +00:00
#include "DNACommon.hpp"
#include "GX.hpp"
2016-10-01 23:20:20 +00:00
2017-12-29 08:08:12 +00:00
namespace DataSpec::DNAMAPA
2015-10-26 02:31:09 +00:00
{
2015-12-06 03:05:34 +00:00
struct MAPA : BigDNA
{
2018-02-22 07:24:51 +00:00
AT_DECL_EXPLICIT_DNA
2015-12-06 03:05:34 +00:00
Value<atUint32> magic;
Value<atUint32> version;
2018-02-22 07:24:51 +00:00
struct IMAPAHeader : BigDNAV
2015-12-06 03:05:34 +00:00
{
Delete _d;
virtual atUint32 visMode() const=0;
2015-12-06 03:05:34 +00:00
virtual atUint32 mappableObjectCount() const=0;
virtual atUint32 vertexCount() const=0;
virtual atUint32 surfaceCount() const=0;
};
struct HeaderMP1 : IMAPAHeader
{
2018-02-22 07:24:51 +00:00
AT_DECL_DNA
AT_DECL_DNAV
2017-03-20 21:15:00 +00:00
Value<atUint32> unknown1 = 0;
Value<atUint32> mapVisMode = 0;
2017-03-20 21:15:00 +00:00
Value<atVec3f> boundingBox[2] = {};
Value<atUint32> moCount = 0;
Value<atUint32> vtxCount = 0;
Value<atUint32> surfCount = 0;
atUint32 visMode() const { return mapVisMode; }
atUint32 mappableObjectCount() const { return moCount;}
atUint32 vertexCount() const { return vtxCount; }
atUint32 surfaceCount() const { return surfCount; }
2015-12-06 03:05:34 +00:00
};
struct HeaderMP2 : IMAPAHeader
{
2018-02-22 07:24:51 +00:00
AT_DECL_DNA
AT_DECL_DNAV
2017-03-20 21:15:00 +00:00
Value<atUint32> unknown1 = 0;
Value<atUint32> mapVisMode = 0;
2017-03-20 21:15:00 +00:00
Value<atVec3f> boundingBox[2] = {};
Value<atUint32> unknown3 = 0;
Value<atUint32> unknown4 = 0;
Value<atUint32> unknown5 = 0;
Value<atUint32> moCount = 0;
Value<atUint32> vtxCount = 0;
Value<atUint32> surfCount = 0;
atUint32 visMode() const { return mapVisMode; }
2015-12-06 03:05:34 +00:00
atUint32 mappableObjectCount() const { return moCount;}
atUint32 vertexCount() const { return vtxCount; }
atUint32 surfaceCount() const { return surfCount; }
};
struct HeaderMP3 : IMAPAHeader
{
2018-02-22 07:24:51 +00:00
AT_DECL_DNA
AT_DECL_DNAV
2017-03-20 21:15:00 +00:00
Value<atUint32> unknown1 = 0;
Value<atUint32> mapVisMode = 0;
2017-03-20 21:15:00 +00:00
Value<atVec3f> boundingBox[2] = {};
Value<atUint32> unknown3 = 0;
Value<atUint32> unknown4 = 0;
Value<atUint32> unknown5 = 0;
Value<atUint32> unknown6 = 0;
Value<atUint32> moCount = 0;
Value<atUint32> vtxCount = 0;
Value<atUint32> surfCount = 0;
Value<atUint32> internalNameLength = 0;
Value<atUint32> unknown7 = 0;
2018-02-25 08:23:27 +00:00
String<AT_DNA_COUNT(internalNameLength)> internalName;
atUint32 visMode() const { return mapVisMode; }
2015-12-06 03:05:34 +00:00
atUint32 mappableObjectCount() const { return moCount;}
atUint32 vertexCount() const { return vtxCount; }
atUint32 surfaceCount() const { return surfCount; }
};
std::unique_ptr<IMAPAHeader> header;
2018-02-22 07:24:51 +00:00
struct IMappableObject : BigDNAV
2015-12-06 03:05:34 +00:00
{
Delete _d;
enum class Type : atUint32
{
BlueDoor = 0,
ShieldDoor = 1,
IceDoor = 2,
WaveDoor = 3,
PlasmaDoor = 4,
BigDoor1 = 5,
BigDoor2 = 6,
IceDoorCeiling = 7,
IceDoorFloor = 8,
WaveDoorCeiling = 9,
WaveDoorFloor = 10,
IceDoorFloor2 = 13,
WaveDoorFloor2 = 14,
DownArrowYellow = 27, /* Maintenance Tunnel */
UpArrowYellow = 28, /* Phazon Processing Center */
DownArrowGreen = 29, /* Elevator A */
UpArrowGreen = 30, /* Elite Control Access */
DownArrowRed = 31, /* Elevator B */
UpArrowRed = 32, /* Fungal Hall Access */
TransportLift = 33,
SaveStation = 34,
MissileStation = 37
};
};
struct MappableObjectMP1_2 : IMappableObject
{
2018-02-22 07:24:51 +00:00
AT_DECL_DNA
AT_DECL_DNAV
2015-12-06 03:05:34 +00:00
Value<Type> type;
2017-04-22 21:46:18 +00:00
Value<atUint32> visMode;
2015-12-06 03:05:34 +00:00
Value<atUint32> sclyId;
2017-03-20 21:15:00 +00:00
Value<atInt32> seek1 = -1;
2015-12-06 03:05:34 +00:00
Value<atVec4f> transformMtx[3];
2017-03-20 21:15:00 +00:00
Value<atInt32> seek2[4] = {-1, -1, -1, -1};
2015-12-06 03:05:34 +00:00
};
struct MappableObjectMP3 : IMappableObject
{
2018-02-22 07:24:51 +00:00
AT_DECL_DNA
AT_DECL_DNAV
2015-12-06 03:05:34 +00:00
Value<Type> type;
2017-04-22 21:46:18 +00:00
Value<atUint32> visMode;
2015-12-06 03:05:34 +00:00
Value<atUint32> sclyId;
2018-02-25 08:23:27 +00:00
Buffer<AT_DNA_COUNT(0x10)> unknownHash;
2017-03-20 21:15:00 +00:00
Value<atInt32> seek1 = -1;
2015-12-06 03:05:34 +00:00
Value<atVec4f> transformMtx[3];
2017-03-20 21:15:00 +00:00
Value<atInt32> seek2[4] = {-1, -1, -1, -1};
2015-12-06 03:05:34 +00:00
};
std::vector<std::unique_ptr<IMappableObject>> mappableObjects;
2018-02-25 08:23:27 +00:00
Vector<atVec3f, AT_DNA_COUNT(header->vertexCount())> vertices;
2015-12-06 03:05:34 +00:00
struct SurfaceHeader : BigDNA
{
2018-02-22 07:24:51 +00:00
AT_DECL_DNA
2015-12-06 03:05:34 +00:00
Value<atVec3f> normal;
Value<atVec3f> centroid;
Value<atUint32> polyOff;
Value<atUint32> edgeOff;
};
2018-02-25 08:23:27 +00:00
Vector<SurfaceHeader, AT_DNA_COUNT(header->surfaceCount())> surfaceHeaders;
2015-12-06 03:05:34 +00:00
struct Surface : BigDNA
{
2018-02-22 07:24:51 +00:00
AT_DECL_DNA
2015-12-06 03:05:34 +00:00
Value<atUint32> primitiveCount;
struct Primitive : BigDNA
{
2018-02-22 07:24:51 +00:00
AT_DECL_DNA
2015-12-06 03:05:34 +00:00
Value<atUint32> type;
Value<atUint32> indexCount;
2018-02-25 08:23:27 +00:00
Vector<atUint8, AT_DNA_COUNT(indexCount)> indices;
2015-12-06 03:05:34 +00:00
Align<4> align;
};
2018-02-25 08:23:27 +00:00
Vector<Primitive, AT_DNA_COUNT(primitiveCount)> primitives;
2015-12-06 03:05:34 +00:00
Value<atUint32> borderCount;
struct Border : BigDNA
{
2018-02-22 07:24:51 +00:00
AT_DECL_DNA
2015-12-06 03:05:34 +00:00
Value<atUint32> indexCount;
2018-02-25 08:23:27 +00:00
Vector<atUint8, AT_DNA_COUNT(indexCount)> indices;
2015-12-06 03:05:34 +00:00
Align<4> align;
};
2018-02-25 08:23:27 +00:00
Vector<Border, AT_DNA_COUNT(borderCount)> borders;
2015-12-06 03:05:34 +00:00
};
2018-02-25 08:23:27 +00:00
Vector<Surface, AT_DNA_COUNT(header->surfaceCount())> surfaces;
2015-12-06 03:05:34 +00:00
};
2015-10-26 02:31:09 +00:00
2015-12-06 03:05:34 +00:00
template <typename PAKRouter>
2017-12-29 08:08:12 +00:00
bool ReadMAPAToBlender(hecl::blender::Connection& conn,
2015-10-26 02:31:09 +00:00
const MAPA& mapa,
2016-03-04 23:04:53 +00:00
const hecl::ProjectPath& outPath,
2015-10-26 02:31:09 +00:00
PAKRouter& pakRouter,
const typename PAKRouter::EntryType& entry,
bool force);
2015-10-26 02:31:09 +00:00
2017-03-20 05:09:53 +00:00
template <typename MAPAType>
2017-12-29 08:08:12 +00:00
bool Cook(const hecl::blender::MapArea& mapa, const hecl::ProjectPath& out);
2017-03-20 05:09:53 +00:00
2015-10-26 02:31:09 +00:00
}
#endif // __DNACOMMON_MAPA_HPP__