2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-12-09 09:07:43 +00:00

TEV->Blender fixes

This commit is contained in:
Jack Andersen
2015-10-10 19:56:42 -10:00
parent c13757106b
commit f77900a9cb
4 changed files with 76 additions and 20 deletions

View File

@@ -1,6 +1,9 @@
#ifndef _DNACOMMON_CMDL_HPP_
#define _DNACOMMON_CMDL_HPP_
#include <Athena/FileWriter.hpp>
#include <HECL/Frontend.hpp>
#include <HECL/Backend/GX.hpp>
#include "PAK.hpp"
#include "BlenderConnection.hpp"
#include "GX.hpp"
@@ -1021,6 +1024,46 @@ bool ReadCMDLToBlender(HECL::BlenderConnection& conn,
return true;
}
template <class MaterialSet, class SurfaceHeader, atUint32 Version>
bool WriteCMDL(const HECL::ProjectPath& outPath, const HECL::ProjectPath& inPath, const Mesh& mesh)
{
Athena::io::FileWriter writer(outPath.getAbsolutePath());
Header head;
head.magic = 0xDEADBABE;
head.version = Version;
head.flags.flags = 0;
head.aabbMin = mesh.aabbMin.val;
head.aabbMax = mesh.aabbMax.val;
head.matSetCount = mesh.materialSets.size();
head.secCount = head.matSetCount + 5 + mesh.surfaces.size();
head.secSizes.reserve(head.secCount);
/* Build material sets */
{
HECL::Frontend::Frontend FE;
int setIdx = 0;
for (const std::vector<Mesh::Material>& mset : mesh.materialSets)
{
int matIdx = 0;
for (const Mesh::Material& mat : mset)
{
std::string diagName = HECL::SysFormat(_S("%s:%d:%d"), inPath.getLastComponent(), setIdx, matIdx);
HECL::Frontend::IR matIR = FE.compileSource(mat.source, diagName);
HECL::Backend::GX matGX;
matGX.reset(matIR);
++matIdx;
}
++setIdx;
}
}
head.write(writer);
return true;
}
}
}