mirror of https://github.com/AxioDL/metaforce.git
Skin intermediate outputting for mesh cooker
This commit is contained in:
parent
0ad2e69988
commit
e20837eabd
|
@ -1228,6 +1228,13 @@ bool WriteCMDL(const HECL::ProjectPath& outPath, const HECL::ProjectPath& inPath
|
|||
++padIt;
|
||||
|
||||
/* Surfaces */
|
||||
GX::Primitive prim;
|
||||
if (mesh.outputMode == Mesh::OutputTriangles)
|
||||
prim = GX::TRIANGLES;
|
||||
else if (mesh.outputMode == Mesh::OutputTriStrips)
|
||||
prim = GX::TRIANGLESTRIP;
|
||||
else
|
||||
LogDNACommon.report(LogVisor::FatalError, "unrecognized mesh output mode");
|
||||
for (const Mesh::Surface& surf : mesh.surfaces)
|
||||
{
|
||||
const typename MaterialSet::Material::VAFlags& vaFlags =
|
||||
|
@ -1241,7 +1248,7 @@ bool WriteCMDL(const HECL::ProjectPath& outPath, const HECL::ProjectPath& inPath
|
|||
header.reflectionNormal = surf.reflectionNormal;
|
||||
header.write(writer);
|
||||
|
||||
writer.writeUByte(GX::TRIANGLESTRIP);
|
||||
writer.writeUByte(prim);
|
||||
writer.writeUint16Big(surf.verts.size());
|
||||
|
||||
for (const Mesh::Surface::Vert& vert : surf.verts)
|
||||
|
|
|
@ -53,7 +53,7 @@ struct CMDL
|
|||
/* Cook and re-extract test */
|
||||
HECL::ProjectPath tempOut = outPath.getWithExtension(_S(".recook"), true);
|
||||
HECL::BlenderConnection::DataStream ds = conn.beginData();
|
||||
HECL::BlenderConnection::DataStream::Mesh mesh = ds.compileMesh(-1);
|
||||
DNACMDL::Mesh mesh = ds.compileMesh(DNACMDL::Mesh::OutputTriStrips, -1);
|
||||
ds.close();
|
||||
DNACMDL::WriteCMDL<MaterialSet, DNACMDL::SurfaceHeader_1_2, 2>(tempOut, outPath, mesh);
|
||||
|
||||
|
@ -71,7 +71,33 @@ struct CMDL
|
|||
const DNACMDL::Mesh& mesh)
|
||||
{
|
||||
HECL::ProjectPath tempOut = outPath.getWithExtension(_S(".recook"));
|
||||
return DNACMDL::WriteCMDL<MaterialSet, DNACMDL::SurfaceHeader_1_2, 2>(tempOut, inPath, mesh);
|
||||
if (mesh.skins.size())
|
||||
{
|
||||
DNACMDL::Mesh skinMesh = mesh.getContiguousSkinningVersion();
|
||||
if (!DNACMDL::WriteCMDL<MaterialSet, DNACMDL::SurfaceHeader_1_2, 2>(tempOut, inPath, skinMesh))
|
||||
return false;
|
||||
|
||||
/* Output skinning intermediate */
|
||||
auto vertCountIt = skinMesh.contiguousSkinVertCounts.cbegin();
|
||||
Athena::io::FileWriter writer(outPath.getWithExtension(_S(".skin")).getAbsolutePath());
|
||||
writer.writeUint32Big(skinMesh.skins.size());
|
||||
for (const std::vector<DNACMDL::Mesh::SkinBind> skin : skinMesh.skins)
|
||||
{
|
||||
writer.writeUint32Big(skin.size());
|
||||
for (const DNACMDL::Mesh::SkinBind& bind : skin)
|
||||
{
|
||||
writer.writeUint32Big(bind.boneIdx);
|
||||
writer.writeFloatBig(bind.weight);
|
||||
}
|
||||
writer.writeUint32Big(*vertCountIt++);
|
||||
}
|
||||
writer.writeUint32Big(skinMesh.boneNames.size());
|
||||
for (const std::string& boneName : skinMesh.boneNames)
|
||||
writer.writeString(boneName);
|
||||
}
|
||||
else if (!DNACMDL::WriteCMDL<MaterialSet, DNACMDL::SurfaceHeader_1_2, 2>(tempOut, inPath, mesh))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -581,6 +581,20 @@ static void AddTEVStage(Stream& out, const MaterialSet::Material::TEVStage& stag
|
|||
AddColorCombiner(out, COMB_ADD, cd, ca, nullptr);
|
||||
++c_combiner_idx;
|
||||
}
|
||||
else if (stage.colorInA() != GX::CC_ZERO &&
|
||||
stage.colorInB() == GX::CC_ZERO &&
|
||||
stage.colorInC() == GX::CC_ZERO &&
|
||||
stage.colorInD() == GX::CC_ZERO)
|
||||
{
|
||||
c_tev_opts |= 0xf;
|
||||
}
|
||||
else if (stage.colorInA() == GX::CC_ZERO &&
|
||||
stage.colorInB() == GX::CC_ZERO &&
|
||||
stage.colorInC() == GX::CC_ZERO &&
|
||||
stage.colorInD() != GX::CC_ZERO)
|
||||
{
|
||||
c_tev_opts |= 0xf;
|
||||
}
|
||||
|
||||
if (!(c_tev_opts & 1))
|
||||
{
|
||||
|
@ -655,6 +669,20 @@ static void AddTEVStage(Stream& out, const MaterialSet::Material::TEVStage& stag
|
|||
AddAlphaCombiner(out, COMB_ADD, ad, aa, nullptr);
|
||||
++a_combiner_idx;
|
||||
}
|
||||
else if (stage.alphaInA() != GX::CA_ZERO &&
|
||||
stage.alphaInB() == GX::CA_ZERO &&
|
||||
stage.alphaInC() == GX::CA_ZERO &&
|
||||
stage.alphaInD() == GX::CA_ZERO)
|
||||
{
|
||||
a_tev_opts |= 0xf;
|
||||
}
|
||||
else if (stage.alphaInA() == GX::CA_ZERO &&
|
||||
stage.alphaInB() == GX::CA_ZERO &&
|
||||
stage.alphaInC() == GX::CA_ZERO &&
|
||||
stage.alphaInD() != GX::CA_ZERO)
|
||||
{
|
||||
a_tev_opts |= 0xf;
|
||||
}
|
||||
|
||||
if (!(a_tev_opts & 1))
|
||||
{
|
||||
|
@ -713,6 +741,8 @@ static void AddTEVStage(Stream& out, const MaterialSet::Material::TEVStage& stag
|
|||
{
|
||||
if (stage.colorInD() != GX::CC_ZERO)
|
||||
strncpy(c_regs[stage.colorOpOutReg()], cd, 64);
|
||||
else if (stage.colorInA() != GX::CC_ZERO)
|
||||
strncpy(c_regs[stage.colorOpOutReg()], ca, 64);
|
||||
}
|
||||
else
|
||||
snprintf(c_regs[stage.colorOpOutReg()], 64, "color_combiner_sockets[%u]", c_combiner_idx - 1);
|
||||
|
@ -720,6 +750,8 @@ static void AddTEVStage(Stream& out, const MaterialSet::Material::TEVStage& stag
|
|||
{
|
||||
if (stage.alphaInD() != GX::CA_ZERO)
|
||||
strncpy(a_regs[stage.alphaOpOutReg()], ad, 64);
|
||||
else if (stage.alphaInA() != GX::CA_ZERO)
|
||||
strncpy(a_regs[stage.alphaOpOutReg()], aa, 64);
|
||||
}
|
||||
else
|
||||
snprintf(a_regs[stage.alphaOpOutReg()], 64, "alpha_combiner_sockets[%u]", a_combiner_idx - 1);
|
||||
|
|
|
@ -112,7 +112,8 @@ bool SpecBase::canCook(const HECL::ProjectPath& path)
|
|||
return false;
|
||||
}
|
||||
|
||||
void SpecBase::doCook(const HECL::ProjectPath& path, const HECL::ProjectPath& cookedPath)
|
||||
void SpecBase::doCook(const HECL::ProjectPath& path, const HECL::ProjectPath& cookedPath,
|
||||
bool fast, FCookProgress progress)
|
||||
{
|
||||
if (HECL::IsPathBlend(path))
|
||||
{
|
||||
|
@ -124,19 +125,19 @@ void SpecBase::doCook(const HECL::ProjectPath& path, const HECL::ProjectPath& co
|
|||
case HECL::BlenderConnection::TypeMesh:
|
||||
{
|
||||
HECL::BlenderConnection::DataStream ds = conn.beginData();
|
||||
cookMesh(cookedPath, path, ds);
|
||||
cookMesh(cookedPath, path, ds, fast, progress);
|
||||
break;
|
||||
}
|
||||
case HECL::BlenderConnection::TypeActor:
|
||||
{
|
||||
HECL::BlenderConnection::DataStream ds = conn.beginData();
|
||||
cookActor(cookedPath, path, ds);
|
||||
cookActor(cookedPath, path, ds, fast, progress);
|
||||
break;
|
||||
}
|
||||
case HECL::BlenderConnection::TypeArea:
|
||||
{
|
||||
HECL::BlenderConnection::DataStream ds = conn.beginData();
|
||||
cookArea(cookedPath, path, ds);
|
||||
cookArea(cookedPath, path, ds, fast, progress);
|
||||
break;
|
||||
}
|
||||
default: break;
|
||||
|
@ -145,7 +146,7 @@ void SpecBase::doCook(const HECL::ProjectPath& path, const HECL::ProjectPath& co
|
|||
else if (HECL::IsPathYAML(path))
|
||||
{
|
||||
FILE* fp = HECL::Fopen(path.getAbsolutePath().c_str(), _S("r"));
|
||||
cookYAML(cookedPath, path, fp);
|
||||
cookYAML(cookedPath, path, fp, progress);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ struct SpecBase : HECL::Database::IDataSpec
|
|||
void doExtract(const ExtractPassInfo& info, FProgress progress);
|
||||
|
||||
bool canCook(const HECL::ProjectPath& path);
|
||||
void doCook(const HECL::ProjectPath& path, const HECL::ProjectPath& cookedPath);
|
||||
void doCook(const HECL::ProjectPath& path, const HECL::ProjectPath& cookedPath, bool fast, FCookProgress progress);
|
||||
|
||||
bool canPackage(const PackagePassInfo& info);
|
||||
void gatherDependencies(const PackagePassInfo& info,
|
||||
|
@ -47,10 +47,10 @@ struct SpecBase : HECL::Database::IDataSpec
|
|||
using BlendStream = HECL::BlenderConnection::DataStream;
|
||||
using Mesh = BlendStream::Mesh;
|
||||
|
||||
virtual void cookMesh(const HECL::ProjectPath& out, const HECL::ProjectPath& in, BlendStream& ds) const=0;
|
||||
virtual void cookActor(const HECL::ProjectPath& out, const HECL::ProjectPath& in, BlendStream& ds) const=0;
|
||||
virtual void cookArea(const HECL::ProjectPath& out, const HECL::ProjectPath& in, BlendStream& ds) const=0;
|
||||
virtual void cookYAML(const HECL::ProjectPath& out, const HECL::ProjectPath& in, FILE* fin) const=0;
|
||||
virtual void cookMesh(const HECL::ProjectPath& out, const HECL::ProjectPath& in, BlendStream& ds, bool fast, FCookProgress progress) const=0;
|
||||
virtual void cookActor(const HECL::ProjectPath& out, const HECL::ProjectPath& in, BlendStream& ds, bool fast, FCookProgress progress) const=0;
|
||||
virtual void cookArea(const HECL::ProjectPath& out, const HECL::ProjectPath& in, BlendStream& ds, bool fast, FCookProgress progress) const=0;
|
||||
virtual void cookYAML(const HECL::ProjectPath& out, const HECL::ProjectPath& in, FILE* fin, FCookProgress progress) const=0;
|
||||
|
||||
const HECL::ProjectPath& getMasterShaderPath() const {return m_masterShader;}
|
||||
|
||||
|
|
|
@ -280,21 +280,29 @@ struct SpecMP1 : SpecBase
|
|||
return false;
|
||||
}
|
||||
|
||||
void cookMesh(const HECL::ProjectPath& out, const HECL::ProjectPath& in, BlendStream& ds) const
|
||||
void cookMesh(const HECL::ProjectPath& out, const HECL::ProjectPath& in,
|
||||
BlendStream& ds, bool fast, FCookProgress progress) const
|
||||
{
|
||||
Mesh mesh = ds.compileMesh(-1);
|
||||
Mesh mesh = ds.compileMesh(fast ? Mesh::OutputTriangles : Mesh::OutputTriStrips, -1,
|
||||
[&progress](int surfCount)
|
||||
{
|
||||
progress(HECL::SysFormat(_S("%d"), surfCount).c_str());
|
||||
});
|
||||
DNAMP1::CMDL::Cook(out, in, mesh);
|
||||
}
|
||||
|
||||
void cookActor(const HECL::ProjectPath& out, const HECL::ProjectPath& in, BlendStream& ds) const
|
||||
void cookActor(const HECL::ProjectPath& out, const HECL::ProjectPath& in,
|
||||
BlendStream& ds, bool fast, FCookProgress progress) const
|
||||
{
|
||||
}
|
||||
|
||||
void cookArea(const HECL::ProjectPath& out, const HECL::ProjectPath& in, BlendStream& ds) const
|
||||
void cookArea(const HECL::ProjectPath& out, const HECL::ProjectPath& in,
|
||||
BlendStream& ds, bool fast, FCookProgress progress) const
|
||||
{
|
||||
}
|
||||
|
||||
void cookYAML(const HECL::ProjectPath& out, const HECL::ProjectPath& in, FILE* fin) const
|
||||
void cookYAML(const HECL::ProjectPath& out, const HECL::ProjectPath& in,
|
||||
FILE* fin, FCookProgress progress) const
|
||||
{
|
||||
}
|
||||
};
|
||||
|
|
|
@ -271,19 +271,23 @@ struct SpecMP2 : SpecBase
|
|||
return false;
|
||||
}
|
||||
|
||||
void cookMesh(const HECL::ProjectPath& out, const HECL::ProjectPath& in, BlendStream& ds) const
|
||||
void cookMesh(const HECL::ProjectPath& out, const HECL::ProjectPath& in,
|
||||
BlendStream& ds, bool fast, FCookProgress progress) const
|
||||
{
|
||||
}
|
||||
|
||||
void cookActor(const HECL::ProjectPath& out, const HECL::ProjectPath& in, BlendStream& ds) const
|
||||
void cookActor(const HECL::ProjectPath& out, const HECL::ProjectPath& in,
|
||||
BlendStream& ds, bool fast, FCookProgress progress) const
|
||||
{
|
||||
}
|
||||
|
||||
void cookArea(const HECL::ProjectPath& out, const HECL::ProjectPath& in, BlendStream& ds) const
|
||||
void cookArea(const HECL::ProjectPath& out, const HECL::ProjectPath& in,
|
||||
BlendStream& ds, bool fast, FCookProgress progress) const
|
||||
{
|
||||
}
|
||||
|
||||
void cookYAML(const HECL::ProjectPath& out, const HECL::ProjectPath& in, FILE* fin) const
|
||||
void cookYAML(const HECL::ProjectPath& out, const HECL::ProjectPath& in,
|
||||
FILE* fin, FCookProgress progress) const
|
||||
{
|
||||
}
|
||||
};
|
||||
|
|
|
@ -453,19 +453,23 @@ struct SpecMP3 : SpecBase
|
|||
return false;
|
||||
}
|
||||
|
||||
void cookMesh(const HECL::ProjectPath& out, const HECL::ProjectPath& in, BlendStream& ds) const
|
||||
void cookMesh(const HECL::ProjectPath& out, const HECL::ProjectPath& in,
|
||||
BlendStream& ds, bool fast, FCookProgress progress) const
|
||||
{
|
||||
}
|
||||
|
||||
void cookActor(const HECL::ProjectPath& out, const HECL::ProjectPath& in, BlendStream& ds) const
|
||||
void cookActor(const HECL::ProjectPath& out, const HECL::ProjectPath& in,
|
||||
BlendStream& ds, bool fast, FCookProgress progress) const
|
||||
{
|
||||
}
|
||||
|
||||
void cookArea(const HECL::ProjectPath& out, const HECL::ProjectPath& in, BlendStream& ds) const
|
||||
void cookArea(const HECL::ProjectPath& out, const HECL::ProjectPath& in,
|
||||
BlendStream& ds, bool fast, FCookProgress progress) const
|
||||
{
|
||||
}
|
||||
|
||||
void cookYAML(const HECL::ProjectPath& out, const HECL::ProjectPath& in, FILE* fin) const
|
||||
void cookYAML(const HECL::ProjectPath& out, const HECL::ProjectPath& in,
|
||||
FILE* fin, FCookProgress progress) const
|
||||
{
|
||||
}
|
||||
};
|
||||
|
|
2
hecl
2
hecl
|
@ -1 +1 @@
|
|||
Subproject commit 43498db9f7a56f46ba8844c83113c5d8e2fb7adc
|
||||
Subproject commit 8d513577cb199a8e567119fe45356b75ab3700ed
|
Loading…
Reference in New Issue