metaforce/DataSpec/DNAMP2/ANCS.hpp

261 lines
8.2 KiB
C++
Raw Normal View History

#ifndef _DNAMP2_ANCS_HPP_
#define _DNAMP2_ANCS_HPP_
#include <map>
#include "../DNACommon/DNACommon.hpp"
#include "../DNACommon/ANCS.hpp"
#include "CMDLMaterials.hpp"
#include "CINF.hpp"
#include "CSKR.hpp"
#include "ANIM.hpp"
#include "../DNAMP1/ANCS.hpp"
2017-12-29 08:08:12 +00:00
namespace DataSpec::DNAMP2
{
2018-02-22 07:24:51 +00:00
struct ANCS : BigDNA
{
using CINFType = CINF;
using CSKRType = CSKR;
using ANIMType = ANIM;
2018-02-22 07:24:51 +00:00
AT_DECL_DNA_YAML
Value<atUint16> version;
2018-02-22 07:24:51 +00:00
struct CharacterSet : BigDNA
2015-08-15 04:12:15 +00:00
{
2018-02-22 07:24:51 +00:00
AT_DECL_DNA_YAML
2015-08-15 04:12:15 +00:00
Value<atUint16> version;
Value<atUint32> characterCount;
2018-02-22 07:24:51 +00:00
struct CharacterInfo : BigDNA
2015-08-15 04:12:15 +00:00
{
2018-02-22 07:24:51 +00:00
AT_DECL_EXPLICIT_DNA_YAML
2015-08-15 04:12:15 +00:00
using MP1CharacterInfo = DNAMP1::ANCS::CharacterSet::CharacterInfo;
atUint32 idx;
std::string name;
UniqueID32 cmdl;
2016-04-07 03:40:25 +00:00
UniqueID32 cskr;
UniqueID32 cinf;
2015-08-15 04:12:15 +00:00
2018-02-22 07:24:51 +00:00
struct Animation : BigDNA
2015-08-15 04:12:15 +00:00
{
2018-02-22 07:24:51 +00:00
AT_DECL_DNA_YAML
2015-08-15 04:12:15 +00:00
Value<atUint32> animIdx;
String<-1> strA;
};
std::vector<Animation> animations;
MP1CharacterInfo::PASDatabase pasDatabase;
struct ParticleResData
{
std::vector<UniqueID32> part;
std::vector<UniqueID32> swhc;
std::vector<UniqueID32> unk;
std::vector<UniqueID32> elsc;
std::vector<UniqueID32> spsc;
std::vector<UniqueID32> unk2;
} partResData;
atUint32 unk1 = 0;
std::vector<MP1CharacterInfo::ActionAABB> animAABBs;
2018-02-22 07:24:51 +00:00
struct Effect : BigDNA
2015-08-15 04:12:15 +00:00
{
2018-02-22 07:24:51 +00:00
AT_DECL_DNA_YAML
2015-08-15 04:12:15 +00:00
String<-1> name;
Value<atUint32> compCount;
2018-02-22 07:24:51 +00:00
struct EffectComponent : BigDNA
2015-08-15 04:12:15 +00:00
{
2018-02-22 07:24:51 +00:00
AT_DECL_DNA_YAML
2015-08-15 04:12:15 +00:00
String<-1> name;
2015-08-23 06:42:29 +00:00
DNAFourCC type;
2015-08-15 04:12:15 +00:00
UniqueID32 id;
Value<atUint32> unkMP2;
Value<float> unk1;
Value<atUint32> unk2;
Value<atUint32> unk3;
};
2018-02-25 08:23:27 +00:00
Vector<EffectComponent, AT_DNA_COUNT(compCount)> comps;
2015-08-15 04:12:15 +00:00
};
std::vector<Effect> effects;
2015-09-26 03:12:08 +00:00
UniqueID32 cmdlOverlay;
2016-04-07 03:40:25 +00:00
UniqueID32 cskrOverlay;
2015-08-15 04:12:15 +00:00
std::vector<atUint32> animIdxs;
atUint32 unk4;
atUint8 unk5;
2018-02-22 07:24:51 +00:00
struct Extents : BigDNA
2015-08-15 04:12:15 +00:00
{
2018-02-22 07:24:51 +00:00
AT_DECL_DNA_YAML
2015-08-15 04:12:15 +00:00
Value<atUint32> animIdx;
Value<atVec3f> aabb[2];
};
std::vector<Extents> extents;
};
2018-02-25 08:23:27 +00:00
Vector<CharacterInfo, AT_DNA_COUNT(characterCount)> characters;
2015-08-15 04:12:15 +00:00
} characterSet;
2018-02-22 07:24:51 +00:00
struct AnimationSet : BigDNA
2015-08-15 04:12:15 +00:00
{
2018-02-22 07:24:51 +00:00
AT_DECL_DNA_YAML
2015-08-15 04:12:15 +00:00
Delete expl;
2015-08-15 04:12:15 +00:00
using MP1AnimationSet = DNAMP1::ANCS::AnimationSet;
std::vector<MP1AnimationSet::Animation> animations;
std::vector<MP1AnimationSet::Transition> transitions;
MP1AnimationSet::MetaTransFactory defaultTransition;
std::vector<MP1AnimationSet::AdditiveAnimationInfo> additiveAnims;
float floatA = 0.0;
float floatB = 0.0;
std::vector<MP1AnimationSet::HalfTransition> halfTransitions;
2018-02-22 07:24:51 +00:00
struct EVNT : BigDNA
2015-08-15 04:12:15 +00:00
{
2018-02-22 07:24:51 +00:00
AT_DECL_EXPLICIT_DNA_YAML
2015-08-15 04:12:15 +00:00
atUint32 version;
2018-02-22 07:24:51 +00:00
struct EventBase : BigDNA
2015-08-15 04:12:15 +00:00
{
2018-02-22 07:24:51 +00:00
AT_DECL_DNA_YAML
2015-08-15 04:12:15 +00:00
Value<atUint16> unk0;
String<-1> name;
Value<atUint16> type;
Value<float> startTime;
Value<atUint32> unk1;
Value<atUint32> idx;
Value<atUint8> unk2;
Value<float> unk3;
2016-03-04 01:01:37 +00:00
Value<atUint32> unk4;
2015-08-15 04:12:15 +00:00
Value<atUint32> unk5;
};
struct LoopEvent : EventBase
{
2018-02-22 07:24:51 +00:00
AT_DECL_DNA_YAML
2015-08-15 04:12:15 +00:00
Value<atUint8> flag;
};
2018-02-22 07:24:51 +00:00
Value<atUint32> loopEventCount;
2018-02-25 08:23:27 +00:00
Vector<LoopEvent, AT_DNA_COUNT(loopEventCount)> loopEvents;
2015-08-15 04:12:15 +00:00
struct UEVTEvent : EventBase
{
2018-02-22 07:24:51 +00:00
AT_DECL_DNA_YAML
2015-08-15 04:12:15 +00:00
Value<atUint32> uevtType;
String<-1> boneName;
};
2018-02-22 07:24:51 +00:00
Value<atUint32> uevtEventCount;
2018-02-25 08:23:27 +00:00
Vector<UEVTEvent, AT_DNA_COUNT(uevtEventCount)> uevtEvents;
2015-08-15 04:12:15 +00:00
struct EffectEvent : EventBase
{
2018-02-22 07:24:51 +00:00
AT_DECL_DNA_YAML
2015-08-15 04:12:15 +00:00
Value<atUint32> frameCount;
2015-08-23 06:42:29 +00:00
DNAFourCC effectType;
2015-08-15 04:12:15 +00:00
UniqueID32 effectId;
Value<atUint32> boneId;
Value<float> scale;
Value<atUint32> parentMode;
};
2018-02-22 07:24:51 +00:00
Value<atUint32> effectEventCount;
2018-02-25 08:23:27 +00:00
Vector<EffectEvent, AT_DNA_COUNT(effectEventCount)> effectEvents;
2015-08-15 04:12:15 +00:00
struct SFXEvent : EventBase
{
2018-02-22 07:24:51 +00:00
AT_DECL_DNA_YAML
2015-08-15 04:12:15 +00:00
Value<atUint32> soundId;
Value<float> smallNum;
Value<float> bigNum;
Value<atUint32> sfxUnk1;
Value<atUint16> sfxUnk2;
Value<atUint16> sfxUnk3;
Value<float> sfxUnk4;
};
2018-02-22 07:24:51 +00:00
Value<atUint32> sfxEventCount;
2018-02-25 08:23:27 +00:00
Vector<SFXEvent, AT_DNA_COUNT(sfxEventCount)> sfxEvents;
2015-08-15 04:12:15 +00:00
};
std::vector<EVNT> evnts;
} animationSet;
void getCharacterResInfo(std::vector<DNAANCS::CharacterResInfo<UniqueID32>>& out) const
{
out.clear();
out.reserve(characterSet.characters.size());
2015-08-15 04:12:15 +00:00
for (const CharacterSet::CharacterInfo& ci : characterSet.characters)
{
out.emplace_back();
DNAANCS::CharacterResInfo<UniqueID32>& chOut = out.back();
chOut.name = ci.name;
chOut.cmdl = ci.cmdl;
2016-04-07 03:40:25 +00:00
chOut.cskr = ci.cskr;
chOut.cinf = ci.cinf;
2015-09-27 02:24:03 +00:00
if (ci.cmdlOverlay)
2016-04-07 03:40:25 +00:00
chOut.overlays.emplace_back(FOURCC('OVER'), std::make_pair(ci.cmdlOverlay, ci.cskrOverlay));
}
}
void getAnimationResInfo(std::map<atUint32, DNAANCS::AnimationResInfo<UniqueID32>>& out) const
{
out.clear();
for (const DNAMP1::ANCS::AnimationSet::Animation& ai : animationSet.animations)
ai.metaAnim.m_anim->gatherPrimitives(out);
2016-04-07 03:40:25 +00:00
for (const DNAMP1::ANCS::AnimationSet::Transition& ti : animationSet.transitions)
if (ti.metaTrans.m_trans)
ti.metaTrans.m_trans->gatherPrimitives(out);
if (animationSet.defaultTransition.m_trans)
animationSet.defaultTransition.m_trans->gatherPrimitives(out);
}
2015-09-06 21:44:57 +00:00
static bool Extract(const SpecBase& dataSpec,
PAKEntryReadStream& rs,
2016-03-04 23:04:53 +00:00
const hecl::ProjectPath& outPath,
PAKRouter<PAKBridge>& pakRouter,
const DNAMP1::PAK::Entry& entry,
bool force,
2017-12-29 08:08:12 +00:00
hecl::blender::Token& btok,
2016-03-04 23:04:53 +00:00
std::function<void(const hecl::SystemChar*)> fileChanged)
{
2016-09-18 23:47:48 +00:00
hecl::ProjectPath yamlPath = outPath.getWithExtension(_S(".yaml"), true);
2016-03-04 23:04:53 +00:00
hecl::ProjectPath::Type yamlType = yamlPath.getPathType();
2016-09-18 23:47:48 +00:00
hecl::ProjectPath blendPath = outPath.getWithExtension(_S(".blend"), true);
2016-03-04 23:04:53 +00:00
hecl::ProjectPath::Type blendType = blendPath.getPathType();
2015-08-15 04:12:15 +00:00
if (force ||
2016-03-04 23:04:53 +00:00
yamlType == hecl::ProjectPath::Type::None ||
blendType == hecl::ProjectPath::Type::None)
{
2016-04-07 03:40:25 +00:00
ANCS ancs;
2015-08-15 04:12:15 +00:00
ancs.read(rs);
2016-03-04 23:04:53 +00:00
if (force || yamlType == hecl::ProjectPath::Type::None)
2015-08-15 04:12:15 +00:00
{
2016-08-22 03:47:48 +00:00
athena::io::FileWriter writer(yamlPath.getAbsolutePath());
2018-02-22 07:24:51 +00:00
athena::io::ToYAMLStream(ancs, writer);
2015-08-15 04:12:15 +00:00
}
2016-03-04 23:04:53 +00:00
if (force || blendType == hecl::ProjectPath::Type::None)
2015-08-15 04:12:15 +00:00
{
2017-12-29 08:08:12 +00:00
hecl::blender::Connection& conn = btok.getBlenderConnection();
DNAANCS::ReadANCSToBlender<PAKRouter<PAKBridge>, ANCS, MaterialSet, DNACMDL::SurfaceHeader_2, 4>
2015-09-06 21:44:57 +00:00
(conn, ancs, blendPath, pakRouter, entry, dataSpec, fileChanged, force);
2015-08-15 04:12:15 +00:00
}
}
return true;
}
};
}
#endif // _DNAMP2_ANCS_HPP_