mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-12-10 00:27:43 +00:00
ANIM fixes and explicit-endian refactor
This commit is contained in:
@@ -7,23 +7,23 @@ namespace DNAMP1
|
||||
|
||||
void ANCS::CharacterSet::CharacterInfo::PASDatabase::AnimState::ParmInfo::read(Athena::io::IStreamReader& reader)
|
||||
{
|
||||
parmType = reader.readUint32();
|
||||
unk1 = reader.readUint32();
|
||||
unk2 = reader.readFloat();
|
||||
parmType = reader.readUint32Big();
|
||||
unk1 = reader.readUint32Big();
|
||||
unk2 = reader.readFloatBig();
|
||||
switch (DataType(parmType))
|
||||
{
|
||||
case DataType::DTInt32:
|
||||
parmVals[0].int32 = reader.readInt32();
|
||||
parmVals[1].int32 = reader.readInt32();
|
||||
parmVals[0].int32 = reader.readInt32Big();
|
||||
parmVals[1].int32 = reader.readInt32Big();
|
||||
break;
|
||||
case DataType::DTUInt32:
|
||||
case DataType::DTEnum:
|
||||
parmVals[0].uint32 = reader.readUint32();
|
||||
parmVals[1].uint32 = reader.readUint32();
|
||||
parmVals[0].uint32 = reader.readUint32Big();
|
||||
parmVals[1].uint32 = reader.readUint32Big();
|
||||
break;
|
||||
case DataType::DTFloat:
|
||||
parmVals[0].float32 = reader.readFloat();
|
||||
parmVals[1].float32 = reader.readFloat();
|
||||
parmVals[0].float32 = reader.readFloatBig();
|
||||
parmVals[1].float32 = reader.readFloatBig();
|
||||
break;
|
||||
case DataType::DTBool:
|
||||
parmVals[0].bool1 = reader.readBool();
|
||||
@@ -34,23 +34,23 @@ void ANCS::CharacterSet::CharacterInfo::PASDatabase::AnimState::ParmInfo::read(A
|
||||
|
||||
void ANCS::CharacterSet::CharacterInfo::PASDatabase::AnimState::ParmInfo::write(Athena::io::IStreamWriter& writer) const
|
||||
{
|
||||
writer.writeUint32(parmType);
|
||||
writer.writeUint32(unk1);
|
||||
writer.writeFloat(unk2);
|
||||
writer.writeUint32Big(parmType);
|
||||
writer.writeUint32Big(unk1);
|
||||
writer.writeFloatBig(unk2);
|
||||
switch (DataType(parmType))
|
||||
{
|
||||
case DataType::DTInt32:
|
||||
writer.writeInt32(parmVals[0].int32);
|
||||
writer.writeInt32(parmVals[1].int32);
|
||||
writer.writeInt32Big(parmVals[0].int32);
|
||||
writer.writeInt32Big(parmVals[1].int32);
|
||||
break;
|
||||
case DataType::DTUInt32:
|
||||
case DataType::DTEnum:
|
||||
writer.writeUint32(parmVals[0].uint32);
|
||||
writer.writeUint32(parmVals[0].uint32);
|
||||
writer.writeUint32Big(parmVals[0].uint32);
|
||||
writer.writeUint32Big(parmVals[0].uint32);
|
||||
break;
|
||||
case DataType::DTFloat:
|
||||
writer.writeFloat(parmVals[0].float32);
|
||||
writer.writeFloat(parmVals[0].float32);
|
||||
writer.writeFloatBig(parmVals[0].float32);
|
||||
writer.writeFloatBig(parmVals[0].float32);
|
||||
break;
|
||||
case DataType::DTBool:
|
||||
writer.writeBool(parmVals[0].bool1);
|
||||
@@ -120,9 +120,9 @@ void ANCS::CharacterSet::CharacterInfo::PASDatabase::AnimState::ParmInfo::toYAML
|
||||
|
||||
void ANCS::CharacterSet::CharacterInfo::PASDatabase::AnimState::read(Athena::io::IStreamReader& reader)
|
||||
{
|
||||
id = reader.readUint32();
|
||||
atUint32 parmInfoCount = reader.readUint32();
|
||||
atUint32 animInfoCount = reader.readUint32();
|
||||
id = reader.readUint32Big();
|
||||
atUint32 parmInfoCount = reader.readUint32Big();
|
||||
atUint32 animInfoCount = reader.readUint32Big();
|
||||
|
||||
reader.enumerate(parmInfos, parmInfoCount);
|
||||
|
||||
@@ -131,21 +131,21 @@ void ANCS::CharacterSet::CharacterInfo::PASDatabase::AnimState::read(Athena::io:
|
||||
reader.enumerate<AnimInfo>(animInfos, animInfoCount,
|
||||
[this, parmInfoCount](Athena::io::IStreamReader& reader, AnimInfo& ai)
|
||||
{
|
||||
ai.id = reader.readUint32();
|
||||
ai.id = reader.readUint32Big();
|
||||
ai.parmVals.reserve(parmInfoCount);
|
||||
for (const ParmInfo& pi : parmInfos)
|
||||
{
|
||||
switch (ParmInfo::DataType(pi.parmType))
|
||||
{
|
||||
case ParmInfo::DTInt32:
|
||||
ai.parmVals.emplace_back(reader.readInt32());
|
||||
ai.parmVals.emplace_back(reader.readInt32Big());
|
||||
break;
|
||||
case ParmInfo::DTUInt32:
|
||||
case ParmInfo::DTEnum:
|
||||
ai.parmVals.emplace_back(reader.readUint32());
|
||||
ai.parmVals.emplace_back(reader.readUint32Big());
|
||||
break;
|
||||
case ParmInfo::DTFloat:
|
||||
ai.parmVals.emplace_back(reader.readFloat());
|
||||
ai.parmVals.emplace_back(reader.readFloatBig());
|
||||
break;
|
||||
case ParmInfo::DTBool:
|
||||
ai.parmVals.emplace_back(reader.readBool());
|
||||
@@ -158,16 +158,16 @@ void ANCS::CharacterSet::CharacterInfo::PASDatabase::AnimState::read(Athena::io:
|
||||
|
||||
void ANCS::CharacterSet::CharacterInfo::PASDatabase::AnimState::write(Athena::io::IStreamWriter& writer) const
|
||||
{
|
||||
writer.writeUint32(id);
|
||||
writer.writeUint32(parmInfos.size());
|
||||
writer.writeUint32(animInfos.size());
|
||||
writer.writeUint32Big(id);
|
||||
writer.writeUint32Big(parmInfos.size());
|
||||
writer.writeUint32Big(animInfos.size());
|
||||
|
||||
for (const ParmInfo& pi : parmInfos)
|
||||
pi.write(writer);
|
||||
|
||||
for (const AnimInfo& ai : animInfos)
|
||||
{
|
||||
writer.writeUint32(ai.id);
|
||||
writer.writeUint32Big(ai.id);
|
||||
auto it = ai.parmVals.begin();
|
||||
for (const ParmInfo& pi : parmInfos)
|
||||
{
|
||||
@@ -177,14 +177,14 @@ void ANCS::CharacterSet::CharacterInfo::PASDatabase::AnimState::write(Athena::io
|
||||
switch (ParmInfo::DataType(pi.parmType))
|
||||
{
|
||||
case ParmInfo::DTInt32:
|
||||
writer.writeInt32(pVal.int32);
|
||||
writer.writeInt32Big(pVal.int32);
|
||||
break;
|
||||
case ParmInfo::DTUInt32:
|
||||
case ParmInfo::DTEnum:
|
||||
writer.writeUint32(pVal.uint32);
|
||||
writer.writeUint32Big(pVal.uint32);
|
||||
break;
|
||||
case ParmInfo::DTFloat:
|
||||
writer.writeFloat(pVal.float32);
|
||||
writer.writeFloatBig(pVal.float32);
|
||||
break;
|
||||
case ParmInfo::DTBool:
|
||||
writer.writeBool(pVal.bool1);
|
||||
@@ -276,52 +276,52 @@ void ANCS::CharacterSet::CharacterInfo::PASDatabase::AnimState::toYAML(Athena::i
|
||||
|
||||
void ANCS::CharacterSet::CharacterInfo::read(Athena::io::IStreamReader& reader)
|
||||
{
|
||||
idx = reader.readUint32();
|
||||
atUint16 sectionCount = reader.readUint16();
|
||||
idx = reader.readUint32Big();
|
||||
atUint16 sectionCount = reader.readUint16Big();
|
||||
name = reader.readString();
|
||||
cmdl.read(reader);
|
||||
cskr.read(reader);
|
||||
cinf.read(reader);
|
||||
|
||||
atUint32 animationCount = reader.readUint32();
|
||||
atUint32 animationCount = reader.readUint32Big();
|
||||
reader.enumerate(animations, animationCount);
|
||||
|
||||
pasDatabase.read(reader);
|
||||
|
||||
atUint32 partCount = reader.readUint32();
|
||||
atUint32 partCount = reader.readUint32Big();
|
||||
reader.enumerate(partResData.part, partCount);
|
||||
|
||||
atUint32 swhcCount = reader.readUint32();
|
||||
atUint32 swhcCount = reader.readUint32Big();
|
||||
reader.enumerate(partResData.swhc, swhcCount);
|
||||
|
||||
atUint32 unkCount = reader.readUint32();
|
||||
atUint32 unkCount = reader.readUint32Big();
|
||||
reader.enumerate(partResData.unk, unkCount);
|
||||
|
||||
partResData.elsc.clear();
|
||||
if (sectionCount > 5)
|
||||
{
|
||||
atUint32 elscCount = reader.readUint32();
|
||||
atUint32 elscCount = reader.readUint32Big();
|
||||
reader.enumerate(partResData.elsc, elscCount);
|
||||
}
|
||||
|
||||
unk1 = reader.readUint32();
|
||||
unk1 = reader.readUint32Big();
|
||||
if (sectionCount > 9)
|
||||
{
|
||||
unk2 = reader.readUint32();
|
||||
unk3 = reader.readUint32();
|
||||
unk2 = reader.readUint32Big();
|
||||
unk3 = reader.readUint32Big();
|
||||
}
|
||||
|
||||
animAABBs.clear();
|
||||
if (sectionCount > 1)
|
||||
{
|
||||
atUint32 aabbCount = reader.readUint32();
|
||||
atUint32 aabbCount = reader.readUint32Big();
|
||||
reader.enumerate(animAABBs, aabbCount);
|
||||
}
|
||||
|
||||
effects.clear();
|
||||
if (sectionCount > 2)
|
||||
{
|
||||
atUint32 effectCount = reader.readUint32();
|
||||
atUint32 effectCount = reader.readUint32Big();
|
||||
reader.enumerate(effects, effectCount);
|
||||
}
|
||||
|
||||
@@ -334,14 +334,14 @@ void ANCS::CharacterSet::CharacterInfo::read(Athena::io::IStreamReader& reader)
|
||||
animIdxs.clear();
|
||||
if (sectionCount > 4)
|
||||
{
|
||||
atUint32 aidxCount = reader.readUint32();
|
||||
reader.enumerate(animIdxs, aidxCount);
|
||||
atUint32 aidxCount = reader.readUint32Big();
|
||||
reader.enumerateBig(animIdxs, aidxCount);
|
||||
}
|
||||
}
|
||||
|
||||
void ANCS::CharacterSet::CharacterInfo::write(Athena::io::IStreamWriter& writer) const
|
||||
{
|
||||
writer.writeUint32(idx);
|
||||
writer.writeUint32Big(idx);
|
||||
|
||||
atUint16 sectionCount;
|
||||
if (unk2 || unk3)
|
||||
@@ -358,49 +358,49 @@ void ANCS::CharacterSet::CharacterInfo::write(Athena::io::IStreamWriter& writer)
|
||||
sectionCount = 2;
|
||||
else
|
||||
sectionCount = 1;
|
||||
writer.writeUint16(sectionCount);
|
||||
writer.writeUint16Big(sectionCount);
|
||||
|
||||
writer.writeString(name);
|
||||
cmdl.write(writer);
|
||||
cskr.write(writer);
|
||||
cinf.write(writer);
|
||||
|
||||
writer.writeUint32(animations.size());
|
||||
writer.writeUint32Big(animations.size());
|
||||
writer.enumerate(animations);
|
||||
|
||||
pasDatabase.write(writer);
|
||||
|
||||
writer.writeUint32(partResData.part.size());
|
||||
writer.writeUint32Big(partResData.part.size());
|
||||
writer.enumerate(partResData.part);
|
||||
|
||||
writer.writeUint32(partResData.swhc.size());
|
||||
writer.writeUint32Big(partResData.swhc.size());
|
||||
writer.enumerate(partResData.swhc);
|
||||
|
||||
writer.writeUint32(partResData.unk.size());
|
||||
writer.writeUint32Big(partResData.unk.size());
|
||||
writer.enumerate(partResData.unk);
|
||||
|
||||
if (sectionCount > 5)
|
||||
{
|
||||
writer.writeUint32(partResData.elsc.size());
|
||||
writer.writeUint32Big(partResData.elsc.size());
|
||||
writer.enumerate(partResData.elsc);
|
||||
}
|
||||
|
||||
writer.writeUint32(unk1);
|
||||
writer.writeUint32Big(unk1);
|
||||
if (sectionCount > 9)
|
||||
{
|
||||
writer.writeUint32(unk2);
|
||||
writer.writeUint32(unk3);
|
||||
writer.writeUint32Big(unk2);
|
||||
writer.writeUint32Big(unk3);
|
||||
}
|
||||
|
||||
if (sectionCount > 1)
|
||||
{
|
||||
writer.writeUint32(animAABBs.size());
|
||||
writer.writeUint32Big(animAABBs.size());
|
||||
writer.enumerate(animAABBs);
|
||||
}
|
||||
|
||||
if (sectionCount > 2)
|
||||
{
|
||||
writer.writeUint32(effects.size());
|
||||
writer.writeUint32Big(effects.size());
|
||||
writer.enumerate(effects);
|
||||
}
|
||||
|
||||
@@ -412,9 +412,9 @@ void ANCS::CharacterSet::CharacterInfo::write(Athena::io::IStreamWriter& writer)
|
||||
|
||||
if (sectionCount > 4)
|
||||
{
|
||||
writer.writeUint32(animIdxs.size());
|
||||
writer.writeUint32Big(animIdxs.size());
|
||||
for (atUint32 idx : animIdxs)
|
||||
writer.writeUint32(idx);
|
||||
writer.writeUint32Big(idx);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -563,7 +563,7 @@ void ANCS::CharacterSet::CharacterInfo::toYAML(Athena::io::YAMLDocWriter& writer
|
||||
|
||||
void ANCS::AnimationSet::MetaAnimFactory::read(Athena::io::IStreamReader& reader)
|
||||
{
|
||||
IMetaAnim::Type type(IMetaAnim::Type(reader.readUint32()));
|
||||
IMetaAnim::Type type(IMetaAnim::Type(reader.readUint32Big()));
|
||||
switch (type)
|
||||
{
|
||||
case IMetaAnim::MAPrimitive:
|
||||
@@ -596,7 +596,7 @@ void ANCS::AnimationSet::MetaAnimFactory::write(Athena::io::IStreamWriter& write
|
||||
{
|
||||
if (!m_anim)
|
||||
return;
|
||||
writer.writeInt32(m_anim->m_type);
|
||||
writer.writeInt32Big(m_anim->m_type);
|
||||
m_anim->write(writer);
|
||||
}
|
||||
|
||||
@@ -646,7 +646,7 @@ void ANCS::AnimationSet::MetaAnimFactory::toYAML(Athena::io::YAMLDocWriter& writ
|
||||
|
||||
void ANCS::AnimationSet::MetaTransFactory::read(Athena::io::IStreamReader& reader)
|
||||
{
|
||||
IMetaTrans::Type type(IMetaTrans::Type(reader.readUint32()));
|
||||
IMetaTrans::Type type(IMetaTrans::Type(reader.readUint32Big()));
|
||||
switch (type)
|
||||
{
|
||||
case IMetaTrans::MTMetaAnim:
|
||||
@@ -672,10 +672,10 @@ void ANCS::AnimationSet::MetaTransFactory::write(Athena::io::IStreamWriter& writ
|
||||
{
|
||||
if (!m_trans)
|
||||
{
|
||||
writer.writeInt32(IMetaTrans::MTNoTrans);
|
||||
writer.writeInt32Big(IMetaTrans::MTNoTrans);
|
||||
return;
|
||||
}
|
||||
writer.writeInt32(m_trans->m_type);
|
||||
writer.writeInt32Big(m_trans->m_type);
|
||||
m_trans->write(writer);
|
||||
}
|
||||
|
||||
@@ -718,35 +718,35 @@ void ANCS::AnimationSet::MetaTransFactory::toYAML(Athena::io::YAMLDocWriter& wri
|
||||
|
||||
void ANCS::AnimationSet::read(Athena::io::IStreamReader& reader)
|
||||
{
|
||||
atUint16 sectionCount = reader.readUint16();
|
||||
atUint16 sectionCount = reader.readUint16Big();
|
||||
|
||||
atUint32 animationCount = reader.readUint32();
|
||||
atUint32 animationCount = reader.readUint32Big();
|
||||
reader.enumerate(animations, animationCount);
|
||||
|
||||
atUint32 transitionCount = reader.readUint32();
|
||||
atUint32 transitionCount = reader.readUint32Big();
|
||||
reader.enumerate(transitions, transitionCount);
|
||||
defaultTransition.read(reader);
|
||||
|
||||
additiveAnims.clear();
|
||||
if (sectionCount > 1)
|
||||
{
|
||||
atUint32 additiveAnimCount = reader.readUint32();
|
||||
atUint32 additiveAnimCount = reader.readUint32Big();
|
||||
reader.enumerate(additiveAnims, additiveAnimCount);
|
||||
floatA = reader.readFloat();
|
||||
floatB = reader.readFloat();
|
||||
floatA = reader.readFloatBig();
|
||||
floatB = reader.readFloatBig();
|
||||
}
|
||||
|
||||
halfTransitions.clear();
|
||||
if (sectionCount > 2)
|
||||
{
|
||||
atUint32 halfTransitionCount = reader.readUint32();
|
||||
atUint32 halfTransitionCount = reader.readUint32Big();
|
||||
reader.enumerate(halfTransitions, halfTransitionCount);
|
||||
}
|
||||
|
||||
animResources.clear();
|
||||
if (sectionCount > 3)
|
||||
{
|
||||
atUint32 animResourcesCount = reader.readUint32();
|
||||
atUint32 animResourcesCount = reader.readUint32Big();
|
||||
reader.enumerate(animResources, animResourcesCount);
|
||||
}
|
||||
}
|
||||
@@ -763,32 +763,32 @@ void ANCS::AnimationSet::write(Athena::io::IStreamWriter& writer) const
|
||||
else
|
||||
sectionCount = 1;
|
||||
|
||||
writer.writeUint16(sectionCount);
|
||||
writer.writeUint16Big(sectionCount);
|
||||
|
||||
writer.writeUint32(animations.size());
|
||||
writer.writeUint32Big(animations.size());
|
||||
writer.enumerate(animations);
|
||||
|
||||
writer.writeUint32(transitions.size());
|
||||
writer.writeUint32Big(transitions.size());
|
||||
writer.enumerate(transitions);
|
||||
defaultTransition.write(writer);
|
||||
|
||||
if (sectionCount > 1)
|
||||
{
|
||||
writer.writeUint32(additiveAnims.size());
|
||||
writer.writeUint32Big(additiveAnims.size());
|
||||
writer.enumerate(additiveAnims);
|
||||
writer.writeFloat(floatA);
|
||||
writer.writeFloat(floatB);
|
||||
writer.writeFloatBig(floatA);
|
||||
writer.writeFloatBig(floatB);
|
||||
}
|
||||
|
||||
if (sectionCount > 2)
|
||||
{
|
||||
writer.writeUint32(halfTransitions.size());
|
||||
writer.writeUint32Big(halfTransitions.size());
|
||||
writer.enumerate(halfTransitions);
|
||||
}
|
||||
|
||||
if (sectionCount > 3)
|
||||
{
|
||||
writer.writeUint32(animResources.size());
|
||||
writer.writeUint32Big(animResources.size());
|
||||
writer.enumerate(animResources);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -382,14 +382,25 @@ struct ANCS : BigYAML
|
||||
{
|
||||
ANCS ancs;
|
||||
ancs.read(rs);
|
||||
FILE* fp = HECL::Fopen((outPath.getAbsolutePath() + ".yaml").c_str(), _S("wb"));
|
||||
ancs.toYAMLFile(fp);
|
||||
fclose(fp);
|
||||
|
||||
HECL::BlenderConnection& conn = HECL::BlenderConnection::SharedConnection();
|
||||
DNAANCS::ReadANCSToBlender<PAKRouter<PAKBridge>, ANCS, MaterialSet, 2>
|
||||
(conn, ancs, outPath, pakRouter, entry, dataSpec.getMasterShaderPath(), force);
|
||||
return conn.saveBlend();
|
||||
HECL::ProjectPath yamlPath = outPath.getWithExtension(_S(".yaml"));
|
||||
if (force || yamlPath.getPathType() == HECL::ProjectPath::PT_NONE)
|
||||
{
|
||||
FILE* fp = HECL::Fopen(yamlPath.getAbsolutePath().c_str(), _S("wb"));
|
||||
ancs.toYAMLFile(fp);
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
HECL::ProjectPath blendPath = outPath.getWithExtension(_S(".blend"));
|
||||
if (force || blendPath.getPathType() == HECL::ProjectPath::PT_NONE)
|
||||
{
|
||||
HECL::BlenderConnection& conn = HECL::BlenderConnection::SharedConnection();
|
||||
DNAANCS::ReadANCSToBlender<PAKRouter<PAKBridge>, ANCS, MaterialSet, 2>
|
||||
(conn, ancs, blendPath, pakRouter, entry, dataSpec.getMasterShaderPath(), force);
|
||||
return conn.saveBlend();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -89,7 +89,7 @@ void ANIM::ANIM0::read(Athena::io::IStreamReader& reader)
|
||||
boneMap[idx] = b;
|
||||
}
|
||||
|
||||
atUint32 boneCount = reader.readUint32();
|
||||
atUint32 boneCount = reader.readUint32Big();
|
||||
bones.clear();
|
||||
bones.reserve(boneCount);
|
||||
channels.clear();
|
||||
@@ -109,7 +109,7 @@ void ANIM::ANIM0::read(Athena::io::IStreamReader& reader)
|
||||
}
|
||||
}
|
||||
|
||||
reader.readUint32();
|
||||
reader.readUint32Big();
|
||||
chanKeys.clear();
|
||||
chanKeys.reserve(channels.size());
|
||||
for (const std::pair<atUint32, bool>& bone : bones)
|
||||
@@ -117,13 +117,13 @@ void ANIM::ANIM0::read(Athena::io::IStreamReader& reader)
|
||||
chanKeys.emplace_back();
|
||||
std::vector<DNAANIM::Value>& keys = chanKeys.back();
|
||||
for (size_t k=0 ; k<head.keyCount ; ++k)
|
||||
keys.emplace_back(reader.readVec4f());
|
||||
keys.emplace_back(reader.readVec4fBig());
|
||||
|
||||
if (bone.second)
|
||||
chanKeys.emplace_back();
|
||||
}
|
||||
|
||||
reader.readUint32();
|
||||
reader.readUint32Big();
|
||||
auto kit = chanKeys.begin();
|
||||
for (const std::pair<atUint32, bool>& bone : bones)
|
||||
{
|
||||
@@ -132,7 +132,7 @@ void ANIM::ANIM0::read(Athena::io::IStreamReader& reader)
|
||||
{
|
||||
std::vector<DNAANIM::Value>& keys = *kit++;
|
||||
for (size_t k=0 ; k<head.keyCount ; ++k)
|
||||
keys.emplace_back(reader.readVec3f());
|
||||
keys.emplace_back(reader.readVec3fBig());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -173,7 +173,7 @@ void ANIM::ANIM0::write(Athena::io::IStreamWriter& writer) const
|
||||
writer.writeUByte(0xff);
|
||||
}
|
||||
|
||||
writer.writeUint32(bones.size());
|
||||
writer.writeUint32Big(bones.size());
|
||||
size_t boneIdx = 0;
|
||||
for (const std::pair<atUint32, bool>& bone : bones)
|
||||
{
|
||||
@@ -184,7 +184,7 @@ void ANIM::ANIM0::write(Athena::io::IStreamWriter& writer) const
|
||||
++boneIdx;
|
||||
}
|
||||
|
||||
writer.writeUint32(bones.size() * head.keyCount);
|
||||
writer.writeUint32Big(bones.size() * head.keyCount);
|
||||
auto cit = chanKeys.begin();
|
||||
atUint32 transKeyCount = 0;
|
||||
for (const std::pair<atUint32, bool>& bone : bones)
|
||||
@@ -192,7 +192,7 @@ void ANIM::ANIM0::write(Athena::io::IStreamWriter& writer) const
|
||||
const std::vector<DNAANIM::Value>& keys = *cit++;
|
||||
auto kit = keys.begin();
|
||||
for (size_t k=0 ; k<head.keyCount ; ++k)
|
||||
writer.writeVec4f((*kit++).v4);
|
||||
writer.writeVec4fBig((*kit++).v4);
|
||||
if (bone.second)
|
||||
{
|
||||
transKeyCount += head.keyCount;
|
||||
@@ -200,7 +200,7 @@ void ANIM::ANIM0::write(Athena::io::IStreamWriter& writer) const
|
||||
}
|
||||
}
|
||||
|
||||
writer.writeUint32(transKeyCount);
|
||||
writer.writeUint32Big(transKeyCount);
|
||||
cit = chanKeys.begin();
|
||||
for (const std::pair<atUint32, bool>& bone : bones)
|
||||
{
|
||||
@@ -210,7 +210,7 @@ void ANIM::ANIM0::write(Athena::io::IStreamWriter& writer) const
|
||||
const std::vector<DNAANIM::Value>& keys = *cit++;
|
||||
auto kit = keys.begin();
|
||||
for (size_t k=0 ; k<head.keyCount ; ++k)
|
||||
writer.writeVec3f((*kit++).v3);
|
||||
writer.writeVec3fBig((*kit++).v3);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -316,8 +316,8 @@ void ANIM::ANIM2::write(Athena::io::IStreamWriter& writer) const
|
||||
|
||||
head.write(writer);
|
||||
keyBmp.write(writer);
|
||||
writer.writeUint32(head.boneChannelCount);
|
||||
writer.writeUint32(head.boneChannelCount);
|
||||
writer.writeUint32Big(head.boneChannelCount);
|
||||
writer.writeUint32Big(head.boneChannelCount);
|
||||
auto cit = qChannels.begin();
|
||||
for (const std::pair<atUint32, bool>& bone : bones)
|
||||
{
|
||||
|
||||
@@ -43,9 +43,9 @@ struct ANIM : BigDNA
|
||||
Value<atUint32> unk0;
|
||||
Value<float> interval;
|
||||
Value<atUint32> unk1;
|
||||
Value<atUint32> boneSlotCount;
|
||||
Value<atUint32> unk2;
|
||||
Value<atUint32> keyCount;
|
||||
Value<atUint32> unk2;
|
||||
Value<atUint32> boneSlotCount;
|
||||
};
|
||||
};
|
||||
|
||||
@@ -92,43 +92,43 @@ struct ANIM : BigDNA
|
||||
|
||||
void read(Athena::io::IStreamReader& reader)
|
||||
{
|
||||
id = reader.readUint32();
|
||||
keyCount1 = reader.readUint16();
|
||||
initRX = reader.readUint16();
|
||||
id = reader.readUint32Big();
|
||||
keyCount1 = reader.readUint16Big();
|
||||
initRX = reader.readUint16Big();
|
||||
qRX = reader.readUByte();
|
||||
initRY = reader.readUint16();
|
||||
initRY = reader.readUint16Big();
|
||||
qRY = reader.readUByte();
|
||||
initRZ = reader.readUint16();
|
||||
initRZ = reader.readUint16Big();
|
||||
qRZ = reader.readUByte();
|
||||
keyCount2 = reader.readUint16();
|
||||
keyCount2 = reader.readUint16Big();
|
||||
if (keyCount2)
|
||||
{
|
||||
initTX = reader.readUint16();
|
||||
initTX = reader.readUint16Big();
|
||||
qTX = reader.readUByte();
|
||||
initTY = reader.readUint16();
|
||||
initTY = reader.readUint16Big();
|
||||
qTY = reader.readUByte();
|
||||
initTZ = reader.readUint16();
|
||||
initTZ = reader.readUint16Big();
|
||||
qTZ = reader.readUByte();
|
||||
}
|
||||
}
|
||||
void write(Athena::io::IStreamWriter& writer) const
|
||||
{
|
||||
writer.writeUint32(id);
|
||||
writer.writeUint16(keyCount1);
|
||||
writer.writeUint16(initRX);
|
||||
writer.writeUint32Big(id);
|
||||
writer.writeUint16Big(keyCount1);
|
||||
writer.writeUint16Big(initRX);
|
||||
writer.writeUByte(qRX);
|
||||
writer.writeUint16(initRY);
|
||||
writer.writeUint16Big(initRY);
|
||||
writer.writeUByte(qRY);
|
||||
writer.writeUint16(initRZ);
|
||||
writer.writeUint16Big(initRZ);
|
||||
writer.writeUByte(qRZ);
|
||||
writer.writeUint16(keyCount2);
|
||||
writer.writeUint16Big(keyCount2);
|
||||
if (keyCount2)
|
||||
{
|
||||
writer.writeUint16(initTX);
|
||||
writer.writeUint16Big(initTX);
|
||||
writer.writeUByte(qTX);
|
||||
writer.writeUint16(initTY);
|
||||
writer.writeUint16Big(initTY);
|
||||
writer.writeUByte(qTY);
|
||||
writer.writeUint16(initTZ);
|
||||
writer.writeUint16Big(initTZ);
|
||||
writer.writeUByte(qTZ);
|
||||
}
|
||||
}
|
||||
@@ -138,8 +138,7 @@ struct ANIM : BigDNA
|
||||
std::unique_ptr<IANIM> m_anim;
|
||||
void read(Athena::io::IStreamReader& reader)
|
||||
{
|
||||
reader.setEndian(Athena::BigEndian);
|
||||
atUint32 version = reader.readUint32();
|
||||
atUint32 version = reader.readUint32Big();
|
||||
switch (version)
|
||||
{
|
||||
case 0:
|
||||
@@ -158,8 +157,7 @@ struct ANIM : BigDNA
|
||||
|
||||
void write(Athena::io::IStreamWriter& writer) const
|
||||
{
|
||||
writer.setEndian(Athena::BigEndian);
|
||||
writer.writeUint32(m_anim->m_version);
|
||||
writer.writeUint32Big(m_anim->m_version);
|
||||
m_anim->write(writer);
|
||||
}
|
||||
|
||||
|
||||
@@ -250,8 +250,7 @@ struct MaterialSet : BigDNA
|
||||
float vals[4];
|
||||
void read(Athena::io::IStreamReader& reader)
|
||||
{
|
||||
reader.setEndian(Athena::BigEndian);
|
||||
mode = Mode(reader.readUint32());
|
||||
mode = Mode(reader.readUint32Big());
|
||||
switch (mode)
|
||||
{
|
||||
case ANIM_MV_INV_NOTRANS:
|
||||
@@ -261,22 +260,21 @@ struct MaterialSet : BigDNA
|
||||
case ANIM_SCROLL:
|
||||
case ANIM_HSTRIP:
|
||||
case ANIM_VSTRIP:
|
||||
vals[0] = reader.readFloat();
|
||||
vals[1] = reader.readFloat();
|
||||
vals[2] = reader.readFloat();
|
||||
vals[3] = reader.readFloat();
|
||||
vals[0] = reader.readFloatBig();
|
||||
vals[1] = reader.readFloatBig();
|
||||
vals[2] = reader.readFloatBig();
|
||||
vals[3] = reader.readFloatBig();
|
||||
break;
|
||||
case ANIM_ROTATION:
|
||||
case ANIM_MODE_WHO_MUST_NOT_BE_NAMED:
|
||||
vals[0] = reader.readFloat();
|
||||
vals[1] = reader.readFloat();
|
||||
vals[0] = reader.readFloatBig();
|
||||
vals[1] = reader.readFloatBig();
|
||||
break;
|
||||
}
|
||||
}
|
||||
void write(Athena::io::IStreamWriter& writer) const
|
||||
{
|
||||
writer.setEndian(Athena::BigEndian);
|
||||
writer.writeUint32(mode);
|
||||
writer.writeUint32Big(mode);
|
||||
switch (mode)
|
||||
{
|
||||
case ANIM_MV_INV_NOTRANS:
|
||||
@@ -286,15 +284,15 @@ struct MaterialSet : BigDNA
|
||||
case ANIM_SCROLL:
|
||||
case ANIM_HSTRIP:
|
||||
case ANIM_VSTRIP:
|
||||
writer.writeFloat(vals[0]);
|
||||
writer.writeFloat(vals[1]);
|
||||
writer.writeFloat(vals[2]);
|
||||
writer.writeFloat(vals[3]);
|
||||
writer.writeFloatBig(vals[0]);
|
||||
writer.writeFloatBig(vals[1]);
|
||||
writer.writeFloatBig(vals[2]);
|
||||
writer.writeFloatBig(vals[3]);
|
||||
break;
|
||||
case ANIM_ROTATION:
|
||||
case ANIM_MODE_WHO_MUST_NOT_BE_NAMED:
|
||||
writer.writeFloat(vals[0]);
|
||||
writer.writeFloat(vals[1]);
|
||||
writer.writeFloatBig(vals[0]);
|
||||
writer.writeFloatBig(vals[1]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,13 +10,12 @@ namespace DNAMP1
|
||||
|
||||
void PAK::read(Athena::io::IStreamReader& reader)
|
||||
{
|
||||
reader.setEndian(Athena::BigEndian);
|
||||
atUint32 version = reader.readUint32();
|
||||
atUint32 version = reader.readUint32Big();
|
||||
if (version != 0x00030005)
|
||||
Log.report(LogVisor::FatalError, "unexpected PAK magic");
|
||||
reader.readUint32();
|
||||
reader.readUint32Big();
|
||||
|
||||
atUint32 nameCount = reader.readUint32();
|
||||
atUint32 nameCount = reader.readUint32Big();
|
||||
m_nameEntries.clear();
|
||||
m_nameEntries.reserve(nameCount);
|
||||
for (atUint32 n=0 ; n<nameCount ; ++n)
|
||||
@@ -25,7 +24,7 @@ void PAK::read(Athena::io::IStreamReader& reader)
|
||||
m_nameEntries.back().read(reader);
|
||||
}
|
||||
|
||||
atUint32 count = reader.readUint32();
|
||||
atUint32 count = reader.readUint32Big();
|
||||
m_entries.clear();
|
||||
m_entries.reserve(count);
|
||||
m_idMap.clear();
|
||||
@@ -53,18 +52,17 @@ void PAK::read(Athena::io::IStreamReader& reader)
|
||||
|
||||
void PAK::write(Athena::io::IStreamWriter& writer) const
|
||||
{
|
||||
writer.setEndian(Athena::BigEndian);
|
||||
writer.writeUint32(0x00030005);
|
||||
writer.writeUint32(0);
|
||||
writer.writeUint32Big(0x00030005);
|
||||
writer.writeUint32Big(0);
|
||||
|
||||
writer.writeUint32((atUint32)m_nameEntries.size());
|
||||
writer.writeUint32Big((atUint32)m_nameEntries.size());
|
||||
for (const NameEntry& entry : m_nameEntries)
|
||||
{
|
||||
((NameEntry&)entry).nameLen = entry.name.size();
|
||||
entry.write(writer);
|
||||
}
|
||||
|
||||
writer.writeUint32(m_entries.size());
|
||||
writer.writeUint32Big(m_entries.size());
|
||||
for (const Entry& entry : m_entries)
|
||||
{
|
||||
Entry tmp = entry;
|
||||
|
||||
@@ -8,8 +8,8 @@ namespace DNAMP1
|
||||
|
||||
void STRG::_read(Athena::io::IStreamReader& reader)
|
||||
{
|
||||
atUint32 langCount = reader.readUint32();
|
||||
atUint32 strCount = reader.readUint32();
|
||||
atUint32 langCount = reader.readUint32Big();
|
||||
atUint32 strCount = reader.readUint32Big();
|
||||
|
||||
std::vector<FourCC> readLangs;
|
||||
readLangs.reserve(langCount);
|
||||
@@ -28,7 +28,7 @@ void STRG::_read(Athena::io::IStreamReader& reader)
|
||||
std::vector<std::wstring> strs;
|
||||
reader.seek(strCount * 4 + 4);
|
||||
for (atUint32 s=0 ; s<strCount ; ++s)
|
||||
strs.emplace_back(reader.readWString());
|
||||
strs.emplace_back(reader.readWStringBig());
|
||||
langs.emplace_back(lang, strs);
|
||||
}
|
||||
|
||||
@@ -40,12 +40,11 @@ void STRG::_read(Athena::io::IStreamReader& reader)
|
||||
|
||||
void STRG::read(Athena::io::IStreamReader& reader)
|
||||
{
|
||||
reader.setEndian(Athena::BigEndian);
|
||||
atUint32 magic = reader.readUint32();
|
||||
atUint32 magic = reader.readUint32Big();
|
||||
if (magic != 0x87654321)
|
||||
Log.report(LogVisor::Error, "invalid STRG magic");
|
||||
|
||||
atUint32 version = reader.readUint32();
|
||||
atUint32 version = reader.readUint32Big();
|
||||
if (version != 0)
|
||||
Log.report(LogVisor::Error, "invalid STRG version");
|
||||
|
||||
@@ -54,18 +53,17 @@ void STRG::read(Athena::io::IStreamReader& reader)
|
||||
|
||||
void STRG::write(Athena::io::IStreamWriter& writer) const
|
||||
{
|
||||
writer.setEndian(Athena::BigEndian);
|
||||
writer.writeUint32(0x87654321);
|
||||
writer.writeUint32(0);
|
||||
writer.writeUint32(langs.size());
|
||||
writer.writeUint32Big(0x87654321);
|
||||
writer.writeUint32Big(0);
|
||||
writer.writeUint32Big(langs.size());
|
||||
atUint32 strCount = STRG::count();
|
||||
writer.writeUint32(strCount);
|
||||
writer.writeUint32Big(strCount);
|
||||
|
||||
atUint32 offset = 0;
|
||||
for (const std::pair<FourCC, std::vector<std::wstring>>& lang : langs)
|
||||
{
|
||||
lang.first.write(writer);
|
||||
writer.writeUint32(offset);
|
||||
writer.writeUint32Big(offset);
|
||||
offset += strCount * 4 + 4;
|
||||
atUint32 langStrCount = lang.second.size();
|
||||
for (atUint32 s=0 ; s<strCount ; ++s)
|
||||
@@ -89,12 +87,12 @@ void STRG::write(Athena::io::IStreamWriter& writer) const
|
||||
else
|
||||
tableSz += 1;
|
||||
}
|
||||
writer.writeUint32(tableSz);
|
||||
writer.writeUint32Big(tableSz);
|
||||
|
||||
offset = strCount * 4;
|
||||
for (atUint32 s=0 ; s<strCount ; ++s)
|
||||
{
|
||||
writer.writeUint32(offset);
|
||||
writer.writeUint32Big(offset);
|
||||
if (s < langStrCount)
|
||||
offset += lang.second[s].size() * 2 + 1;
|
||||
else
|
||||
@@ -104,7 +102,7 @@ void STRG::write(Athena::io::IStreamWriter& writer) const
|
||||
for (atUint32 s=0 ; s<strCount ; ++s)
|
||||
{
|
||||
if (s < langStrCount)
|
||||
writer.writeWString(lang.second[s]);
|
||||
writer.writeWStringBig(lang.second[s]);
|
||||
else
|
||||
writer.writeUByte(0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user