2015-08-08 04:49:42 +00:00
|
|
|
#include "ANCS.hpp"
|
2017-12-29 08:08:12 +00:00
|
|
|
#include "hecl/Blender/Connection.hpp"
|
2015-08-08 04:49:42 +00:00
|
|
|
|
2016-02-13 09:02:47 +00:00
|
|
|
namespace DataSpec
|
2015-08-08 04:49:42 +00:00
|
|
|
{
|
2016-08-22 00:11:18 +00:00
|
|
|
extern hecl::Database::DataSpecEntry SpecEntMP1;
|
2016-04-10 04:49:02 +00:00
|
|
|
extern hecl::Database::DataSpecEntry SpecEntMP1PC;
|
|
|
|
|
2015-08-08 04:49:42 +00:00
|
|
|
namespace DNAMP1
|
|
|
|
{
|
|
|
|
|
2018-02-22 07:24:51 +00:00
|
|
|
template <>
|
|
|
|
void ANCS::CharacterSet::CharacterInfo::PASDatabase::AnimState::ParmInfo::Enumerate<BigDNA::Read>
|
|
|
|
(athena::io::IStreamReader& reader)
|
2015-08-08 04:49:42 +00:00
|
|
|
{
|
2015-08-14 03:00:51 +00:00
|
|
|
parmType = reader.readUint32Big();
|
2017-07-06 21:06:56 +00:00
|
|
|
weightFunction = reader.readUint32Big();
|
|
|
|
weight = reader.readFloatBig();
|
2015-08-08 23:24:17 +00:00
|
|
|
switch (DataType(parmType))
|
2015-08-08 04:49:42 +00:00
|
|
|
{
|
2015-11-21 01:16:07 +00:00
|
|
|
case DataType::Int32:
|
2017-07-06 21:06:56 +00:00
|
|
|
range[0].int32 = reader.readInt32Big();
|
|
|
|
range[1].int32 = reader.readInt32Big();
|
2015-08-08 04:49:42 +00:00
|
|
|
break;
|
2015-11-21 01:16:07 +00:00
|
|
|
case DataType::UInt32:
|
|
|
|
case DataType::Enum:
|
2017-07-06 21:06:56 +00:00
|
|
|
range[0].uint32 = reader.readUint32Big();
|
|
|
|
range[1].uint32 = reader.readUint32Big();
|
2015-08-08 04:49:42 +00:00
|
|
|
break;
|
2015-11-21 01:16:07 +00:00
|
|
|
case DataType::Float:
|
2017-07-06 21:06:56 +00:00
|
|
|
range[0].float32 = reader.readFloatBig();
|
|
|
|
range[1].float32 = reader.readFloatBig();
|
2015-08-08 04:49:42 +00:00
|
|
|
break;
|
2015-11-21 01:16:07 +00:00
|
|
|
case DataType::Bool:
|
2017-07-06 21:06:56 +00:00
|
|
|
range[0].bool1 = reader.readBool();
|
|
|
|
range[1].bool1 = reader.readBool();
|
2015-08-08 04:49:42 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-02-22 07:24:51 +00:00
|
|
|
template <>
|
|
|
|
void ANCS::CharacterSet::CharacterInfo::PASDatabase::AnimState::ParmInfo::Enumerate<BigDNA::Write>
|
|
|
|
(athena::io::IStreamWriter& writer)
|
2015-08-08 04:49:42 +00:00
|
|
|
{
|
2015-08-14 03:00:51 +00:00
|
|
|
writer.writeUint32Big(parmType);
|
2017-07-06 21:06:56 +00:00
|
|
|
writer.writeUint32Big(weightFunction);
|
|
|
|
writer.writeFloatBig(weight);
|
2015-08-08 23:24:17 +00:00
|
|
|
switch (DataType(parmType))
|
2015-08-08 04:49:42 +00:00
|
|
|
{
|
2015-11-21 01:16:07 +00:00
|
|
|
case DataType::Int32:
|
2017-07-06 21:06:56 +00:00
|
|
|
writer.writeInt32Big(range[0].int32);
|
|
|
|
writer.writeInt32Big(range[1].int32);
|
2015-08-08 04:49:42 +00:00
|
|
|
break;
|
2015-11-21 01:16:07 +00:00
|
|
|
case DataType::UInt32:
|
|
|
|
case DataType::Enum:
|
2017-07-06 21:06:56 +00:00
|
|
|
writer.writeUint32Big(range[0].uint32);
|
|
|
|
writer.writeUint32Big(range[0].uint32);
|
2015-08-08 04:49:42 +00:00
|
|
|
break;
|
2015-11-21 01:16:07 +00:00
|
|
|
case DataType::Float:
|
2017-07-06 21:06:56 +00:00
|
|
|
writer.writeFloatBig(range[0].float32);
|
|
|
|
writer.writeFloatBig(range[0].float32);
|
2015-08-08 04:49:42 +00:00
|
|
|
break;
|
2015-11-21 01:16:07 +00:00
|
|
|
case DataType::Bool:
|
2017-07-06 21:06:56 +00:00
|
|
|
writer.writeBool(range[0].bool1);
|
|
|
|
writer.writeBool(range[0].bool1);
|
2015-08-08 04:49:42 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-02-22 07:24:51 +00:00
|
|
|
template <>
|
|
|
|
void ANCS::CharacterSet::CharacterInfo::PASDatabase::AnimState::ParmInfo::Enumerate<BigDNA::BinarySize>(size_t& __isz)
|
2015-10-18 04:08:45 +00:00
|
|
|
{
|
|
|
|
__isz += 12;
|
|
|
|
switch (DataType(parmType))
|
|
|
|
{
|
2015-11-21 01:16:07 +00:00
|
|
|
case DataType::Int32:
|
|
|
|
case DataType::UInt32:
|
|
|
|
case DataType::Enum:
|
|
|
|
case DataType::Float:
|
2015-10-18 04:08:45 +00:00
|
|
|
__isz += 8;
|
|
|
|
break;
|
2015-11-21 01:16:07 +00:00
|
|
|
case DataType::Bool:
|
2015-10-18 04:08:45 +00:00
|
|
|
__isz += 2;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-02-22 07:24:51 +00:00
|
|
|
template <>
|
|
|
|
void ANCS::CharacterSet::CharacterInfo::PASDatabase::AnimState::ParmInfo::Enumerate<BigDNA::ReadYaml>
|
|
|
|
(athena::io::YAMLDocReader& reader)
|
2015-08-08 04:49:42 +00:00
|
|
|
{
|
|
|
|
parmType = reader.readUint32("parmType");
|
2017-07-06 21:06:56 +00:00
|
|
|
weightFunction = reader.readUint32("weightFunction");
|
|
|
|
weight = reader.readFloat("weight");
|
2016-03-05 00:03:41 +00:00
|
|
|
size_t parmValCount;
|
2017-07-06 21:06:56 +00:00
|
|
|
if (auto v = reader.enterSubVector("range", parmValCount))
|
2015-08-08 04:49:42 +00:00
|
|
|
{
|
2017-02-12 23:56:03 +00:00
|
|
|
switch (DataType(parmType))
|
|
|
|
{
|
|
|
|
case DataType::Int32:
|
2017-07-06 21:06:56 +00:00
|
|
|
range[0].int32 = reader.readInt32(nullptr);
|
|
|
|
range[1].int32 = reader.readInt32(nullptr);
|
2017-02-12 23:56:03 +00:00
|
|
|
break;
|
|
|
|
case DataType::UInt32:
|
|
|
|
case DataType::Enum:
|
2017-07-06 21:06:56 +00:00
|
|
|
range[0].uint32 = reader.readUint32(nullptr);
|
|
|
|
range[1].uint32 = reader.readUint32(nullptr);
|
2017-02-12 23:56:03 +00:00
|
|
|
break;
|
|
|
|
case DataType::Float:
|
2017-07-06 21:06:56 +00:00
|
|
|
range[0].float32 = reader.readFloat(nullptr);
|
|
|
|
range[1].float32 = reader.readFloat(nullptr);
|
2017-02-12 23:56:03 +00:00
|
|
|
break;
|
|
|
|
case DataType::Bool:
|
2017-07-06 21:06:56 +00:00
|
|
|
range[0].bool1 = reader.readBool(nullptr);
|
|
|
|
range[1].bool1 = reader.readBool(nullptr);
|
2017-02-12 23:56:03 +00:00
|
|
|
break;
|
|
|
|
default: break;
|
|
|
|
}
|
2015-08-08 04:49:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-02-22 07:24:51 +00:00
|
|
|
template <>
|
|
|
|
void ANCS::CharacterSet::CharacterInfo::PASDatabase::AnimState::ParmInfo::Enumerate<BigDNA::WriteYaml>
|
|
|
|
(athena::io::YAMLDocWriter& writer)
|
2015-08-08 04:49:42 +00:00
|
|
|
{
|
|
|
|
writer.writeUint32("parmType", parmType);
|
2017-07-06 21:06:56 +00:00
|
|
|
writer.writeUint32("weightFunction", weightFunction);
|
|
|
|
writer.writeFloat("weight", weight);
|
|
|
|
if (auto v = writer.enterSubVector("range"))
|
2015-08-08 04:49:42 +00:00
|
|
|
{
|
2017-02-12 23:56:03 +00:00
|
|
|
switch (DataType(parmType))
|
|
|
|
{
|
|
|
|
case DataType::Int32:
|
2017-07-06 21:06:56 +00:00
|
|
|
writer.writeInt32(nullptr, range[0].int32);
|
|
|
|
writer.writeInt32(nullptr, range[1].int32);
|
2017-02-12 23:56:03 +00:00
|
|
|
break;
|
|
|
|
case DataType::UInt32:
|
|
|
|
case DataType::Enum:
|
2017-07-06 21:06:56 +00:00
|
|
|
writer.writeUint32(nullptr, range[0].uint32);
|
|
|
|
writer.writeUint32(nullptr, range[0].uint32);
|
2017-02-12 23:56:03 +00:00
|
|
|
break;
|
|
|
|
case DataType::Float:
|
2017-07-06 21:06:56 +00:00
|
|
|
writer.writeFloat(nullptr, range[0].float32);
|
|
|
|
writer.writeFloat(nullptr, range[0].float32);
|
2017-02-12 23:56:03 +00:00
|
|
|
break;
|
|
|
|
case DataType::Bool:
|
2017-07-06 21:06:56 +00:00
|
|
|
writer.writeBool(nullptr, range[0].bool1);
|
|
|
|
writer.writeBool(nullptr, range[0].bool1);
|
2017-02-12 23:56:03 +00:00
|
|
|
break;
|
|
|
|
}
|
2015-08-08 04:49:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-10-01 00:40:21 +00:00
|
|
|
const char* ANCS::CharacterSet::CharacterInfo::PASDatabase::AnimState::ParmInfo::DNAType()
|
|
|
|
{
|
2016-03-04 23:04:53 +00:00
|
|
|
return "urde::DNAMP1::ANCS::CharacterSet::CharacterInfo::PASDatabase::AnimState::ParmInfo";
|
2015-10-01 00:40:21 +00:00
|
|
|
}
|
|
|
|
|
2018-02-22 07:24:51 +00:00
|
|
|
template <>
|
|
|
|
void ANCS::CharacterSet::CharacterInfo::PASDatabase::AnimState::Enumerate<BigDNA::Read>
|
|
|
|
(athena::io::IStreamReader& reader)
|
2015-08-08 04:49:42 +00:00
|
|
|
{
|
2015-08-14 03:00:51 +00:00
|
|
|
id = reader.readUint32Big();
|
|
|
|
atUint32 parmInfoCount = reader.readUint32Big();
|
|
|
|
atUint32 animInfoCount = reader.readUint32Big();
|
2015-08-08 04:49:42 +00:00
|
|
|
|
2015-08-08 23:24:17 +00:00
|
|
|
reader.enumerate(parmInfos, parmInfoCount);
|
2015-08-08 04:49:42 +00:00
|
|
|
|
2015-08-08 23:24:17 +00:00
|
|
|
animInfos.clear();
|
2015-08-08 04:49:42 +00:00
|
|
|
animInfos.reserve(animInfoCount);
|
2015-08-08 23:24:17 +00:00
|
|
|
reader.enumerate<AnimInfo>(animInfos, animInfoCount,
|
2016-03-04 23:04:53 +00:00
|
|
|
[this, parmInfoCount](athena::io::IStreamReader& reader, AnimInfo& ai)
|
2015-08-08 04:49:42 +00:00
|
|
|
{
|
2015-08-14 03:00:51 +00:00
|
|
|
ai.id = reader.readUint32Big();
|
2015-08-08 04:49:42 +00:00
|
|
|
ai.parmVals.reserve(parmInfoCount);
|
|
|
|
for (const ParmInfo& pi : parmInfos)
|
|
|
|
{
|
2015-08-08 23:24:17 +00:00
|
|
|
switch (ParmInfo::DataType(pi.parmType))
|
2015-08-08 04:49:42 +00:00
|
|
|
{
|
2015-11-21 01:16:07 +00:00
|
|
|
case ParmInfo::DataType::Int32:
|
2015-08-14 03:00:51 +00:00
|
|
|
ai.parmVals.emplace_back(reader.readInt32Big());
|
2015-08-08 04:49:42 +00:00
|
|
|
break;
|
2015-11-21 01:16:07 +00:00
|
|
|
case ParmInfo::DataType::UInt32:
|
|
|
|
case ParmInfo::DataType::Enum:
|
2015-08-14 03:00:51 +00:00
|
|
|
ai.parmVals.emplace_back(reader.readUint32Big());
|
2015-08-08 04:49:42 +00:00
|
|
|
break;
|
2015-11-21 01:16:07 +00:00
|
|
|
case ParmInfo::DataType::Float:
|
2015-08-14 03:00:51 +00:00
|
|
|
ai.parmVals.emplace_back(reader.readFloatBig());
|
2015-08-08 04:49:42 +00:00
|
|
|
break;
|
2015-11-21 01:16:07 +00:00
|
|
|
case ParmInfo::DataType::Bool:
|
2015-08-08 04:49:42 +00:00
|
|
|
ai.parmVals.emplace_back(reader.readBool());
|
|
|
|
break;
|
|
|
|
default: break;
|
|
|
|
}
|
|
|
|
}
|
2015-08-08 23:24:17 +00:00
|
|
|
});
|
2015-08-08 04:49:42 +00:00
|
|
|
}
|
|
|
|
|
2018-02-22 07:24:51 +00:00
|
|
|
template <>
|
|
|
|
void ANCS::CharacterSet::CharacterInfo::PASDatabase::AnimState::Enumerate<BigDNA::Write>
|
|
|
|
(athena::io::IStreamWriter& writer)
|
2015-08-08 04:49:42 +00:00
|
|
|
{
|
2015-08-14 03:00:51 +00:00
|
|
|
writer.writeUint32Big(id);
|
|
|
|
writer.writeUint32Big(parmInfos.size());
|
|
|
|
writer.writeUint32Big(animInfos.size());
|
2015-08-08 04:49:42 +00:00
|
|
|
|
|
|
|
for (const ParmInfo& pi : parmInfos)
|
|
|
|
pi.write(writer);
|
|
|
|
|
|
|
|
for (const AnimInfo& ai : animInfos)
|
|
|
|
{
|
2015-08-14 03:00:51 +00:00
|
|
|
writer.writeUint32Big(ai.id);
|
2015-08-08 04:49:42 +00:00
|
|
|
auto it = ai.parmVals.begin();
|
|
|
|
for (const ParmInfo& pi : parmInfos)
|
|
|
|
{
|
|
|
|
ParmInfo::Parm pVal;
|
|
|
|
if (it != ai.parmVals.end())
|
|
|
|
pVal = *it++;
|
2015-08-08 23:24:17 +00:00
|
|
|
switch (ParmInfo::DataType(pi.parmType))
|
2015-08-08 04:49:42 +00:00
|
|
|
{
|
2015-11-21 01:16:07 +00:00
|
|
|
case ParmInfo::DataType::Int32:
|
2015-08-14 03:00:51 +00:00
|
|
|
writer.writeInt32Big(pVal.int32);
|
2015-08-08 04:49:42 +00:00
|
|
|
break;
|
2015-11-21 01:16:07 +00:00
|
|
|
case ParmInfo::DataType::UInt32:
|
|
|
|
case ParmInfo::DataType::Enum:
|
2015-08-14 03:00:51 +00:00
|
|
|
writer.writeUint32Big(pVal.uint32);
|
2015-08-08 04:49:42 +00:00
|
|
|
break;
|
2015-11-21 01:16:07 +00:00
|
|
|
case ParmInfo::DataType::Float:
|
2015-08-14 03:00:51 +00:00
|
|
|
writer.writeFloatBig(pVal.float32);
|
2015-08-08 04:49:42 +00:00
|
|
|
break;
|
2015-11-21 01:16:07 +00:00
|
|
|
case ParmInfo::DataType::Bool:
|
2015-08-08 04:49:42 +00:00
|
|
|
writer.writeBool(pVal.bool1);
|
|
|
|
break;
|
|
|
|
default: break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-02-22 07:24:51 +00:00
|
|
|
template <>
|
|
|
|
void ANCS::CharacterSet::CharacterInfo::PASDatabase::AnimState::Enumerate<BigDNA::BinarySize>(size_t& __isz)
|
2015-10-18 04:08:45 +00:00
|
|
|
{
|
|
|
|
__isz += 12;
|
2018-02-22 07:24:51 +00:00
|
|
|
for (const ParmInfo& pi : parmInfos)
|
|
|
|
pi.binarySize(__isz);
|
2015-10-18 04:08:45 +00:00
|
|
|
|
|
|
|
__isz += animInfos.size() * 4;
|
|
|
|
for (const ParmInfo& pi : parmInfos)
|
|
|
|
{
|
|
|
|
switch (ParmInfo::DataType(pi.parmType))
|
|
|
|
{
|
2015-11-21 01:16:07 +00:00
|
|
|
case ParmInfo::DataType::Int32:
|
|
|
|
case ParmInfo::DataType::UInt32:
|
|
|
|
case ParmInfo::DataType::Enum:
|
|
|
|
case ParmInfo::DataType::Float:
|
2015-10-18 04:08:45 +00:00
|
|
|
__isz += animInfos.size() * 4;
|
|
|
|
break;
|
2015-11-21 01:16:07 +00:00
|
|
|
case ParmInfo::DataType::Bool:
|
2015-10-18 04:08:45 +00:00
|
|
|
__isz += animInfos.size();
|
|
|
|
break;
|
|
|
|
default: break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-02-22 07:24:51 +00:00
|
|
|
template <>
|
|
|
|
void ANCS::CharacterSet::CharacterInfo::PASDatabase::AnimState::Enumerate<BigDNA::ReadYaml>
|
|
|
|
(athena::io::YAMLDocReader& reader)
|
2015-08-08 04:49:42 +00:00
|
|
|
{
|
|
|
|
id = reader.readUint32("id");
|
|
|
|
|
2016-03-04 01:01:37 +00:00
|
|
|
size_t parmInfoCount = reader.enumerate("parmInfos", parmInfos);
|
2015-08-08 04:49:42 +00:00
|
|
|
|
2016-03-04 01:01:37 +00:00
|
|
|
reader.enumerate<AnimInfo>("animInfos", animInfos,
|
2016-03-04 23:04:53 +00:00
|
|
|
[this, parmInfoCount](athena::io::YAMLDocReader& reader, AnimInfo& ai)
|
2015-08-08 04:49:42 +00:00
|
|
|
{
|
|
|
|
ai.id = reader.readUint32("id");
|
|
|
|
ai.parmVals.reserve(parmInfoCount);
|
2016-03-04 23:04:53 +00:00
|
|
|
size_t parmValCount;
|
2017-02-12 23:56:03 +00:00
|
|
|
if (auto v = reader.enterSubVector("parms", parmValCount))
|
2015-08-08 04:49:42 +00:00
|
|
|
{
|
2017-02-12 23:56:03 +00:00
|
|
|
for (const ParmInfo& pi : parmInfos)
|
2015-08-08 04:49:42 +00:00
|
|
|
{
|
2017-02-12 23:56:03 +00:00
|
|
|
switch (ParmInfo::DataType(pi.parmType))
|
|
|
|
{
|
|
|
|
case ParmInfo::DataType::Int32:
|
|
|
|
ai.parmVals.emplace_back(reader.readInt32(nullptr));
|
|
|
|
break;
|
|
|
|
case ParmInfo::DataType::UInt32:
|
|
|
|
case ParmInfo::DataType::Enum:
|
|
|
|
ai.parmVals.emplace_back(reader.readUint32(nullptr));
|
|
|
|
break;
|
|
|
|
case ParmInfo::DataType::Float:
|
|
|
|
ai.parmVals.emplace_back(reader.readFloat(nullptr));
|
|
|
|
break;
|
|
|
|
case ParmInfo::DataType::Bool:
|
|
|
|
ai.parmVals.emplace_back(reader.readBool(nullptr));
|
|
|
|
break;
|
|
|
|
default: break;
|
|
|
|
}
|
2015-08-08 04:49:42 +00:00
|
|
|
}
|
|
|
|
}
|
2015-08-08 23:24:17 +00:00
|
|
|
});
|
2015-08-08 04:49:42 +00:00
|
|
|
}
|
|
|
|
|
2018-02-22 07:24:51 +00:00
|
|
|
template <>
|
|
|
|
void ANCS::CharacterSet::CharacterInfo::PASDatabase::AnimState::Enumerate<BigDNA::WriteYaml>
|
|
|
|
(athena::io::YAMLDocWriter& writer)
|
2015-08-08 04:49:42 +00:00
|
|
|
{
|
|
|
|
writer.writeUint32("id", id);
|
|
|
|
|
2015-08-08 23:24:17 +00:00
|
|
|
writer.enumerate("parmInfos", parmInfos);
|
2015-08-08 04:49:42 +00:00
|
|
|
|
2015-08-08 23:24:17 +00:00
|
|
|
writer.enumerate<AnimInfo>("animInfos", animInfos,
|
2016-03-04 23:04:53 +00:00
|
|
|
[this](athena::io::YAMLDocWriter& writer, const AnimInfo& ai)
|
2015-08-08 04:49:42 +00:00
|
|
|
{
|
|
|
|
writer.writeUint32("id", ai.id);
|
|
|
|
auto it = ai.parmVals.begin();
|
2017-02-12 23:56:03 +00:00
|
|
|
if (auto v = writer.enterSubVector("parms"))
|
2015-08-08 04:49:42 +00:00
|
|
|
{
|
2017-02-12 23:56:03 +00:00
|
|
|
for (const ParmInfo& pi : parmInfos)
|
2015-08-08 04:49:42 +00:00
|
|
|
{
|
2017-02-12 23:56:03 +00:00
|
|
|
ParmInfo::Parm pVal;
|
|
|
|
if (it != ai.parmVals.end())
|
|
|
|
pVal = *it++;
|
|
|
|
switch (ParmInfo::DataType(pi.parmType))
|
|
|
|
{
|
|
|
|
case ParmInfo::DataType::Int32:
|
|
|
|
writer.writeInt32(nullptr, pVal.int32);
|
|
|
|
break;
|
|
|
|
case ParmInfo::DataType::UInt32:
|
|
|
|
case ParmInfo::DataType::Enum:
|
|
|
|
writer.writeUint32(nullptr, pVal.uint32);
|
|
|
|
break;
|
|
|
|
case ParmInfo::DataType::Float:
|
|
|
|
writer.writeFloat(nullptr, pVal.float32);
|
|
|
|
break;
|
|
|
|
case ParmInfo::DataType::Bool:
|
|
|
|
writer.writeBool(nullptr, pVal.bool1);
|
|
|
|
break;
|
|
|
|
default: break;
|
|
|
|
}
|
2015-08-08 04:49:42 +00:00
|
|
|
}
|
|
|
|
}
|
2015-08-08 23:24:17 +00:00
|
|
|
});
|
2015-08-08 04:49:42 +00:00
|
|
|
}
|
|
|
|
|
2015-10-01 00:40:21 +00:00
|
|
|
const char* ANCS::CharacterSet::CharacterInfo::PASDatabase::AnimState::DNAType()
|
|
|
|
{
|
2016-03-04 23:04:53 +00:00
|
|
|
return "urde::DNAMP1::ANCS::CharacterSet::CharacterInfo::PASDatabase::AnimState";
|
2015-10-01 00:40:21 +00:00
|
|
|
}
|
|
|
|
|
2018-02-22 07:24:51 +00:00
|
|
|
template <>
|
|
|
|
void ANCS::CharacterSet::CharacterInfo::Enumerate<BigDNA::Read>(athena::io::IStreamReader& reader)
|
2015-08-08 04:49:42 +00:00
|
|
|
{
|
2015-08-14 03:00:51 +00:00
|
|
|
idx = reader.readUint32Big();
|
|
|
|
atUint16 sectionCount = reader.readUint16Big();
|
2015-08-08 04:49:42 +00:00
|
|
|
name = reader.readString();
|
|
|
|
cmdl.read(reader);
|
|
|
|
cskr.read(reader);
|
|
|
|
cinf.read(reader);
|
|
|
|
|
2015-08-14 03:00:51 +00:00
|
|
|
atUint32 animationCount = reader.readUint32Big();
|
2015-08-08 23:24:17 +00:00
|
|
|
reader.enumerate(animations, animationCount);
|
2015-08-08 04:49:42 +00:00
|
|
|
|
|
|
|
pasDatabase.read(reader);
|
|
|
|
|
2015-08-14 03:00:51 +00:00
|
|
|
atUint32 partCount = reader.readUint32Big();
|
2015-08-08 23:24:17 +00:00
|
|
|
reader.enumerate(partResData.part, partCount);
|
2015-08-08 04:49:42 +00:00
|
|
|
|
2015-08-14 03:00:51 +00:00
|
|
|
atUint32 swhcCount = reader.readUint32Big();
|
2015-08-08 23:24:17 +00:00
|
|
|
reader.enumerate(partResData.swhc, swhcCount);
|
2015-08-08 04:49:42 +00:00
|
|
|
|
2015-08-14 03:00:51 +00:00
|
|
|
atUint32 unkCount = reader.readUint32Big();
|
2015-08-08 23:24:17 +00:00
|
|
|
reader.enumerate(partResData.unk, unkCount);
|
2015-08-08 04:49:42 +00:00
|
|
|
|
2015-08-08 23:24:17 +00:00
|
|
|
partResData.elsc.clear();
|
2015-08-08 04:49:42 +00:00
|
|
|
if (sectionCount > 5)
|
|
|
|
{
|
2015-08-14 03:00:51 +00:00
|
|
|
atUint32 elscCount = reader.readUint32Big();
|
2015-08-08 23:24:17 +00:00
|
|
|
reader.enumerate(partResData.elsc, elscCount);
|
2015-08-08 04:49:42 +00:00
|
|
|
}
|
|
|
|
|
2015-08-14 03:00:51 +00:00
|
|
|
unk1 = reader.readUint32Big();
|
2015-08-08 04:49:42 +00:00
|
|
|
|
|
|
|
animAABBs.clear();
|
|
|
|
if (sectionCount > 1)
|
|
|
|
{
|
2015-08-14 03:00:51 +00:00
|
|
|
atUint32 aabbCount = reader.readUint32Big();
|
2015-08-08 23:24:17 +00:00
|
|
|
reader.enumerate(animAABBs, aabbCount);
|
2015-08-08 04:49:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
effects.clear();
|
|
|
|
if (sectionCount > 2)
|
|
|
|
{
|
2015-08-14 03:00:51 +00:00
|
|
|
atUint32 effectCount = reader.readUint32Big();
|
2015-08-08 23:24:17 +00:00
|
|
|
reader.enumerate(effects, effectCount);
|
2015-08-08 04:49:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (sectionCount > 3)
|
|
|
|
{
|
2018-10-11 20:50:05 +00:00
|
|
|
cmdlIce.read(reader);
|
|
|
|
cskrIce.read(reader);
|
2015-08-08 04:49:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
animIdxs.clear();
|
|
|
|
if (sectionCount > 4)
|
|
|
|
{
|
2015-08-14 03:00:51 +00:00
|
|
|
atUint32 aidxCount = reader.readUint32Big();
|
|
|
|
reader.enumerateBig(animIdxs, aidxCount);
|
2015-08-08 04:49:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-02-22 07:24:51 +00:00
|
|
|
template <>
|
|
|
|
void ANCS::CharacterSet::CharacterInfo::Enumerate<BigDNA::Write>(athena::io::IStreamWriter& writer)
|
2015-08-08 04:49:42 +00:00
|
|
|
{
|
2015-08-14 03:00:51 +00:00
|
|
|
writer.writeUint32Big(idx);
|
2015-08-08 04:49:42 +00:00
|
|
|
|
|
|
|
atUint16 sectionCount;
|
2015-08-15 04:12:15 +00:00
|
|
|
if (partResData.elsc.size())
|
2015-08-08 04:49:42 +00:00
|
|
|
sectionCount = 6;
|
|
|
|
else if (animIdxs.size())
|
|
|
|
sectionCount = 5;
|
2018-10-11 20:50:05 +00:00
|
|
|
else if (cmdlIce)
|
2015-08-08 04:49:42 +00:00
|
|
|
sectionCount = 4;
|
|
|
|
else if (effects.size())
|
|
|
|
sectionCount = 3;
|
|
|
|
else if (animAABBs.size())
|
|
|
|
sectionCount = 2;
|
|
|
|
else
|
|
|
|
sectionCount = 1;
|
2015-08-14 03:00:51 +00:00
|
|
|
writer.writeUint16Big(sectionCount);
|
2015-08-08 04:49:42 +00:00
|
|
|
|
|
|
|
writer.writeString(name);
|
2018-04-02 04:27:24 +00:00
|
|
|
cmdl.write(writer);
|
|
|
|
cskr.write(writer);
|
|
|
|
cinf.write(writer);
|
2015-08-08 04:49:42 +00:00
|
|
|
|
2015-08-14 03:00:51 +00:00
|
|
|
writer.writeUint32Big(animations.size());
|
2015-08-08 23:24:17 +00:00
|
|
|
writer.enumerate(animations);
|
2015-08-08 04:49:42 +00:00
|
|
|
|
|
|
|
pasDatabase.write(writer);
|
|
|
|
|
2015-08-14 03:00:51 +00:00
|
|
|
writer.writeUint32Big(partResData.part.size());
|
2015-08-08 23:24:17 +00:00
|
|
|
writer.enumerate(partResData.part);
|
2015-08-08 04:49:42 +00:00
|
|
|
|
2015-08-14 03:00:51 +00:00
|
|
|
writer.writeUint32Big(partResData.swhc.size());
|
2015-08-08 23:24:17 +00:00
|
|
|
writer.enumerate(partResData.swhc);
|
2015-08-08 04:49:42 +00:00
|
|
|
|
2015-08-14 03:00:51 +00:00
|
|
|
writer.writeUint32Big(partResData.unk.size());
|
2015-08-08 23:24:17 +00:00
|
|
|
writer.enumerate(partResData.unk);
|
2015-08-08 04:49:42 +00:00
|
|
|
|
|
|
|
if (sectionCount > 5)
|
|
|
|
{
|
2015-08-14 03:00:51 +00:00
|
|
|
writer.writeUint32Big(partResData.elsc.size());
|
2015-08-08 23:24:17 +00:00
|
|
|
writer.enumerate(partResData.elsc);
|
2015-08-08 04:49:42 +00:00
|
|
|
}
|
|
|
|
|
2015-08-14 03:00:51 +00:00
|
|
|
writer.writeUint32Big(unk1);
|
2015-08-08 04:49:42 +00:00
|
|
|
|
|
|
|
if (sectionCount > 1)
|
|
|
|
{
|
2015-08-14 03:00:51 +00:00
|
|
|
writer.writeUint32Big(animAABBs.size());
|
2015-08-08 23:24:17 +00:00
|
|
|
writer.enumerate(animAABBs);
|
2015-08-08 04:49:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (sectionCount > 2)
|
|
|
|
{
|
2015-08-14 03:00:51 +00:00
|
|
|
writer.writeUint32Big(effects.size());
|
2015-08-08 23:24:17 +00:00
|
|
|
writer.enumerate(effects);
|
2015-08-08 04:49:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (sectionCount > 3)
|
|
|
|
{
|
2018-10-11 20:50:05 +00:00
|
|
|
cmdlIce.write(writer);
|
|
|
|
cskrIce.write(writer);
|
2015-08-08 04:49:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (sectionCount > 4)
|
|
|
|
{
|
2015-08-14 03:00:51 +00:00
|
|
|
writer.writeUint32Big(animIdxs.size());
|
2015-08-08 04:49:42 +00:00
|
|
|
for (atUint32 idx : animIdxs)
|
2015-08-14 03:00:51 +00:00
|
|
|
writer.writeUint32Big(idx);
|
2015-08-08 04:49:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-02-22 07:24:51 +00:00
|
|
|
template <>
|
|
|
|
void ANCS::CharacterSet::CharacterInfo::Enumerate<BigDNA::BinarySize>(size_t& __isz)
|
2015-10-18 04:08:45 +00:00
|
|
|
{
|
|
|
|
__isz += 6;
|
|
|
|
|
|
|
|
atUint16 sectionCount;
|
|
|
|
if (partResData.elsc.size())
|
|
|
|
sectionCount = 6;
|
|
|
|
else if (animIdxs.size())
|
|
|
|
sectionCount = 5;
|
2018-10-11 20:50:05 +00:00
|
|
|
else if (cmdlIce)
|
2015-10-18 04:08:45 +00:00
|
|
|
sectionCount = 4;
|
|
|
|
else if (effects.size())
|
|
|
|
sectionCount = 3;
|
|
|
|
else if (animAABBs.size())
|
|
|
|
sectionCount = 2;
|
|
|
|
else
|
|
|
|
sectionCount = 1;
|
|
|
|
|
|
|
|
__isz += name.size() + 1;
|
|
|
|
__isz += 12;
|
|
|
|
|
|
|
|
__isz += 4;
|
2018-02-22 07:24:51 +00:00
|
|
|
for (const Animation& a : animations)
|
|
|
|
a.binarySize(__isz);
|
2015-10-18 04:08:45 +00:00
|
|
|
|
2018-02-22 07:24:51 +00:00
|
|
|
pasDatabase.binarySize(__isz);
|
2015-10-18 04:08:45 +00:00
|
|
|
|
|
|
|
__isz += 4;
|
2018-02-22 07:24:51 +00:00
|
|
|
for (const UniqueID32& id : partResData.part)
|
|
|
|
id.binarySize(__isz);
|
2015-10-18 04:08:45 +00:00
|
|
|
|
|
|
|
__isz += 4;
|
2018-02-22 07:24:51 +00:00
|
|
|
for (const UniqueID32& id : partResData.swhc)
|
|
|
|
id.binarySize(__isz);
|
2015-10-18 04:08:45 +00:00
|
|
|
|
|
|
|
__isz += 4;
|
2018-02-22 07:24:51 +00:00
|
|
|
for (const UniqueID32& id : partResData.unk)
|
|
|
|
id.binarySize(__isz);
|
2015-10-18 04:08:45 +00:00
|
|
|
|
|
|
|
if (sectionCount > 5)
|
|
|
|
{
|
|
|
|
__isz += 4;
|
2018-02-22 07:24:51 +00:00
|
|
|
for (const UniqueID32& id : partResData.elsc)
|
|
|
|
id.binarySize(__isz);
|
2015-10-18 04:08:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
__isz += 4;
|
|
|
|
|
|
|
|
if (sectionCount > 1)
|
|
|
|
{
|
|
|
|
__isz += 4;
|
2018-02-22 07:24:51 +00:00
|
|
|
for (const ActionAABB& aabb : animAABBs)
|
|
|
|
aabb.binarySize(__isz);
|
2015-10-18 04:08:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (sectionCount > 2)
|
|
|
|
{
|
|
|
|
__isz += 4;
|
2018-02-22 07:24:51 +00:00
|
|
|
for (const Effect& e : effects)
|
|
|
|
e.binarySize(__isz);
|
2015-10-18 04:08:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (sectionCount > 3)
|
|
|
|
__isz += 8;
|
|
|
|
|
|
|
|
if (sectionCount > 4)
|
|
|
|
__isz += 4 + animIdxs.size() * 4;
|
|
|
|
}
|
|
|
|
|
2018-02-22 07:24:51 +00:00
|
|
|
template <>
|
|
|
|
void ANCS::CharacterSet::CharacterInfo::Enumerate<BigDNA::ReadYaml>(athena::io::YAMLDocReader& reader)
|
2015-08-08 04:49:42 +00:00
|
|
|
{
|
|
|
|
idx = reader.readUint32("idx");
|
|
|
|
atUint16 sectionCount = reader.readUint16("sectionCount");
|
|
|
|
name = reader.readString("name");
|
2015-08-08 23:24:17 +00:00
|
|
|
reader.enumerate("cmdl", cmdl);
|
2015-08-08 04:49:42 +00:00
|
|
|
|
2016-03-04 01:01:37 +00:00
|
|
|
reader.enumerate("animations", animations);
|
2015-08-08 04:49:42 +00:00
|
|
|
|
2015-08-08 23:24:17 +00:00
|
|
|
reader.enumerate("pasDatabase", pasDatabase);
|
2015-08-08 04:49:42 +00:00
|
|
|
|
2016-03-04 01:01:37 +00:00
|
|
|
reader.enumerate("part", partResData.part);
|
2015-08-08 04:49:42 +00:00
|
|
|
|
2016-03-04 01:01:37 +00:00
|
|
|
reader.enumerate("swhc", partResData.swhc);
|
2015-08-08 04:49:42 +00:00
|
|
|
|
2016-03-04 01:01:37 +00:00
|
|
|
reader.enumerate("unk", partResData.unk);
|
2015-08-08 04:49:42 +00:00
|
|
|
|
2015-08-08 23:24:17 +00:00
|
|
|
partResData.elsc.clear();
|
2015-08-08 04:49:42 +00:00
|
|
|
if (sectionCount > 5)
|
|
|
|
{
|
2016-03-04 01:01:37 +00:00
|
|
|
reader.enumerate("elsc", partResData.elsc);
|
2015-08-08 04:49:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
unk1 = reader.readUint32("unk1");
|
|
|
|
|
|
|
|
animAABBs.clear();
|
|
|
|
if (sectionCount > 1)
|
|
|
|
{
|
2016-03-04 01:01:37 +00:00
|
|
|
reader.enumerate("part", animAABBs);
|
2015-08-08 04:49:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
effects.clear();
|
|
|
|
if (sectionCount > 2)
|
|
|
|
{
|
2016-03-04 01:01:37 +00:00
|
|
|
reader.enumerate("effects", effects);
|
2015-08-08 04:49:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (sectionCount > 3)
|
|
|
|
{
|
2018-10-11 20:50:05 +00:00
|
|
|
reader.enumerate("cmdlIce", cmdlIce);
|
2015-08-08 04:49:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
animIdxs.clear();
|
|
|
|
if (sectionCount > 4)
|
|
|
|
{
|
2016-03-04 01:01:37 +00:00
|
|
|
reader.enumerate("animIdxs", animIdxs);
|
2015-08-08 04:49:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-02-22 07:24:51 +00:00
|
|
|
template <>
|
|
|
|
void ANCS::CharacterSet::CharacterInfo::Enumerate<BigDNA::WriteYaml>(athena::io::YAMLDocWriter& writer)
|
2015-08-08 04:49:42 +00:00
|
|
|
{
|
|
|
|
writer.writeUint32("idx", idx);
|
|
|
|
|
|
|
|
atUint16 sectionCount;
|
2015-08-15 04:12:15 +00:00
|
|
|
if (partResData.elsc.size())
|
2015-08-08 04:49:42 +00:00
|
|
|
sectionCount = 6;
|
|
|
|
else if (animIdxs.size())
|
|
|
|
sectionCount = 5;
|
2018-10-11 20:50:05 +00:00
|
|
|
else if (cmdlIce)
|
2015-08-08 04:49:42 +00:00
|
|
|
sectionCount = 4;
|
|
|
|
else if (effects.size())
|
|
|
|
sectionCount = 3;
|
|
|
|
else if (animAABBs.size())
|
|
|
|
sectionCount = 2;
|
|
|
|
else
|
|
|
|
sectionCount = 1;
|
|
|
|
writer.writeUint16("sectionCount", sectionCount);
|
|
|
|
|
|
|
|
writer.writeString("name", name);
|
2015-08-08 23:24:17 +00:00
|
|
|
writer.enumerate("cmdl", cmdl);
|
2015-08-08 04:49:42 +00:00
|
|
|
|
2015-08-08 23:24:17 +00:00
|
|
|
writer.enumerate("animations", animations);
|
2015-08-08 04:49:42 +00:00
|
|
|
|
2015-08-08 23:24:17 +00:00
|
|
|
writer.enumerate("pasDatabase", pasDatabase);
|
2015-08-08 04:49:42 +00:00
|
|
|
|
2015-08-08 23:24:17 +00:00
|
|
|
writer.enumerate("part", partResData.part);
|
2015-08-08 04:49:42 +00:00
|
|
|
|
2015-08-08 23:24:17 +00:00
|
|
|
writer.enumerate("swhc", partResData.swhc);
|
2015-08-08 04:49:42 +00:00
|
|
|
|
2015-08-08 23:24:17 +00:00
|
|
|
writer.enumerate("unk", partResData.unk);
|
2015-08-08 04:49:42 +00:00
|
|
|
|
|
|
|
if (sectionCount > 5)
|
|
|
|
{
|
2015-08-08 23:24:17 +00:00
|
|
|
writer.enumerate("elsc", partResData.elsc);
|
2015-08-08 04:49:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
writer.writeUint32("unk1", unk1);
|
|
|
|
|
|
|
|
if (sectionCount > 1)
|
|
|
|
{
|
2015-08-08 23:24:17 +00:00
|
|
|
writer.enumerate("animAABBs", animAABBs);
|
2015-08-08 04:49:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (sectionCount > 2)
|
|
|
|
{
|
2015-08-08 23:24:17 +00:00
|
|
|
writer.enumerate("effects", effects);
|
2015-08-08 04:49:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (sectionCount > 3)
|
|
|
|
{
|
2018-10-11 20:50:05 +00:00
|
|
|
writer.enumerate("cmdlIce", cmdlIce);
|
2015-08-08 04:49:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (sectionCount > 4)
|
|
|
|
{
|
2015-08-08 23:24:17 +00:00
|
|
|
writer.enumerate("animIdxs", animIdxs);
|
2015-08-08 04:49:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-10-01 00:40:21 +00:00
|
|
|
const char* ANCS::CharacterSet::CharacterInfo::DNAType()
|
|
|
|
{
|
2016-03-04 23:04:53 +00:00
|
|
|
return "urde::DNAMP1::ANCS::CharacterSet::CharacterInfo";
|
2015-10-01 00:40:21 +00:00
|
|
|
}
|
|
|
|
|
2018-02-22 07:24:51 +00:00
|
|
|
template <>
|
|
|
|
void ANCS::AnimationSet::MetaAnimFactory::Enumerate<BigDNA::Read>(athena::io::IStreamReader& reader)
|
2015-08-08 04:49:42 +00:00
|
|
|
{
|
2015-08-14 03:00:51 +00:00
|
|
|
IMetaAnim::Type type(IMetaAnim::Type(reader.readUint32Big()));
|
2015-08-08 04:49:42 +00:00
|
|
|
switch (type)
|
|
|
|
{
|
2015-11-21 01:16:07 +00:00
|
|
|
case IMetaAnim::Type::Primitive:
|
2016-04-07 03:40:25 +00:00
|
|
|
m_anim.reset(new struct MetaAnimPrimitive);
|
2015-08-08 04:49:42 +00:00
|
|
|
m_anim->read(reader);
|
|
|
|
break;
|
2015-11-21 01:16:07 +00:00
|
|
|
case IMetaAnim::Type::Blend:
|
2016-04-07 03:40:25 +00:00
|
|
|
m_anim.reset(new struct MetaAnimBlend);
|
2015-08-08 04:49:42 +00:00
|
|
|
m_anim->read(reader);
|
|
|
|
break;
|
2015-11-21 01:16:07 +00:00
|
|
|
case IMetaAnim::Type::PhaseBlend:
|
2016-04-07 03:40:25 +00:00
|
|
|
m_anim.reset(new struct MetaAnimPhaseBlend);
|
2015-08-08 04:49:42 +00:00
|
|
|
m_anim->read(reader);
|
|
|
|
break;
|
2015-11-21 01:16:07 +00:00
|
|
|
case IMetaAnim::Type::Random:
|
2016-04-07 03:40:25 +00:00
|
|
|
m_anim.reset(new struct MetaAnimRandom);
|
2015-08-08 04:49:42 +00:00
|
|
|
m_anim->read(reader);
|
|
|
|
break;
|
2015-11-21 01:16:07 +00:00
|
|
|
case IMetaAnim::Type::Sequence:
|
2016-04-07 03:40:25 +00:00
|
|
|
m_anim.reset(new struct MetaAnimSequence);
|
2015-08-08 04:49:42 +00:00
|
|
|
m_anim->read(reader);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
m_anim.reset(nullptr);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-02-22 07:24:51 +00:00
|
|
|
template <>
|
|
|
|
void ANCS::AnimationSet::MetaAnimFactory::Enumerate<BigDNA::Write>(athena::io::IStreamWriter& writer)
|
2015-08-08 04:49:42 +00:00
|
|
|
{
|
|
|
|
if (!m_anim)
|
|
|
|
return;
|
2015-11-21 01:16:07 +00:00
|
|
|
writer.writeInt32Big(atUint32(m_anim->m_type));
|
2015-08-08 04:49:42 +00:00
|
|
|
m_anim->write(writer);
|
|
|
|
}
|
|
|
|
|
2018-02-22 07:24:51 +00:00
|
|
|
template <>
|
|
|
|
void ANCS::AnimationSet::MetaAnimFactory::Enumerate<BigDNA::BinarySize>(size_t& __isz)
|
2015-10-18 04:08:45 +00:00
|
|
|
{
|
|
|
|
if (!m_anim)
|
2018-02-22 07:24:51 +00:00
|
|
|
return;
|
|
|
|
__isz += 4;
|
|
|
|
m_anim->binarySize(__isz);
|
2015-10-18 04:08:45 +00:00
|
|
|
}
|
|
|
|
|
2018-02-22 07:24:51 +00:00
|
|
|
template <>
|
|
|
|
void ANCS::AnimationSet::MetaAnimFactory::Enumerate<BigDNA::ReadYaml>(athena::io::YAMLDocReader& reader)
|
2015-08-08 04:49:42 +00:00
|
|
|
{
|
|
|
|
std::string type = reader.readString("type");
|
|
|
|
std::transform(type.begin(), type.end(), type.begin(), tolower);
|
|
|
|
if (!type.compare("primitive"))
|
|
|
|
{
|
2016-04-07 03:40:25 +00:00
|
|
|
m_anim.reset(new struct MetaAnimPrimitive);
|
2016-01-04 05:31:02 +00:00
|
|
|
m_anim->read(reader);
|
2015-08-08 04:49:42 +00:00
|
|
|
}
|
|
|
|
else if (!type.compare("blend"))
|
|
|
|
{
|
2016-04-07 03:40:25 +00:00
|
|
|
m_anim.reset(new struct MetaAnimBlend);
|
2016-01-04 05:31:02 +00:00
|
|
|
m_anim->read(reader);
|
2015-08-08 04:49:42 +00:00
|
|
|
}
|
|
|
|
else if (!type.compare("phaseblend"))
|
|
|
|
{
|
2016-04-07 03:40:25 +00:00
|
|
|
m_anim.reset(new struct MetaAnimPhaseBlend);
|
2016-01-04 05:31:02 +00:00
|
|
|
m_anim->read(reader);
|
2015-08-08 04:49:42 +00:00
|
|
|
}
|
|
|
|
else if (!type.compare("random"))
|
|
|
|
{
|
2016-04-07 03:40:25 +00:00
|
|
|
m_anim.reset(new struct MetaAnimRandom);
|
2016-01-04 05:31:02 +00:00
|
|
|
m_anim->read(reader);
|
2015-08-08 04:49:42 +00:00
|
|
|
}
|
|
|
|
else if (!type.compare("sequence"))
|
|
|
|
{
|
2016-04-07 03:40:25 +00:00
|
|
|
m_anim.reset(new struct MetaAnimSequence);
|
2016-01-04 05:31:02 +00:00
|
|
|
m_anim->read(reader);
|
2015-08-08 04:49:42 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_anim.reset(nullptr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-02-22 07:24:51 +00:00
|
|
|
template <>
|
|
|
|
void ANCS::AnimationSet::MetaAnimFactory::Enumerate<BigDNA::WriteYaml>(athena::io::YAMLDocWriter& writer)
|
2015-08-08 23:24:17 +00:00
|
|
|
{
|
|
|
|
if (!m_anim)
|
|
|
|
return;
|
|
|
|
writer.writeString("type", m_anim->m_typeStr);
|
2016-01-04 05:31:02 +00:00
|
|
|
m_anim->write(writer);
|
2015-08-08 23:24:17 +00:00
|
|
|
}
|
|
|
|
|
2015-10-01 00:40:21 +00:00
|
|
|
const char* ANCS::AnimationSet::MetaAnimFactory::DNAType()
|
|
|
|
{
|
2016-03-04 23:04:53 +00:00
|
|
|
return "urde::DNAMP1::ANCS::AnimationSet::MetaAnimFactory";
|
2015-10-01 00:40:21 +00:00
|
|
|
}
|
|
|
|
|
2018-02-22 07:24:51 +00:00
|
|
|
template <>
|
|
|
|
void ANCS::AnimationSet::MetaTransFactory::Enumerate<BigDNA::Read>(athena::io::IStreamReader& reader)
|
2015-08-08 04:49:42 +00:00
|
|
|
{
|
2015-08-14 03:00:51 +00:00
|
|
|
IMetaTrans::Type type(IMetaTrans::Type(reader.readUint32Big()));
|
2015-08-08 04:49:42 +00:00
|
|
|
switch (type)
|
|
|
|
{
|
2015-11-21 01:16:07 +00:00
|
|
|
case IMetaTrans::Type::MetaAnim:
|
2016-04-07 03:40:25 +00:00
|
|
|
m_trans.reset(new struct MetaTransMetaAnim);
|
2015-08-08 04:49:42 +00:00
|
|
|
m_trans->read(reader);
|
|
|
|
break;
|
2015-11-21 01:16:07 +00:00
|
|
|
case IMetaTrans::Type::Trans:
|
2016-04-07 03:40:25 +00:00
|
|
|
m_trans.reset(new struct MetaTransTrans);
|
2015-08-08 04:49:42 +00:00
|
|
|
m_trans->read(reader);
|
|
|
|
break;
|
2015-11-21 01:16:07 +00:00
|
|
|
case IMetaTrans::Type::PhaseTrans:
|
2016-04-07 03:40:25 +00:00
|
|
|
m_trans.reset(new struct MetaTransPhaseTrans);
|
2015-08-08 04:49:42 +00:00
|
|
|
m_trans->read(reader);
|
|
|
|
break;
|
2015-11-21 01:16:07 +00:00
|
|
|
case IMetaTrans::Type::NoTrans:
|
2015-08-08 04:49:42 +00:00
|
|
|
default:
|
|
|
|
m_trans.reset(nullptr);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-02-22 07:24:51 +00:00
|
|
|
template <>
|
|
|
|
void ANCS::AnimationSet::MetaTransFactory::Enumerate<BigDNA::Write>(athena::io::IStreamWriter& writer)
|
2015-08-08 04:49:42 +00:00
|
|
|
{
|
|
|
|
if (!m_trans)
|
|
|
|
{
|
2015-11-21 01:16:07 +00:00
|
|
|
writer.writeInt32Big(atUint32(IMetaTrans::Type::NoTrans));
|
2015-08-08 04:49:42 +00:00
|
|
|
return;
|
|
|
|
}
|
2015-11-21 01:16:07 +00:00
|
|
|
writer.writeInt32Big(atUint32(m_trans->m_type));
|
2015-08-08 04:49:42 +00:00
|
|
|
m_trans->write(writer);
|
|
|
|
}
|
|
|
|
|
2018-02-22 07:24:51 +00:00
|
|
|
template <>
|
|
|
|
void ANCS::AnimationSet::MetaTransFactory::Enumerate<BigDNA::BinarySize>(size_t& __isz)
|
2015-10-18 04:08:45 +00:00
|
|
|
{
|
2018-02-22 07:24:51 +00:00
|
|
|
__isz += 4;
|
2015-10-18 04:08:45 +00:00
|
|
|
if (!m_trans)
|
2018-02-22 07:24:51 +00:00
|
|
|
return;
|
|
|
|
m_trans->binarySize(__isz);
|
2015-10-18 04:08:45 +00:00
|
|
|
}
|
|
|
|
|
2018-02-22 07:24:51 +00:00
|
|
|
template <>
|
|
|
|
void ANCS::AnimationSet::MetaTransFactory::Enumerate<BigDNA::ReadYaml>(athena::io::YAMLDocReader& reader)
|
2015-08-08 04:49:42 +00:00
|
|
|
{
|
|
|
|
std::string type = reader.readString("type");
|
|
|
|
std::transform(type.begin(), type.end(), type.begin(), tolower);
|
|
|
|
if (!type.compare("metaanim"))
|
|
|
|
{
|
2016-04-07 03:40:25 +00:00
|
|
|
m_trans.reset(new struct MetaTransMetaAnim);
|
2016-01-04 05:31:02 +00:00
|
|
|
m_trans->read(reader);
|
2015-08-08 04:49:42 +00:00
|
|
|
}
|
|
|
|
else if (!type.compare("trans"))
|
|
|
|
{
|
2016-04-07 03:40:25 +00:00
|
|
|
m_trans.reset(new struct MetaTransTrans);
|
2016-01-04 05:31:02 +00:00
|
|
|
m_trans->read(reader);
|
2015-08-08 04:49:42 +00:00
|
|
|
}
|
|
|
|
else if (!type.compare("phasetrans"))
|
|
|
|
{
|
2016-04-07 03:40:25 +00:00
|
|
|
m_trans.reset(new struct MetaTransPhaseTrans);
|
2016-01-04 05:31:02 +00:00
|
|
|
m_trans->read(reader);
|
2015-08-08 04:49:42 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_trans.reset(nullptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2018-02-22 07:24:51 +00:00
|
|
|
template <>
|
|
|
|
void ANCS::AnimationSet::MetaTransFactory::Enumerate<BigDNA::WriteYaml>(athena::io::YAMLDocWriter& writer)
|
2015-08-08 04:49:42 +00:00
|
|
|
{
|
|
|
|
if (!m_trans)
|
|
|
|
{
|
|
|
|
writer.writeString("type", "NoTrans");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
writer.writeString("type", m_trans->m_typeStr?m_trans->m_typeStr:"NoTrans");
|
2016-01-04 05:31:02 +00:00
|
|
|
m_trans->write(writer);
|
2015-08-08 04:49:42 +00:00
|
|
|
}
|
|
|
|
|
2015-10-01 00:40:21 +00:00
|
|
|
const char* ANCS::AnimationSet::MetaTransFactory::DNAType()
|
|
|
|
{
|
2016-03-04 23:04:53 +00:00
|
|
|
return "urde::DNAMP1::ANCS::AnimationSet::MetaTransFactory";
|
2015-10-01 00:40:21 +00:00
|
|
|
}
|
|
|
|
|
2018-02-22 07:24:51 +00:00
|
|
|
template <>
|
|
|
|
void ANCS::AnimationSet::Enumerate<BigDNA::Read>(athena::io::IStreamReader& reader)
|
2015-08-08 04:49:42 +00:00
|
|
|
{
|
2015-08-14 03:00:51 +00:00
|
|
|
atUint16 sectionCount = reader.readUint16Big();
|
2015-08-08 04:49:42 +00:00
|
|
|
|
2015-08-14 03:00:51 +00:00
|
|
|
atUint32 animationCount = reader.readUint32Big();
|
2016-04-07 03:40:25 +00:00
|
|
|
reader.enumerate(animations, animationCount);
|
2015-08-08 04:49:42 +00:00
|
|
|
|
2015-08-14 03:00:51 +00:00
|
|
|
atUint32 transitionCount = reader.readUint32Big();
|
2016-04-07 03:40:25 +00:00
|
|
|
reader.enumerate(transitions, transitionCount);
|
2015-08-08 23:24:17 +00:00
|
|
|
defaultTransition.read(reader);
|
2015-08-08 04:49:42 +00:00
|
|
|
|
2015-08-08 23:24:17 +00:00
|
|
|
additiveAnims.clear();
|
2015-08-08 04:49:42 +00:00
|
|
|
if (sectionCount > 1)
|
|
|
|
{
|
2015-08-14 03:00:51 +00:00
|
|
|
atUint32 additiveAnimCount = reader.readUint32Big();
|
2015-08-08 23:24:17 +00:00
|
|
|
reader.enumerate(additiveAnims, additiveAnimCount);
|
2015-08-14 03:00:51 +00:00
|
|
|
floatA = reader.readFloatBig();
|
|
|
|
floatB = reader.readFloatBig();
|
2015-08-08 04:49:42 +00:00
|
|
|
}
|
|
|
|
|
2015-08-08 23:24:17 +00:00
|
|
|
halfTransitions.clear();
|
2015-08-08 04:49:42 +00:00
|
|
|
if (sectionCount > 2)
|
|
|
|
{
|
2016-04-07 03:40:25 +00:00
|
|
|
atUint32 halfTransitionCount = reader.readUint32Big();
|
|
|
|
reader.enumerate(halfTransitions, halfTransitionCount);
|
2015-08-08 04:49:42 +00:00
|
|
|
}
|
|
|
|
|
2015-08-08 23:24:17 +00:00
|
|
|
animResources.clear();
|
2015-08-08 04:49:42 +00:00
|
|
|
if (sectionCount > 3)
|
|
|
|
{
|
2015-08-14 03:00:51 +00:00
|
|
|
atUint32 animResourcesCount = reader.readUint32Big();
|
2015-08-08 23:24:17 +00:00
|
|
|
reader.enumerate(animResources, animResourcesCount);
|
2015-08-08 04:49:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-02-22 07:24:51 +00:00
|
|
|
template <>
|
|
|
|
void ANCS::AnimationSet::Enumerate<BigDNA::Write>(athena::io::IStreamWriter& writer)
|
2015-08-08 04:49:42 +00:00
|
|
|
{
|
|
|
|
atUint16 sectionCount;
|
|
|
|
if (animResources.size())
|
|
|
|
sectionCount = 4;
|
|
|
|
else if (halfTransitions.size())
|
|
|
|
sectionCount = 3;
|
|
|
|
else if (additiveAnims.size())
|
|
|
|
sectionCount = 2;
|
|
|
|
else
|
|
|
|
sectionCount = 1;
|
|
|
|
|
2015-08-14 03:00:51 +00:00
|
|
|
writer.writeUint16Big(sectionCount);
|
2015-08-08 04:49:42 +00:00
|
|
|
|
2015-08-14 03:00:51 +00:00
|
|
|
writer.writeUint32Big(animations.size());
|
2015-08-08 23:24:17 +00:00
|
|
|
writer.enumerate(animations);
|
2015-08-08 04:49:42 +00:00
|
|
|
|
2015-08-14 03:00:51 +00:00
|
|
|
writer.writeUint32Big(transitions.size());
|
2015-08-08 23:24:17 +00:00
|
|
|
writer.enumerate(transitions);
|
|
|
|
defaultTransition.write(writer);
|
2015-08-08 04:49:42 +00:00
|
|
|
|
|
|
|
if (sectionCount > 1)
|
|
|
|
{
|
2015-08-14 03:00:51 +00:00
|
|
|
writer.writeUint32Big(additiveAnims.size());
|
2015-08-08 23:24:17 +00:00
|
|
|
writer.enumerate(additiveAnims);
|
2015-08-14 03:00:51 +00:00
|
|
|
writer.writeFloatBig(floatA);
|
|
|
|
writer.writeFloatBig(floatB);
|
2015-08-08 04:49:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (sectionCount > 2)
|
|
|
|
{
|
2015-08-14 03:00:51 +00:00
|
|
|
writer.writeUint32Big(halfTransitions.size());
|
2015-08-08 23:24:17 +00:00
|
|
|
writer.enumerate(halfTransitions);
|
2015-08-08 04:49:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (sectionCount > 3)
|
|
|
|
{
|
2015-08-14 03:00:51 +00:00
|
|
|
writer.writeUint32Big(animResources.size());
|
2015-08-08 23:24:17 +00:00
|
|
|
writer.enumerate(animResources);
|
2015-08-08 04:49:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-02-22 07:24:51 +00:00
|
|
|
template <>
|
|
|
|
void ANCS::AnimationSet::Enumerate<BigDNA::BinarySize>(size_t& __isz)
|
2015-10-18 04:08:45 +00:00
|
|
|
{
|
|
|
|
atUint16 sectionCount;
|
|
|
|
if (animResources.size())
|
|
|
|
sectionCount = 4;
|
|
|
|
else if (halfTransitions.size())
|
|
|
|
sectionCount = 3;
|
|
|
|
else if (additiveAnims.size())
|
|
|
|
sectionCount = 2;
|
|
|
|
else
|
|
|
|
sectionCount = 1;
|
|
|
|
|
|
|
|
__isz += 6;
|
2018-02-22 07:24:51 +00:00
|
|
|
for (const Animation& a : animations)
|
|
|
|
a.binarySize(__isz);
|
2015-10-18 04:08:45 +00:00
|
|
|
|
|
|
|
__isz += 4;
|
2018-02-22 07:24:51 +00:00
|
|
|
for (const Transition& t : transitions)
|
|
|
|
t.binarySize(__isz);
|
|
|
|
defaultTransition.binarySize(__isz);
|
2015-10-18 04:08:45 +00:00
|
|
|
|
|
|
|
if (sectionCount > 1)
|
|
|
|
{
|
|
|
|
__isz += 4;
|
2018-02-22 07:24:51 +00:00
|
|
|
for (const AdditiveAnimationInfo& aa : additiveAnims)
|
|
|
|
aa.binarySize(__isz);
|
2015-10-18 04:08:45 +00:00
|
|
|
__isz += 8;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sectionCount > 2)
|
|
|
|
{
|
|
|
|
__isz += 4;
|
2018-02-22 07:24:51 +00:00
|
|
|
for (const HalfTransition& ht : halfTransitions)
|
|
|
|
ht.binarySize(__isz);
|
2015-10-18 04:08:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (sectionCount > 3)
|
|
|
|
{
|
|
|
|
__isz += 4;
|
2018-02-22 07:24:51 +00:00
|
|
|
for (const AnimationResources& ar : animResources)
|
|
|
|
ar.binarySize(__isz);
|
2015-10-18 04:08:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-02-22 07:24:51 +00:00
|
|
|
template <>
|
|
|
|
void ANCS::AnimationSet::Enumerate<BigDNA::ReadYaml>(athena::io::YAMLDocReader& reader)
|
2015-08-08 04:49:42 +00:00
|
|
|
{
|
|
|
|
atUint16 sectionCount = reader.readUint16("sectionCount");
|
|
|
|
|
2016-04-07 03:40:25 +00:00
|
|
|
reader.enumerate("animations", animations);
|
2015-08-08 04:49:42 +00:00
|
|
|
|
2016-04-07 03:40:25 +00:00
|
|
|
reader.enumerate("transitions", transitions);
|
2015-08-08 23:24:17 +00:00
|
|
|
reader.enumerate("defaultTransition", defaultTransition);
|
2015-08-08 04:49:42 +00:00
|
|
|
|
2015-08-08 23:24:17 +00:00
|
|
|
additiveAnims.clear();
|
2015-08-08 04:49:42 +00:00
|
|
|
if (sectionCount > 1)
|
|
|
|
{
|
2016-03-04 01:01:37 +00:00
|
|
|
reader.enumerate("additiveAnims", additiveAnims);
|
2015-08-08 04:49:42 +00:00
|
|
|
floatA = reader.readFloat("floatA");
|
|
|
|
floatB = reader.readFloat("floatB");
|
|
|
|
}
|
|
|
|
|
2015-08-08 23:24:17 +00:00
|
|
|
halfTransitions.clear();
|
2015-08-08 04:49:42 +00:00
|
|
|
if (sectionCount > 2)
|
|
|
|
{
|
2016-04-07 03:40:25 +00:00
|
|
|
reader.enumerate("halfTransitions", halfTransitions);
|
2015-08-08 04:49:42 +00:00
|
|
|
}
|
|
|
|
|
2015-08-08 23:24:17 +00:00
|
|
|
animResources.clear();
|
2015-08-08 04:49:42 +00:00
|
|
|
if (sectionCount > 3)
|
|
|
|
{
|
2016-03-04 01:01:37 +00:00
|
|
|
reader.enumerate("animResources", animResources);
|
2015-08-08 04:49:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-02-22 07:24:51 +00:00
|
|
|
template <>
|
|
|
|
void ANCS::AnimationSet::Enumerate<BigDNA::WriteYaml>(athena::io::YAMLDocWriter& writer)
|
2015-08-08 04:49:42 +00:00
|
|
|
{
|
|
|
|
atUint16 sectionCount;
|
|
|
|
if (animResources.size())
|
|
|
|
sectionCount = 4;
|
|
|
|
else if (halfTransitions.size())
|
|
|
|
sectionCount = 3;
|
|
|
|
else if (additiveAnims.size())
|
|
|
|
sectionCount = 2;
|
|
|
|
else
|
|
|
|
sectionCount = 1;
|
|
|
|
|
|
|
|
writer.writeUint16("sectionCount", sectionCount);
|
|
|
|
|
2015-08-08 23:24:17 +00:00
|
|
|
writer.enumerate("animations", animations);
|
2015-08-08 04:49:42 +00:00
|
|
|
|
2015-08-08 23:24:17 +00:00
|
|
|
writer.enumerate("transitions", transitions);
|
|
|
|
writer.enumerate("defaultTransition", defaultTransition);
|
2015-08-08 04:49:42 +00:00
|
|
|
|
|
|
|
if (sectionCount > 1)
|
|
|
|
{
|
2015-08-08 23:24:17 +00:00
|
|
|
writer.enumerate("additiveAnims", additiveAnims);
|
2015-08-08 04:49:42 +00:00
|
|
|
writer.writeFloat("floatA", floatA);
|
|
|
|
writer.writeFloat("floatB", floatB);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sectionCount > 2)
|
|
|
|
{
|
2015-08-08 23:24:17 +00:00
|
|
|
writer.enumerate("halfTransitions", halfTransitions);
|
2015-08-08 04:49:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (sectionCount > 3)
|
|
|
|
{
|
2015-08-08 23:24:17 +00:00
|
|
|
writer.enumerate("animResources", animResources);
|
2015-08-08 04:49:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-05-28 01:54:55 +00:00
|
|
|
void ANCS::AnimationSet::MetaAnimPrimitive::
|
|
|
|
gatherPrimitives(PAKRouter<PAKBridge>* pakRouter,
|
|
|
|
std::map<atUint32, DNAANCS::AnimationResInfo<UniqueID32>>& out)
|
|
|
|
{
|
|
|
|
if (!pakRouter)
|
|
|
|
{
|
|
|
|
out[animIdx] = {animName, animId, UniqueID32(), false};
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const nod::Node* node;
|
|
|
|
const PAK::Entry* entry = pakRouter->lookupEntry(animId, &node, true);
|
|
|
|
if (!entry)
|
|
|
|
{
|
|
|
|
out[animIdx] = {animName, animId, UniqueID32(), false};
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
PAKEntryReadStream rs = entry->beginReadStream(*node);
|
|
|
|
out[animIdx] = {animName, animId, ANIM::GetEVNTId(rs), false};
|
|
|
|
}
|
|
|
|
|
2015-10-01 00:40:21 +00:00
|
|
|
const char* ANCS::AnimationSet::DNAType()
|
|
|
|
{
|
2016-03-04 23:04:53 +00:00
|
|
|
return "urde::DNAMP1::ANCS::AnimationSet";
|
2015-10-01 00:40:21 +00:00
|
|
|
}
|
|
|
|
|
2016-04-10 04:49:02 +00:00
|
|
|
bool ANCS::Extract(const SpecBase& dataSpec,
|
|
|
|
PAKEntryReadStream& rs,
|
|
|
|
const hecl::ProjectPath& outPath,
|
|
|
|
PAKRouter<PAKBridge>& pakRouter,
|
|
|
|
const PAK::Entry& entry,
|
|
|
|
bool force,
|
2017-12-29 08:08:12 +00:00
|
|
|
hecl::blender::Token& btok,
|
2016-04-10 04:49:02 +00:00
|
|
|
std::function<void(const hecl::SystemChar*)> fileChanged)
|
|
|
|
{
|
2018-10-14 20:16:21 +00:00
|
|
|
hecl::ProjectPath yamlPath = outPath.getWithExtension(_SYS_STR(".yaml"), true);
|
2016-04-10 04:49:02 +00:00
|
|
|
hecl::ProjectPath::Type yamlType = yamlPath.getPathType();
|
2018-10-14 20:16:21 +00:00
|
|
|
hecl::ProjectPath blendPath = outPath.getWithExtension(_SYS_STR(".blend"), true);
|
2016-04-10 04:49:02 +00:00
|
|
|
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)
|
|
|
|
{
|
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);
|
2016-04-10 04:49:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (force || blendType == hecl::ProjectPath::Type::None)
|
|
|
|
{
|
2017-12-29 08:08:12 +00:00
|
|
|
hecl::blender::Connection& conn = btok.getBlenderConnection();
|
2016-04-10 04:49:02 +00:00
|
|
|
DNAANCS::ReadANCSToBlender<PAKRouter<PAKBridge>, ANCS, MaterialSet, DNACMDL::SurfaceHeader_1, 2>
|
|
|
|
(conn, ancs, blendPath, pakRouter, entry, dataSpec, fileChanged, force);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ANCS::Cook(const hecl::ProjectPath& outPath,
|
|
|
|
const hecl::ProjectPath& inPath,
|
2017-02-13 06:51:47 +00:00
|
|
|
const DNAANCS::Actor& actor)
|
2016-04-10 04:49:02 +00:00
|
|
|
{
|
|
|
|
/* Search for yaml */
|
2018-10-14 20:16:21 +00:00
|
|
|
hecl::ProjectPath yamlPath = inPath.getWithExtension(_SYS_STR(".yaml"), true);
|
2016-09-18 23:47:48 +00:00
|
|
|
if (!yamlPath.isFile())
|
2018-10-14 20:16:21 +00:00
|
|
|
Log.report(logvisor::Fatal, _SYS_STR("'%s' not found as file"),
|
2017-11-13 06:19:18 +00:00
|
|
|
yamlPath.getRelativePath().data());
|
2016-04-10 04:49:02 +00:00
|
|
|
|
2016-08-22 03:47:48 +00:00
|
|
|
athena::io::FileReader reader(yamlPath.getAbsolutePath());
|
|
|
|
if (!reader.isOpen())
|
2018-10-14 20:16:21 +00:00
|
|
|
Log.report(logvisor::Fatal, _SYS_STR("can't open '%s' for reading"),
|
2017-11-13 06:19:18 +00:00
|
|
|
yamlPath.getRelativePath().data());
|
2016-08-21 20:39:18 +00:00
|
|
|
|
2018-02-22 07:24:51 +00:00
|
|
|
if (!athena::io::ValidateFromYAMLStream<ANCS>(reader))
|
2016-08-21 20:39:18 +00:00
|
|
|
{
|
2018-10-14 20:16:21 +00:00
|
|
|
Log.report(logvisor::Fatal, _SYS_STR("'%s' is not urde::DNAMP1::ANCS type"),
|
2017-11-13 06:19:18 +00:00
|
|
|
yamlPath.getRelativePath().data());
|
2016-08-21 20:39:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
athena::io::YAMLDocReader yamlReader;
|
2016-08-22 03:47:48 +00:00
|
|
|
if (!yamlReader.parse(&reader))
|
2016-08-21 20:39:18 +00:00
|
|
|
{
|
2018-10-14 20:16:21 +00:00
|
|
|
Log.report(logvisor::Fatal, _SYS_STR("unable to parse '%s'"),
|
2017-11-13 06:19:18 +00:00
|
|
|
yamlPath.getRelativePath().data());
|
2016-08-21 20:39:18 +00:00
|
|
|
}
|
2016-04-10 04:49:02 +00:00
|
|
|
ANCS ancs;
|
|
|
|
ancs.read(yamlReader);
|
|
|
|
|
|
|
|
/* Set Character Resource IDs */
|
|
|
|
for (ANCS::CharacterSet::CharacterInfo& ch : ancs.characterSet.characters)
|
|
|
|
{
|
2016-08-31 19:58:21 +00:00
|
|
|
ch.cmdl = UniqueID32{};
|
|
|
|
ch.cskr = UniqueID32{};
|
|
|
|
ch.cinf = UniqueID32{};
|
2018-10-11 20:50:05 +00:00
|
|
|
ch.cmdlIce = UniqueID32Zero{};
|
|
|
|
ch.cskrIce = UniqueID32Zero{};
|
2016-08-31 19:58:21 +00:00
|
|
|
|
2017-11-13 06:19:18 +00:00
|
|
|
hecl::SystemStringConv chSysName(ch.name);
|
2018-10-14 20:16:21 +00:00
|
|
|
ch.cskr = inPath.ensureAuxInfo(hecl::SystemString(chSysName.sys_str()) + _SYS_STR(".CSKR"));
|
2016-04-10 04:49:02 +00:00
|
|
|
|
2018-04-04 08:31:29 +00:00
|
|
|
int subtypeIdx = 0;
|
|
|
|
ch.animAABBs.clear();
|
2016-04-10 04:49:02 +00:00
|
|
|
for (const DNAANCS::Actor::Subtype& sub : actor.subtypes)
|
|
|
|
{
|
|
|
|
if (!sub.name.compare(ch.name))
|
|
|
|
{
|
2018-04-04 08:31:29 +00:00
|
|
|
/* Add subtype AABBs */
|
|
|
|
ch.animAABBs.reserve(actor.actions.size());
|
|
|
|
for (const DNAANCS::Action& act : actor.actions)
|
|
|
|
{
|
|
|
|
const auto& sourceAABB = act.subtypeAABBs[subtypeIdx];
|
|
|
|
ch.animAABBs.emplace_back();
|
|
|
|
auto& destAABB = ch.animAABBs.back();
|
|
|
|
destAABB.name = act.name;
|
|
|
|
destAABB.aabb[0] = sourceAABB.first.val;
|
|
|
|
destAABB.aabb[1] = sourceAABB.second.val;
|
|
|
|
}
|
|
|
|
|
2016-04-10 04:49:02 +00:00
|
|
|
if (sub.armature >= 0)
|
|
|
|
{
|
2017-12-29 08:08:12 +00:00
|
|
|
const DNAANCS::Armature& arm = actor.armatures[sub.armature];
|
2017-11-13 06:19:18 +00:00
|
|
|
hecl::SystemStringConv armSysName(arm.name);
|
2018-10-14 20:16:21 +00:00
|
|
|
ch.cinf = inPath.ensureAuxInfo(hecl::SystemString(armSysName.sys_str()) + _SYS_STR(".CINF"));
|
2016-08-31 19:58:21 +00:00
|
|
|
ch.cmdl = sub.mesh;
|
2018-10-11 20:50:05 +00:00
|
|
|
auto search = std::find_if(sub.overlayMeshes.cbegin(), sub.overlayMeshes.cend(),
|
|
|
|
[](const auto& p) { return p.first == "ICE"; });
|
|
|
|
if (search != sub.overlayMeshes.cend())
|
2016-08-31 19:58:21 +00:00
|
|
|
{
|
2018-10-11 20:50:05 +00:00
|
|
|
hecl::SystemStringConv overlaySys(search->first);
|
|
|
|
ch.cmdlIce = search->second;
|
2018-10-14 20:16:21 +00:00
|
|
|
ch.cskrIce = inPath.ensureAuxInfo(hecl::SystemString(chSysName.sys_str()) + _SYS_STR('.') +
|
|
|
|
overlaySys.c_str() + _SYS_STR(".CSKR"));
|
2016-08-31 19:58:21 +00:00
|
|
|
}
|
2016-04-10 04:49:02 +00:00
|
|
|
}
|
2018-04-04 08:31:29 +00:00
|
|
|
|
|
|
|
break;
|
2016-04-10 04:49:02 +00:00
|
|
|
}
|
2018-04-04 08:31:29 +00:00
|
|
|
++subtypeIdx;
|
2016-04-10 04:49:02 +00:00
|
|
|
}
|
2018-04-04 08:31:29 +00:00
|
|
|
|
|
|
|
std::sort(ch.animAABBs.begin(), ch.animAABBs.end(),
|
|
|
|
[](const ANCS::CharacterSet::CharacterInfo::ActionAABB& a,
|
|
|
|
const ANCS::CharacterSet::CharacterInfo::ActionAABB& b)
|
|
|
|
{ return a.name < b.name; });
|
2016-04-10 04:49:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Set Animation Resource IDs */
|
|
|
|
ancs.enumeratePrimitives([&](AnimationSet::MetaAnimPrimitive& prim) -> bool
|
|
|
|
{
|
2017-11-13 06:19:18 +00:00
|
|
|
hecl::SystemStringConv sysStr(prim.animName);
|
2018-10-14 20:16:21 +00:00
|
|
|
hecl::ProjectPath pathOut = inPath.ensureAuxInfo(hecl::SystemString(sysStr.sys_str()) + _SYS_STR(".ANIM"));
|
2016-04-10 04:49:02 +00:00
|
|
|
prim.animId = pathOut;
|
|
|
|
return true;
|
|
|
|
});
|
|
|
|
|
2017-02-13 06:51:47 +00:00
|
|
|
/* Gather ANIM resources */
|
|
|
|
ancs.animationSet.animResources.reserve(actor.actions.size());
|
2017-12-29 08:08:12 +00:00
|
|
|
for (const DNAANCS::Action& act : actor.actions)
|
2017-02-13 06:51:47 +00:00
|
|
|
{
|
2017-11-13 06:19:18 +00:00
|
|
|
hecl::SystemStringConv sysStr(act.name);
|
2018-10-14 20:16:21 +00:00
|
|
|
hecl::ProjectPath pathOut = inPath.ensureAuxInfo(hecl::SystemString(sysStr.sys_str()) + _SYS_STR(".ANIM"));
|
2017-02-13 06:51:47 +00:00
|
|
|
|
|
|
|
ancs.animationSet.animResources.emplace_back();
|
|
|
|
ancs.animationSet.animResources.back().animId = pathOut;
|
|
|
|
|
|
|
|
/* Check for associated EVNT YAML */
|
2018-10-14 20:16:21 +00:00
|
|
|
hecl::ProjectPath evntYamlPath = inPath.getWithExtension((hecl::SystemString(_SYS_STR(".")) +
|
2017-11-13 06:19:18 +00:00
|
|
|
sysStr.c_str() +
|
2018-10-14 20:16:21 +00:00
|
|
|
_SYS_STR(".evnt.yaml")).c_str(), true);
|
|
|
|
evntYamlPath = evntYamlPath.ensureAuxInfo(_SYS_STR(""));
|
2017-02-13 06:51:47 +00:00
|
|
|
if (evntYamlPath.isFile())
|
|
|
|
ancs.animationSet.animResources.back().evntId = evntYamlPath;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Write out ANCS */
|
|
|
|
athena::io::TransactionalFileWriter w(outPath.getAbsolutePath());
|
|
|
|
ancs.write(w);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ANCS::CookCINF(const hecl::ProjectPath& outPath,
|
|
|
|
const hecl::ProjectPath& inPath,
|
|
|
|
const DNAANCS::Actor& actor)
|
|
|
|
{
|
|
|
|
hecl::SystemString armName(inPath.getAuxInfo().begin(),
|
|
|
|
inPath.getAuxInfo().end() - 5);
|
2016-04-10 04:49:02 +00:00
|
|
|
|
2017-12-29 08:08:12 +00:00
|
|
|
for (const DNAANCS::Armature& arm : actor.armatures)
|
2017-02-13 06:51:47 +00:00
|
|
|
{
|
2017-11-13 06:19:18 +00:00
|
|
|
hecl::SystemStringConv sysStr(arm.name);
|
2017-02-13 06:51:47 +00:00
|
|
|
if (sysStr.sys_str() == armName)
|
2016-08-22 00:11:18 +00:00
|
|
|
{
|
2017-02-13 06:51:47 +00:00
|
|
|
std::unordered_map<std::string, atInt32> boneIdMap;
|
|
|
|
CINF cinf(arm, boneIdMap);
|
|
|
|
|
|
|
|
/* Write out CINF resource */
|
|
|
|
athena::io::TransactionalFileWriter w(outPath.getAbsolutePath());
|
|
|
|
cinf.write(w);
|
|
|
|
return true;
|
2016-08-22 00:11:18 +00:00
|
|
|
}
|
2016-04-10 04:49:02 +00:00
|
|
|
}
|
|
|
|
|
2017-02-13 06:51:47 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ANCS::CookCSKR(const hecl::ProjectPath& outPath,
|
|
|
|
const hecl::ProjectPath& inPath,
|
|
|
|
const DNAANCS::Actor& actor,
|
|
|
|
const std::function<bool(const hecl::ProjectPath& modelPath)>& modelCookFunc)
|
|
|
|
{
|
|
|
|
hecl::SystemString subName(inPath.getAuxInfo().begin(),
|
|
|
|
inPath.getAuxInfo().end() - 5);
|
2017-10-25 07:47:49 +00:00
|
|
|
hecl::SystemString overName;
|
2018-10-14 20:16:21 +00:00
|
|
|
auto dotPos = subName.rfind(_SYS_STR('.'));
|
2017-10-25 07:47:49 +00:00
|
|
|
if (dotPos != hecl::SystemString::npos)
|
|
|
|
{
|
|
|
|
overName = hecl::SystemString(subName.begin() + dotPos + 1, subName.end());
|
|
|
|
subName = hecl::SystemString(subName.begin(), subName.begin() + dotPos);
|
|
|
|
}
|
2017-11-13 06:19:18 +00:00
|
|
|
hecl::SystemUTF8Conv subNameView(subName);
|
|
|
|
hecl::SystemUTF8Conv overNameView(overName);
|
2017-02-13 06:51:47 +00:00
|
|
|
|
2018-03-28 08:09:41 +00:00
|
|
|
/* Build bone ID map */
|
|
|
|
std::unordered_map<std::string, atInt32> boneIdMap;
|
|
|
|
for (const DNAANCS::Armature& arm : actor.armatures)
|
|
|
|
{
|
|
|
|
CINF cinf(arm, boneIdMap);
|
|
|
|
}
|
|
|
|
|
|
|
|
const DNAANCS::Actor::Subtype* subtype = nullptr;
|
2018-10-14 20:16:21 +00:00
|
|
|
if (subName != _SYS_STR("ATTACH"))
|
2018-03-28 08:09:41 +00:00
|
|
|
{
|
2018-10-11 20:50:05 +00:00
|
|
|
for (const DNAANCS::Actor::Subtype& sub : actor.subtypes)
|
2018-03-28 08:09:41 +00:00
|
|
|
{
|
2018-10-11 20:50:05 +00:00
|
|
|
if (!sub.name.compare(subNameView.str()))
|
|
|
|
{
|
|
|
|
subtype = ⊂
|
|
|
|
break;
|
|
|
|
}
|
2018-03-28 08:09:41 +00:00
|
|
|
}
|
2018-10-11 20:50:05 +00:00
|
|
|
if (!subtype)
|
2018-10-14 20:16:21 +00:00
|
|
|
Log.report(logvisor::Fatal, _SYS_STR("unable to find subtype '%s'"), subName.c_str());
|
2018-03-28 08:09:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const hecl::ProjectPath* modelPath = nullptr;
|
2018-10-14 20:16:21 +00:00
|
|
|
if (subName == _SYS_STR("ATTACH"))
|
2018-10-11 20:50:05 +00:00
|
|
|
{
|
|
|
|
const DNAANCS::Actor::Attachment* attachment = nullptr;
|
|
|
|
for (const DNAANCS::Actor::Attachment& att : actor.attachments)
|
|
|
|
{
|
|
|
|
if (!att.name.compare(overNameView.str()))
|
|
|
|
{
|
|
|
|
attachment = &att;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!attachment)
|
2018-10-14 20:16:21 +00:00
|
|
|
Log.report(logvisor::Fatal, _SYS_STR("unable to find attachment '%s'"), overName.c_str());
|
2018-10-11 20:50:05 +00:00
|
|
|
modelPath = &attachment->mesh;
|
|
|
|
}
|
|
|
|
else if (overName.empty())
|
2018-03-28 08:09:41 +00:00
|
|
|
{
|
|
|
|
modelPath = &subtype->mesh;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for (const auto& overlay : subtype->overlayMeshes)
|
|
|
|
if (!overlay.first.compare(overNameView.str()))
|
|
|
|
{
|
|
|
|
modelPath = &overlay.second;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!modelPath)
|
2018-10-14 20:16:21 +00:00
|
|
|
Log.report(logvisor::Fatal, _SYS_STR("unable to resolve model path of %s:%s"), subName.c_str(), overName.c_str());
|
2018-03-28 08:09:41 +00:00
|
|
|
|
|
|
|
if (!modelPath->isFile())
|
2018-10-14 20:16:21 +00:00
|
|
|
Log.report(logvisor::Fatal, _SYS_STR("unable to resolve '%s'"), modelPath->getRelativePath().data());
|
2018-03-28 08:09:41 +00:00
|
|
|
|
2018-10-14 20:16:21 +00:00
|
|
|
hecl::ProjectPath skinIntPath = modelPath->getCookedPath(SpecEntMP1).getWithExtension(_SYS_STR(".skinint"));
|
2018-03-28 08:09:41 +00:00
|
|
|
if (!skinIntPath.isFileOrGlob() || skinIntPath.getModtime() < modelPath->getModtime())
|
|
|
|
if (!modelCookFunc(*modelPath))
|
2018-10-14 20:16:21 +00:00
|
|
|
Log.report(logvisor::Fatal, _SYS_STR("unable to cook '%s'"), modelPath->getRelativePath().data());
|
2018-03-28 08:09:41 +00:00
|
|
|
|
2018-11-09 06:57:16 +00:00
|
|
|
std::vector<std::pair<std::vector<std::pair<uint32_t, float>>, uint32_t>> skins;
|
|
|
|
uint32_t posCount = 0;
|
|
|
|
uint32_t normCount = 0;
|
2018-03-28 08:09:41 +00:00
|
|
|
athena::io::FileReader skinIO(skinIntPath.getAbsolutePath(), 1024*32, false);
|
2018-11-09 06:57:16 +00:00
|
|
|
if (!skinIO.hasError())
|
|
|
|
{
|
|
|
|
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());
|
2018-03-28 08:09:41 +00:00
|
|
|
|
2018-11-09 06:57:16 +00:00
|
|
|
uint32_t skinCount = skinIO.readUint32Big();
|
|
|
|
skins.resize(skinCount);
|
|
|
|
for (uint32_t i=0 ; i<skinCount ; ++i)
|
2018-03-28 08:09:41 +00:00
|
|
|
{
|
2018-11-09 06:57:16 +00:00
|
|
|
std::pair<std::vector<std::pair<uint32_t, float>>, uint32_t>& virtualBone = skins[i];
|
|
|
|
uint32_t bindCount = skinIO.readUint32Big();
|
|
|
|
virtualBone.first.reserve(bindCount);
|
|
|
|
for (uint32_t j=0 ; j<bindCount ; ++j)
|
|
|
|
{
|
|
|
|
uint32_t bIdx = skinIO.readUint32Big();
|
|
|
|
float weight = skinIO.readFloatBig();
|
|
|
|
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().data());
|
|
|
|
virtualBone.first.emplace_back(search->second, weight);
|
|
|
|
}
|
|
|
|
virtualBone.second = skinIO.readUint32Big();
|
2018-03-28 08:09:41 +00:00
|
|
|
}
|
|
|
|
|
2018-11-09 06:57:16 +00:00
|
|
|
posCount = skinIO.readUint32Big();
|
|
|
|
normCount = skinIO.readUint32Big();
|
2018-03-28 08:09:41 +00:00
|
|
|
|
2018-11-09 06:57:16 +00:00
|
|
|
skinIO.close();
|
|
|
|
}
|
2018-03-28 08:09:41 +00:00
|
|
|
|
|
|
|
athena::io::TransactionalFileWriter skinOut(outPath.getAbsolutePath());
|
|
|
|
|
|
|
|
skinOut.writeUint32Big(skins.size());
|
|
|
|
for (auto& virtuaBone : skins)
|
|
|
|
{
|
|
|
|
skinOut.writeUint32Big(virtuaBone.first.size());
|
|
|
|
for (auto& bind : virtuaBone.first)
|
|
|
|
{
|
|
|
|
skinOut.writeUint32Big(bind.first);
|
|
|
|
skinOut.writeFloatBig(bind.second);
|
|
|
|
}
|
|
|
|
skinOut.writeUint32Big(virtuaBone.second);
|
|
|
|
}
|
|
|
|
|
|
|
|
skinOut.writeUint32Big(0xffffffff);
|
|
|
|
skinOut.writeUint32Big(posCount);
|
|
|
|
skinOut.writeUint32Big(0xffffffff);
|
|
|
|
skinOut.writeUint32Big(normCount);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ANCS::CookCSKRPC(const hecl::ProjectPath& outPath,
|
|
|
|
const hecl::ProjectPath& inPath,
|
|
|
|
const DNAANCS::Actor& actor,
|
|
|
|
const std::function<bool(const hecl::ProjectPath& modelPath)>& modelCookFunc)
|
|
|
|
{
|
|
|
|
hecl::SystemString subName(inPath.getAuxInfo().begin(),
|
|
|
|
inPath.getAuxInfo().end() - 5);
|
|
|
|
hecl::SystemString overName;
|
2018-10-14 20:16:21 +00:00
|
|
|
auto dotPos = subName.rfind(_SYS_STR('.'));
|
2018-03-28 08:09:41 +00:00
|
|
|
if (dotPos != hecl::SystemString::npos)
|
|
|
|
{
|
|
|
|
overName = hecl::SystemString(subName.begin() + dotPos + 1, subName.end());
|
|
|
|
subName = hecl::SystemString(subName.begin(), subName.begin() + dotPos);
|
|
|
|
}
|
|
|
|
hecl::SystemUTF8Conv subNameView(subName);
|
|
|
|
hecl::SystemUTF8Conv overNameView(overName);
|
|
|
|
|
2017-02-13 06:51:47 +00:00
|
|
|
/* Build bone ID map */
|
|
|
|
std::unordered_map<std::string, atInt32> boneIdMap;
|
2017-12-29 08:08:12 +00:00
|
|
|
for (const DNAANCS::Armature& arm : actor.armatures)
|
2016-04-10 04:49:02 +00:00
|
|
|
{
|
2017-02-13 06:51:47 +00:00
|
|
|
CINF cinf(arm, boneIdMap);
|
|
|
|
}
|
|
|
|
|
|
|
|
const DNAANCS::Actor::Subtype* subtype = nullptr;
|
2018-10-14 20:16:21 +00:00
|
|
|
if (subName != _SYS_STR("ATTACH"))
|
2017-02-13 06:51:47 +00:00
|
|
|
{
|
2018-10-11 20:50:05 +00:00
|
|
|
for (const DNAANCS::Actor::Subtype& sub : actor.subtypes)
|
2016-08-22 00:11:18 +00:00
|
|
|
{
|
2018-10-11 20:50:05 +00:00
|
|
|
if (!sub.name.compare(subNameView.str()))
|
|
|
|
{
|
|
|
|
subtype = ⊂
|
|
|
|
break;
|
|
|
|
}
|
2016-08-22 00:11:18 +00:00
|
|
|
}
|
2018-10-11 20:50:05 +00:00
|
|
|
if (!subtype)
|
2018-10-14 20:16:21 +00:00
|
|
|
Log.report(logvisor::Fatal, _SYS_STR("unable to find subtype '%s'"), subName.c_str());
|
2017-02-13 06:51:47 +00:00
|
|
|
}
|
2016-08-22 00:11:18 +00:00
|
|
|
|
2017-10-25 07:47:49 +00:00
|
|
|
const hecl::ProjectPath* modelPath = nullptr;
|
2018-10-14 20:16:21 +00:00
|
|
|
if (subName == _SYS_STR("ATTACH"))
|
2018-10-11 20:50:05 +00:00
|
|
|
{
|
|
|
|
const DNAANCS::Actor::Attachment* attachment = nullptr;
|
|
|
|
for (const DNAANCS::Actor::Attachment& att : actor.attachments)
|
|
|
|
{
|
|
|
|
if (!att.name.compare(overNameView.str()))
|
|
|
|
{
|
|
|
|
attachment = &att;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!attachment)
|
2018-10-14 20:16:21 +00:00
|
|
|
Log.report(logvisor::Fatal, _SYS_STR("unable to find attachment '%s'"), overName.c_str());
|
2018-10-11 20:50:05 +00:00
|
|
|
modelPath = &attachment->mesh;
|
|
|
|
}
|
|
|
|
else if (overName.empty())
|
2017-10-25 07:47:49 +00:00
|
|
|
{
|
|
|
|
modelPath = &subtype->mesh;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for (const auto& overlay : subtype->overlayMeshes)
|
|
|
|
if (!overlay.first.compare(overNameView.str()))
|
|
|
|
{
|
|
|
|
modelPath = &overlay.second;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!modelPath)
|
2018-10-14 20:16:21 +00:00
|
|
|
Log.report(logvisor::Fatal, _SYS_STR("unable to resolve model path of %s:%s"), subName.c_str(), overName.c_str());
|
2016-04-10 04:49:02 +00:00
|
|
|
|
2017-10-25 07:47:49 +00:00
|
|
|
if (!modelPath->isFile())
|
2018-10-14 20:16:21 +00:00
|
|
|
Log.report(logvisor::Fatal, _SYS_STR("unable to resolve '%s'"), modelPath->getRelativePath().data());
|
2016-04-10 04:49:02 +00:00
|
|
|
|
2018-10-14 20:16:21 +00:00
|
|
|
hecl::ProjectPath skinIntPath = modelPath->getCookedPath(SpecEntMP1PC).getWithExtension(_SYS_STR(".skinint"));
|
2017-10-25 07:47:49 +00:00
|
|
|
if (!skinIntPath.isFileOrGlob() || skinIntPath.getModtime() < modelPath->getModtime())
|
|
|
|
if (!modelCookFunc(*modelPath))
|
2018-10-14 20:16:21 +00:00
|
|
|
Log.report(logvisor::Fatal, _SYS_STR("unable to cook '%s'"), modelPath->getRelativePath().data());
|
2016-04-10 04:49:02 +00:00
|
|
|
|
2018-11-09 06:57:16 +00:00
|
|
|
uint32_t bankCount = 0;
|
2017-02-13 06:51:47 +00:00
|
|
|
std::vector<std::vector<uint32_t>> skinBanks;
|
2018-11-09 06:57:16 +00:00
|
|
|
std::vector<std::string> boneNames;
|
|
|
|
std::vector<std::vector<std::pair<uint32_t, float>>> skins;
|
|
|
|
atUint64 uniquePoolIndexLen = 0;
|
|
|
|
std::unique_ptr<atUint8[]> uniquePoolIndexData;
|
|
|
|
athena::io::FileReader skinIO(skinIntPath.getAbsolutePath(), 1024*32, false);
|
|
|
|
if (!skinIO.hasError())
|
|
|
|
{
|
|
|
|
bankCount = skinIO.readUint32Big();
|
|
|
|
skinBanks.reserve(bankCount);
|
|
|
|
for (uint32_t i=0 ; i<bankCount ; ++i)
|
2016-04-10 04:49:02 +00:00
|
|
|
{
|
2018-11-09 06:57:16 +00:00
|
|
|
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);
|
|
|
|
}
|
2016-04-10 04:49:02 +00:00
|
|
|
}
|
|
|
|
|
2018-11-09 06:57:16 +00:00
|
|
|
uint32_t boneNameCount = skinIO.readUint32Big();
|
|
|
|
boneNames.reserve(boneNameCount);
|
|
|
|
for (uint32_t i=0 ; i<boneNameCount ; ++i)
|
|
|
|
boneNames.push_back(skinIO.readString());
|
2016-04-10 04:49:02 +00:00
|
|
|
|
2018-11-09 06:57:16 +00:00
|
|
|
uint32_t skinCount = skinIO.readUint32Big();
|
|
|
|
skins.resize(skinCount);
|
|
|
|
for (uint32_t i=0 ; i<skinCount ; ++i)
|
2017-08-21 05:46:59 +00:00
|
|
|
{
|
2018-11-09 06:57:16 +00:00
|
|
|
std::vector<std::pair<uint32_t, float>>& virtualBone = skins[i];
|
|
|
|
uint32_t bindCount = skinIO.readUint32Big();
|
|
|
|
virtualBone.reserve(bindCount);
|
|
|
|
for (uint32_t j=0 ; j<bindCount ; ++j)
|
|
|
|
{
|
|
|
|
uint32_t bIdx = skinIO.readUint32Big();
|
|
|
|
float weight = skinIO.readFloatBig();
|
|
|
|
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().data());
|
|
|
|
virtualBone.emplace_back(search->second, weight);
|
|
|
|
}
|
2017-08-21 05:46:59 +00:00
|
|
|
}
|
|
|
|
|
2018-11-09 06:57:16 +00:00
|
|
|
uniquePoolIndexLen = skinIO.length() - skinIO.position();
|
|
|
|
uniquePoolIndexData = skinIO.readUBytes(uniquePoolIndexLen);
|
2017-08-21 05:46:59 +00:00
|
|
|
|
2018-11-09 06:57:16 +00:00
|
|
|
skinIO.close();
|
|
|
|
}
|
2016-04-10 04:49:02 +00:00
|
|
|
|
2017-02-13 06:51:47 +00:00
|
|
|
athena::io::TransactionalFileWriter skinOut(outPath.getAbsolutePath());
|
2016-04-10 04:49:02 +00:00
|
|
|
|
2017-02-13 06:51:47 +00:00
|
|
|
skinOut.writeUint32Big(bankCount);
|
|
|
|
for (const std::vector<uint32_t>& bank : skinBanks)
|
|
|
|
{
|
|
|
|
skinOut.writeUint32Big(bank.size());
|
|
|
|
for (uint32_t bIdx : bank)
|
2016-04-10 04:49:02 +00:00
|
|
|
{
|
2017-02-13 06:51:47 +00:00
|
|
|
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",
|
2017-11-13 06:19:18 +00:00
|
|
|
name.c_str(), inPath.getRelativePathUTF8().data());
|
2017-02-13 06:51:47 +00:00
|
|
|
skinOut.writeUint32Big(search->second);
|
2016-04-10 04:49:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-08-21 05:46:59 +00:00
|
|
|
skinOut.writeUint32Big(skins.size());
|
|
|
|
for (auto& virtuaBone : skins)
|
|
|
|
{
|
|
|
|
skinOut.writeUint32Big(virtuaBone.size());
|
|
|
|
for (auto& bind : virtuaBone)
|
|
|
|
{
|
|
|
|
skinOut.writeUint32Big(bind.first);
|
|
|
|
skinOut.writeFloatBig(bind.second);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-11-09 06:57:16 +00:00
|
|
|
if (uniquePoolIndexLen)
|
|
|
|
skinOut.writeUBytes(uniquePoolIndexData.get(), uniquePoolIndexLen);
|
2017-08-21 05:46:59 +00:00
|
|
|
|
2017-02-13 06:51:47 +00:00
|
|
|
return true;
|
|
|
|
}
|
2016-04-10 04:49:02 +00:00
|
|
|
|
2017-02-13 06:51:47 +00:00
|
|
|
bool ANCS::CookANIM(const hecl::ProjectPath& outPath,
|
|
|
|
const hecl::ProjectPath& inPath,
|
|
|
|
const DNAANCS::Actor& actor,
|
2017-12-29 08:08:12 +00:00
|
|
|
hecl::blender::DataStream& ds,
|
2017-02-13 06:51:47 +00:00
|
|
|
bool pc)
|
|
|
|
{
|
|
|
|
hecl::SystemString actName(inPath.getAuxInfo().begin(),
|
|
|
|
inPath.getAuxInfo().end() - 5);
|
2017-11-13 06:19:18 +00:00
|
|
|
hecl::SystemUTF8Conv actNameView(actName);
|
2017-12-29 08:08:12 +00:00
|
|
|
DNAANCS::Action action = ds.compileActionChannelsOnly(actNameView.str());
|
2016-04-10 04:49:02 +00:00
|
|
|
|
2017-02-13 06:51:47 +00:00
|
|
|
if (!actor.armatures.size())
|
2018-10-14 20:16:21 +00:00
|
|
|
Log.report(logvisor::Fatal, _SYS_STR("0 armatures in %s"),
|
2017-11-13 06:19:18 +00:00
|
|
|
inPath.getRelativePath().data());
|
2017-02-13 06:51:47 +00:00
|
|
|
|
|
|
|
/* Build bone ID map */
|
|
|
|
std::unordered_map<std::string, atInt32> boneIdMap;
|
2017-12-23 05:40:50 +00:00
|
|
|
std::experimental::optional<CINF> rigCinf;
|
2017-02-13 06:51:47 +00:00
|
|
|
std::experimental::optional<DNAANIM::RigInverter<CINF>> rigInv;
|
2017-12-29 08:08:12 +00:00
|
|
|
for (const DNAANCS::Armature& arm : actor.armatures)
|
2017-02-13 06:51:47 +00:00
|
|
|
{
|
|
|
|
if (!rigInv)
|
2016-04-10 04:49:02 +00:00
|
|
|
{
|
2017-12-23 05:40:50 +00:00
|
|
|
rigCinf.emplace(arm, boneIdMap);
|
2017-02-13 06:51:47 +00:00
|
|
|
auto matrices = ds.getBoneMatrices(arm.name);
|
2017-12-23 05:40:50 +00:00
|
|
|
rigInv.emplace(*rigCinf, matrices);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CINF cinf(arm, boneIdMap);
|
2016-04-10 04:49:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-02-13 06:51:47 +00:00
|
|
|
ANIM anim(action, boneIdMap, *rigInv, pc);
|
|
|
|
|
|
|
|
/* Check for associated EVNT YAML */
|
2018-10-14 20:16:21 +00:00
|
|
|
hecl::ProjectPath evntYamlPath = inPath.getWithExtension((hecl::SystemString(_SYS_STR(".")) + actName +
|
|
|
|
_SYS_STR(".evnt.yaml")).c_str(), true);
|
|
|
|
evntYamlPath = evntYamlPath.ensureAuxInfo(_SYS_STR(""));
|
2017-02-13 06:51:47 +00:00
|
|
|
if (evntYamlPath.isFile())
|
|
|
|
anim.m_anim->evnt = evntYamlPath;
|
2016-04-10 04:49:02 +00:00
|
|
|
|
2017-02-13 06:51:47 +00:00
|
|
|
/* Write out ANIM resource */
|
|
|
|
athena::io::TransactionalFileWriter w(outPath.getAbsolutePath());
|
|
|
|
anim.write(w);
|
2016-04-10 04:49:02 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-08-08 04:49:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|