Work on cooking features

This commit is contained in:
Jack Andersen 2015-09-30 14:40:21 -10:00
parent 5f68a2a992
commit 1f9c8811d2
21 changed files with 152 additions and 27 deletions

View File

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

View File

@ -51,7 +51,7 @@ bool ReadANCSToBlender(HECL::BlenderConnection& conn,
HECL::ProjectPath cmdlPath = pakRouter.getWorking(cmdlE);
if (force || cmdlPath.getPathType() == HECL::ProjectPath::PT_NONE)
{
if (!conn.createBlend(cmdlPath.getAbsolutePath()))
if (!conn.createBlend(cmdlPath.getAbsolutePath(), HECL::BlenderConnection::TypeMesh))
return false;
HECL::SystemStringView bestNameView(pakRouter.getBestEntryName(*cmdlE));
@ -77,14 +77,13 @@ bool ReadANCSToBlender(HECL::BlenderConnection& conn,
fileChanged(bestNameView.sys_str().c_str());
/* Establish ANCS blend */
if (!conn.createBlend(outPath.getAbsolutePath()))
if (!conn.createBlend(outPath.getAbsolutePath(), HECL::BlenderConnection::TypeActor))
return false;
HECL::BlenderConnection::PyOutStream os = conn.beginPythonOut(true);
os.format("import bpy\n"
"from mathutils import Vector\n"
"bpy.context.scene.name = '%s'\n"
"bpy.context.scene.hecl_type = 'ACTOR'\n"
"bpy.context.scene.hecl_mesh_obj = bpy.context.scene.name\n"
"\n"
"# Using 'Blender Game'\n"

View File

@ -1001,7 +1001,6 @@ bool ReadCMDLToBlender(HECL::BlenderConnection& conn,
"import bmesh\n"
"\n"
"bpy.context.scene.name = '%s'\n"
"bpy.context.scene.hecl_type = 'MESH'\n"
"bpy.context.scene.hecl_mesh_obj = bpy.context.scene.name\n",
pakRouter.getBestEntryName(entry).c_str());
InitGeomBlenderContext(os, dataspec.getMasterShaderPath());

View File

@ -118,6 +118,11 @@ void ANCS::CharacterSet::CharacterInfo::PASDatabase::AnimState::ParmInfo::toYAML
writer.leaveSubVector();
}
const char* ANCS::CharacterSet::CharacterInfo::PASDatabase::AnimState::ParmInfo::DNAType()
{
return "Retro::DNAMP1::ANCS::CharacterSet::CharacterInfo::PASDatabase::AnimState::ParmInfo";
}
void ANCS::CharacterSet::CharacterInfo::PASDatabase::AnimState::read(Athena::io::IStreamReader& reader)
{
id = reader.readUint32Big();
@ -274,6 +279,11 @@ void ANCS::CharacterSet::CharacterInfo::PASDatabase::AnimState::toYAML(Athena::i
});
}
const char* ANCS::CharacterSet::CharacterInfo::PASDatabase::AnimState::DNAType()
{
return "Retro::DNAMP1::ANCS::CharacterSet::CharacterInfo::PASDatabase::AnimState";
}
void ANCS::CharacterSet::CharacterInfo::read(Athena::io::IStreamReader& reader)
{
idx = reader.readUint32Big();
@ -537,6 +547,11 @@ void ANCS::CharacterSet::CharacterInfo::toYAML(Athena::io::YAMLDocWriter& writer
}
}
const char* ANCS::CharacterSet::CharacterInfo::DNAType()
{
return "Retro::DNAMP1::ANCS::CharacterSet::CharacterInfo";
}
void ANCS::AnimationSet::MetaAnimFactory::read(Athena::io::IStreamReader& reader)
{
IMetaAnim::Type type(IMetaAnim::Type(reader.readUint32Big()));
@ -620,6 +635,11 @@ void ANCS::AnimationSet::MetaAnimFactory::toYAML(Athena::io::YAMLDocWriter& writ
m_anim->toYAML(writer);
}
const char* ANCS::AnimationSet::MetaAnimFactory::DNAType()
{
return "Retro::DNAMP1::ANCS::AnimationSet::MetaAnimFactory";
}
void ANCS::AnimationSet::MetaTransFactory::read(Athena::io::IStreamReader& reader)
{
IMetaTrans::Type type(IMetaTrans::Type(reader.readUint32Big()));
@ -692,6 +712,11 @@ void ANCS::AnimationSet::MetaTransFactory::toYAML(Athena::io::YAMLDocWriter& wri
m_trans->toYAML(writer);
}
const char* ANCS::AnimationSet::MetaTransFactory::DNAType()
{
return "Retro::DNAMP1::ANCS::AnimationSet::MetaTransFactory";
}
void ANCS::AnimationSet::read(Athena::io::IStreamReader& reader)
{
atUint16 sectionCount = reader.readUint16Big();
@ -846,6 +871,11 @@ void ANCS::AnimationSet::toYAML(Athena::io::YAMLDocWriter& writer) const
}
}
const char* ANCS::AnimationSet::DNAType()
{
return "Retro::DNAMP1::ANCS::AnimationSet";
}
}
}

View File

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

View File

@ -49,7 +49,7 @@ bool MREA::Extract(const SpecBase& dataSpec,
rs.seekAlign32();
HECL::BlenderConnection& conn = HECL::BlenderConnection::SharedConnection();
if (!conn.createBlend(outPath.getAbsolutePath()))
if (!conn.createBlend(outPath.getAbsolutePath(), HECL::BlenderConnection::TypeArea))
return false;
/* Open Py Stream and read sections */
@ -58,8 +58,7 @@ bool MREA::Extract(const SpecBase& dataSpec,
"import bmesh\n"
"from mathutils import Vector\n"
"\n"
"bpy.context.scene.name = '%s'\n"
"bpy.context.scene.hecl_type = 'AREA'\n",
"bpy.context.scene.name = '%s'\n",
pakRouter.getBestEntryName(entry).c_str());
DNACMDL::InitGeomBlenderContext(os, dataSpec.getMasterShaderPath());
MaterialSet::RegisterMaterialProps(os);

View File

@ -171,5 +171,10 @@ void STRG::toYAML(Athena::io::YAMLDocWriter& writer) const
}
}
const char* STRG::DNAType()
{
return "Retro::DNAMP1::STRG";
}
}
}

View File

@ -318,6 +318,11 @@ void ANCS::CharacterSet::CharacterInfo::toYAML(Athena::io::YAMLDocWriter& writer
}
}
const char* ANCS::CharacterSet::CharacterInfo::DNAType()
{
return "Retro::DNAMP2::ANCS::CharacterSet::CharacterInfo";
}
void ANCS::AnimationSet::read(Athena::io::IStreamReader& reader)
{
atUint16 sectionCount = reader.readUint16Big();
@ -472,6 +477,11 @@ void ANCS::AnimationSet::toYAML(Athena::io::YAMLDocWriter& writer) const
}
}
const char* ANCS::AnimationSet::DNAType()
{
return "Retro::DNAMP2::ANCS::AnimationSet";
}
void ANCS::AnimationSet::EVNT::read(Athena::io::IStreamReader& reader)
{
version = reader.readUint32Big();
@ -554,5 +564,10 @@ void ANCS::AnimationSet::EVNT::toYAML(Athena::io::YAMLDocWriter& writer) const
writer.enumerate("sfxEvents", sfxEvents);
}
const char* ANCS::AnimationSet::EVNT::DNAType()
{
return "Retro::DNAMP2::ANCS::AnimationSet::EVNT";
}
}
}

View File

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

View File

@ -186,7 +186,7 @@ bool MREA::Extract(const SpecBase& dataSpec,
/* Start up blender connection */
HECL::BlenderConnection& conn = HECL::BlenderConnection::SharedConnection();
if (!conn.createBlend(outPath.getAbsolutePath()))
if (!conn.createBlend(outPath.getAbsolutePath(), HECL::BlenderConnection::TypeArea))
return false;
/* Open Py Stream and read sections */
@ -195,8 +195,7 @@ bool MREA::Extract(const SpecBase& dataSpec,
"import bmesh\n"
"from mathutils import Vector\n"
"\n"
"bpy.context.scene.name = '%s'\n"
"bpy.context.scene.hecl_type = 'AREA'\n",
"bpy.context.scene.name = '%s'\n",
pakRouter.getBestEntryName(entry).c_str());
DNACMDL::InitGeomBlenderContext(os, dataSpec.getMasterShaderPath());
MaterialSet::RegisterMaterialProps(os);

View File

@ -218,5 +218,10 @@ void STRG::toYAML(Athena::io::YAMLDocWriter& writer) const
}
}
const char* STRG::DNAType()
{
return "Retro::DNAMP2::STRG";
}
}
}

View File

@ -61,6 +61,11 @@ void CHAR::AnimationInfo::EVNT::SFXEvent::toYAML(Athena::io::YAMLDocWriter& writ
writer.writeFloat("extraFloat", extraFloat);
}
const char* CHAR::AnimationInfo::EVNT::SFXEvent::DNAType()
{
return "Retro::DNAMP3::CHAR::AnimationInfo::EVNT::SFXEvent";
}
void CHAR::AnimationInfo::MetaAnimFactory::read(Athena::io::IStreamReader& reader)
{
IMetaAnim::Type type(IMetaAnim::Type(reader.readUint32Big()));
@ -144,5 +149,10 @@ void CHAR::AnimationInfo::MetaAnimFactory::toYAML(Athena::io::YAMLDocWriter& wri
m_anim->toYAML(writer);
}
const char* CHAR::AnimationInfo::MetaAnimFactory::DNAType()
{
return "Retro::DNAMP3::CHAR::AnimationInfo::MetaAnimFactory";
}
}
}

View File

@ -20,8 +20,8 @@ struct CMDL
const HECL::ProjectPath& outPath,
PAKRouter<PAKBridge>& pakRouter,
const PAK::Entry& entry,
bool force,
std::function<void(const HECL::SystemChar*)> fileChanged)
bool,
std::function<void(const HECL::SystemChar*)>)
{
/* Check for RigPair */
const PAKRouter<PAKBridge>::RigPair* rp = pakRouter.lookupCMDLRigPair(entry.id);
@ -38,7 +38,7 @@ struct CMDL
/* Do extract */
HECL::BlenderConnection& conn = HECL::BlenderConnection::SharedConnection();
if (!conn.createBlend(outPath.getAbsolutePath()))
if (!conn.createBlend(outPath.getAbsolutePath(), HECL::BlenderConnection::TypeMesh))
return false;
DNACMDL::ReadCMDLToBlender<PAKRouter<PAKBridge>, MaterialSet, std::pair<CSKR*,CINF*>, DNACMDL::SurfaceHeader_3, 5>
(conn, rs, pakRouter, entry, dataSpec, loadRp);

View File

@ -99,7 +99,7 @@ bool MREA::Extract(const SpecBase& dataSpec,
/* Start up blender connection */
HECL::BlenderConnection& conn = HECL::BlenderConnection::SharedConnection();
if (!conn.createBlend(outPath.getAbsolutePath()))
if (!conn.createBlend(outPath.getAbsolutePath(), HECL::BlenderConnection::TypeArea))
return false;
/* Open Py Stream and read sections */
@ -108,8 +108,7 @@ bool MREA::Extract(const SpecBase& dataSpec,
"import bmesh\n"
"from mathutils import Vector\n"
"\n"
"bpy.context.scene.name = '%s'\n"
"bpy.context.scene.hecl_type = 'AREA'\n",
"bpy.context.scene.name = '%s'\n",
pakRouter.getBestEntryName(entry).c_str());
DNACMDL::InitGeomBlenderContext(os, dataSpec.getMasterShaderPath());
MaterialSet::RegisterMaterialProps(os);

View File

@ -234,5 +234,10 @@ void STRG::toYAML(Athena::io::YAMLDocWriter& writer) const
}
}
const char* STRG::DNAType()
{
return "Retro::DNAMP3::STRG";
}
}
}

View File

@ -1,5 +1,6 @@
#include "SpecBase.hpp"
#include "Blender/BlenderSupport.hpp"
#include "BlenderConnection.hpp"
namespace Retro
{
@ -52,7 +53,7 @@ void SpecBase::doExtract(const ExtractPassInfo& info, FProgress progress)
if (m_isWii)
{
/* Extract update partition for repacking later */
const HECL::SystemString& target = m_project.getProjectRootPath().getAbsolutePath();
const HECL::SystemString& target = m_project.getProjectWorkingPath().getAbsolutePath();
NOD::DiscBase::IPartition* update = m_disc->getUpdatePartition();
NOD::ExtractionContext ctx = {true, info.force, nullptr};
@ -87,6 +88,25 @@ void SpecBase::doExtract(const ExtractPassInfo& info, FProgress progress)
bool SpecBase::canCook(const HECL::ProjectPath& path)
{
if (HECL::IsPathBlend(path))
{
HECL::BlenderConnection& conn = HECL::BlenderConnection::SharedConnection();
if (!conn.openBlend(path.getAbsolutePath()))
return false;
if (conn.getBlendType() != HECL::BlenderConnection::TypeNone)
return true;
}
else if (HECL::IsPathPNG(path))
{
return true;
}
else if (HECL::IsPathYAML(path))
{
FILE* fp = HECL::Fopen(path.getAbsolutePath().c_str(), _S("r"));
bool retval = validateYAMLDNAType(fp);
fclose(fp);
return retval;
}
return false;
}

View File

@ -34,12 +34,13 @@ struct SpecBase : HECL::Database::IDataSpec
virtual bool extractFromDisc(NOD::DiscBase& disc, bool force,
FProgress progress)=0;
virtual bool validateYAMLDNAType(FILE* fp) const=0;
const HECL::ProjectPath& getMasterShaderPath() const {return m_masterShader;}
SpecBase(HECL::Database::Project& project)
: m_project(project),
m_masterShader(project.getProjectRootPath(), ".hecl/RetroMasterShader.blend") {}
m_masterShader(project.getProjectWorkingPath(), ".hecl/RetroMasterShader.blend") {}
protected:
HECL::Database::Project& m_project;
HECL::ProjectPath m_masterShader;

View File

@ -5,6 +5,9 @@
#include "SpecBase.hpp"
#include "DNAMP1/DNAMP1.hpp"
#include "DNAMP1/MLVL.hpp"
#include "DNAMP1/STRG.hpp"
namespace Retro
{
@ -30,7 +33,7 @@ struct SpecMP1 : SpecBase
SpecMP1(HECL::Database::Project& project)
: SpecBase(project),
m_workPath(project.getProjectRootPath(), _S("MP1")),
m_workPath(project.getProjectWorkingPath(), _S("MP1")),
m_cookPath(project.getProjectCookedPath(SpecEntMP1), _S("MP1")),
m_pakRouter(*this, m_workPath, m_cookPath) {}
@ -259,6 +262,15 @@ struct SpecMP1 : SpecBase
return true;
}
bool validateYAMLDNAType(FILE* fp) const
{
if (BigYAML::ValidateFromYAMLFile<DNAMP1::MLVL>(fp))
return true;
if (BigYAML::ValidateFromYAMLFile<DNAMP1::STRG>(fp))
return true;
return false;
}
};
HECL::Database::DataSpecEntry SpecEntMP1 =

View File

@ -3,6 +3,9 @@
#include "SpecBase.hpp"
#include "DNAMP2/DNAMP2.hpp"
#include "DNAMP2/MLVL.hpp"
#include "DNAMP2/STRG.hpp"
namespace Retro
{
@ -28,7 +31,7 @@ struct SpecMP2 : SpecBase
SpecMP2(HECL::Database::Project& project)
: SpecBase(project),
m_workPath(project.getProjectRootPath(), _S("MP2")),
m_workPath(project.getProjectWorkingPath(), _S("MP2")),
m_cookPath(project.getProjectCookedPath(SpecEntMP2), _S("MP2")),
m_pakRouter(*this, m_workPath, m_cookPath) {}
@ -251,6 +254,15 @@ struct SpecMP2 : SpecBase
return true;
}
bool validateYAMLDNAType(FILE* fp) const
{
if (BigYAML::ValidateFromYAMLFile<DNAMP2::MLVL>(fp))
return true;
if (BigYAML::ValidateFromYAMLFile<DNAMP2::STRG>(fp))
return true;
return false;
}
};
HECL::Database::DataSpecEntry SpecEntMP2

View File

@ -4,6 +4,10 @@
#include "SpecBase.hpp"
#include "DNAMP3/DNAMP3.hpp"
#include "DNAMP3/MLVL.hpp"
#include "DNAMP3/STRG.hpp"
#include "DNAMP2/STRG.hpp"
namespace Retro
{
@ -40,10 +44,10 @@ struct SpecMP3 : SpecBase
SpecMP3(HECL::Database::Project& project)
: SpecBase(project),
m_workPath(project.getProjectRootPath(), _S("MP3")),
m_workPath(project.getProjectWorkingPath(), _S("MP3")),
m_cookPath(project.getProjectCookedPath(SpecEntMP3), _S("MP3")),
m_pakRouter(*this, m_workPath, m_cookPath),
m_feWorkPath(project.getProjectRootPath(), _S("fe")),
m_feWorkPath(project.getProjectWorkingPath(), _S("fe")),
m_feCookPath(project.getProjectCookedPath(SpecEntMP3), _S("fe")),
m_fePakRouter(*this, m_feWorkPath, m_feCookPath) {}
@ -340,7 +344,7 @@ struct SpecMP3 : SpecBase
});
progress(_S("Indexing PAKs"), _S(""), compIdx++, 1.0);
HECL::ProjectPath mp3WorkPath(m_project.getProjectRootPath(), "MP3");
HECL::ProjectPath mp3WorkPath(m_project.getProjectWorkingPath(), "MP3");
mp3WorkPath.makeDir();
currentTarget = _S("MP3 Root");
progress(currentTarget.c_str(), _S(""), compIdx, 0.0);
@ -430,6 +434,17 @@ struct SpecMP3 : SpecBase
}
return true;
}
bool validateYAMLDNAType(FILE* fp) const
{
if (BigYAML::ValidateFromYAMLFile<DNAMP3::MLVL>(fp))
return true;
if (BigYAML::ValidateFromYAMLFile<DNAMP3::STRG>(fp))
return true;
if (BigYAML::ValidateFromYAMLFile<DNAMP2::STRG>(fp))
return true;
return false;
}
};
HECL::Database::DataSpecEntry SpecEntMP3

2
hecl

@ -1 +1 @@
Subproject commit aae0f7390ff6a7fcf81df423a7fe66091713b7da
Subproject commit e8544adf496c1aeb2b9be212fa34cfc295e807a8