This commit is contained in:
Phillip Stephens 2016-04-10 22:14:02 -07:00
commit b533069925
99 changed files with 2668 additions and 408 deletions

View File

@ -1,13 +1,14 @@
#include "DNACommon.hpp"
#include "PAK.hpp"
#include "boo/ThreadLocalPtr.hpp"
namespace DataSpec
{
logvisor::Module LogDNACommon("urde::DNACommon");
SpecBase* g_curSpec = nullptr;
PAKRouterBase* g_PakRouter = nullptr;
hecl::Database::Project* UniqueIDBridge::s_Project = nullptr;
ThreadLocalPtr<SpecBase> g_curSpec;
ThreadLocalPtr<PAKRouterBase> g_PakRouter;
ThreadLocalPtr<hecl::Database::Project> UniqueIDBridge::s_Project;
UniqueID32 UniqueID32::kInvalidId;
}

View File

@ -7,13 +7,14 @@
#include "hecl/hecl.hpp"
#include "hecl/Database.hpp"
#include "../SpecBase.hpp"
#include "boo/ThreadLocalPtr.hpp"
namespace DataSpec
{
extern logvisor::Module LogDNACommon;
extern SpecBase* g_curSpec;
extern class PAKRouterBase* g_PakRouter;
extern ThreadLocalPtr<SpecBase> g_curSpec;
extern ThreadLocalPtr<class PAKRouterBase> g_PakRouter;
/* This comes up a great deal */
typedef athena::io::DNA<athena::BigEndian> BigDNA;
@ -84,22 +85,24 @@ class UniqueIDBridge
friend class UniqueID32;
friend class UniqueID64;
static hecl::Database::Project* s_Project;
static ThreadLocalPtr<hecl::Database::Project> s_Project;
public:
template <class IDType>
static hecl::ProjectPath TranslatePakIdToPath(const IDType& id, bool silenceWarnings=false)
{
if (!g_PakRouter)
PAKRouterBase* pakRouter = g_PakRouter.get();
if (!pakRouter)
LogDNACommon.report(logvisor::Fatal,
"g_Project must be set to non-null before calling UniqueIDBridge::TranslatePakIdToPath");
return g_PakRouter->getWorking(id, silenceWarnings);
return pakRouter->getWorking(id, silenceWarnings);
}
static hecl::ProjectPath MakePathFromString(const std::string& str)
{
if (!s_Project)
hecl::Database::Project* project = s_Project.get();
if (!project)
LogDNACommon.report(logvisor::Fatal,
"UniqueIDBridge::setGlobalProject must be called before MakePathFromString");
return hecl::ProjectPath(*s_Project, str);
return hecl::ProjectPath(*project, str);
}
template <class IDType>
static void TransformOldHashToNewHash(IDType& id)
@ -109,7 +112,7 @@ public:
static void setGlobalProject(hecl::Database::Project& project)
{
s_Project = &project;
s_Project.reset(&project);
}
};

View File

@ -224,7 +224,7 @@ void PAKRouter<BRIDGETYPE>::build(std::vector<BRIDGETYPE>& bridges, std::functio
template <class BRIDGETYPE>
void PAKRouter<BRIDGETYPE>::enterPAKBridge(const BRIDGETYPE& pakBridge)
{
g_PakRouter = this;
g_PakRouter.reset(this);
auto pit = m_bridgePaths.begin();
size_t bridgeIdx = 0;
for (const BRIDGETYPE& bridge : *m_bridges)

View File

@ -2,6 +2,8 @@
namespace DataSpec
{
extern hecl::Database::DataSpecEntry SpecEntMP1PC;
namespace DNAMP1
{
@ -1005,6 +1007,255 @@ const char* ANCS::AnimationSet::DNAType()
return "urde::DNAMP1::ANCS::AnimationSet";
}
bool ANCS::Extract(const SpecBase& dataSpec,
PAKEntryReadStream& rs,
const hecl::ProjectPath& outPath,
PAKRouter<PAKBridge>& pakRouter,
const PAK::Entry& entry,
bool force,
hecl::BlenderToken& btok,
std::function<void(const hecl::SystemChar*)> fileChanged)
{
hecl::ProjectPath yamlPath = outPath.getWithExtension(_S(".yaml"));
hecl::ProjectPath::Type yamlType = yamlPath.getPathType();
hecl::ProjectPath blendPath = outPath.getWithExtension(_S(".blend"));
hecl::ProjectPath::Type blendType = blendPath.getPathType();
ANCS ancs;
ancs.read(rs);
if (force ||
yamlType == hecl::ProjectPath::Type::None ||
blendType == hecl::ProjectPath::Type::None)
{
if (force || yamlType == hecl::ProjectPath::Type::None)
{
FILE* fp = hecl::Fopen(yamlPath.getAbsolutePath().c_str(), _S("w"));
ancs.toYAMLFile(fp);
fclose(fp);
}
if (force || blendType == hecl::ProjectPath::Type::None)
{
hecl::BlenderConnection& conn = btok.getBlenderConnection();
DNAANCS::ReadANCSToBlender<PAKRouter<PAKBridge>, ANCS, MaterialSet, DNACMDL::SurfaceHeader_1, 2>
(conn, ancs, blendPath, pakRouter, entry, dataSpec, fileChanged, force);
}
}
/* Extract EVNTs */
std::map<atUint32, DNAANCS::AnimationResInfo<UniqueID32>> animRes;
ancs.getAnimationResInfo(animRes);
for (const auto& res : animRes)
{
if (res.second.evntId)
{
hecl::SystemStringView sysStr(res.second.name);
hecl::ProjectPath evntYamlPath = outPath.getWithExtension((hecl::SystemString(_S(".")) +
sysStr.sys_str() +
_S(".evnt.yaml")).c_str());
hecl::ProjectPath::Type evntYamlType = evntYamlPath.getPathType();
if (force || evntYamlType == hecl::ProjectPath::Type::None)
{
EVNT evnt;
if (pakRouter.lookupAndReadDNA(res.second.evntId, evnt, true))
{
FILE* fp = hecl::Fopen(evntYamlPath.getAbsolutePath().c_str(), _S("w"));
evnt.toYAMLFile(fp);
fclose(fp);
}
}
}
}
return true;
}
bool ANCS::Cook(const hecl::ProjectPath& outPath,
const hecl::ProjectPath& inPath,
const DNAANCS::Actor& actor,
const std::function<bool(const hecl::ProjectPath& modelPath)>& modelCookFunc)
{
/* Search for yaml */
hecl::ProjectPath yamlPath = inPath.getWithExtension(_S(".yaml"), true);
if (yamlPath.getPathType() != hecl::ProjectPath::Type::File)
Log.report(logvisor::Fatal, _S("'%s' not found as file"),
yamlPath.getRelativePath().c_str());
athena::io::FileReader yamlReader(yamlPath.getAbsolutePath());
if (!BigYAML::ValidateFromYAMLFile<ANCS>(yamlReader))
Log.report(logvisor::Fatal, _S("'%s' is not urde::DNAMP1::ANCS type"),
yamlPath.getRelativePath().c_str());
ANCS ancs;
ancs.read(yamlReader);
/* Set Character Resource IDs */
for (ANCS::CharacterSet::CharacterInfo& ch : ancs.characterSet.characters)
{
hecl::ProjectPath path = UniqueIDBridge::TranslatePakIdToPath(ch.cmdl);
if (path)
ch.cskr = path.ensureAuxInfo(_S("skin"));
for (const DNAANCS::Actor::Subtype& sub : actor.subtypes)
{
if (!sub.name.compare(ch.name))
{
if (sub.armature >= 0)
{
const DNAANCS::Actor::Armature& arm = actor.armatures[sub.armature];
hecl::SystemStringView chSysName(arm.name);
ch.cinf = inPath.ensureAuxInfo(chSysName.c_str());
break;
}
}
}
path = UniqueIDBridge::TranslatePakIdToPath(ch.cmdlOverlay);
if (path)
ch.cskrOverlay = path.ensureAuxInfo(_S("skin"));
}
/* Set Animation Resource IDs */
ancs.enumeratePrimitives([&](AnimationSet::MetaAnimPrimitive& prim) -> bool
{
hecl::SystemStringView sysStr(prim.animName);
hecl::ProjectPath pathOut = inPath.getWithExtension((_S('.') + sysStr.sys_str()).c_str(), true);
prim.animId = pathOut;
return true;
});
std::unordered_map<std::string, atInt32> boneIdMap;
/* Write out CINF resources */
for (const DNAANCS::Actor::Armature& arm : actor.armatures)
{
hecl::SystemStringView sysStr(arm.name);
hecl::ProjectPath pathOut = inPath.getWithExtension((_S('.') + sysStr.sys_str()).c_str(), true);
athena::io::FileWriter w(pathOut.getAbsolutePath(), true, false);
if (w.hasError())
Log.report(logvisor::Fatal, _S("unable to open '%s' for writing"),
pathOut.getRelativePath().c_str());
CINF cinf(arm, boneIdMap);
cinf.write(w);
}
/* Write out CSKR resources */
for (ANCS::CharacterSet::CharacterInfo& ch : ancs.characterSet.characters)
{
hecl::ProjectPath path = UniqueIDBridge::TranslatePakIdToPath(ch.cmdl);
if (path.getPathType() != hecl::ProjectPath::Type::File)
Log.report(logvisor::Fatal, _S("unable to resolve '%s'"), path.getRelativePath().c_str());
hecl::ProjectPath skinIntPath = path.getCookedPath(SpecEntMP1PC).getWithExtension(_S(".skinint"));
if (skinIntPath.getModtime() < path.getModtime())
if (!modelCookFunc(path))
Log.report(logvisor::Fatal, _S("unable to cook '%s'"), path.getRelativePath().c_str());
athena::io::FileReader skinIO(skinIntPath.getAbsolutePath(), 1024*32, false);
if (skinIO.hasError())
Log.report(logvisor::Fatal, _S("unable to open '%s'"), skinIntPath.getRelativePath().c_str());
std::vector<std::vector<uint32_t>> skinBanks;
uint32_t bankCount = skinIO.readUint32Big();
skinBanks.reserve(bankCount);
for (uint32_t i=0 ; i<bankCount ; ++i)
{
skinBanks.emplace_back();
std::vector<uint32_t>& bonesOut = skinBanks.back();
uint32_t boneCount = skinIO.readUint32Big();
bonesOut.reserve(boneCount);
for (uint32_t j=0 ; j<boneCount ; ++j)
{
uint32_t idx = skinIO.readUint32Big();
bonesOut.push_back(idx);
}
}
std::vector<std::string> boneNames;
uint32_t boneNameCount = skinIO.readUint32Big();
boneNames.reserve(boneNameCount);
for (uint32_t i=0 ; i<boneNameCount ; ++i)
boneNames.push_back(skinIO.readString());
skinIO.close();
hecl::ProjectPath skinPath = path.getCookedPath(SpecEntMP1PC).getWithExtension(_S(".skin"));
athena::io::FileWriter skinOut(skinPath.getAbsolutePath(), true, false);
if (skinOut.hasError())
Log.report(logvisor::Fatal, _S("unable to open '%s' for writing"),
skinPath.getRelativePath().c_str());
skinOut.writeUint32Big(bankCount);
for (const std::vector<uint32_t>& bank : skinBanks)
{
skinOut.writeUint32Big(bank.size());
for (uint32_t bIdx : bank)
{
const std::string& name = boneNames[bIdx];
auto search = boneIdMap.find(name);
if (search == boneIdMap.cend())
Log.report(logvisor::Fatal, "unable to find bone '%s' in %s",
name.c_str(), inPath.getRelativePathUTF8().c_str());
skinOut.writeUint32Big(search->second);
}
}
}
/* Write out ANIM resources */
ancs.animationSet.animResources.reserve(actor.actions.size());
for (const DNAANCS::Actor::Action& act : actor.actions)
{
hecl::SystemStringView sysStr(act.name);
hecl::ProjectPath pathOut = inPath.getWithExtension((_S('.') + sysStr.sys_str()).c_str(), true);
athena::io::FileWriter w(pathOut.getAbsolutePath(), true, false);
if (w.hasError())
Log.report(logvisor::Fatal, _S("unable to open '%s' for writing"),
pathOut.getRelativePath().c_str());
ANIM anim(act, boneIdMap);
ancs.animationSet.animResources.emplace_back();
ancs.animationSet.animResources.back().animId = pathOut;
/* Check for associated EVNT YAML */
hecl::ProjectPath evntYamlPath = inPath.getWithExtension((hecl::SystemString(_S(".")) +
sysStr.sys_str() +
_S(".evnt.yaml")).c_str(), true);
if (evntYamlPath.getPathType() == hecl::ProjectPath::Type::File)
{
FILE* fp = hecl::Fopen(evntYamlPath.getAbsolutePath().c_str(), _S("r"));
if (fp)
{
EVNT evnt;
evnt.fromYAMLFile(fp);
fclose(fp);
anim.m_anim->evnt = evntYamlPath;
hecl::ProjectPath evntYamlOut = pathOut.getWithExtension(_S(".evnt"));
athena::io::FileWriter w(evntYamlOut.getAbsolutePath(), true, false);
if (w.hasError())
Log.report(logvisor::Fatal, _S("unable to open '%s' for writing"),
evntYamlOut.getRelativePath().c_str());
evnt.write(w);
ancs.animationSet.animResources.back().evntId = evntYamlPath;
}
}
anim.write(w);
}
/* Write out ANCS */
athena::io::FileWriter w(outPath.getAbsolutePath(), true, false);
if (w.hasError())
Log.report(logvisor::Fatal, _S("unable to open '%s' for writing"),
outPath.getRelativePath().c_str());
ancs.write(w);
return true;
}
}
}

View File

@ -534,183 +534,12 @@ struct ANCS : BigYAML
const PAK::Entry& entry,
bool force,
hecl::BlenderToken& btok,
std::function<void(const hecl::SystemChar*)> fileChanged)
{
hecl::ProjectPath yamlPath = outPath.getWithExtension(_S(".yaml"));
hecl::ProjectPath::Type yamlType = yamlPath.getPathType();
hecl::ProjectPath blendPath = outPath.getWithExtension(_S(".blend"));
hecl::ProjectPath::Type blendType = blendPath.getPathType();
ANCS ancs;
ancs.read(rs);
if (force ||
yamlType == hecl::ProjectPath::Type::None ||
blendType == hecl::ProjectPath::Type::None)
{
if (force || yamlType == hecl::ProjectPath::Type::None)
{
FILE* fp = hecl::Fopen(yamlPath.getAbsolutePath().c_str(), _S("w"));
ancs.toYAMLFile(fp);
fclose(fp);
}
if (force || blendType == hecl::ProjectPath::Type::None)
{
hecl::BlenderConnection& conn = btok.getBlenderConnection();
DNAANCS::ReadANCSToBlender<PAKRouter<PAKBridge>, ANCS, MaterialSet, DNACMDL::SurfaceHeader_1, 2>
(conn, ancs, blendPath, pakRouter, entry, dataSpec, fileChanged, force);
}
}
/* Extract EVNTs */
std::map<atUint32, DNAANCS::AnimationResInfo<UniqueID32>> animRes;
ancs.getAnimationResInfo(animRes);
for (const auto& res : animRes)
{
if (res.second.evntId)
{
hecl::SystemStringView sysStr(res.second.name);
hecl::ProjectPath evntYamlPath = outPath.getWithExtension((hecl::SystemString(_S(".")) +
sysStr.sys_str() +
_S(".evnt.yaml")).c_str());
hecl::ProjectPath::Type evntYamlType = evntYamlPath.getPathType();
if (force || evntYamlType == hecl::ProjectPath::Type::None)
{
EVNT evnt;
if (pakRouter.lookupAndReadDNA(res.second.evntId, evnt, true))
{
FILE* fp = hecl::Fopen(evntYamlPath.getAbsolutePath().c_str(), _S("w"));
evnt.toYAMLFile(fp);
fclose(fp);
}
}
}
}
return true;
}
std::function<void(const hecl::SystemChar*)> fileChanged);
static bool Cook(const hecl::ProjectPath& outPath,
const hecl::ProjectPath& inPath,
const DNAANCS::Actor& actor)
{
/* Search for yaml */
hecl::ProjectPath yamlPath = inPath.getWithExtension(_S(".yaml"), true);
if (yamlPath.getPathType() != hecl::ProjectPath::Type::File)
Log.report(logvisor::Fatal, _S("'%s' not found as file"),
yamlPath.getRelativePath().c_str());
athena::io::FileReader yamlReader(yamlPath.getAbsolutePath());
if (!BigYAML::ValidateFromYAMLFile<ANCS>(yamlReader))
Log.report(logvisor::Fatal, _S("'%s' is not urde::DNAMP1::ANCS type"),
yamlPath.getRelativePath().c_str());
ANCS ancs;
ancs.read(yamlReader);
/* Set Character Resource IDs */
for (ANCS::CharacterSet::CharacterInfo& ch : ancs.characterSet.characters)
{
hecl::ProjectPath path = UniqueIDBridge::TranslatePakIdToPath(ch.cmdl);
if (path)
ch.cskr = path.ensureAuxInfo(_S("skin"));
for (const DNAANCS::Actor::Subtype& sub : actor.subtypes)
{
if (!sub.name.compare(ch.name))
{
if (sub.armature >= 0)
{
const DNAANCS::Actor::Armature& arm = actor.armatures[sub.armature];
hecl::SystemStringView chSysName(arm.name);
ch.cinf = inPath.ensureAuxInfo(chSysName.c_str());
break;
}
}
}
path = UniqueIDBridge::TranslatePakIdToPath(ch.cmdlOverlay);
if (path)
ch.cskrOverlay = path.ensureAuxInfo(_S("skin"));
}
/* Set Animation Resource IDs */
ancs.enumeratePrimitives([&](AnimationSet::MetaAnimPrimitive& prim) -> bool
{
hecl::SystemStringView sysStr(prim.animName);
hecl::ProjectPath pathOut = inPath.getWithExtension((_S('.') + sysStr.sys_str()).c_str(), true);
prim.animId = pathOut;
return true;
});
std::unordered_map<std::string, atInt32> boneIdMap;
/* Write out CINF resources */
for (const DNAANCS::Actor::Armature& arm : actor.armatures)
{
hecl::SystemStringView sysStr(arm.name);
hecl::ProjectPath pathOut = inPath.getWithExtension((_S('.') + sysStr.sys_str()).c_str(), true);
athena::io::FileWriter w(pathOut.getAbsolutePath(), true, false);
if (w.hasError())
Log.report(logvisor::Fatal, _S("unable to open '%s' for writing"),
pathOut.getRelativePath().c_str());
CINF cinf(arm, boneIdMap);
cinf.write(w);
}
/* Write out ANIM resources */
ancs.animationSet.animResources.reserve(actor.actions.size());
for (const DNAANCS::Actor::Action& act : actor.actions)
{
hecl::SystemStringView sysStr(act.name);
hecl::ProjectPath pathOut = inPath.getWithExtension((_S('.') + sysStr.sys_str()).c_str(), true);
athena::io::FileWriter w(pathOut.getAbsolutePath(), true, false);
if (w.hasError())
Log.report(logvisor::Fatal, _S("unable to open '%s' for writing"),
pathOut.getRelativePath().c_str());
ANIM anim(act, boneIdMap);
ancs.animationSet.animResources.emplace_back();
ancs.animationSet.animResources.back().animId = pathOut;
/* Check for associated EVNT YAML */
hecl::ProjectPath evntYamlPath = inPath.getWithExtension((hecl::SystemString(_S(".")) +
sysStr.sys_str() +
_S(".evnt.yaml")).c_str(), true);
if (evntYamlPath.getPathType() == hecl::ProjectPath::Type::File)
{
FILE* fp = hecl::Fopen(evntYamlPath.getAbsolutePath().c_str(), _S("r"));
if (fp)
{
EVNT evnt;
evnt.fromYAMLFile(fp);
fclose(fp);
anim.m_anim->evnt = evntYamlPath;
hecl::ProjectPath evntYamlOut = pathOut.getWithExtension(_S(".evnt"));
athena::io::FileWriter w(evntYamlOut.getAbsolutePath(), true, false);
if (w.hasError())
Log.report(logvisor::Fatal, _S("unable to open '%s' for writing"),
evntYamlOut.getRelativePath().c_str());
evnt.write(w);
ancs.animationSet.animResources.back().evntId = evntYamlPath;
}
}
anim.write(w);
}
/* Write out ANCS */
athena::io::FileWriter w(outPath.getAbsolutePath(), true, false);
if (w.hasError())
Log.report(logvisor::Fatal, _S("unable to open '%s' for writing"),
outPath.getRelativePath().c_str());
ancs.write(w);
return true;
}
const DNAANCS::Actor& actor,
const std::function<bool(const hecl::ProjectPath& modelPath)>& modelCookFunc);
};
}

View File

@ -94,7 +94,7 @@ struct CMDL
/* Output skinning intermediate */
auto vertCountIt = skinMesh.contiguousSkinVertCounts.cbegin();
athena::io::FileWriter writer(outPath.getWithExtension(_S(".skin")).getAbsolutePath());
athena::io::FileWriter writer(outPath.getWithExtension(_S(".skinint")).getAbsolutePath());
writer.writeUint32Big(skinMesh.skins.size());
for (const std::vector<DNACMDL::Mesh::SkinBind> skin : skinMesh.skins)
{
@ -126,7 +126,7 @@ struct CMDL
return false;
/* Output skinning intermediate */
athena::io::FileWriter writer(outPath.getWithExtension(_S(".skin")).getAbsolutePath());
athena::io::FileWriter writer(outPath.getWithExtension(_S(".skinint")).getAbsolutePath());
writer.writeUint32Big(mesh.skinBanks.banks.size());
for (const DNACMDL::Mesh::SkinBanks::Bank& sb : mesh.skinBanks.banks)
{

View File

@ -93,7 +93,7 @@ bool SpecBase::canExtract(const ExtractPassInfo& info, std::vector<ExtractReport
void SpecBase::doExtract(const ExtractPassInfo& info, FProgress progress)
{
DataSpec::g_curSpec = this;
DataSpec::g_curSpec.reset(this);
if (!Blender::BuildMasterShader(m_masterShader))
Log.report(logvisor::Fatal, "Unable to build master shader blend");
if (m_isWii)
@ -173,7 +173,7 @@ const hecl::Database::DataSpecEntry* SpecBase::overrideDataSpec(const hecl::Proj
void SpecBase::doCook(const hecl::ProjectPath& path, const hecl::ProjectPath& cookedPath,
bool fast, hecl::BlenderToken& btok, FCookProgress progress)
{
DataSpec::g_curSpec = this;
DataSpec::g_curSpec.reset(this);
if (hecl::IsPathBlend(path))
{
hecl::BlenderConnection& conn = btok.getBlenderConnection();
@ -184,19 +184,19 @@ void SpecBase::doCook(const hecl::ProjectPath& path, const hecl::ProjectPath& co
case hecl::BlenderConnection::BlendType::Mesh:
{
hecl::BlenderConnection::DataStream ds = conn.beginData();
cookMesh(cookedPath, path, ds, fast, progress);
cookMesh(cookedPath, path, ds, fast, btok, progress);
break;
}
case hecl::BlenderConnection::BlendType::Actor:
{
hecl::BlenderConnection::DataStream ds = conn.beginData();
cookActor(cookedPath, path, ds, fast, progress);
cookActor(cookedPath, path, ds, fast, btok, progress);
break;
}
case hecl::BlenderConnection::BlendType::Area:
{
hecl::BlenderConnection::DataStream ds = conn.beginData();
cookArea(cookedPath, path, ds, fast, progress);
cookArea(cookedPath, path, ds, fast, btok, progress);
break;
}
default: break;

View File

@ -56,13 +56,16 @@ struct SpecBase : hecl::Database::IDataSpec
using Actor = BlendStream::Actor;
virtual void cookMesh(const hecl::ProjectPath& out, const hecl::ProjectPath& in,
BlendStream& ds, bool fast, FCookProgress progress) const=0;
BlendStream& ds, bool fast, hecl::BlenderToken& btok,
FCookProgress progress)=0;
virtual void cookActor(const hecl::ProjectPath& out, const hecl::ProjectPath& in,
BlendStream& ds, bool fast, FCookProgress progress) const=0;
BlendStream& ds, bool fast, hecl::BlenderToken& btok,
FCookProgress progress)=0;
virtual void cookArea(const hecl::ProjectPath& out, const hecl::ProjectPath& in,
BlendStream& ds, bool fast, FCookProgress progress) const=0;
BlendStream& ds, bool fast, hecl::BlenderToken& btok,
FCookProgress progress)=0;
virtual void cookYAML(const hecl::ProjectPath& out, const hecl::ProjectPath& in,
FILE* fin, FCookProgress progress) const=0;
FILE* fin, FCookProgress progress)=0;
const hecl::ProjectPath& getMasterShaderPath() const {return m_masterShader;}

View File

@ -23,6 +23,7 @@ namespace DataSpec
static logvisor::Module Log("urde::SpecMP1");
extern hecl::Database::DataSpecEntry SpecEntMP1;
extern hecl::Database::DataSpecEntry SpecEntMP1PC;
struct SpecMP1 : SpecBase
{
@ -343,7 +344,8 @@ struct SpecMP1 : SpecBase
}
void cookMesh(const hecl::ProjectPath& out, const hecl::ProjectPath& in,
BlendStream& ds, bool fast, FCookProgress progress) const
BlendStream& ds, bool fast, hecl::BlenderToken& btok,
FCookProgress progress)
{
Mesh mesh = ds.compileMesh(fast ? hecl::HMDLTopology::Triangles : hecl::HMDLTopology::TriStrips, -1,
[&progress](int surfCount)
@ -358,19 +360,31 @@ struct SpecMP1 : SpecBase
}
void cookActor(const hecl::ProjectPath& out, const hecl::ProjectPath& in,
BlendStream& ds, bool fast, FCookProgress progress) const
BlendStream& ds, bool fast, hecl::BlenderToken& btok,
FCookProgress progress)
{
Actor actor = ds.compileActor();
DNAMP1::ANCS::Cook(out, in, actor);
DNAMP1::ANCS::Cook(out, in, actor,
[&](const hecl::ProjectPath& modelPath) -> bool
{
hecl::ProjectPath cooked;
if (m_pc)
cooked = modelPath.getCookedPath(SpecEntMP1PC);
else
cooked = modelPath.getCookedPath(SpecEntMP1);
doCook(modelPath, cooked, fast, btok, progress);
return true;
});
}
void cookArea(const hecl::ProjectPath& out, const hecl::ProjectPath& in,
BlendStream& ds, bool fast, FCookProgress progress) const
BlendStream& ds, bool fast, hecl::BlenderToken& btok,
FCookProgress progress)
{
}
void cookYAML(const hecl::ProjectPath& out, const hecl::ProjectPath& in,
FILE* fin, FCookProgress progress) const
FILE* fin, FCookProgress progress)
{
athena::io::YAMLDocReader reader;
yaml_parser_set_input_file(reader.getParser(), fin);

View File

@ -295,22 +295,25 @@ struct SpecMP2 : SpecBase
}
void cookMesh(const hecl::ProjectPath& out, const hecl::ProjectPath& in,
BlendStream& ds, bool fast, FCookProgress progress) const
BlendStream& ds, bool fast, hecl::BlenderToken& btok,
FCookProgress progress)
{
}
void cookActor(const hecl::ProjectPath& out, const hecl::ProjectPath& in,
BlendStream& ds, bool fast, FCookProgress progress) const
BlendStream& ds, bool fast, hecl::BlenderToken& btok,
FCookProgress progress)
{
}
void cookArea(const hecl::ProjectPath& out, const hecl::ProjectPath& in,
BlendStream& ds, bool fast, FCookProgress progress) const
BlendStream& ds, bool fast, hecl::BlenderToken& btok,
FCookProgress progress)
{
}
void cookYAML(const hecl::ProjectPath& out, const hecl::ProjectPath& in,
FILE* fin, FCookProgress progress) const
FILE* fin, FCookProgress progress)
{
}
};

View File

@ -490,22 +490,25 @@ struct SpecMP3 : SpecBase
}
void cookMesh(const hecl::ProjectPath& out, const hecl::ProjectPath& in,
BlendStream& ds, bool fast, FCookProgress progress) const
BlendStream& ds, bool fast, hecl::BlenderToken& btok,
FCookProgress progress)
{
}
void cookActor(const hecl::ProjectPath& out, const hecl::ProjectPath& in,
BlendStream& ds, bool fast, FCookProgress progress) const
BlendStream& ds, bool fast, hecl::BlenderToken& btok,
FCookProgress progress)
{
}
void cookArea(const hecl::ProjectPath& out, const hecl::ProjectPath& in,
BlendStream& ds, bool fast, FCookProgress progress) const
BlendStream& ds, bool fast, hecl::BlenderToken& btok,
FCookProgress progress)
{
}
void cookYAML(const hecl::ProjectPath& out, const hecl::ProjectPath& in,
FILE* fin, FCookProgress progress) const
FILE* fin, FCookProgress progress)
{
}
};

View File

@ -6,7 +6,7 @@ namespace urde
{
static logvisor::Module Log("URDE::ProjectManager");
CToken ProjectResourcePool::GetObj(char const* name)
CToken ProjectResourcePool::GetObj(const char* name)
{
CToken ret = CSimplePool::GetObj(name);
if (ret)
@ -21,7 +21,7 @@ CToken ProjectResourcePool::GetObj(char const* name)
return {};
}
CToken ProjectResourcePool::GetObj(char const* name, const CVParamTransfer& pvxfer)
CToken ProjectResourcePool::GetObj(const char* name, const CVParamTransfer& pvxfer)
{
CToken ret = CSimplePool::GetObj(name, pvxfer);
if (ret)

View File

@ -20,8 +20,8 @@ class ProjectResourcePool : public CSimplePool
public:
ProjectResourcePool(IFactory& factory, ProjectManager& parent)
: CSimplePool(factory), m_parent(parent) {}
CToken GetObj(char const*);
CToken GetObj(char const*, const CVParamTransfer&);
CToken GetObj(const char*);
CToken GetObj(const char*, const CVParamTransfer&);
};
class ProjectManager

View File

@ -10,6 +10,7 @@
#include "Runtime/Graphics/CModel.hpp"
#include "Runtime/Graphics/CTexture.hpp"
#include "Runtime/Character/CCharLayoutInfo.hpp"
#include "Runtime/Character/CAnimCharacterSet.hpp"
#include "DataSpec/DNACommon/TXTR.hpp"
@ -31,6 +32,7 @@ ProjectResourceFactoryMP1::ProjectResourceFactoryMP1(hecl::ClientProcess& client
m_factoryMgr.AddFactory(FOURCC('FONT'), FFactoryFunc(FRasterFontFactory));
m_factoryMgr.AddFactory(FOURCC('CMDL'), FMemFactoryFunc(FModelFactory));
m_factoryMgr.AddFactory(FOURCC('CINF'), FFactoryFunc(FCharLayoutInfo));
m_factoryMgr.AddFactory(FOURCC('ANCS'), FFactoryFunc(FAnimCharacterSet));
}
void ProjectResourceFactoryMP1::IndexMP1Resources(hecl::Database::Project& proj)

View File

@ -9,7 +9,7 @@ class CCallStack
const char* x0_fileAndLineStr;
const char* x4_typeStr;
public:
CCallStack(char const* fileAndLineStr, char const* typeStr)
CCallStack(const char* fileAndLineStr, const char* typeStr)
: x0_fileAndLineStr(fileAndLineStr), x4_typeStr(typeStr) {}
const char* GetFileAndLineText() const {return x0_fileAndLineStr;}
const char* GetTypeText() const {return x4_typeStr;}

View File

@ -30,12 +30,12 @@ CToken CSimplePool::GetObj(const SObjectTag& tag)
return GetObj(tag, x34_paramXfer);
}
CToken CSimplePool::GetObj(char const* resourceName)
CToken CSimplePool::GetObj(const char* resourceName)
{
return GetObj(resourceName, x34_paramXfer);
}
CToken CSimplePool::GetObj(char const* resourceName, const CVParamTransfer& paramXfer)
CToken CSimplePool::GetObj(const char* resourceName, const CVParamTransfer& paramXfer)
{
const SObjectTag* tag = x30_factory.GetResourceIdByName(resourceName);
if (!tag)

View File

@ -22,8 +22,8 @@ public:
CSimplePool(IFactory& factory);
CToken GetObj(const SObjectTag&, const CVParamTransfer&);
CToken GetObj(const SObjectTag&);
CToken GetObj(char const*);
CToken GetObj(char const*, const CVParamTransfer&);
CToken GetObj(const char*);
CToken GetObj(const char*, const CVParamTransfer&);
bool HasObject(const SObjectTag&) const;
bool ObjectIsLive(const SObjectTag&) const;
IFactory& GetFactory() const {return x30_factory;}

View File

@ -0,0 +1,15 @@
#include "CAnimCharacterSet.hpp"
#include "CToken.hpp"
namespace urde
{
CAnimCharacterSet::CAnimCharacterSet(CInputStream& in)
: x0_version(in.readUint16Big()), x4_characterSet(in), x1c_animationSet(in) {}
CFactoryFnReturn FAnimCharacterSet(const SObjectTag&, CInputStream& in, const CVParamTransfer&)
{
return TToken<CAnimCharacterSet>::GetIObjObjectFor(std::make_unique<CAnimCharacterSet>(in));
}
}

View File

@ -0,0 +1,24 @@
#ifndef __PSHAG_CANIMCHARACTERSET_HPP__
#define __PSHAG_CANIMCHARACTERSET_HPP__
#include "CFactoryMgr.hpp"
#include "CCharacterSet.hpp"
#include "CAnimationSet.hpp"
namespace urde
{
class CAnimCharacterSet
{
u16 x0_version;
CCharacterSet x4_characterSet;
CAnimationSet x1c_animationSet;
public:
CAnimCharacterSet(CInputStream& in);
};
CFactoryFnReturn FAnimCharacterSet(const SObjectTag&, CInputStream&, const CVParamTransfer&);
}
#endif // __PSHAG_CANIMCHARACTERSET_HPP__

View File

@ -0,0 +1,13 @@
#ifndef __PSHAG_CANIMTREEANIMREADERCONTAINER_HPP__
#define __PSHAG_CANIMTREEANIMREADERCONTAINER_HPP__
namespace urde
{
class CAnimTreeAnimReaderContainer
{
};
}
#endif // __PSHAG_CANIMTREEANIMREADERCONTAINER_HPP__

View File

View File

@ -0,0 +1,13 @@
#ifndef __PSHAG_CANIMTREEBLEND_HPP__
#define __PSHAG_CANIMTREEBLEND_HPP__
namespace urde
{
class CAnimTreeBlend
{
};
}
#endif // __PSHAG_CANIMTREEBLEND_HPP__

View File

@ -0,0 +1,30 @@
#ifndef __PSHAG_CANIMTREEDOUBLECHILD_HPP__
#define __PSHAG_CANIMTREEDOUBLECHILD_HPP__
#include "CAnimTreeNode.hpp"
namespace urde
{
class CAnimTreeDoubleChild : public CAnimTreeNode
{
public:
void VAdvanceView(const CCharAnimTime& a);
void VGetBoolPOIList(const CCharAnimTime& time, CBoolPOINode* listOut, u32, u32, u32) const;
void VGetInt32POIList(const CCharAnimTime& time, CInt32POINode* listOut, u32, u32, u32) const;
void VGetParticlePOIList(const CCharAnimTime& time, CParticlePOINode* listOut, u32, u32, u32) const;
void VGetSoundPOIList(const CCharAnimTime& time, CSoundPOINode* listOut, u32, u32, u32) const;
void VGetBoolPOIState(const char*) const;
void VGetInt32POIState(const char*) const;
void VGetParticlePOIState(const char*) const;
void VSetPhase(float);
SAdvancementResults VGetAdvancementResults(const CCharAnimTime& a, const CCharAnimTime& b) const;
void Depth() const;
void VGetContributionOfHighestInfluence() const;
void VGetNumChildren() const;
void VGetBestUnblendedChild() const;
};
}
#endif // __PSHAG_CANIMTREEDOUBLECHILD_HPP__

View File

View File

@ -0,0 +1,13 @@
#ifndef __PSHAG_CANIMTREELOOPIN_HPP__
#define __PSHAG_CANIMTREELOOPIN_HPP__
namespace urde
{
class CAnimTreeLoopIn
{
};
}
#endif // __PSHAG_CANIMTREELOOPIN_HPP__

View File

View File

@ -0,0 +1,19 @@
#ifndef __PSHAG_CANIMTREENODE_HPP__
#define __PSHAG_CANIMTREENODE_HPP__
#include "IAnimReader.hpp"
namespace urde
{
class CAnimTreeNode : public IAnimReader
{
std::string x4_name;
public:
CAnimTreeNode(const std::string& name) : x4_name(name) {}
bool IsCAnimTreeNode() const {return true;}
};
}
#endif // __PSHAG_CANIMTREENODE_HPP__

View File

View File

@ -0,0 +1,13 @@
#ifndef __PSHAG_CANIMTREESCALE_HPP__
#define __PSHAG_CANIMTREESCALE_HPP__
namespace urde
{
class CAnimTreeScale
{
};
}
#endif // __PSHAG_CANIMTREESCALE_HPP__

View File

View File

@ -0,0 +1,13 @@
#ifndef __PSHAG_CANIMTREESEQUENCE_HPP__
#define __PSHAG_CANIMTREESEQUENCE_HPP__
namespace urde
{
class CAnimTreeSequence
{
};
}
#endif // __PSHAG_CANIMTREESEQUENCE_HPP__

View File

@ -0,0 +1,97 @@
#include "CAnimTreeSingleChild.hpp"
namespace urde
{
CAnimTreeSingleChild::CAnimTreeSingleChild(const std::weak_ptr<CAnimTreeNode>& node, const std::string& name)
: CAnimTreeNode(name)
{
}
void CAnimTreeSingleChild::VAdvanceView(const CCharAnimTime& a)
{
}
void CAnimTreeSingleChild::VGetTimeRemaining() const
{
}
bool CAnimTreeSingleChild::VHasOffset(const CSegId& seg) const
{
}
void CAnimTreeSingleChild::VGetOffset(const CSegId& seg) const
{
}
void CAnimTreeSingleChild::VGetRotation(const CSegId& seg) const
{
}
void CAnimTreeSingleChild::VGetBoolPOIList(const CCharAnimTime& time,
CBoolPOINode* listOut,
u32, u32, u32) const
{
}
void CAnimTreeSingleChild::VGetInt32POIList(const CCharAnimTime& time,
CInt32POINode* listOut,
u32, u32, u32) const
{
}
void CAnimTreeSingleChild::VGetParticlePOIList(const CCharAnimTime& time,
CParticlePOINode* listOut,
u32, u32, u32) const
{
}
void CAnimTreeSingleChild::VGetSoundPOIList(const CCharAnimTime& time,
CSoundPOINode* listOut,
u32, u32, u32) const
{
}
void CAnimTreeSingleChild::VGetBoolPOIState(const char*) const
{
}
void CAnimTreeSingleChild::VGetInt32POIState(const char*) const
{
}
void CAnimTreeSingleChild::VGetParticlePOIState(const char*) const
{
}
void CAnimTreeSingleChild::VGetSegStatementSet(const CSegIdList& list,
CSegStatementSet& setOut) const
{
}
void CAnimTreeSingleChild::VGetSegStatementSet(const CSegIdList& list,
CSegStatementSet& setOut,
const CCharAnimTime& time) const
{
}
void CAnimTreeSingleChild::VSetPhase(float)
{
}
SAdvancementResults
CAnimTreeSingleChild::VGetAdvancementResults(const CCharAnimTime& a,
const CCharAnimTime& b) const
{
}
void CAnimTreeSingleChild::Depth() const
{
}
void CAnimTreeSingleChild::VGetNumChildren() const
{
}
}

View File

@ -0,0 +1,37 @@
#ifndef __PSHAG_CANIMTREESINGLECHILD_HPP__
#define __PSHAG_CANIMTREESINGLECHILD_HPP__
#include "CAnimTreeNode.hpp"
namespace urde
{
class CAnimTreeSingleChild : public CAnimTreeNode
{
std::shared_ptr<CAnimTreeNode> x14_child;
public:
CAnimTreeSingleChild(const std::weak_ptr<CAnimTreeNode>& node, const std::string& name);
void VAdvanceView(const CCharAnimTime& a);
void VGetTimeRemaining() const;
bool VHasOffset(const CSegId& seg) const;
void VGetOffset(const CSegId& seg) const;
void VGetRotation(const CSegId& seg) const;
void VGetBoolPOIList(const CCharAnimTime& time, CBoolPOINode* listOut, u32, u32, u32) const;
void VGetInt32POIList(const CCharAnimTime& time, CInt32POINode* listOut, u32, u32, u32) const;
void VGetParticlePOIList(const CCharAnimTime& time, CParticlePOINode* listOut, u32, u32, u32) const;
void VGetSoundPOIList(const CCharAnimTime& time, CSoundPOINode* listOut, u32, u32, u32) const;
void VGetBoolPOIState(const char*) const;
void VGetInt32POIState(const char*) const;
void VGetParticlePOIState(const char*) const;
void VGetSegStatementSet(const CSegIdList& list, CSegStatementSet& setOut) const;
void VGetSegStatementSet(const CSegIdList& list, CSegStatementSet& setOut, const CCharAnimTime& time) const;
void VSetPhase(float);
SAdvancementResults VGetAdvancementResults(const CCharAnimTime& a, const CCharAnimTime& b) const;
void Depth() const;
void VGetNumChildren() const;
};
}
#endif // __PSHAG_CANIMTREESINGLECHILD_HPP__

View File

View File

@ -0,0 +1,13 @@
#ifndef __PSHAG_CANIMTREETIMESCALE_HPP__
#define __PSHAG_CANIMTREETIMESCALE_HPP__
namespace urde
{
class CAnimTreeTimeScale
{
};
}
#endif // __PSHAG_CANIMTREETIMESCALE_HPP__

View File

@ -0,0 +1,18 @@
#ifndef __PSHAG_CANIMTREETRANSITION_HPP__
#define __PSHAG_CANIMTREETRANSITION_HPP__
#include "RetroTypes.hpp"
#include "CAnimTreeTweenBase.hpp"
namespace urde
{
class CAnimTreeTransition : public CAnimTreeTweenBase
{
public:
static std::string CreatePrimitiveName();
};
}
#endif // __PSHAG_CANIMTREETRANSITION_HPP__

View File

View File

@ -0,0 +1,15 @@
#ifndef __PSHAG_CANIMTREETWEENBASE_HPP__
#define __PSHAG_CANIMTREETWEENBASE_HPP__
#include "CAnimTreeDoubleChild.hpp"
namespace urde
{
class CAnimTreeTweenBase : public CAnimTreeDoubleChild
{
};
}
#endif // __PSHAG_CANIMTREETWEENBASE_HPP__

View File

@ -0,0 +1,13 @@
#include "CAnimation.hpp"
#include "CMetaAnimFactory.hpp"
namespace urde
{
CAnimation::CAnimation(CInputStream& in)
{
x0_name = in.readString();
x10_anim = CMetaAnimFactory::CreateMetaAnim(in);
}
}

View File

@ -0,0 +1,21 @@
#ifndef __PSHAG_CANIMATION_HPP__
#define __PSHAG_CANIMATION_HPP__
#include "IOStreams.hpp"
#include "CMetaAnimFactory.hpp"
namespace urde
{
class IMetaAnim;
class CAnimation
{
std::string x0_name;
std::shared_ptr<IMetaAnim> x10_anim;
public:
CAnimation(CInputStream& in);
};
}
#endif // __PSHAG_CANIMATION_HPP__

View File

@ -0,0 +1,55 @@
#include "CAnimationSet.hpp"
#include "CMetaTransFactory.hpp"
namespace urde
{
CAnimationSet::CAnimationSet(CInputStream& in)
: x0_tableCount(in.readUint16Big())
{
u32 animationCount = in.readUint32Big();
x4_animations.reserve(animationCount);
for (u32 i=0 ; i<animationCount ; ++i)
x4_animations.emplace_back(in);
u32 transitionCount = in.readUint32Big();
x14_transitions.reserve(transitionCount);
for (u32 i=0 ; i<transitionCount ; ++i)
x14_transitions.emplace_back(in);
x24_defaultTransition = CMetaTransFactory::CreateMetaTrans(in);
if (x0_tableCount > 1)
{
u32 additiveAnimCount = in.readUint32Big();
x28_additiveInfo.reserve(additiveAnimCount);
for (u32 i=0 ; i<additiveAnimCount ; ++i)
{
u32 id = in.readUint32Big();
x28_additiveInfo.emplace_back(id, in);
}
x38_defaultAdditiveInfo.read(in);
}
if (x0_tableCount > 2)
{
u32 halfTransitionCount = in.readUint32Big();
x40_halfTransitions.reserve(halfTransitionCount);
for (u32 i=0 ; i<halfTransitionCount ; ++i)
x40_halfTransitions.emplace_back(in);
}
if (x0_tableCount > 3)
{
u32 animResourcesCount = in.readUint32Big();
x50_animRes.reserve(animResourcesCount);
for (u32 i=0 ; i<animResourcesCount ; ++i)
{
TResId anim = in.readUint32Big();
TResId evnt = in.readUint32Big();
x50_animRes.emplace_back(anim, evnt);
}
}
}
}

View File

@ -0,0 +1,43 @@
#ifndef __PSHAG_CANIMATIONSET_HPP__
#define __PSHAG_CANIMATIONSET_HPP__
#include "IOStreams.hpp"
#include "CAnimation.hpp"
#include "CTransition.hpp"
#include "CHalfTransition.hpp"
namespace urde
{
class CAdditiveAnimationInfo
{
float x0_a = 0.f;
float x4_b = 0.f;
public:
void read(CInputStream& in)
{
x0_a = in.readFloatBig();
x4_b = in.readFloatBig();
}
CAdditiveAnimationInfo() = default;
CAdditiveAnimationInfo(CInputStream& in) {read(in);}
};
class CAnimationSet
{
u16 x0_tableCount;
std::vector<CAnimation> x4_animations;
std::vector<CTransition> x14_transitions;
std::shared_ptr<IMetaTrans> x24_defaultTransition;
std::vector<std::pair<u32, CAdditiveAnimationInfo>> x28_additiveInfo;
CAdditiveAnimationInfo x38_defaultAdditiveInfo;
std::vector<CHalfTransition> x40_halfTransitions;
std::vector<std::pair<TResId, TResId>> x50_animRes;
public:
CAnimationSet(CInputStream& in);
};
}
#endif // __PSHAG_CANIMATIONSET_HPP__

View File

@ -3,4 +3,332 @@
namespace urde
{
CCharAnimTime CCharAnimTime::Infinity()
{
CCharAnimTime ret(1.f);
ret.m_type = Type::Infinity;
return ret;
}
bool CCharAnimTime::EqualsZero() const
{
if (m_type == Type::ZeroIncreasing || m_type == Type::ZeroSteady || m_type == Type::ZeroDecreasing)
return false;
return (m_time == 0.f);
}
bool CCharAnimTime::GreaterThanZero() const
{
if (EqualsZero())
return false;
return (m_time > 0.f);
}
bool CCharAnimTime::operator ==(const CCharAnimTime& other) const
{
if (m_type == Type::NonZero)
{
if (other.m_type == Type::NonZero)
return m_time == other.m_time;
return !other.EqualsZero();
}
if (EqualsZero())
{
if (other.EqualsZero())
{
int type = -1;
if (m_type != Type::ZeroDecreasing)
{
if (m_type != Type::ZeroSteady)
type = 1;
else
type = 0;
}
int otherType = -1;
if (other.m_type != Type::ZeroDecreasing)
{
if (other.m_type != Type::ZeroSteady)
otherType = 1;
else
otherType = 0;
}
return type == otherType;
}
return false;
}
if (other.m_type == Type::Infinity)
return m_time * other.m_time < 0.f;
return false;
}
bool CCharAnimTime::operator !=(const CCharAnimTime& other) const
{
return !(*this == other);
}
bool CCharAnimTime::operator>=(const CCharAnimTime& other)
{
if (*this == other)
return true;
return (*this > other);
}
bool CCharAnimTime::operator<=(const CCharAnimTime& other)
{
if (*this == other)
return true;
return (*this < other);
}
bool CCharAnimTime::operator >(const CCharAnimTime& other) const
{
return (!(*this == other) && !(*this < other));
}
bool CCharAnimTime::operator <(const CCharAnimTime& other) const
{
if (m_type == Type::NonZero)
{
if (other.m_type == Type::NonZero)
return m_time < other.m_time;
if (other.EqualsZero())
return m_time < 0.f;
else
return other.m_time > 0.f;
}
if (EqualsZero())
{
if (other.EqualsZero())
{
int type = -1;
if (m_type != Type::ZeroDecreasing)
{
if (m_type != Type::ZeroSteady)
type = 1;
else
type = 0;
}
int otherType = -1;
if (other.m_type != Type::ZeroDecreasing)
{
if (other.m_type != Type::ZeroSteady)
otherType = 1;
else
otherType = 0;
}
return type < otherType;
}
if (other.m_type == Type::NonZero)
return other.m_time > 0.f;
return other.m_time < 0.f;
}
else
{
if (m_type == Type::Infinity)
return m_time < 0.f && other.m_time > 0.f;
return m_time < 0.f;
}
}
CCharAnimTime& CCharAnimTime::operator*=(const CCharAnimTime& other)
{
*this = *this * other;
return *this;
}
CCharAnimTime& CCharAnimTime::operator+=(const CCharAnimTime& other)
{
*this = *this + other;
return *this;
}
CCharAnimTime CCharAnimTime::operator+(const CCharAnimTime& other)
{
if (m_type == Type::Infinity && other.m_type == Type::Infinity)
{
if (other.m_time != m_time)
return CCharAnimTime();
return *this;
}
else if (m_type == Type::Infinity)
return *this;
else if (other.m_type == Type::Infinity)
return other;
if (!EqualsZero() || !other.EqualsZero())
return CCharAnimTime(m_time + other.m_time);
int type = -1;
if (m_type != Type::ZeroDecreasing)
{
if (m_type != Type::ZeroSteady)
type = 1;
else
type = 0;
}
int otherType = -1;
if (other.m_type != Type::ZeroDecreasing)
{
if (other.m_type != Type::ZeroSteady)
otherType = 1;
else
otherType = 0;
}
type += otherType;
otherType = std::max(-1, std::min(type, 1));
CCharAnimTime ret;
if (otherType == -1)
ret.m_type = Type::ZeroDecreasing;
else if (otherType == 0)
ret.m_type = Type::ZeroSteady;
else
ret.m_type = Type::ZeroIncreasing;
return ret;
}
CCharAnimTime& CCharAnimTime::operator-=(const CCharAnimTime& other)
{
*this = *this - other;
return *this;
}
CCharAnimTime CCharAnimTime::operator-(const CCharAnimTime& other)
{
if (m_type == Type::Infinity && other.m_type == Type::Infinity)
{
if (other.m_time == m_time)
return CCharAnimTime();
return *this;
}
else if (m_type == Type::Infinity)
return *this;
else if (other.m_type == Type::Infinity)
{
CCharAnimTime ret(-other.m_time);
ret.m_type = Type::Infinity;
return ret;
}
if (!EqualsZero() || !other.EqualsZero())
return CCharAnimTime(m_time - other.m_time);
int type = -1;
if (m_type != Type::ZeroDecreasing)
{
if (m_type != Type::ZeroSteady)
type = 1;
else
type = 0;
}
int otherType = -1;
if (other.m_type != Type::ZeroDecreasing)
{
if (other.m_type != Type::ZeroSteady)
otherType = 1;
else
otherType = 0;
}
CCharAnimTime ret;
type -= otherType;
if (type == -1)
ret.m_type = Type::ZeroDecreasing;
else if (type == 0)
ret.m_type = Type::ZeroSteady;
else
ret.m_type = Type::ZeroIncreasing;
return ret;
}
CCharAnimTime CCharAnimTime::operator*(const CCharAnimTime& other)
{
if (m_type == Type::Infinity && other.m_type == Type::Infinity)
{
if (other.m_time != m_time)
return CCharAnimTime();
return *this;
}
else if (m_type == Type::Infinity)
return *this;
else if (other.m_type == Type::Infinity)
return other;
if (!EqualsZero() || !other.EqualsZero())
return CCharAnimTime(m_time * other.m_time);
int type = -1;
if (m_type != Type::ZeroDecreasing)
{
if (m_type != Type::ZeroSteady)
type = 1;
else
type = 0;
}
int otherType = -1;
if (other.m_type != Type::ZeroDecreasing)
{
if (other.m_type != Type::ZeroSteady)
otherType = 1;
else
otherType = 0;
}
type += otherType;
otherType = std::max(-1, std::min(type, 1));
CCharAnimTime ret;
if (otherType == -1)
ret.m_type = Type::ZeroDecreasing;
else if (otherType == 0)
ret.m_type = Type::ZeroSteady;
else
ret.m_type = Type::ZeroIncreasing;
return ret;
}
CCharAnimTime CCharAnimTime::operator*(const float& other)
{
CCharAnimTime ret;
if (other == 0.f)
return ret;
if (!EqualsZero())
return CCharAnimTime(m_time * other);
if (other > 0.f)
return *this;
else if (other == 0.f)
return ret;
ret.m_type = m_type;
return ret;
}
float CCharAnimTime::operator/(const CCharAnimTime& other)
{
if (other.EqualsZero())
return 0.f;
return m_time / other.m_time;
}
}

View File

@ -1,205 +1,47 @@
#ifndef __PSHAG_CCHARANIMTIME_HPP__
#define __PSHAG_CCHARANIMTIME_HPP__
#include <algorithm>
namespace urde
{
class CCharAnimTime
{
float m_time = 0.f;
int m_unk = 2; // enum?
enum class Type
{
NonZero,
ZeroIncreasing,
ZeroSteady,
ZeroDecreasing,
Infinity
} m_type = Type::ZeroSteady;
public:
CCharAnimTime() = default;
CCharAnimTime(float time)
: m_time(time),
m_unk(m_time != 0.f ? 0 : 2)
{
}
m_type(m_time != 0.f ? Type::NonZero : Type::ZeroSteady) {}
bool EqualsZero() const
{
if (m_unk == 1 || m_unk == 2 || m_unk == 3)
return false;
static CCharAnimTime Infinity();
operator float() const {return m_time;}
return (m_time == 0.f);
}
bool GreaterThanZero() const
{
if (EqualsZero())
return false;
return (m_time > 0.f);
}
#if 1
bool operator ==(const CCharAnimTime& other) const
{
return false;
}
bool operator !=(const CCharAnimTime& other) const
{
return !(*this == other);
}
bool operator>=(const CCharAnimTime& other)
{
if (*this == other)
return true;
return (*this > other);
}
bool operator<=(const CCharAnimTime& other)
{
if (*this == other)
return true;
return (*this < other);
}
bool operator >(const CCharAnimTime& other) const
{
return false;
}
bool operator <(const CCharAnimTime& other) const
{
return false;
}
CCharAnimTime& operator*=(const CCharAnimTime& other)
{
*this = *this * other;
return *this;
}
CCharAnimTime& operator+=(const CCharAnimTime& other)
{
*this = *this + other;
return *this;
}
CCharAnimTime operator+(const CCharAnimTime& other)
{
if (m_unk == 4 && other.m_unk == 4)
{
if (other.m_time != m_time)
return CCharAnimTime();
return *this;
}
else if (m_unk == 4)
return *this;
else if (other.m_unk == 4)
return other;
if (!EqualsZero() || !other.EqualsZero())
return CCharAnimTime(m_time + other.m_time);
int type = -1;
if (m_unk != 3)
{
if (m_unk != 2)
type = 1;
else
type = 0;
}
int otherType = -1;
if (other.m_unk != 3)
{
if (other.m_unk != 2)
otherType = 1;
else
otherType = 0;
}
type += otherType;
if (type < 1)
otherType = 1;
else
otherType = type;
if (otherType < -1)
otherType = -1;
CCharAnimTime ret;
if (otherType == -1)
ret.m_unk = 3;
else if (otherType == 0)
ret.m_unk = 2;
else
ret.m_unk = 1;
return ret;
}
CCharAnimTime operator*(const CCharAnimTime& other)
{
if (m_unk == 4 && other.m_unk == 4)
{
if (other.m_time != m_time)
return CCharAnimTime();
return *this;
}
else if (m_unk == 4)
return *this;
else if (other.m_unk == 4)
return other;
if (!EqualsZero() || !other.EqualsZero())
return CCharAnimTime(m_time * other.m_time);
int type = -1;
if (m_unk != 3)
{
if (m_unk != 2)
type = 1;
else
type = 0;
}
int otherType = -1;
if (other.m_unk != 3)
{
if (other.m_unk != 2)
otherType = 1;
else
otherType = 0;
}
type += otherType;
if (type < 1)
otherType = 1;
else
otherType = type;
if (otherType < -1)
otherType = -1;
CCharAnimTime ret;
if (otherType == -1)
ret.m_unk = 3;
else if (otherType == 0)
ret.m_unk = 2;
else
ret.m_unk = 1;
return ret;
}
CCharAnimTime operator*(const float& other)
{
return CCharAnimTime();
}
float operator/(const CCharAnimTime& other)
{
if (other.EqualsZero())
return 0.f;
return m_time / other.m_time;
}
#endif
bool EqualsZero() const;
bool GreaterThanZero() const;
bool operator ==(const CCharAnimTime& other) const;
bool operator !=(const CCharAnimTime& other) const;
bool operator>=(const CCharAnimTime& other);
bool operator<=(const CCharAnimTime& other);
bool operator >(const CCharAnimTime& other) const;
bool operator <(const CCharAnimTime& other) const;
CCharAnimTime& operator*=(const CCharAnimTime& other);
CCharAnimTime& operator+=(const CCharAnimTime& other);
CCharAnimTime operator+(const CCharAnimTime& other);
CCharAnimTime& operator-=(const CCharAnimTime& other);
CCharAnimTime operator-(const CCharAnimTime& other);
CCharAnimTime operator*(const CCharAnimTime& other);
CCharAnimTime operator*(const float& other);
float operator/(const CCharAnimTime& other);
};
}

View File

@ -0,0 +1,102 @@
#include "CCharacterInfo.hpp"
namespace urde
{
CCharacterInfo::CParticleResData::CParticleResData(CInputStream& in, u16 tableCount)
{
u32 partCount = in.readUint32Big();
x0_part.reserve(partCount);
for (u32 i=0 ; i<partCount ; ++i)
x0_part.push_back(in.readUint32Big());
u32 swhcCount = in.readUint32Big();
x10_swhc.reserve(swhcCount);
for (u32 i=0 ; i<swhcCount ; ++i)
x10_swhc.push_back(in.readUint32Big());
u32 unkCount = in.readUint32Big();
x20_.reserve(unkCount);
for (u32 i=0 ; i<unkCount ; ++i)
x20_.push_back(in.readUint32Big());
if (tableCount > 5)
{
u32 elscCount = in.readUint32Big();
x30_elsc.reserve(elscCount);
for (u32 i=0 ; i<elscCount ; ++i)
x30_elsc.push_back(in.readUint32Big());
}
}
static std::vector<std::pair<u32, std::pair<std::string, std::string>>>
MakeAnimInfoVector(CInputStream& in)
{
std::vector<std::pair<u32, std::pair<std::string, std::string>>> ret;
u32 animInfoCount = in.readUint32Big();
ret.reserve(animInfoCount);
for (u32 i=0 ; i<animInfoCount ; ++i)
{
u32 idx = in.readUint32Big();
std::string a = in.readString();
std::string b = in.readString();
ret.emplace_back(idx, std::make_pair(a, b));
}
return ret;
}
CCharacterInfo::CCharacterInfo(CInputStream& in)
: x0_tableCount(in.readUint16Big()),
x4_name(in.readString()),
x14_cmdl(in.readUint32Big()),
x18_cskr(in.readUint32Big()),
x1c_cinf(in.readUint32Big()),
x20_animInfo(MakeAnimInfoVector(in)),
x30_pasDatabase(in),
x44_partRes(in, x0_tableCount),
x84_unk(in.readUint32Big())
{
if (x0_tableCount > 1)
{
u32 aabbCount = in.readUint32Big();
x88_aabbs.reserve(aabbCount);
for (u32 i=0 ; i<aabbCount ; ++i)
{
std::string name = in.readString();
x88_aabbs.emplace_back(name, zeus::CAABox());
x88_aabbs.back().second.readBoundingBoxBig(in);
}
}
if (x0_tableCount > 2)
{
u32 effectCount = in.readUint32Big();
x98_effects.reserve(effectCount);
for (u32 i=0 ; i<effectCount ; ++i)
{
std::string name = in.readString();
x98_effects.emplace_back(name, std::vector<CEffectComponent>());
std::vector<CEffectComponent>& comps = x98_effects.back().second;
u32 compCount = in.readUint32Big();
comps.reserve(compCount);
for (u32 j=0 ; j<compCount ; ++i)
comps.emplace_back(in);
}
}
if (x0_tableCount > 3)
{
xa8_cmdlOverlay = in.readUint32Big();
xac_cskrOverlay = in.readUint32Big();
}
if (x0_tableCount > 4)
{
u32 aidxCount = in.readUint32Big();
xb0_animIdxs.reserve(aidxCount);
for (u32 i=0 ; i<aidxCount ; ++i)
xb0_animIdxs.push_back(in.readUint32Big());
}
}
}

View File

@ -0,0 +1,47 @@
#ifndef __PSHAG_CCHARACTERINFO_HPP__
#define __PSHAG_CCHARACTERINFO_HPP__
#include "IOStreams.hpp"
#include "CPASDatabase.hpp"
#include "zeus/CAABox.hpp"
#include "CEffectComponent.hpp"
namespace urde
{
class CCharacterInfo
{
public:
struct CParticleResData
{
std::vector<TResId> x0_part;
std::vector<TResId> x10_swhc;
std::vector<TResId> x20_;
std::vector<TResId> x30_elsc;
CParticleResData(CInputStream& in, u16 tableCount);
};
private:
u16 x0_tableCount;
std::string x4_name;
TResId x14_cmdl;
TResId x18_cskr;
TResId x1c_cinf;
std::vector<std::pair<u32, std::pair<std::string, std::string>>> x20_animInfo;
CPASDatabase x30_pasDatabase;
CParticleResData x44_partRes;
u32 x84_unk;
std::vector<std::pair<std::string, zeus::CAABox>> x88_aabbs;
std::vector<std::pair<std::string, std::vector<CEffectComponent>>> x98_effects;
TResId xa8_cmdlOverlay = 0;
TResId xac_cskrOverlay = 0;
std::vector<u32> xb0_animIdxs;
public:
CCharacterInfo(CInputStream& in);
};
}
#endif // __PSHAG_CCHARACTERINFO_HPP__

View File

@ -0,0 +1,17 @@
#include "CCharacterSet.hpp"
namespace urde
{
CCharacterSet::CCharacterSet(CInputStream& in)
: x0_version(in.readUint16Big())
{
u32 charCount = in.readUint32Big();
for (u32 i=0 ; i<charCount ; ++i)
{
u32 id = in.readUint32Big();
x4_characters.emplace(id, in);
}
}
}

View File

@ -0,0 +1,20 @@
#ifndef __PSHAG_CCHARACTERSET_HPP__
#define __PSHAG_CCHARACTERSET_HPP__
#include "IOStreams.hpp"
#include "CCharacterInfo.hpp"
namespace urde
{
class CCharacterSet
{
u16 x0_version;
std::map<u32, CCharacterInfo> x4_characters;
public:
CCharacterSet(CInputStream& in);
};
}
#endif // __PSHAG_CCHARACTERSET_HPP__

View File

@ -0,0 +1,23 @@
#include "CEffectComponent.hpp"
namespace urde
{
SObjectTag CEffectComponent::GetSObjectTagFromStream(CInputStream& in)
{
char tpChars[4];
in.readBytesToBuf(tpChars, 4);
return {tpChars, in.readUint32Big()};
}
CEffectComponent::CEffectComponent(CInputStream& in)
{
x0_name = in.readString();
x10_tag = GetSObjectTagFromStream(in);
x18_boneName = in.readString();
x28_ = in.readFloatBig();
x2c_ = in.readUint32Big();
x30_ = in.readUint32Big();
}
}

View File

@ -0,0 +1,24 @@
#ifndef __PSHAG_CEFFECTCOMPONENT_HPP__
#define __PSHAG_CEFFECTCOMPONENT_HPP__
#include "IOStreams.hpp"
namespace urde
{
class CEffectComponent
{
std::string x0_name;
SObjectTag x10_tag;
std::string x18_boneName;
float x28_;
u32 x2c_;
u32 x30_;
static SObjectTag GetSObjectTagFromStream(CInputStream& in);
public:
CEffectComponent(CInputStream& in);
};
}
#endif // __PSHAG_CEFFECTCOMPONENT_HPP__

View File

@ -0,0 +1,13 @@
#include "CHalfTransition.hpp"
#include "CMetaTransFactory.hpp"
namespace urde
{
CHalfTransition::CHalfTransition(CInputStream& in)
{
x0_id = in.readUint32Big();
x4_trans = CMetaTransFactory::CreateMetaTrans(in);
}
}

View File

@ -0,0 +1,20 @@
#ifndef __PSHAG_CHALFTRANSITION_HPP__
#define __PSHAG_CHALFTRANSITION_HPP__
#include "IOStreams.hpp"
#include "IMetaTrans.hpp"
namespace urde
{
class CHalfTransition
{
u32 x0_id;
std::shared_ptr<IMetaTrans> x4_trans;
public:
CHalfTransition(CInputStream& in);
};
}
#endif // __PSHAG_CHALFTRANSITION_HPP__

View File

@ -16,4 +16,42 @@ add_library(RuntimeCommonCharacter
CSegIdList.hpp CSegIdList.cpp
CSegId.hpp CSegId.cpp
CSkinRules.hpp CSkinRules.cpp
CAnimCharacterSet.hpp CAnimCharacterSet.cpp
CAnimationSet.hpp CAnimationSet.cpp
CCharacterSet.hpp CCharacterSet.cpp
CCharacterInfo.hpp CCharacterInfo.cpp
CPASDatabase.hpp CPASDatabase.cpp
CPASAnimState.hpp CPASAnimState.cpp
CPASParmInfo.hpp CPASParmInfo.cpp
CPASAnimInfo.hpp CPASAnimInfo.cpp
CPASAnimParm.hpp CPASAnimParm.cpp
CEffectComponent.hpp CEffectComponent.cpp
CAnimation.hpp CAnimation.cpp
CTransition.hpp CTransition.cpp
CMetaAnimFactory.hpp CMetaAnimFactory.cpp
CMetaAnimPlay.hpp CMetaAnimPlay.cpp
CMetaAnimBlend.hpp CMetaAnimBlend.cpp
CMetaAnimPhaseBlend.hpp CMetaAnimPhaseBlend.cpp
CMetaAnimRandom.hpp CMetaAnimRandom.cpp
CMetaAnimSequence.hpp CMetaAnimSequence.cpp
CMetaTransFactory.hpp CMetaTransFactory.cpp
CMetaTransMetaAnim.hpp CMetaTransMetaAnim.cpp
CMetaTransTrans.hpp CMetaTransTrans.cpp
CMetaTransPhaseTrans.hpp CMetaTransPhaseTrans.cpp
CMetaTransSnap.hpp CMetaTransSnap.cpp
CAnimTreeLoopIn.hpp CAnimTreeLoopIn.cpp
CAnimTreeSequence.hpp CAnimTreeSequence.cpp
CAnimTreeAnimReaderContainer.hpp CAnimTreeAnimReaderContainer.cpp
CAnimTreeBlend.hpp CAnimTreeBlend.cpp
CAnimTreeNode.hpp CAnimTreeNode.cpp
CAnimTreeScale.hpp CAnimTreeScale.cpp
CAnimTreeTimeScale.hpp CAnimTreeTimeScale.cpp
CAnimTreeTransition.hpp CAnimTreeTransition.cpp
CAnimTreeTweenBase.hpp CAnimTreeTweenBase.cpp
CAnimTreeSingleChild.hpp CAnimTreeSingleChild.cpp
CAnimTreeDoubleChild.hpp CAnimTreeDoubleChild.cpp
IAnimReader.hpp IAnimReader.cpp
CPrimitive.hpp CPrimitive.cpp
CHalfTransition.hpp CHalfTransition.cpp
CTimeScaleFunctions.hpp CTimeScaleFunctions.cpp
CBodyState.hpp)

View File

@ -0,0 +1,31 @@
#include "CMetaAnimBlend.hpp"
#include "CMetaAnimFactory.hpp"
namespace urde
{
CMetaAnimBlend::CMetaAnimBlend(CInputStream& in)
{
x4_animA = CMetaAnimFactory::CreateMetaAnim(in);
x8_animB = CMetaAnimFactory::CreateMetaAnim(in);
xc_blend = in.readFloatBig();
x10_ = in.readBool();
}
std::shared_ptr<CAnimTreeNode>
CMetaAnimBlend::GetAnimationTree(const CAnimSysContext& animSys,
const CMetaAnimTreeBuildOrders& orders) const
{
}
void CMetaAnimBlend::GetUniquePrimitives(std::set<CPrimitive>& primsOut) const
{
}
std::shared_ptr<CAnimTreeNode>
CMetaAnimBlend::VGetAnimationTree(const CAnimSysContext& animSys,
const CMetaAnimTreeBuildOrders& orders) const
{
}
}

View File

@ -0,0 +1,29 @@
#ifndef __PSHAG_CMETAANIMBLEND_HPP__
#define __PSHAG_CMETAANIMBLEND_HPP__
#include "IMetaAnim.hpp"
#include "IOStreams.hpp"
namespace urde
{
class CMetaAnimBlend : public IMetaAnim
{
std::shared_ptr<IMetaAnim> x4_animA;
std::shared_ptr<IMetaAnim> x8_animB;
float xc_blend;
bool x10_;
public:
CMetaAnimBlend(CInputStream& in);
EMetaAnimType GetType() const {return EMetaAnimType::Blend;}
std::shared_ptr<CAnimTreeNode> GetAnimationTree(const CAnimSysContext& animSys,
const CMetaAnimTreeBuildOrders& orders) const;
void GetUniquePrimitives(std::set<CPrimitive>& primsOut) const;
std::shared_ptr<CAnimTreeNode> VGetAnimationTree(const CAnimSysContext& animSys,
const CMetaAnimTreeBuildOrders& orders) const;
};
}
#endif // __PSHAG_CMETAANIMBLEND_HPP__

View File

@ -0,0 +1,33 @@
#include "CMetaAnimFactory.hpp"
#include "CMetaAnimPlay.hpp"
#include "CMetaAnimBlend.hpp"
#include "CMetaAnimPhaseBlend.hpp"
#include "CMetaAnimRandom.hpp"
#include "CMetaAnimSequence.hpp"
namespace urde
{
std::shared_ptr<IMetaAnim> CMetaAnimFactory::CreateMetaAnim(CInputStream& in)
{
EMetaAnimType type = EMetaAnimType(in.readUint32Big());
switch (type)
{
case EMetaAnimType::Primitive:
return std::make_shared<CMetaAnimPlay>(in);
case EMetaAnimType::Blend:
return std::make_shared<CMetaAnimBlend>(in);
case EMetaAnimType::PhaseBlend:
return std::make_shared<CMetaAnimPhaseBlend>(in);
case EMetaAnimType::Random:
return std::make_shared<CMetaAnimRandom>(in);
case EMetaAnimType::Sequence:
return std::make_shared<CMetaAnimSequence>(in);
default: break;
}
return {};
}
}

View File

@ -0,0 +1,18 @@
#ifndef __PSHAG_CMETAANIMFACTORY_HPP__
#define __PSHAG_CMETAANIMFACTORY_HPP__
#include "IOStreams.hpp"
#include "IMetaAnim.hpp"
namespace urde
{
class CMetaAnimFactory
{
public:
static std::shared_ptr<IMetaAnim> CreateMetaAnim(CInputStream& in);
};
}
#endif // __PSHAG_CMETAANIMFACTORY_HPP__

View File

@ -0,0 +1,31 @@
#include "CMetaAnimPhaseBlend.hpp"
#include "CMetaAnimFactory.hpp"
namespace urde
{
CMetaAnimPhaseBlend::CMetaAnimPhaseBlend(CInputStream& in)
{
x4_animA = CMetaAnimFactory::CreateMetaAnim(in);
x8_animB = CMetaAnimFactory::CreateMetaAnim(in);
xc_blend = in.readFloatBig();
x10_ = in.readBool();
}
std::shared_ptr<CAnimTreeNode>
CMetaAnimPhaseBlend::GetAnimationTree(const CAnimSysContext& animSys,
const CMetaAnimTreeBuildOrders& orders) const
{
}
void CMetaAnimPhaseBlend::GetUniquePrimitives(std::set<CPrimitive>& primsOut) const
{
}
std::shared_ptr<CAnimTreeNode>
CMetaAnimPhaseBlend::VGetAnimationTree(const CAnimSysContext& animSys,
const CMetaAnimTreeBuildOrders& orders) const
{
}
}

View File

@ -0,0 +1,29 @@
#ifndef __PSHAG_CMETAANIMPHASEBLEND_HPP__
#define __PSHAG_CMETAANIMPHASEBLEND_HPP__
#include "IMetaAnim.hpp"
#include "IOStreams.hpp"
namespace urde
{
class CMetaAnimPhaseBlend : public IMetaAnim
{
std::shared_ptr<IMetaAnim> x4_animA;
std::shared_ptr<IMetaAnim> x8_animB;
float xc_blend;
bool x10_;
public:
CMetaAnimPhaseBlend(CInputStream& in);
EMetaAnimType GetType() const {return EMetaAnimType::PhaseBlend;}
std::shared_ptr<CAnimTreeNode> GetAnimationTree(const CAnimSysContext& animSys,
const CMetaAnimTreeBuildOrders& orders) const;
void GetUniquePrimitives(std::set<CPrimitive>& primsOut) const;
std::shared_ptr<CAnimTreeNode> VGetAnimationTree(const CAnimSysContext& animSys,
const CMetaAnimTreeBuildOrders& orders) const;
};
}
#endif // __PSHAG_CMETAANIMPHASEBLEND_HPP__

View File

@ -0,0 +1,25 @@
#include "CMetaAnimPlay.hpp"
namespace urde
{
CMetaAnimPlay::CMetaAnimPlay(CInputStream& in)
: x4_primitive(in), x1c_(in.readFloatBig()), x20_(in.readUint32Big()) {}
std::shared_ptr<CAnimTreeNode>
CMetaAnimPlay::GetAnimationTree(const CAnimSysContext& animSys,
const CMetaAnimTreeBuildOrders& orders) const
{
}
void CMetaAnimPlay::GetUniquePrimitives(std::set<CPrimitive>& primsOut) const
{
}
std::shared_ptr<CAnimTreeNode>
CMetaAnimPlay::VGetAnimationTree(const CAnimSysContext& animSys,
const CMetaAnimTreeBuildOrders& orders) const
{
}
}

View File

@ -0,0 +1,29 @@
#ifndef __PSHAG_CMETAANIMPLAY_HPP__
#define __PSHAG_CMETAANIMPLAY_HPP__
#include "IMetaAnim.hpp"
#include "CPrimitive.hpp"
#include "IOStreams.hpp"
namespace urde
{
class CMetaAnimPlay : public IMetaAnim
{
CPrimitive x4_primitive;
float x1c_;
u32 x20_;
public:
CMetaAnimPlay(CInputStream& in);
EMetaAnimType GetType() const {return EMetaAnimType::Primitive;}
std::shared_ptr<CAnimTreeNode> GetAnimationTree(const CAnimSysContext& animSys,
const CMetaAnimTreeBuildOrders& orders) const;
void GetUniquePrimitives(std::set<CPrimitive>& primsOut) const;
std::shared_ptr<CAnimTreeNode> VGetAnimationTree(const CAnimSysContext& animSys,
const CMetaAnimTreeBuildOrders& orders) const;
};
}
#endif // __PSHAG_CMETAANIMPLAY_HPP__

View File

@ -0,0 +1,41 @@
#include "CMetaAnimRandom.hpp"
#include "CMetaAnimFactory.hpp"
namespace urde
{
CMetaAnimRandom::RandomData CMetaAnimRandom::CreateRandomData(CInputStream& in)
{
CMetaAnimRandom::RandomData ret;
u32 randCount = in.readUint32Big();
ret.reserve(randCount);
for (u32 i=0 ; i<randCount ; ++i)
{
std::shared_ptr<IMetaAnim> metaAnim = CMetaAnimFactory::CreateMetaAnim(in);
ret.emplace_back(std::move(metaAnim), in.readUint32Big());
}
return ret;
}
CMetaAnimRandom::CMetaAnimRandom(CInputStream& in)
: x4_randomData(CreateRandomData(in)) {}
std::shared_ptr<CAnimTreeNode>
CMetaAnimRandom::GetAnimationTree(const CAnimSysContext& animSys,
const CMetaAnimTreeBuildOrders& orders) const
{
}
void CMetaAnimRandom::GetUniquePrimitives(std::set<CPrimitive>& primsOut) const
{
}
std::shared_ptr<CAnimTreeNode>
CMetaAnimRandom::VGetAnimationTree(const CAnimSysContext& animSys,
const CMetaAnimTreeBuildOrders& orders) const
{
}
}

View File

@ -0,0 +1,28 @@
#ifndef __PSHAG_CMETAANIMRANDOM_HPP__
#define __PSHAG_CMETAANIMRANDOM_HPP__
#include "IMetaAnim.hpp"
#include "IOStreams.hpp"
namespace urde
{
class CMetaAnimRandom : public IMetaAnim
{
using RandomData = std::vector<std::pair<std::shared_ptr<IMetaAnim>, u32>>;
RandomData x4_randomData;
static RandomData CreateRandomData(CInputStream& in);
public:
CMetaAnimRandom(CInputStream& in);
EMetaAnimType GetType() const {return EMetaAnimType::Random;}
std::shared_ptr<CAnimTreeNode> GetAnimationTree(const CAnimSysContext& animSys,
const CMetaAnimTreeBuildOrders& orders) const;
void GetUniquePrimitives(std::set<CPrimitive>& primsOut) const;
std::shared_ptr<CAnimTreeNode> VGetAnimationTree(const CAnimSysContext& animSys,
const CMetaAnimTreeBuildOrders& orders) const;
};
}
#endif // __PSHAG_CMETAANIMRANDOM_HPP__

View File

@ -0,0 +1,38 @@
#include "CMetaAnimSequence.hpp"
#include "CMetaAnimFactory.hpp"
namespace urde
{
std::vector<std::shared_ptr<IMetaAnim>> CMetaAnimSequence::CreateSequence(CInputStream& in)
{
std::vector<std::shared_ptr<IMetaAnim>> ret;
u32 seqCount = in.readUint32Big();
ret.reserve(seqCount);
for (u32 i=0 ; i<seqCount ; ++i)
ret.push_back(std::move(CMetaAnimFactory::CreateMetaAnim(in)));
return ret;
}
CMetaAnimSequence::CMetaAnimSequence(CInputStream& in)
: x4_sequence(CreateSequence(in)) {}
std::shared_ptr<CAnimTreeNode>
CMetaAnimSequence::GetAnimationTree(const CAnimSysContext& animSys,
const CMetaAnimTreeBuildOrders& orders) const
{
}
void CMetaAnimSequence::GetUniquePrimitives(std::set<CPrimitive>& primsOut) const
{
}
std::shared_ptr<CAnimTreeNode>
CMetaAnimSequence::VGetAnimationTree(const CAnimSysContext& animSys,
const CMetaAnimTreeBuildOrders& orders) const
{
}
}

View File

@ -0,0 +1,27 @@
#ifndef __PSHAG_CMETAANIMSEQUENCE_HPP__
#define __PSHAG_CMETAANIMSEQUENCE_HPP__
#include "IMetaAnim.hpp"
#include "IOStreams.hpp"
namespace urde
{
class CMetaAnimSequence : public IMetaAnim
{
std::vector<std::shared_ptr<IMetaAnim>> x4_sequence;
std::vector<std::shared_ptr<IMetaAnim>> CreateSequence(CInputStream& in);
public:
CMetaAnimSequence(CInputStream& in);
EMetaAnimType GetType() const {return EMetaAnimType::Sequence;}
std::shared_ptr<CAnimTreeNode> GetAnimationTree(const CAnimSysContext& animSys,
const CMetaAnimTreeBuildOrders& orders) const;
void GetUniquePrimitives(std::set<CPrimitive>& primsOut) const;
std::shared_ptr<CAnimTreeNode> VGetAnimationTree(const CAnimSysContext& animSys,
const CMetaAnimTreeBuildOrders& orders) const;
};
}
#endif // __PSHAG_CMETAANIMSEQUENCE_HPP__

View File

@ -0,0 +1,30 @@
#include "CMetaTransFactory.hpp"
#include "CMetaTransMetaAnim.hpp"
#include "CMetaTransTrans.hpp"
#include "CMetaTransPhaseTrans.hpp"
#include "CMetaTransSnap.hpp"
namespace urde
{
std::shared_ptr<IMetaTrans> CMetaTransFactory::CreateMetaTrans(CInputStream& in)
{
EMetaTransType type = EMetaTransType(in.readUint32Big());
switch (type)
{
case EMetaTransType::MetaAnim:
return std::make_shared<CMetaTransMetaAnim>(in);
case EMetaTransType::Trans:
return std::make_shared<CMetaTransTrans>(in);
case EMetaTransType::PhaseTrans:
return std::make_shared<CMetaTransPhaseTrans>(in);
case EMetaTransType::Snap:
return std::make_shared<CMetaTransSnap>();
default: break;
}
return {};
}
}

View File

@ -0,0 +1,18 @@
#ifndef __PSHAG_CMETATRANSFACTORY_HPP__
#define __PSHAG_CMETATRANSFACTORY_HPP__
#include "IOStreams.hpp"
#include "IMetaTrans.hpp"
namespace urde
{
class CMetaTransFactory
{
public:
static std::shared_ptr<IMetaTrans> CreateMetaTrans(CInputStream& in);
};
}
#endif // __PSHAG_CMETATRANSFACTORY_HPP__

View File

@ -0,0 +1,17 @@
#include "CMetaTransMetaAnim.hpp"
#include "CMetaAnimFactory.hpp"
namespace urde
{
CMetaTransMetaAnim::CMetaTransMetaAnim(CInputStream& in)
: x4_metaAnim(CMetaAnimFactory::CreateMetaAnim(in)) {}
std::shared_ptr<CAnimTreeNode>
CMetaTransMetaAnim::VGetTransitionTree(const std::weak_ptr<CAnimTreeNode>& a,
const std::weak_ptr<CAnimTreeNode>& b,
const CAnimSysContext& animSys) const
{
}
}

View File

@ -0,0 +1,25 @@
#ifndef __PSHAG_CMETATRANSMETAANIM_HPP__
#define __PSHAG_CMETATRANSMETAANIM_HPP__
#include "IMetaTrans.hpp"
#include "IMetaAnim.hpp"
#include "IOStreams.hpp"
namespace urde
{
class CMetaTransMetaAnim : public IMetaTrans
{
std::shared_ptr<IMetaAnim> x4_metaAnim;
public:
CMetaTransMetaAnim(CInputStream& in);
EMetaTransType GetType() const {return EMetaTransType::MetaAnim;}
std::shared_ptr<CAnimTreeNode> VGetTransitionTree(const std::weak_ptr<CAnimTreeNode>& a,
const std::weak_ptr<CAnimTreeNode>& b,
const CAnimSysContext& animSys) const;
};
}
#endif // __PSHAG_CMETATRANSMETAANIM_HPP__

View File

@ -0,0 +1,22 @@
#include "CMetaTransPhaseTrans.hpp"
namespace urde
{
CMetaTransPhaseTrans::CMetaTransPhaseTrans(CInputStream& in)
{
x4_ = in.readFloatBig();
x8_ = in.readUint32Big();
xc_ = in.readBool();
xd_ = in.readBool();
x10_ = in.readUint32Big();
}
std::shared_ptr<CAnimTreeNode>
CMetaTransPhaseTrans::VGetTransitionTree(const std::weak_ptr<CAnimTreeNode>& a,
const std::weak_ptr<CAnimTreeNode>& b,
const CAnimSysContext& animSys) const
{
}
}

View File

@ -0,0 +1,28 @@
#ifndef __PSHAG_CMETATRANSPHASETRANS_HPP__
#define __PSHAG_CMETATRANSPHASETRANS_HPP__
#include "IMetaTrans.hpp"
#include "IOStreams.hpp"
namespace urde
{
class CMetaTransPhaseTrans : public IMetaTrans
{
float x4_;
u32 x8_;
bool xc_;
bool xd_;
u32 x10_;
public:
CMetaTransPhaseTrans(CInputStream& in);
EMetaTransType GetType() const {return EMetaTransType::PhaseTrans;}
std::shared_ptr<CAnimTreeNode> VGetTransitionTree(const std::weak_ptr<CAnimTreeNode>& a,
const std::weak_ptr<CAnimTreeNode>& b,
const CAnimSysContext& animSys) const;
};
}
#endif // __PSHAG_CMETATRANSPHASETRANS_HPP__

View File

@ -0,0 +1,14 @@
#include "CMetaTransSnap.hpp"
namespace urde
{
std::shared_ptr<CAnimTreeNode>
CMetaTransSnap::VGetTransitionTree(const std::weak_ptr<CAnimTreeNode>& a,
const std::weak_ptr<CAnimTreeNode>& b,
const CAnimSysContext& animSys) const
{
return b.lock();
}
}

View File

@ -0,0 +1,22 @@
#ifndef __PSHAG_CMETATRANSSNAP_HPP__
#define __PSHAG_CMETATRANSSNAP_HPP__
#include "IMetaTrans.hpp"
#include "IOStreams.hpp"
namespace urde
{
class CMetaTransSnap : public IMetaTrans
{
public:
EMetaTransType GetType() const {return EMetaTransType::Snap;}
std::shared_ptr<CAnimTreeNode> VGetTransitionTree(const std::weak_ptr<CAnimTreeNode>& a,
const std::weak_ptr<CAnimTreeNode>& b,
const CAnimSysContext& animSys) const;
};
}
#endif // __PSHAG_CMETATRANSSNAP_HPP__

View File

@ -0,0 +1,24 @@
#include "CMetaTransTrans.hpp"
#include "CAnimTreeTransition.hpp"
namespace urde
{
CMetaTransTrans::CMetaTransTrans(CInputStream& in)
{
x4_ = in.readFloatBig();
x8_ = in.readUint32Big();
xc_ = in.readBool();
xd_ = in.readBool();
x10_ = in.readUint32Big();
}
std::shared_ptr<CAnimTreeNode>
CMetaTransTrans::VGetTransitionTree(const std::weak_ptr<CAnimTreeNode>& a,
const std::weak_ptr<CAnimTreeNode>& b,
const CAnimSysContext& animSys) const
{
}
}

View File

@ -0,0 +1,28 @@
#ifndef __PSHAG_CMETATRANSTRANS_HPP__
#define __PSHAG_CMETATRANSTRANS_HPP__
#include "IMetaTrans.hpp"
#include "IOStreams.hpp"
namespace urde
{
class CMetaTransTrans : public IMetaTrans
{
float x4_;
u32 x8_;
bool xc_;
bool xd_;
u32 x10_;
public:
CMetaTransTrans(CInputStream& in);
EMetaTransType GetType() const {return EMetaTransType::Trans;}
std::shared_ptr<CAnimTreeNode> VGetTransitionTree(const std::weak_ptr<CAnimTreeNode>& a,
const std::weak_ptr<CAnimTreeNode>& b,
const CAnimSysContext& animSys) const;
};
}
#endif // __PSHAG_CMETATRANSTRANS_HPP__

View File

@ -0,0 +1,9 @@
#include "CPASAnimInfo.hpp"
namespace urde
{
CPASAnimInfo::CPASAnimInfo(u32 id, rstl::reserved_vector<CPASAnimParm::UParmValue, 8>&& parms)
: x0_id(id), x4_parms(std::move(parms)) {}
}

View File

@ -0,0 +1,22 @@
#ifndef __PSHAG_CPASANIMINFO_HPP__
#define __PSHAG_CPASANIMINFO_HPP__
#include "IOStreams.hpp"
#include "rstl.hpp"
#include "CPASAnimParm.hpp"
namespace urde
{
class CPASAnimInfo
{
u32 x0_id;
rstl::reserved_vector<CPASAnimParm::UParmValue, 8> x4_parms;
public:
CPASAnimInfo(u32 id, rstl::reserved_vector<CPASAnimParm::UParmValue, 8>&& parms);
u32 GetId() const {return x0_id;}
};
}
#endif // __PSHAG_CPASANIMINFO_HPP__

View File

View File

@ -0,0 +1,86 @@
#ifndef __PSHAG_CPASANIMPARM_HPP__
#define __PSHAG_CPASANIMPARM_HPP__
#include "RetroTypes.hpp"
namespace urde
{
class CPASAnimParm
{
public:
enum class EParmType
{
None = -1,
Int32 = 0,
UInt32 = 1,
Float = 2,
Bool = 3,
Enum = 4
};
union UParmValue
{
s32 m_int;
u32 m_uint;
float m_float;
bool m_bool;
};
private:
UParmValue x0_value;
EParmType x4_type;
public:
CPASAnimParm(UParmValue val, EParmType tp) : x4_type(tp), x0_value(val) {}
s32 GetEnumValue() const {return x0_value.m_int;}
bool GetBoolValue() const {return x0_value.m_bool;}
float GetReal32Value() const {return x0_value.m_float;}
u32 GetUint32Value() const {return x0_value.m_uint;}
s32 GetInt32Value() const {return x0_value.m_int;}
static CPASAnimParm FromEnum(s32 val)
{
UParmValue valin;
valin.m_int = val;
return CPASAnimParm(valin, EParmType::Enum);
}
static CPASAnimParm FromBool(bool val)
{
UParmValue valin;
valin.m_bool = val;
return CPASAnimParm(valin, EParmType::Bool);
}
static CPASAnimParm FromReal32(float val)
{
UParmValue valin;
valin.m_float = val;
return CPASAnimParm(valin, EParmType::Float);
}
static CPASAnimParm FromUint32(u32 val)
{
UParmValue valin;
valin.m_uint = val;
return CPASAnimParm(valin, EParmType::UInt32);
}
static CPASAnimParm FromInt32(s32 val)
{
UParmValue valin;
valin.m_int = val;
return CPASAnimParm(valin, EParmType::Int32);
}
static CPASAnimParm NoParameter()
{
UParmValue valin;
valin.m_int = -1;
return CPASAnimParm(valin, EParmType::None);
}
};
}
#endif // __PSHAG_CPASANIMPARM_HPP__

View File

@ -0,0 +1,54 @@
#include "CPASAnimState.hpp"
namespace urde
{
CPASAnimState::CPASAnimState(CInputStream& in)
{
x0_id = in.readUint32Big();
u32 parmCount = in.readUint32Big();
u32 animCount = in.readUint32Big();
x4_parms.reserve(parmCount);
x14_anims.reserve(animCount);
x24_.reserve(animCount);
for (u32 i=0 ; i<parmCount ; ++i)
x4_parms.emplace_back(in);
for (u32 i=0 ; i<animCount ; ++i)
{
u32 id = in.readUint32Big();
rstl::reserved_vector<CPASAnimParm::UParmValue, 8> parms;
for (const CPASParmInfo& parm : x4_parms)
{
CPASAnimParm::UParmValue val = {};
switch (parm.GetType())
{
case CPASAnimParm::EParmType::Int32:
val.m_int = in.readInt32Big();
break;
case CPASAnimParm::EParmType::UInt32:
val.m_uint = in.readUint32Big();
break;
case CPASAnimParm::EParmType::Float:
val.m_float = in.readFloatBig();
break;
case CPASAnimParm::EParmType::Bool:
val.m_bool = in.readBool();
break;
case CPASAnimParm::EParmType::Enum:
val.m_int = in.readInt32Big();
break;
default: break;
}
parms.push_back(val);
}
auto search = std::lower_bound(x14_anims.begin(), x14_anims.end(), id,
[](const CPASAnimInfo& item, const u32& testId) -> bool {return item.GetId() < testId;});
x14_anims.emplace(search, id, std::move(parms));
}
}
}

View File

@ -0,0 +1,24 @@
#ifndef __PSHAG_CPASANIMSTATE_HPP__
#define __PSHAG_CPASANIMSTATE_HPP__
#include "IOStreams.hpp"
#include "CPASParmInfo.hpp"
#include "CPASAnimInfo.hpp"
namespace urde
{
class CPASAnimState
{
u32 x0_id;
std::vector<CPASParmInfo> x4_parms;
std::vector<CPASAnimInfo> x14_anims;
std::vector<u32> x24_;
public:
CPASAnimState(CInputStream& in);
u32 GetId() const {return x0_id;}
};
}
#endif // __PSHAG_CPASANIMSTATE_HPP__

View File

@ -0,0 +1,30 @@
#include "CPASDatabase.hpp"
namespace urde
{
void CPASDatabase::AddAnimState(CPASAnimState&& state)
{
auto it = std::lower_bound(x0_states.begin(), x0_states.end(), state,
[](const CPASAnimState& item, const CPASAnimState& test) -> bool {return item.GetId() < test.GetId();});
x0_states.insert(it, std::move(state));
}
CPASDatabase::CPASDatabase(CInputStream& in)
{
in.readUint32Big();
u32 animStateCount = in.readUint32Big();
u32 defaultState = in.readUint32Big();
x0_states.reserve(animStateCount);
for (u32 i=0 ; i<animStateCount ; ++i)
{
CPASAnimState state(in);
AddAnimState(std::move(state));
}
if (animStateCount)
SetDefaultState(defaultState);
}
}

View File

@ -0,0 +1,22 @@
#ifndef __PSHAG_CPASDATABASE_HPP__
#define __PSHAG_CPASDATABASE_HPP__
#include "IOStreams.hpp"
#include "CPASAnimState.hpp"
namespace urde
{
class CPASDatabase
{
std::vector<CPASAnimState> x0_states;
u32 x10_defaultState;
void AddAnimState(CPASAnimState&& state);
void SetDefaultState(u32 state) {x10_defaultState = state;}
public:
CPASDatabase(CInputStream& in);
};
}
#endif // __PSHAG_CPASDATABASE_HPP__

View File

@ -0,0 +1,40 @@
#include "CPASParmInfo.hpp"
namespace urde
{
CPASParmInfo::CPASParmInfo(CInputStream& in)
{
xc_val1.m_int = 0;
x10_val2.m_int = 0;
x0_type = CPASAnimParm::EParmType(in.readUint32Big());
x4_unk1 = in.readUint32Big();
x8_unk2 = in.readFloatBig();
switch (x0_type)
{
case CPASAnimParm::EParmType::Int32:
xc_val1.m_int = in.readInt32Big();
x10_val2.m_int = in.readInt32Big();
break;
case CPASAnimParm::EParmType::UInt32:
xc_val1.m_uint = in.readUint32Big();
x10_val2.m_uint = in.readUint32Big();
break;
case CPASAnimParm::EParmType::Float:
xc_val1.m_float = in.readFloatBig();
x10_val2.m_float = in.readFloatBig();
break;
case CPASAnimParm::EParmType::Bool:
xc_val1.m_bool = in.readBool();
x10_val2.m_bool = in.readBool();
break;
case CPASAnimParm::EParmType::Enum:
xc_val1.m_int = in.readInt32Big();
x10_val2.m_int = in.readInt32Big();
break;
default: break;
}
}
}

View File

@ -0,0 +1,24 @@
#ifndef __PSHAG_CPASPARMINFO_HPP__
#define __PSHAG_CPASPARMINFO_HPP__
#include "IOStreams.hpp"
#include "CPASAnimParm.hpp"
namespace urde
{
class CPASParmInfo
{
CPASAnimParm::EParmType x0_type;
u32 x4_unk1;
float x8_unk2;
CPASAnimParm::UParmValue xc_val1;
CPASAnimParm::UParmValue x10_val2;
public:
CPASParmInfo(CInputStream& in);
CPASAnimParm::EParmType GetType() const {return x0_type;}
};
}
#endif // __PSHAG_CPASPARMINFO_HPP__

View File

@ -0,0 +1,13 @@
#include "CPrimitive.hpp"
namespace urde
{
CPrimitive::CPrimitive(CInputStream& in)
{
x0_animId = in.readUint32Big();
x4_animIdx = in.readUint32Big();
x8_animName = in.readString();
}
}

View File

@ -0,0 +1,20 @@
#ifndef __PSHAG_CPRIMITIVE_HPP__
#define __PSHAG_CPRIMITIVE_HPP__
#include "IOStreams.hpp"
namespace urde
{
class CPrimitive
{
TResId x0_animId;
u32 x4_animIdx;
std::string x8_animName;
public:
CPrimitive(CInputStream& in);
};
}
#endif // __PSHAG_CPRIMITIVE_HPP__

View File

@ -0,0 +1,80 @@
#include "CTimeScaleFunctions.hpp"
#include "CCharAnimTime.hpp"
namespace urde
{
std::shared_ptr<IVaryingAnimationTimeScale> IVaryingAnimationTimeScale::Clone() const
{
return VClone();
}
void CConstantAnimationTimeScale::VTimeScaleIntegral(const float&, const float&) const
{
}
void CConstantAnimationTimeScale::VFindUpperLimit(const float&, const float&) const
{
}
std::shared_ptr<IVaryingAnimationTimeScale> CConstantAnimationTimeScale::VClone() const
{
}
std::shared_ptr<IVaryingAnimationTimeScale>
CConstantAnimationTimeScale::VGetFunctionMirrored(const float&) const
{
}
void CLinearAnimationTimeScale::VTimeScaleIntegral(const float&, const float&) const
{
}
void CLinearAnimationTimeScale::TimeScaleIntegralWithSortedLimits(const CFunctionDescription& desc,
const float&, const float&)
{
}
void CLinearAnimationTimeScale::VFindUpperLimit(const float&, const float&) const
{
}
void CLinearAnimationTimeScale::FindUpperLimitFromRoot(const CFunctionDescription& desc,
const float&, const float&)
{
}
std::shared_ptr<IVaryingAnimationTimeScale> CLinearAnimationTimeScale::VClone() const
{
CCharAnimTime timeA(x10_);
CCharAnimTime timeB(xc_);
CLinearAnimationTimeScale* ret = new CLinearAnimationTimeScale();
float f30 = x4_ * xc_ + x8_;
ret->x4_ = (x4_ * x10_ + x8_ - f30) / timeB;
ret->x8_ = -((x4_ * x10_ + x8_ - f30) / (timeA - timeB) * timeB - f30);
ret->xc_ = timeB;
ret->x10_ = timeA;
return std::shared_ptr<IVaryingAnimationTimeScale>(ret);
}
std::shared_ptr<IVaryingAnimationTimeScale>
CLinearAnimationTimeScale::VGetFunctionMirrored(const float& parm) const
{
float f27 = -(x4_ * parm * 2.f - x8_);
float f31 = -x4_ * parm * 2.f - x10_ + f27;
CCharAnimTime timeA(2.f * parm - xc_);
CCharAnimTime timeB(2.f * parm - x10_);
CLinearAnimationTimeScale* ret = new CLinearAnimationTimeScale();
ret->x4_ = (-x4_ * 2.f * parm - xc_ + f27 - f31) / (timeA - timeB);
ret->x8_ = -(((-x4_ * 2.f * parm - xc_ + f27 - f31) / (timeA - timeB)) * timeB - f31);
ret->xc_ = timeB;
ret->x10_ = timeA;
return std::shared_ptr<IVaryingAnimationTimeScale>(ret);
}
}

View File

@ -0,0 +1,59 @@
#ifndef __PSHAG_CTIMESCALEFUNCTIONS_HPP__
#define __PSHAG_CTIMESCALEFUNCTIONS_HPP__
#include "RetroTypes.hpp"
namespace urde
{
enum class EVaryingAnimationTimeScaleType
{
Constant,
Linear
};
class IVaryingAnimationTimeScale
{
public:
virtual ~IVaryingAnimationTimeScale() = default;
virtual EVaryingAnimationTimeScaleType GetType() const=0;
virtual void VTimeScaleIntegral(const float&, const float&) const=0;
virtual void VFindUpperLimit(const float&, const float&) const=0;
virtual std::shared_ptr<IVaryingAnimationTimeScale> VClone() const=0;
virtual std::shared_ptr<IVaryingAnimationTimeScale> VGetFunctionMirrored(const float&) const=0;
std::shared_ptr<IVaryingAnimationTimeScale> Clone() const;
};
class CConstantAnimationTimeScale : public IVaryingAnimationTimeScale
{
public:
EVaryingAnimationTimeScaleType GetType() const {return EVaryingAnimationTimeScaleType::Constant;}
void VTimeScaleIntegral(const float&, const float&) const;
void VFindUpperLimit(const float&, const float&) const;
std::shared_ptr<IVaryingAnimationTimeScale> VClone() const;
std::shared_ptr<IVaryingAnimationTimeScale> VGetFunctionMirrored(const float&) const;
};
class CLinearAnimationTimeScale : public IVaryingAnimationTimeScale
{
float x4_;
float x8_;
float xc_;
float x10_;
public:
struct CFunctionDescription
{
};
EVaryingAnimationTimeScaleType GetType() const {return EVaryingAnimationTimeScaleType::Linear;}
void VTimeScaleIntegral(const float&, const float&) const;
void TimeScaleIntegralWithSortedLimits(const CFunctionDescription& desc, const float&, const float&);
void VFindUpperLimit(const float&, const float&) const;
void FindUpperLimitFromRoot(const CFunctionDescription& desc, const float&, const float&);
std::shared_ptr<IVaryingAnimationTimeScale> VClone() const;
std::shared_ptr<IVaryingAnimationTimeScale> VGetFunctionMirrored(const float&) const;
};
}
#endif // __PSHAG_CTIMESCALEFUNCTIONS_HPP__

View File

@ -0,0 +1,10 @@
#include "CTransition.hpp"
namespace urde
{
CTransition::CTransition(CInputStream& in)
{
}
}

View File

@ -0,0 +1,22 @@
#ifndef __PSHAG_CTRANSITION_HPP__
#define __PSHAG_CTRANSITION_HPP__
#include "IOStreams.hpp"
#include "CMetaTransFactory.hpp"
namespace urde
{
class CTransition
{
u32 x0_id;
u32 x4_animA;
u32 x8_animB;
std::unique_ptr<IMetaTrans> xc_trans;
public:
CTransition(CInputStream& in);
};
}
#endif // __PSHAG_CTRANSITION_HPP__

View File

@ -0,0 +1,14 @@
#include "IAnimReader.hpp"
#include "CCharAnimTime.hpp"
namespace urde
{
SAdvancementResults IAnimReader::VGetAdvancementResults(const CCharAnimTime& a, const CCharAnimTime& b) const
{
SAdvancementResults ret;
ret.x0_animTime = a;
return ret;
}
}

View File

@ -0,0 +1,58 @@
#ifndef __PSHAG_IANIMREADER_HPP__
#define __PSHAG_IANIMREADER_HPP__
#include "RetroTypes.hpp"
#include "CCharAnimTime.hpp"
#include "zeus/CVector3f.hpp"
#include "zeus/CQuaternion.hpp"
namespace urde
{
class CSegId;
class CBoolPOINode;
class CInt32POINode;
class CParticlePOINode;
class CSoundPOINode;
class CSegIdList;
class CSegStatementSet;
struct SAdvancementResults
{
CCharAnimTime x0_animTime;
zeus::CVector3f x8_posDelta;
zeus::CQuaternion x14_rotDelta;
};
class IAnimReader
{
public:
virtual ~IAnimReader() = default;
virtual bool IsCAnimTreeNode() const {return false;}
virtual void VAdvanceView(const CCharAnimTime& a)=0;
virtual void VGetTimeRemaining() const=0;
virtual void VGetSteadyStateAnimInfo() const=0;
virtual bool VHasOffset(const CSegId& seg) const=0;
virtual void VGetOffset(const CSegId& seg) const=0;
virtual void VGetRotation(const CSegId& seg) const=0;
virtual void VGetBoolPOIList(const CCharAnimTime& time, CBoolPOINode* listOut, u32, u32, u32) const=0;
virtual void VGetInt32POIList(const CCharAnimTime& time, CInt32POINode* listOut, u32, u32, u32) const=0;
virtual void VGetParticlePOIList(const CCharAnimTime& time, CParticlePOINode* listOut, u32, u32, u32) const=0;
virtual void VGetSoundPOIList(const CCharAnimTime& time, CSoundPOINode* listOut, u32, u32, u32) const=0;
virtual void VGetBoolPOIState(const char*) const=0;
virtual void VGetInt32POIState(const char*) const=0;
virtual void VGetParticlePOIState(const char*) const=0;
virtual void VGetSegStatementSet(const CSegIdList& list, CSegStatementSet& setOut) const=0;
virtual void VGetSegStatementSet(const CSegIdList& list, CSegStatementSet& setOut, const CCharAnimTime& time) const=0;
virtual void VClone() const=0;
virtual std::unique_ptr<IAnimReader> VSimplified() {return {};}
virtual void VSetPhase(float)=0;
virtual SAdvancementResults VGetAdvancementResults(const CCharAnimTime& a, const CCharAnimTime& b) const;
virtual void Depth() const=0;
virtual void VGetContributionOfHighestInfluence() const=0;
virtual void VGetNumChildren() const=0;
virtual void VGetBestUnblendedChild() const=0;
};
}
#endif // __PSHAG_IANIMREADER_HPP__

View File

@ -2,12 +2,34 @@
#define __PSHAG_IMETAANIM_HPP__
#include "../RetroTypes.hpp"
#include <set>
namespace urde
{
class CAnimTreeNode;
class CAnimSysContext;
class CMetaAnimTreeBuildOrders;
class CPrimitive;
enum class EMetaAnimType
{
Primitive,
Blend,
PhaseBlend,
Random,
Sequence
};
class IMetaAnim
{
public:
virtual ~IMetaAnim() = default;
virtual std::shared_ptr<CAnimTreeNode> GetAnimationTree(const CAnimSysContext& animSys,
const CMetaAnimTreeBuildOrders& orders) const=0;
virtual void GetUniquePrimitives(std::set<CPrimitive>& primsOut) const=0;
virtual EMetaAnimType GetType() const=0;
virtual std::shared_ptr<CAnimTreeNode> VGetAnimationTree(const CAnimSysContext& animSys,
const CMetaAnimTreeBuildOrders& orders) const=0;
};
}

View File

@ -5,9 +5,25 @@
namespace urde
{
class CAnimTreeNode;
class CAnimSysContext;
enum class EMetaTransType
{
MetaAnim,
Trans,
PhaseTrans,
Snap
};
class IMetaTrans
{
public:
virtual ~IMetaTrans() = default;
virtual std::shared_ptr<CAnimTreeNode> VGetTransitionTree(const std::weak_ptr<CAnimTreeNode>& a,
const std::weak_ptr<CAnimTreeNode>& b,
const CAnimSysContext& animSys) const=0;
virtual EMetaTransType GetType() const=0;
};
}

View File

@ -13,8 +13,8 @@ class IObjectStore
public:
virtual CToken GetObj(const SObjectTag&, const CVParamTransfer&)=0;
virtual CToken GetObj(const SObjectTag&)=0;
virtual CToken GetObj(char const*)=0;
virtual CToken GetObj(char const*, const CVParamTransfer&)=0;
virtual CToken GetObj(const char*)=0;
virtual CToken GetObj(const char*, const CVParamTransfer&)=0;
virtual bool HasObject(const SObjectTag&) const=0;
virtual bool ObjectIsLive(const SObjectTag&) const=0;
virtual IFactory& GetFactory() const=0;