metaforce/DataSpec/DNAMP3/CHAR.hpp

353 lines
11 KiB
C++
Raw Normal View History

2015-09-24 00:59:36 +00:00
#ifndef _DNAMP3_CHAR_HPP_
#define _DNAMP3_CHAR_HPP_
#include <map>
#include "../DNACommon/DNACommon.hpp"
#include "../DNACommon/ANCS.hpp"
#include "CMDLMaterials.hpp"
#include "CINF.hpp"
#include "CSKR.hpp"
#include "ANIM.hpp"
#include "../DNAMP2/ANCS.hpp"
2017-12-29 08:08:12 +00:00
namespace DataSpec::DNAMP3
2015-09-24 00:59:36 +00:00
{
2018-02-22 07:24:51 +00:00
struct CHAR : BigDNA
2015-09-24 00:59:36 +00:00
{
using CINFType = CINF;
using CSKRType = CSKR;
using ANIMType = ANIM;
2018-02-22 07:24:51 +00:00
AT_DECL_DNA_YAML
2015-09-26 03:12:08 +00:00
Value<atUint16> version;
2018-02-22 07:24:51 +00:00
struct CharacterInfo : BigDNA
2015-09-24 00:59:36 +00:00
{
2018-02-22 07:24:51 +00:00
AT_DECL_DNA_YAML
2015-09-26 03:12:08 +00:00
String<-1> name;
UniqueID64 cmdl;
UniqueID64 cskr;
Value<atUint32> overlayCount;
2018-02-22 07:24:51 +00:00
struct Overlay : BigDNA
2015-09-26 03:12:08 +00:00
{
2018-02-22 07:24:51 +00:00
AT_DECL_DNA_YAML
2015-09-26 03:12:08 +00:00
DNAFourCC type;
UniqueID64 cmdl;
UniqueID64 cskr;
};
2018-02-25 08:23:27 +00:00
Vector<Overlay, AT_DNA_COUNT(overlayCount)> overlays;
2015-09-26 03:12:08 +00:00
UniqueID64 cinf;
UniqueID64 sand;
using MP1CharacterInfo = DNAMP1::ANCS::CharacterSet::CharacterInfo;
MP1CharacterInfo::PASDatabase pasDatabase;
2018-02-22 07:24:51 +00:00
struct ParticleResData : BigDNA
2015-09-26 03:12:08 +00:00
{
2018-02-22 07:24:51 +00:00
AT_DECL_DNA_YAML
2015-09-26 03:12:08 +00:00
Value<atUint32> partCount;
2018-02-25 08:23:27 +00:00
Vector<UniqueID64, AT_DNA_COUNT(partCount)> part;
2015-09-26 03:12:08 +00:00
Value<atUint32> swhcCount;
2018-02-25 08:23:27 +00:00
Vector<UniqueID64, AT_DNA_COUNT(swhcCount)> swhc;
2015-09-26 03:12:08 +00:00
Value<atUint32> unkCount;
2018-02-25 08:23:27 +00:00
Vector<UniqueID64, AT_DNA_COUNT(unkCount)> unk;
2015-09-26 03:12:08 +00:00
Value<atUint32> elscCount;
2018-02-25 08:23:27 +00:00
Vector<UniqueID64, AT_DNA_COUNT(elscCount)> elsc;
2015-09-26 03:12:08 +00:00
Value<atUint32> spscCount;
2018-02-25 08:23:27 +00:00
Vector<UniqueID64, AT_DNA_COUNT(spscCount)> spsc;
2015-09-26 03:12:08 +00:00
Value<atUint32> unk2Count;
2018-02-25 08:23:27 +00:00
Vector<UniqueID64, AT_DNA_COUNT(unk2Count)> unk2;
2015-09-26 03:12:08 +00:00
} partResData;
} characterInfo;
2018-02-22 07:24:51 +00:00
struct AnimationInfo : BigDNA
2015-09-24 00:59:36 +00:00
{
2018-02-22 07:24:51 +00:00
AT_DECL_DNA_YAML
2015-09-26 03:12:08 +00:00
2018-02-22 07:24:51 +00:00
struct EVNT : BigDNA
2015-09-26 03:12:08 +00:00
{
2018-02-22 07:24:51 +00:00
AT_DECL_DNA_YAML
2015-09-27 03:48:53 +00:00
Value<atUint32> eventIdx;
2015-09-26 03:12:08 +00:00
String<-1> eventName;
2018-02-22 07:24:51 +00:00
struct EventBase : BigDNA
2015-09-26 03:12:08 +00:00
{
2018-02-22 07:24:51 +00:00
AT_DECL_DNA_YAML
2015-09-26 03:12:08 +00:00
String<-1> name1;
Value<atUint16> unk0;
String<-1> name2;
Value<atUint16> type;
Value<atUint32> unk1;
Value<atUint32> unk2;
Value<atUint32> unk3;
Value<atUint32> unk4;
Value<atUint8> unk5;
Value<float> unk6;
Value<atUint32> unk7;
Value<atUint32> unk8;
Value<atUint32> unk9;
Value<atUint32> unk10;
Value<atUint32> unk11;
Value<atUint32> unk12;
Value<atUint32> unk13;
};
struct EffectEvent : EventBase
{
2018-02-22 07:24:51 +00:00
AT_DECL_DNA_YAML
2015-09-26 03:12:08 +00:00
DNAFourCC effectType;
UniqueID64 effectId;
Value<float> scale;
Value<atUint32> parentMode;
};
Value<atUint32> effectCount;
2018-02-25 08:23:27 +00:00
Vector<EffectEvent, AT_DNA_COUNT(effectCount)> effectEvents;
2015-09-26 03:12:08 +00:00
struct SFXEvent : EventBase
{
2018-02-22 07:24:51 +00:00
AT_DECL_DNA_YAML
2015-09-26 03:12:08 +00:00
Delete expl;
UniqueID64 caudId;
2017-11-26 03:04:25 +00:00
Value<atUint32> unk1_;
Value<atUint32> unk2_;
Value<atUint32> unk3_;
2015-09-27 03:48:53 +00:00
std::vector<float> unk3Vals;
2015-09-26 03:12:08 +00:00
Value<atUint32> extraType;
Value<float> extraFloat;
};
Value<atUint32> sfxCount;
2018-02-25 08:23:27 +00:00
Vector<SFXEvent, AT_DNA_COUNT(sfxCount)> sfxEvents;
2015-09-26 03:12:08 +00:00
};
Value<atUint32> evntCount;
2018-02-25 08:23:27 +00:00
Vector<EVNT, AT_DNA_COUNT(evntCount)> evnts;
2015-09-24 00:59:36 +00:00
2018-02-22 07:24:51 +00:00
struct IMetaAnim : BigDNAVYaml
2015-09-24 00:59:36 +00:00
{
Delete expl;
2015-11-21 01:16:07 +00:00
enum class Type
2015-09-24 00:59:36 +00:00
{
2015-11-21 01:16:07 +00:00
Primitive = 0,
Blend = 1,
PhaseBlend = 2,
Random = 3,
Sequence = 4
2015-09-24 00:59:36 +00:00
} m_type;
const char* m_typeStr;
IMetaAnim(Type type, const char* typeStr)
: m_type(type), m_typeStr(typeStr) {}
virtual void gatherPrimitives(std::map<atUint32, DNAANCS::AnimationResInfo<UniqueID64>>& out)=0;
2015-09-24 00:59:36 +00:00
};
2018-02-22 07:24:51 +00:00
struct MetaAnimFactory : BigDNA
2015-09-24 00:59:36 +00:00
{
2018-02-22 07:24:51 +00:00
AT_DECL_DNA_YAML
2015-09-24 00:59:36 +00:00
Delete expl;
std::unique_ptr<IMetaAnim> m_anim;
};
struct MetaAnimPrimitive : IMetaAnim
{
2015-11-21 01:16:07 +00:00
MetaAnimPrimitive() : IMetaAnim(Type::Primitive, "Primitive") {}
2018-02-22 07:24:51 +00:00
AT_DECL_DNA_YAML
AT_DECL_DNAV
2015-09-24 00:59:36 +00:00
UniqueID64 animId;
Value<atUint32> animIdx;
String<-1> animName;
Value<float> unk1;
Value<atUint32> unk2;
void gatherPrimitives(std::map<atUint32, DNAANCS::AnimationResInfo<UniqueID64>>& out)
2015-09-24 00:59:36 +00:00
{
2015-10-27 00:32:12 +00:00
out[animIdx] = {animName, animId, UniqueID64(), false};
2015-09-24 00:59:36 +00:00
}
};
struct MetaAnimBlend : IMetaAnim
{
2015-11-21 01:16:07 +00:00
MetaAnimBlend() : IMetaAnim(Type::Blend, "Blend") {}
2018-02-22 07:24:51 +00:00
AT_DECL_DNA_YAML
AT_DECL_DNAV
2015-09-24 00:59:36 +00:00
MetaAnimFactory animA;
MetaAnimFactory animB;
Value<float> unkFloat;
Value<atUint8> unk;
void gatherPrimitives(std::map<atUint32, DNAANCS::AnimationResInfo<UniqueID64>>& out)
2015-09-24 00:59:36 +00:00
{
animA.m_anim->gatherPrimitives(out);
animB.m_anim->gatherPrimitives(out);
}
};
struct MetaAnimPhaseBlend : IMetaAnim
{
2015-11-21 01:16:07 +00:00
MetaAnimPhaseBlend() : IMetaAnim(Type::PhaseBlend, "PhaseBlend") {}
2018-02-22 07:24:51 +00:00
AT_DECL_DNA_YAML
AT_DECL_DNAV
2015-09-24 00:59:36 +00:00
MetaAnimFactory animA;
MetaAnimFactory animB;
Value<float> unkFloat;
Value<atUint8> unk;
void gatherPrimitives(std::map<atUint32, DNAANCS::AnimationResInfo<UniqueID64>>& out)
2015-09-24 00:59:36 +00:00
{
animA.m_anim->gatherPrimitives(out);
animB.m_anim->gatherPrimitives(out);
}
};
struct MetaAnimRandom : IMetaAnim
{
2015-11-21 01:16:07 +00:00
MetaAnimRandom() : IMetaAnim(Type::Random, "Random") {}
2018-02-22 07:24:51 +00:00
AT_DECL_DNA_YAML
AT_DECL_DNAV
2015-09-24 00:59:36 +00:00
Value<atUint32> animCount;
2018-02-22 07:24:51 +00:00
struct Child : BigDNA
2015-09-24 00:59:36 +00:00
{
2018-02-22 07:24:51 +00:00
AT_DECL_DNA_YAML
2015-09-24 00:59:36 +00:00
MetaAnimFactory anim;
Value<atUint32> probability;
};
2018-02-25 08:23:27 +00:00
Vector<Child, AT_DNA_COUNT(animCount)> children;
2015-09-24 00:59:36 +00:00
void gatherPrimitives(std::map<atUint32, DNAANCS::AnimationResInfo<UniqueID64>>& out)
2015-09-24 00:59:36 +00:00
{
for (const auto& child : children)
child.anim.m_anim->gatherPrimitives(out);
}
};
struct MetaAnimSequence : IMetaAnim
{
2015-11-21 01:16:07 +00:00
MetaAnimSequence() : IMetaAnim(Type::Sequence, "Sequence") {}
2018-02-22 07:24:51 +00:00
AT_DECL_DNA_YAML
AT_DECL_DNAV
2015-09-24 00:59:36 +00:00
Value<atUint32> animCount;
2018-02-25 08:23:27 +00:00
Vector<MetaAnimFactory, AT_DNA_COUNT(animCount)> children;
2015-09-24 00:59:36 +00:00
void gatherPrimitives(std::map<atUint32, DNAANCS::AnimationResInfo<UniqueID64>>& out)
2015-09-24 00:59:36 +00:00
{
for (const auto& child : children)
child.m_anim->gatherPrimitives(out);
}
};
2018-02-22 07:24:51 +00:00
struct Animation : BigDNA
2015-09-24 00:59:36 +00:00
{
2018-02-22 07:24:51 +00:00
AT_DECL_DNA_YAML
2015-09-24 00:59:36 +00:00
String<-1> name;
MetaAnimFactory metaAnim;
};
2015-09-26 03:12:08 +00:00
Value<atUint32> animationCount;
2018-02-25 08:23:27 +00:00
Vector<Animation, AT_DNA_COUNT(animationCount)> animations;
2015-09-24 00:59:36 +00:00
2018-02-22 07:24:51 +00:00
struct ActionAABB : BigDNA
2015-09-24 00:59:36 +00:00
{
2018-02-22 07:24:51 +00:00
AT_DECL_DNA_YAML
2015-09-24 00:59:36 +00:00
UniqueID64 animId;
2015-09-26 03:12:08 +00:00
Value<atVec3f> aabb[2];
2015-09-24 00:59:36 +00:00
};
2015-09-26 03:12:08 +00:00
Value<atUint32> animAABBCount;
2018-02-25 08:23:27 +00:00
Vector<ActionAABB, AT_DNA_COUNT(animAABBCount)> animAABBs;
2015-09-24 00:59:36 +00:00
2015-09-26 03:12:08 +00:00
Value<atUint8> unkByte;
2015-09-24 00:59:36 +00:00
2015-09-26 03:12:08 +00:00
Value<atUint32> additiveMapCount;
2018-02-25 08:23:27 +00:00
Vector<bool, AT_DNA_COUNT(additiveMapCount)> additiveMap;
2015-09-24 00:59:36 +00:00
2015-09-26 03:12:08 +00:00
} animationInfo;
2015-09-24 00:59:36 +00:00
2018-02-22 07:24:51 +00:00
struct HitboxSet : BigDNA
2015-09-24 00:59:36 +00:00
{
2018-02-22 07:24:51 +00:00
AT_DECL_DNA_YAML
2015-09-24 00:59:36 +00:00
String<-1> name;
2015-09-26 03:12:08 +00:00
Value<atUint32> hitboxCount;
2018-02-22 07:24:51 +00:00
struct Hitbox : BigDNA
2015-09-24 00:59:36 +00:00
{
2018-02-22 07:24:51 +00:00
AT_DECL_DNA_YAML
2015-09-26 03:12:08 +00:00
Value<atUint32> unk1;
2015-09-24 00:59:36 +00:00
Value<atUint32> unk2;
Value<atUint32> unk3;
2015-09-26 03:12:08 +00:00
Value<atUint32> unk4;
Value<atUint32> unk5;
Value<float> unk6;
Value<float> unk7;
Value<float> unk8;
Value<float> unk9;
Value<float> unk10;
Value<float> unk11;
Value<float> unk12;
Value<float> unk13;
String<-1> boneName;
Value<float> unk14;
2015-09-24 00:59:36 +00:00
};
2018-02-25 08:23:27 +00:00
Vector<Hitbox, AT_DNA_COUNT(hitboxCount)> hitboxes;
2015-09-24 00:59:36 +00:00
};
2015-09-26 03:12:08 +00:00
Value<atUint32> hitboxSetCount;
2018-02-25 08:23:27 +00:00
Vector<HitboxSet, AT_DNA_COUNT(hitboxSetCount)> hitboxSets;
2015-09-24 00:59:36 +00:00
void getCharacterResInfo(std::vector<DNAANCS::CharacterResInfo<UniqueID64>>& out) const
{
out.clear();
out.reserve(1);
out.emplace_back();
DNAANCS::CharacterResInfo<UniqueID64>& chOut = out.back();
2015-09-26 03:12:08 +00:00
chOut.name = characterInfo.name;
chOut.cmdl = characterInfo.cmdl;
chOut.cskr = characterInfo.cskr;
chOut.cinf = characterInfo.cinf;
2015-09-27 02:24:03 +00:00
for (const CharacterInfo::Overlay& overlay : characterInfo.overlays)
chOut.overlays.emplace_back(overlay.type, std::make_pair(overlay.cmdl, overlay.cskr));
2015-09-24 00:59:36 +00:00
}
void getAnimationResInfo(PAKRouter<PAKBridge>* pakRouter,
std::map<atUint32, DNAANCS::AnimationResInfo<UniqueID64>>& out) const
2015-09-24 00:59:36 +00:00
{
out.clear();
2015-09-26 03:12:08 +00:00
for (const AnimationInfo::Animation& ai : animationInfo.animations)
2015-09-24 00:59:36 +00:00
ai.metaAnim.m_anim->gatherPrimitives(out);
for (auto& animRes : out)
animRes.second.additive = animationInfo.additiveMap.at(animRes.first);
2015-09-24 00:59:36 +00:00
}
static bool Extract(const SpecBase& dataSpec,
PAKEntryReadStream& rs,
2016-03-04 23:04:53 +00:00
const hecl::ProjectPath& outPath,
2015-09-24 00:59:36 +00:00
PAKRouter<PAKBridge>& pakRouter,
const 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)
2015-09-24 00:59:36 +00:00
{
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-09-24 00:59:36 +00:00
if (force ||
2016-03-04 23:04:53 +00:00
yamlType == hecl::ProjectPath::Type::None ||
blendType == hecl::ProjectPath::Type::None)
2015-09-24 00:59:36 +00:00
{
CHAR aChar;
aChar.read(rs);
2016-03-04 23:04:53 +00:00
if (force || yamlType == hecl::ProjectPath::Type::None)
2015-09-24 00:59:36 +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(aChar, writer);
2015-09-24 00:59:36 +00:00
}
2016-03-04 23:04:53 +00:00
if (force || blendType == hecl::ProjectPath::Type::None)
2015-09-24 00:59:36 +00:00
{
2017-12-29 08:08:12 +00:00
hecl::blender::Connection& conn = btok.getBlenderConnection();
2015-09-26 03:12:08 +00:00
DNAANCS::ReadANCSToBlender<PAKRouter<PAKBridge>, CHAR, MaterialSet, DNACMDL::SurfaceHeader_3, 4>
2015-09-24 00:59:36 +00:00
(conn, aChar, blendPath, pakRouter, entry, dataSpec, fileChanged, force);
}
}
return true;
}
};
}
#endif // _DNAMP3_CHAR_HPP_