2017-05-22 11:24:24 +00:00
|
|
|
#ifndef __DNAMP1_DCLN_HPP__
|
|
|
|
#define __DNAMP1_DCLN_HPP__
|
|
|
|
|
2017-10-17 05:51:53 +00:00
|
|
|
#include <athena/Types.hpp>
|
2017-05-22 11:24:24 +00:00
|
|
|
#include "../DNACommon/DeafBabe.hpp"
|
|
|
|
#include "../DNACommon/PAK.hpp"
|
2017-10-17 05:51:53 +00:00
|
|
|
#include "../DNACommon/OBBTreeBuilder.hpp"
|
2017-05-22 11:24:24 +00:00
|
|
|
#include "DNAMP1.hpp"
|
|
|
|
#include "DeafBabe.hpp"
|
|
|
|
|
2017-10-17 06:05:23 +00:00
|
|
|
#define DCLN_DUMP_OBB 0
|
|
|
|
|
2017-12-29 08:08:12 +00:00
|
|
|
namespace DataSpec::DNAMP1
|
2017-05-22 11:24:24 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
struct DCLN : BigDNA
|
|
|
|
{
|
2017-12-29 08:08:12 +00:00
|
|
|
using Mesh = hecl::blender::ColMesh;
|
2017-10-17 05:51:53 +00:00
|
|
|
|
2018-02-22 07:24:51 +00:00
|
|
|
AT_DECL_DNA
|
2017-05-22 11:24:24 +00:00
|
|
|
Value<atUint32> colCount;
|
|
|
|
struct Collision : BigDNA
|
|
|
|
{
|
|
|
|
using Material = DeafBabe::Material;
|
|
|
|
using Edge = DeafBabe::Edge;
|
|
|
|
using Triangle = DeafBabe::Triangle;
|
|
|
|
|
2018-02-22 07:24:51 +00:00
|
|
|
AT_DECL_DNA
|
2017-05-22 11:24:24 +00:00
|
|
|
Value<atUint32> magic;
|
|
|
|
Value<atUint32> version;
|
|
|
|
Value<atUint32> memSize;
|
|
|
|
Value<atUint32> materialCount;
|
2018-02-25 08:23:27 +00:00
|
|
|
Vector<Material, AT_DNA_COUNT(materialCount)> materials;
|
2017-05-22 11:24:24 +00:00
|
|
|
Value<atUint32> vertMatsCount;
|
2018-02-25 08:23:27 +00:00
|
|
|
Vector<atUint8, AT_DNA_COUNT(vertMatsCount)> vertMats;
|
2017-05-22 11:24:24 +00:00
|
|
|
Value<atUint32> edgeMatsCount;
|
2018-02-25 08:23:27 +00:00
|
|
|
Vector<atUint8, AT_DNA_COUNT(edgeMatsCount)> edgeMats;
|
2017-05-22 11:24:24 +00:00
|
|
|
Value<atUint32> triMatsCount;
|
2018-02-25 08:23:27 +00:00
|
|
|
Vector<atUint8, AT_DNA_COUNT(triMatsCount)> triMats;
|
2017-05-22 11:24:24 +00:00
|
|
|
Value<atUint32> edgeVertsCount;
|
2018-02-25 08:23:27 +00:00
|
|
|
Vector<Edge, AT_DNA_COUNT(edgeVertsCount)> edgeVertConnections;
|
2017-05-22 11:24:24 +00:00
|
|
|
Value<atUint32> triangleEdgesCount;
|
2018-02-25 08:23:27 +00:00
|
|
|
Vector<Triangle, AT_DNA_COUNT(triangleEdgesCount / 3)> triangleEdgeConnections;
|
2017-05-22 11:24:24 +00:00
|
|
|
Value<atUint32> vertCount;
|
2018-02-25 08:23:27 +00:00
|
|
|
Vector<atVec3f, AT_DNA_COUNT(vertCount)> verts;
|
2017-05-22 11:24:24 +00:00
|
|
|
|
|
|
|
struct Node : BigDNA
|
|
|
|
{
|
2018-02-22 07:24:51 +00:00
|
|
|
AT_DECL_EXPLICIT_DNA
|
2017-10-17 05:51:53 +00:00
|
|
|
|
|
|
|
struct LeafData : BigDNA
|
|
|
|
{
|
2018-02-22 07:24:51 +00:00
|
|
|
AT_DECL_DNA
|
2017-10-22 06:11:22 +00:00
|
|
|
Value<atUint32> triangleIndexCount;
|
2018-02-25 08:23:27 +00:00
|
|
|
Vector<atUint16, AT_DNA_COUNT(triangleIndexCount)> triangleIndices;
|
2017-10-22 06:11:22 +00:00
|
|
|
size_t getMemoryUsage() const { return (((triangleIndices.size() * 2) + 16) + 3) & ~3; }
|
2017-10-17 05:51:53 +00:00
|
|
|
};
|
|
|
|
|
2017-05-22 11:24:24 +00:00
|
|
|
Value<atVec4f> xf[3];
|
2017-10-17 05:51:53 +00:00
|
|
|
Value<atVec3f> halfExtent;
|
2017-05-22 11:24:24 +00:00
|
|
|
Value<bool> isLeaf;
|
|
|
|
std::unique_ptr<LeafData> leafData;
|
|
|
|
std::unique_ptr<Node> left;
|
|
|
|
std::unique_ptr<Node> right;
|
|
|
|
|
|
|
|
size_t getMemoryUsage() const
|
|
|
|
{
|
|
|
|
size_t ret = 80;
|
|
|
|
if (isLeaf)
|
|
|
|
ret += leafData->getMemoryUsage();
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ret += left->getMemoryUsage();
|
|
|
|
ret += right->getMemoryUsage();
|
|
|
|
}
|
|
|
|
|
|
|
|
return (ret + 3) & ~3;
|
|
|
|
}
|
2017-10-17 05:51:53 +00:00
|
|
|
|
2017-10-17 06:05:23 +00:00
|
|
|
#if DCLN_DUMP_OBB
|
2017-12-29 08:08:12 +00:00
|
|
|
sendToBlender(hecl::blender::PyOutStream& os) const;
|
2017-10-17 06:05:23 +00:00
|
|
|
#endif
|
2017-05-22 11:24:24 +00:00
|
|
|
};
|
|
|
|
Node root;
|
|
|
|
size_t getMemoryUsage()
|
|
|
|
{
|
|
|
|
return root.getMemoryUsage();
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Dummy MP2 member */
|
2017-12-29 08:08:12 +00:00
|
|
|
void insertNoClimb(hecl::blender::PyOutStream&) const {}
|
2017-05-22 11:24:24 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2018-02-25 08:23:27 +00:00
|
|
|
Vector<Collision, AT_DNA_COUNT(colCount)> collision;
|
2017-05-22 11:24:24 +00:00
|
|
|
|
2017-12-29 08:08:12 +00:00
|
|
|
void sendToBlender(hecl::blender::Connection& conn, std::string_view entryName);
|
2017-05-22 11:24:24 +00:00
|
|
|
|
|
|
|
static bool Extract(const SpecBase& dataSpec,
|
|
|
|
PAKEntryReadStream& rs,
|
|
|
|
const hecl::ProjectPath& outPath,
|
|
|
|
PAKRouter<PAKBridge>& pakRouter,
|
|
|
|
const PAK::Entry& entry,
|
|
|
|
bool force,
|
2017-12-29 08:08:12 +00:00
|
|
|
hecl::blender::Token& btok,
|
|
|
|
std::function<void(const hecl::SystemChar*)> fileChanged);
|
2017-10-17 05:51:53 +00:00
|
|
|
|
|
|
|
static bool Cook(const hecl::ProjectPath& outPath,
|
|
|
|
const hecl::ProjectPath& inPath,
|
|
|
|
const std::vector<Mesh>& meshes,
|
2017-12-29 08:08:12 +00:00
|
|
|
hecl::blender::Connection* conn = nullptr);
|
2017-05-22 11:24:24 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
#endif // __DNAMP1_DCLN_HPP__
|