2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-07-13 16:46:00 +00:00

CMDL cooking updates

This commit is contained in:
Jack Andersen 2015-10-06 15:17:17 -10:00
parent cdeb1234c8
commit 3b7f7f2f3a
16 changed files with 63 additions and 30 deletions

View File

@ -13,7 +13,7 @@ namespace Blender
bool BuildMasterShader(const HECL::ProjectPath& path) bool BuildMasterShader(const HECL::ProjectPath& path)
{ {
HECL::BlenderConnection& conn = HECL::BlenderConnection::SharedConnection(); HECL::BlenderConnection& conn = HECL::BlenderConnection::SharedConnection();
if (!conn.createBlend(path.getAbsolutePath(), HECL::BlenderConnection::TypeNone)) if (!conn.createBlend(path, HECL::BlenderConnection::TypeNone))
return false; return false;
{ {
HECL::BlenderConnection::PyOutStream os = conn.beginPythonOut(true); HECL::BlenderConnection::PyOutStream os = conn.beginPythonOut(true);

View File

@ -51,7 +51,7 @@ bool ReadANCSToBlender(HECL::BlenderConnection& conn,
HECL::ProjectPath cmdlPath = pakRouter.getWorking(cmdlE); HECL::ProjectPath cmdlPath = pakRouter.getWorking(cmdlE);
if (force || cmdlPath.getPathType() == HECL::ProjectPath::PT_NONE) if (force || cmdlPath.getPathType() == HECL::ProjectPath::PT_NONE)
{ {
if (!conn.createBlend(cmdlPath.getAbsolutePath(), HECL::BlenderConnection::TypeMesh)) if (!conn.createBlend(cmdlPath, HECL::BlenderConnection::TypeMesh))
return false; return false;
HECL::SystemStringView bestNameView(pakRouter.getBestEntryName(*cmdlE)); HECL::SystemStringView bestNameView(pakRouter.getBestEntryName(*cmdlE));
@ -77,7 +77,7 @@ bool ReadANCSToBlender(HECL::BlenderConnection& conn,
fileChanged(bestNameView.sys_str().c_str()); fileChanged(bestNameView.sys_str().c_str());
/* Establish ANCS blend */ /* Establish ANCS blend */
if (!conn.createBlend(outPath.getAbsolutePath(), HECL::BlenderConnection::TypeActor)) if (!conn.createBlend(outPath, HECL::BlenderConnection::TypeActor))
return false; return false;
HECL::BlenderConnection::PyOutStream os = conn.beginPythonOut(true); HECL::BlenderConnection::PyOutStream os = conn.beginPythonOut(true);

View File

@ -11,6 +11,8 @@ namespace Retro
namespace DNACMDL namespace DNACMDL
{ {
using Mesh = HECL::BlenderConnection::DataStream::Mesh;
struct Header : BigDNA struct Header : BigDNA
{ {
DECL_DNA DECL_DNA

View File

@ -512,15 +512,6 @@ public:
float thisFac = ++count / fsz; float thisFac = ++count / fsz;
progress(bestNameView.sys_str().c_str(), thisFac); progress(bestNameView.sys_str().c_str(), thisFac);
HECL::ProjectPath cooked = getCooked(item.second);
if (force || cooked.getPathType() == HECL::ProjectPath::PT_NONE)
{
PAKEntryReadStream s = item.second->beginReadStream(*m_node);
FILE* fout = HECL::Fopen(cooked.getAbsolutePath().c_str(), _S("wb"));
fwrite(s.data(), 1, s.length(), fout);
fclose(fout);
}
HECL::ProjectPath working = getWorking(item.second, extractor); HECL::ProjectPath working = getWorking(item.second, extractor);
if (extractor.func_a) /* Doesn't need PAKRouter access */ if (extractor.func_a) /* Doesn't need PAKRouter access */
{ {
@ -542,6 +533,17 @@ public:
}); });
} }
} }
/* Extract original cooked copy AFTER working so timestamps make
* the original a valid cached item */
HECL::ProjectPath cooked = getCooked(item.second);
if (force || cooked.getPathType() == HECL::ProjectPath::PT_NONE)
{
PAKEntryReadStream s = item.second->beginReadStream(*m_node);
FILE* fout = HECL::Fopen(cooked.getAbsolutePath().c_str(), _S("wb"));
fwrite(s.data(), 1, s.length(), fout);
fclose(fout);
}
} }
} }

View File

@ -38,12 +38,18 @@ struct CMDL
/* Do extract */ /* Do extract */
HECL::BlenderConnection& conn = HECL::BlenderConnection::SharedConnection(); HECL::BlenderConnection& conn = HECL::BlenderConnection::SharedConnection();
if (!conn.createBlend(outPath.getAbsolutePath(), HECL::BlenderConnection::TypeMesh)) if (!conn.createBlend(outPath, HECL::BlenderConnection::TypeMesh))
return false; return false;
DNACMDL::ReadCMDLToBlender<PAKRouter<PAKBridge>, MaterialSet, std::pair<CSKR*,CINF*>, DNACMDL::SurfaceHeader_1_2, 2> DNACMDL::ReadCMDLToBlender<PAKRouter<PAKBridge>, MaterialSet, std::pair<CSKR*,CINF*>, DNACMDL::SurfaceHeader_1_2, 2>
(conn, rs, pakRouter, entry, dataSpec, loadRp); (conn, rs, pakRouter, entry, dataSpec, loadRp);
return conn.saveBlend(); return conn.saveBlend();
} }
static bool Cook(const DNACMDL::Mesh& mesh,
const HECL::ProjectPath& outPath)
{
return true;
}
}; };
} }

View File

@ -23,7 +23,7 @@ struct DeafBabe : BigDNA
DECL_DNA DECL_DNA
Value<atUint32> material; Value<atUint32> material;
bool fireThrough() const {return material >> 18 & 0x1;} bool fireThrough() const {return material >> 18 & 0x1;}
void setFireThrough(bool v) {material &= 0x40000; material |= v << 18;} void setFireThrough(bool v) {material &= ~0x40000; material |= v << 18;}
enum Type enum Type
{ {
@ -39,7 +39,7 @@ struct DeafBabe : BigDNA
MatLeaves MatLeaves
}; };
Type type() const {return Type(material & 0xff);} Type type() const {return Type(material & 0xff);}
void setType(Type t) {material &= 0xff; material |= t;} void setType(Type t) {material &= ~0xff; material |= t;}
}; };
struct Edge : BigDNA struct Edge : BigDNA

View File

@ -50,7 +50,7 @@ bool MREA::Extract(const SpecBase& dataSpec,
rs.seekAlign32(); rs.seekAlign32();
HECL::BlenderConnection& conn = HECL::BlenderConnection::SharedConnection(); HECL::BlenderConnection& conn = HECL::BlenderConnection::SharedConnection();
if (!conn.createBlend(outPath.getAbsolutePath(), HECL::BlenderConnection::TypeArea)) if (!conn.createBlend(outPath, HECL::BlenderConnection::TypeArea))
return false; return false;
/* Open Py Stream and read sections */ /* Open Py Stream and read sections */

View File

@ -38,7 +38,7 @@ struct CMDL
/* Do extract */ /* Do extract */
HECL::BlenderConnection& conn = HECL::BlenderConnection::SharedConnection(); HECL::BlenderConnection& conn = HECL::BlenderConnection::SharedConnection();
if (!conn.createBlend(outPath.getAbsolutePath(), HECL::BlenderConnection::TypeMesh)) if (!conn.createBlend(outPath, HECL::BlenderConnection::TypeMesh))
return false; return false;
DNACMDL::ReadCMDLToBlender<PAKRouter<PAKBridge>, MaterialSet, std::pair<CSKR*,CINF*>, DNACMDL::SurfaceHeader_1_2, 4> DNACMDL::ReadCMDLToBlender<PAKRouter<PAKBridge>, MaterialSet, std::pair<CSKR*,CINF*>, DNACMDL::SurfaceHeader_1_2, 4>
(conn, rs, pakRouter, entry, dataSpec, loadRp); (conn, rs, pakRouter, entry, dataSpec, loadRp);

View File

@ -18,7 +18,7 @@ struct DeafBabe : BigDNA
DECL_DNA DECL_DNA
Value<atUint64> material; Value<atUint64> material;
bool fireThrough() const {return material >> 18 & 0x1;} bool fireThrough() const {return material >> 18 & 0x1;}
void setFireThrough(bool v) {material &= 0x40000; material |= v << 18;} void setFireThrough(bool v) {material &= ~0x40000; material |= v << 18;}
enum Type enum Type
{ {
@ -34,7 +34,7 @@ struct DeafBabe : BigDNA
MatLeaves MatLeaves
}; };
Type type() const {return Type(material & 0xff);} Type type() const {return Type(material & 0xff);}
void setType(Type t) {material &= 0xff; material |= t;} void setType(Type t) {material &= ~0xff; material |= t;}
}; };
using Edge = DNAMP1::DeafBabe::Edge; using Edge = DNAMP1::DeafBabe::Edge;

View File

@ -186,7 +186,7 @@ bool MREA::Extract(const SpecBase& dataSpec,
/* Start up blender connection */ /* Start up blender connection */
HECL::BlenderConnection& conn = HECL::BlenderConnection::SharedConnection(); HECL::BlenderConnection& conn = HECL::BlenderConnection::SharedConnection();
if (!conn.createBlend(outPath.getAbsolutePath(), HECL::BlenderConnection::TypeArea)) if (!conn.createBlend(outPath, HECL::BlenderConnection::TypeArea))
return false; return false;
/* Open Py Stream and read sections */ /* Open Py Stream and read sections */

View File

@ -38,7 +38,7 @@ struct CMDL
/* Do extract */ /* Do extract */
HECL::BlenderConnection& conn = HECL::BlenderConnection::SharedConnection(); HECL::BlenderConnection& conn = HECL::BlenderConnection::SharedConnection();
if (!conn.createBlend(outPath.getAbsolutePath(), HECL::BlenderConnection::TypeMesh)) if (!conn.createBlend(outPath, HECL::BlenderConnection::TypeMesh))
return false; return false;
DNACMDL::ReadCMDLToBlender<PAKRouter<PAKBridge>, MaterialSet, std::pair<CSKR*,CINF*>, DNACMDL::SurfaceHeader_3, 5> DNACMDL::ReadCMDLToBlender<PAKRouter<PAKBridge>, MaterialSet, std::pair<CSKR*,CINF*>, DNACMDL::SurfaceHeader_3, 5>
(conn, rs, pakRouter, entry, dataSpec, loadRp); (conn, rs, pakRouter, entry, dataSpec, loadRp);

View File

@ -99,7 +99,7 @@ bool MREA::Extract(const SpecBase& dataSpec,
/* Start up blender connection */ /* Start up blender connection */
HECL::BlenderConnection& conn = HECL::BlenderConnection::SharedConnection(); HECL::BlenderConnection& conn = HECL::BlenderConnection::SharedConnection();
if (!conn.createBlend(outPath.getAbsolutePath(), HECL::BlenderConnection::TypeArea)) if (!conn.createBlend(outPath, HECL::BlenderConnection::TypeArea))
return false; return false;
/* Open Py Stream and read sections */ /* Open Py Stream and read sections */

View File

@ -93,7 +93,7 @@ bool SpecBase::canCook(const HECL::ProjectPath& path)
if (HECL::IsPathBlend(path)) if (HECL::IsPathBlend(path))
{ {
HECL::BlenderConnection& conn = HECL::BlenderConnection::SharedConnection(); HECL::BlenderConnection& conn = HECL::BlenderConnection::SharedConnection();
if (!conn.openBlend(path.getAbsolutePath())) if (!conn.openBlend(path))
return false; return false;
if (conn.getBlendType() != HECL::BlenderConnection::TypeNone) if (conn.getBlendType() != HECL::BlenderConnection::TypeNone)
return true; return true;
@ -112,21 +112,40 @@ bool SpecBase::canCook(const HECL::ProjectPath& path)
return false; return false;
} }
using Mesh = HECL::BlenderConnection::DataStream::Mesh;
void SpecBase::doCook(const HECL::ProjectPath& path, const HECL::ProjectPath& cookedPath) void SpecBase::doCook(const HECL::ProjectPath& path, const HECL::ProjectPath& cookedPath)
{ {
if (HECL::IsPathBlend(path)) if (HECL::IsPathBlend(path))
{ {
HECL::BlenderConnection& conn = HECL::BlenderConnection::SharedConnection(); HECL::BlenderConnection& conn = HECL::BlenderConnection::SharedConnection();
if (!conn.openBlend(path.getAbsolutePath())) if (!conn.openBlend(path))
return; return;
if (conn.getBlendType() == HECL::BlenderConnection::TypeMesh) switch (conn.getBlendType())
{
case HECL::BlenderConnection::TypeMesh:
{ {
HECL::BlenderConnection::DataStream ds = conn.beginData(); HECL::BlenderConnection::DataStream ds = conn.beginData();
Mesh mesh = ds.compileMesh(); cookMesh(path, ds, cookedPath);
ds.close(); break;
} }
case HECL::BlenderConnection::TypeActor:
{
HECL::BlenderConnection::DataStream ds = conn.beginData();
cookActor(path, ds, cookedPath);
break;
}
case HECL::BlenderConnection::TypeArea:
{
HECL::BlenderConnection::DataStream ds = conn.beginData();
cookArea(path, ds, cookedPath);
break;
}
default: break;
}
}
else if (HECL::IsPathYAML(path))
{
FILE* fp = HECL::Fopen(path.getAbsolutePath().c_str(), _S("r"));
cookYAML(fp, cookedPath);
} }
} }

View File

@ -45,6 +45,7 @@ struct SpecBase : HECL::Database::IDataSpec
/* Cook handlers */ /* Cook handlers */
using BlendStream = HECL::BlenderConnection::DataStream; using BlendStream = HECL::BlenderConnection::DataStream;
using Mesh = BlendStream::Mesh;
virtual void cookMesh(const HECL::ProjectPath& in, BlendStream& ds, const HECL::ProjectPath& out) const=0; virtual void cookMesh(const HECL::ProjectPath& in, BlendStream& ds, const HECL::ProjectPath& out) const=0;
virtual void cookActor(const HECL::ProjectPath& in, BlendStream& ds, const HECL::ProjectPath& out) const=0; virtual void cookActor(const HECL::ProjectPath& in, BlendStream& ds, const HECL::ProjectPath& out) const=0;
virtual void cookArea(const HECL::ProjectPath& in, BlendStream& ds, const HECL::ProjectPath& out) const=0; virtual void cookArea(const HECL::ProjectPath& in, BlendStream& ds, const HECL::ProjectPath& out) const=0;

View File

@ -7,6 +7,7 @@
#include "DNAMP1/MLVL.hpp" #include "DNAMP1/MLVL.hpp"
#include "DNAMP1/STRG.hpp" #include "DNAMP1/STRG.hpp"
#include "DNAMP1/CMDL.hpp"
namespace Retro namespace Retro
{ {
@ -281,6 +282,8 @@ struct SpecMP1 : SpecBase
void cookMesh(const HECL::ProjectPath& in, BlendStream& ds, const HECL::ProjectPath& out) const void cookMesh(const HECL::ProjectPath& in, BlendStream& ds, const HECL::ProjectPath& out) const
{ {
Mesh mesh = ds.compileMesh();
DNAMP1::CMDL::Cook(mesh, out);
} }
void cookActor(const HECL::ProjectPath& in, BlendStream& ds, const HECL::ProjectPath& out) const void cookActor(const HECL::ProjectPath& in, BlendStream& ds, const HECL::ProjectPath& out) const

2
hecl

@ -1 +1 @@
Subproject commit dd557bb7c5a3a409988d1b24d81ddd1f66791701 Subproject commit 120d22fd527452be9cc49dd601fd908cd5693555