2015-08-10 01:53:24 +00:00
|
|
|
#ifndef _DNACOMMON_CMDL_HPP_
|
|
|
|
#define _DNACOMMON_CMDL_HPP_
|
2015-07-28 02:24:36 +00:00
|
|
|
|
2015-10-11 05:56:42 +00:00
|
|
|
#include <Athena/FileWriter.hpp>
|
|
|
|
#include <HECL/Frontend.hpp>
|
|
|
|
#include <HECL/Backend/GX.hpp>
|
2015-08-22 01:58:41 +00:00
|
|
|
#include "PAK.hpp"
|
2015-08-10 01:53:24 +00:00
|
|
|
#include "BlenderConnection.hpp"
|
|
|
|
#include "GX.hpp"
|
2015-08-16 23:00:33 +00:00
|
|
|
#include "TXTR.hpp"
|
2015-08-10 01:53:24 +00:00
|
|
|
|
2016-02-13 09:02:47 +00:00
|
|
|
namespace DataSpec
|
2015-08-10 01:53:24 +00:00
|
|
|
{
|
|
|
|
namespace DNACMDL
|
|
|
|
{
|
|
|
|
|
2015-10-07 01:17:17 +00:00
|
|
|
using Mesh = HECL::BlenderConnection::DataStream::Mesh;
|
|
|
|
|
2015-08-10 01:53:24 +00:00
|
|
|
struct Header : BigDNA
|
2015-08-05 21:46:07 +00:00
|
|
|
{
|
2015-08-10 01:53:24 +00:00
|
|
|
DECL_DNA
|
|
|
|
Value<atUint32> magic;
|
|
|
|
Value<atUint32> version;
|
|
|
|
struct Flags : BigDNA
|
|
|
|
{
|
|
|
|
DECL_DNA
|
2015-10-19 03:28:47 +00:00
|
|
|
Value<atUint32> flags = 0;
|
2015-09-29 02:00:28 +00:00
|
|
|
bool shortNormals() const {return (flags & 0x2) != 0;}
|
|
|
|
void setShortNormals(bool val) {flags &= ~0x2; flags |= val << 1;}
|
|
|
|
bool shortUVs() const {return (flags & 0x4) != 0;}
|
|
|
|
void setShortUVs(bool val) {flags &= ~0x4; flags |= val << 2;}
|
2015-08-10 01:53:24 +00:00
|
|
|
} flags;
|
|
|
|
Value<atVec3f> aabbMin;
|
|
|
|
Value<atVec3f> aabbMax;
|
|
|
|
Value<atUint32> secCount;
|
|
|
|
Value<atUint32> matSetCount;
|
|
|
|
Vector<atUint32, DNA_COUNT(secCount)> secSizes;
|
|
|
|
Align<32> align;
|
2015-08-05 21:46:07 +00:00
|
|
|
};
|
|
|
|
|
2016-01-14 22:42:44 +00:00
|
|
|
struct SurfaceHeader_1 : BigDNA
|
2015-08-10 01:53:24 +00:00
|
|
|
{
|
|
|
|
DECL_DNA
|
|
|
|
Value<atVec3f> centroid;
|
2015-10-19 03:28:47 +00:00
|
|
|
Value<atUint32> matIdx = 0;
|
|
|
|
Value<atUint16> qDiv = 0x8000;
|
|
|
|
Value<atUint16> dlSize = 0;
|
|
|
|
Value<atUint32> unk1 = 0;
|
|
|
|
Value<atUint32> unk2 = 0;
|
|
|
|
Value<atUint32> aabbSz = 0;
|
2015-08-10 01:53:24 +00:00
|
|
|
Value<atVec3f> reflectionNormal;
|
|
|
|
Seek<DNA_COUNT(aabbSz), Athena::Current> seek2;
|
|
|
|
Align<32> align;
|
2015-09-26 03:12:08 +00:00
|
|
|
|
|
|
|
static constexpr bool UseMatrixSkinning() {return false;}
|
2015-11-14 23:42:58 +00:00
|
|
|
static constexpr atInt16 skinMatrixBankIdx() {return -1;}
|
2015-09-26 03:12:08 +00:00
|
|
|
};
|
|
|
|
|
2016-01-14 22:42:44 +00:00
|
|
|
struct SurfaceHeader_2 : BigDNA
|
|
|
|
{
|
|
|
|
DECL_DNA
|
|
|
|
Value<atVec3f> centroid;
|
|
|
|
Value<atUint32> matIdx = 0;
|
|
|
|
Value<atUint16> qDiv = 0x8000;
|
|
|
|
Value<atUint16> dlSize = 0;
|
|
|
|
Value<atUint32> unk1 = 0;
|
|
|
|
Value<atUint32> unk2 = 0;
|
|
|
|
Value<atUint32> aabbSz = 0;
|
|
|
|
Value<atVec3f> reflectionNormal;
|
|
|
|
Value<atInt16> skinMtxBankIdx;
|
|
|
|
Value<atUint16> surfaceGroup;
|
|
|
|
Seek<DNA_COUNT(aabbSz), Athena::Current> seek2;
|
|
|
|
Align<32> align;
|
|
|
|
|
|
|
|
static constexpr bool UseMatrixSkinning() {return false;}
|
|
|
|
atInt16 skinMatrixBankIdx() const {return skinMtxBankIdx;}
|
|
|
|
};
|
|
|
|
|
2015-09-26 03:12:08 +00:00
|
|
|
struct SurfaceHeader_3 : BigDNA
|
|
|
|
{
|
|
|
|
DECL_DNA
|
|
|
|
Value<atVec3f> centroid;
|
2015-10-19 03:28:47 +00:00
|
|
|
Value<atUint32> matIdx = 0;
|
|
|
|
Value<atUint16> qDiv = 0x8000;
|
|
|
|
Value<atUint16> dlSize = 0;
|
|
|
|
Value<atUint32> unk1 = 0;
|
|
|
|
Value<atUint32> unk2 = 0;
|
|
|
|
Value<atUint32> aabbSz = 0;
|
2015-09-26 03:12:08 +00:00
|
|
|
Value<atVec3f> reflectionNormal;
|
|
|
|
Value<atInt16> skinMtxBankIdx;
|
2016-01-14 22:42:44 +00:00
|
|
|
Value<atUint16> surfaceGroup;
|
2015-09-26 03:12:08 +00:00
|
|
|
Seek<DNA_COUNT(aabbSz), Athena::Current> seek2;
|
2016-01-14 22:42:44 +00:00
|
|
|
Value<atUint8> unk3;
|
2015-09-26 03:12:08 +00:00
|
|
|
Align<32> align;
|
|
|
|
|
|
|
|
static constexpr bool UseMatrixSkinning() {return true;}
|
|
|
|
atInt16 skinMatrixBankIdx() const {return skinMtxBankIdx;}
|
2015-08-10 01:53:24 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct VertexAttributes
|
|
|
|
{
|
|
|
|
GX::AttrType pos = GX::NONE;
|
|
|
|
GX::AttrType norm = GX::NONE;
|
|
|
|
GX::AttrType color0 = GX::NONE;
|
|
|
|
GX::AttrType color1 = GX::NONE;
|
|
|
|
unsigned uvCount = 0;
|
|
|
|
GX::AttrType uvs[7] = {GX::NONE};
|
|
|
|
GX::AttrType pnMtxIdx = GX::NONE;
|
|
|
|
unsigned texMtxIdxCount = 0;
|
|
|
|
GX::AttrType texMtxIdx[7] = {GX::NONE};
|
2015-09-07 04:05:44 +00:00
|
|
|
bool shortUVs;
|
2015-08-10 01:53:24 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
template <class MaterialSet>
|
|
|
|
void GetVertexAttributes(const MaterialSet& matSet,
|
2016-03-02 07:29:19 +00:00
|
|
|
std::vector<VertexAttributes>& attributesOut);
|
2015-08-10 01:53:24 +00:00
|
|
|
|
|
|
|
template <class PAKRouter, class MaterialSet>
|
|
|
|
void ReadMaterialSetToBlender_1_2(HECL::BlenderConnection::PyOutStream& os,
|
|
|
|
const MaterialSet& matSet,
|
|
|
|
const PAKRouter& pakRouter,
|
|
|
|
const typename PAKRouter::EntryType& entry,
|
2016-03-02 07:29:19 +00:00
|
|
|
unsigned setIdx);
|
2015-08-10 01:53:24 +00:00
|
|
|
|
|
|
|
template <class PAKRouter, class MaterialSet>
|
|
|
|
void ReadMaterialSetToBlender_3(HECL::BlenderConnection::PyOutStream& os,
|
|
|
|
const MaterialSet& matSet,
|
|
|
|
const PAKRouter& pakRouter,
|
|
|
|
const typename PAKRouter::EntryType& entry,
|
2016-03-02 07:29:19 +00:00
|
|
|
unsigned setIdx);
|
2015-07-28 02:24:36 +00:00
|
|
|
|
2015-09-07 04:05:44 +00:00
|
|
|
void InitGeomBlenderContext(HECL::BlenderConnection::PyOutStream& os,
|
|
|
|
const HECL::ProjectPath& masterShaderPath);
|
|
|
|
void FinishBlenderMesh(HECL::BlenderConnection::PyOutStream& os,
|
|
|
|
unsigned matSetCount, int meshIdx);
|
|
|
|
|
2015-09-26 03:12:08 +00:00
|
|
|
template <class PAKRouter, class MaterialSet, class RigPair, class SurfaceHeader>
|
2015-09-07 04:05:44 +00:00
|
|
|
atUint32 ReadGeomSectionsToBlender(HECL::BlenderConnection::PyOutStream& os,
|
|
|
|
Athena::io::IStreamReader& reader,
|
|
|
|
PAKRouter& pakRouter,
|
|
|
|
const typename PAKRouter::EntryType& entry,
|
2015-09-26 03:12:08 +00:00
|
|
|
const RigPair& rp,
|
2015-09-07 04:05:44 +00:00
|
|
|
bool shortNormals,
|
|
|
|
bool shortUVs,
|
|
|
|
std::vector<VertexAttributes>& vertAttribs,
|
|
|
|
int meshIdx,
|
|
|
|
atUint32 secCount,
|
|
|
|
atUint32 matSetCount,
|
2015-09-20 06:09:27 +00:00
|
|
|
const atUint32* secSizes,
|
2016-03-02 07:29:19 +00:00
|
|
|
atUint32 surfaceCount=0);
|
2015-09-07 04:05:44 +00:00
|
|
|
|
2015-09-26 03:12:08 +00:00
|
|
|
template <class PAKRouter, class MaterialSet, class RigPair, class SurfaceHeader, atUint32 Version>
|
2015-09-07 04:05:44 +00:00
|
|
|
bool ReadCMDLToBlender(HECL::BlenderConnection& conn,
|
|
|
|
Athena::io::IStreamReader& reader,
|
|
|
|
PAKRouter& pakRouter,
|
|
|
|
const typename PAKRouter::EntryType& entry,
|
|
|
|
const SpecBase& dataspec,
|
2016-03-02 07:29:19 +00:00
|
|
|
const RigPair& rp);
|
2015-07-28 02:24:36 +00:00
|
|
|
|
2015-10-27 00:19:03 +00:00
|
|
|
template <class PAKRouter, class MaterialSet>
|
|
|
|
void NameCMDL(Athena::io::IStreamReader& reader,
|
|
|
|
PAKRouter& pakRouter,
|
|
|
|
typename PAKRouter::EntryType& entry,
|
2016-03-02 07:29:19 +00:00
|
|
|
const SpecBase& dataspec);
|
2015-10-19 03:28:47 +00:00
|
|
|
|
2015-10-11 05:56:42 +00:00
|
|
|
template <class MaterialSet, class SurfaceHeader, atUint32 Version>
|
2016-03-02 07:29:19 +00:00
|
|
|
bool WriteCMDL(const HECL::ProjectPath& outPath, const HECL::ProjectPath& inPath, const Mesh& mesh);
|
2015-10-11 05:56:42 +00:00
|
|
|
|
2015-11-14 02:28:45 +00:00
|
|
|
template <class MaterialSet, class SurfaceHeader, atUint32 Version>
|
2016-03-02 07:29:19 +00:00
|
|
|
bool WriteHMDLCMDL(const HECL::ProjectPath& outPath, const HECL::ProjectPath& inPath, const Mesh& mesh);
|
2015-11-14 02:28:45 +00:00
|
|
|
|
2015-07-28 02:24:36 +00:00
|
|
|
}
|
|
|
|
}
|
2015-08-10 01:53:24 +00:00
|
|
|
|
|
|
|
#endif // _DNACOMMON_CMDL_HPP_
|