Additional animation tree imps

This commit is contained in:
Jack Andersen 2016-08-27 11:16:44 -10:00
parent f76324a029
commit b25e5ad014
34 changed files with 467 additions and 85 deletions

View File

@ -379,7 +379,7 @@ void ANIM::ANIM2::write(athena::io::IStreamWriter& writer) const
head.unk0 = 1; head.unk0 = 1;
head.interval = mainInterval; head.interval = mainInterval;
head.rootBoneId = 3; head.rootBoneId = 3;
head.unk2 = 0; head.looping = 0;
head.unk3 = 1; head.unk3 = 1;
WordBitmap keyBmp; WordBitmap keyBmp;

View File

@ -64,7 +64,7 @@ struct ANIM : BigDNA
Value<float> duration; Value<float> duration;
Value<float> interval; Value<float> interval;
Value<atUint32> rootBoneId = 3; Value<atUint32> rootBoneId = 3;
Value<atUint32> unk2 = 0; Value<atUint32> looping = 0;
Value<atUint32> rotDiv; Value<atUint32> rotDiv;
Value<float> translationMult; Value<float> translationMult;
Value<atUint32> boneChannelCount; Value<atUint32> boneChannelCount;

View File

@ -475,7 +475,7 @@ void ANIM::ANIM2::write(athena::io::IStreamWriter& writer) const
{ {
Header head; Header head;
head.unk1 = 1; head.unk1 = 1;
head.unk2 = 1; head.looping = 1;
head.interval = mainInterval; head.interval = mainInterval;
head.rootBoneId = 0; head.rootBoneId = 0;
head.scaleMult = 0.f; head.scaleMult = 0.f;

View File

@ -62,7 +62,7 @@ struct ANIM : BigDNA
Value<float> duration; Value<float> duration;
Value<float> interval; Value<float> interval;
Value<atUint32> rootBoneId = 3; Value<atUint32> rootBoneId = 3;
Value<atUint32> unk2 = 0; Value<atUint32> looping = 0;
Value<atUint32> rotDiv; Value<atUint32> rotDiv;
Value<float> translationMult; Value<float> translationMult;
Value<float> scaleMult; Value<float> scaleMult;

View File

@ -450,11 +450,9 @@ zeus::CQuaternion CAnimSourceReader::VGetRotation(const CSegId& seg) const
CAnimSourceReader::CAnimSourceReader(const TSubAnimTypeToken<CAnimSource>& source, CAnimSourceReader::CAnimSourceReader(const TSubAnimTypeToken<CAnimSource>& source,
const CCharAnimTime& time) const CCharAnimTime& time)
: CAnimSourceReaderBase(std::make_unique<CAnimSourceInfo>(source), CCharAnimTime()), : CAnimSourceReaderBase(std::make_unique<CAnimSourceInfo>(source), CCharAnimTime()),
x54_source(source) x54_source(source), x64_steadyStateInfo(false, source->GetDuration(),
source->GetOffset(source->GetRootBoneId(), time))
{ {
CAnimSource* sourceData = x54_source.GetObj();
x64_steadyStateInfo.x64_duration = sourceData->GetDuration();
x64_steadyStateInfo.x6c_curRootOffset = sourceData->GetOffset(sourceData->GetRootBoneId(), time);
PostConstruct(time); PostConstruct(time);
} }

View File

@ -10,11 +10,32 @@ CAnimTreeAnimReaderContainer::CAnimTreeAnimReaderContainer(const std::string& na
{ {
} }
u32 CAnimTreeAnimReaderContainer::Depth() const
{
return 1;
}
CAnimTreeEffectiveContribution CAnimTreeAnimReaderContainer::VGetContributionOfHighestInfluence() const CAnimTreeEffectiveContribution CAnimTreeAnimReaderContainer::VGetContributionOfHighestInfluence() const
{ {
return {1.f, x4_name, VGetSteadyStateAnimInfo(), VGetTimeRemaining(), x1c_animDbIdx}; return {1.f, x4_name, VGetSteadyStateAnimInfo(), VGetTimeRemaining(), x1c_animDbIdx};
} }
u32 CAnimTreeAnimReaderContainer::VGetNumChildren() const
{
return 0;
}
std::shared_ptr<IAnimReader> CAnimTreeAnimReaderContainer::VGetBestUnblendedChild() const
{
return {};
}
void CAnimTreeAnimReaderContainer::VGetWeightedReaders
(std::vector<std::pair<float, std::weak_ptr<IAnimReader>>>& out, float w) const
{
out.push_back(std::make_pair(w, x14_reader));
}
SAdvancementResults CAnimTreeAnimReaderContainer::VAdvanceView(const CCharAnimTime& dt) SAdvancementResults CAnimTreeAnimReaderContainer::VAdvanceView(const CCharAnimTime& dt)
{ {
return x14_reader->VAdvanceView(dt); return x14_reader->VAdvanceView(dt);
@ -101,6 +122,11 @@ std::shared_ptr<IAnimReader> CAnimTreeAnimReaderContainer::VClone() const
return ret; return ret;
} }
std::shared_ptr<IAnimReader> CAnimTreeAnimReaderContainer::VSimplified()
{
return {};
}
void CAnimTreeAnimReaderContainer::VSetPhase(float ph) void CAnimTreeAnimReaderContainer::VSetPhase(float ph)
{ {
x14_reader->VSetPhase(ph); x14_reader->VSetPhase(ph);

View File

@ -15,10 +15,11 @@ public:
std::shared_ptr<IAnimReader> reader, std::shared_ptr<IAnimReader> reader,
u32 animDbIdx); u32 animDbIdx);
u32 Depth() const { return 1; } u32 Depth() const;
CAnimTreeEffectiveContribution VGetContributionOfHighestInfluence() const; CAnimTreeEffectiveContribution VGetContributionOfHighestInfluence() const;
u32 VGetNumChildren() const { return 0; } u32 VGetNumChildren() const;
std::shared_ptr<IAnimReader> VGetBestUnblendedChild() const { return {}; } std::shared_ptr<IAnimReader> VGetBestUnblendedChild() const;
void VGetWeightedReaders(std::vector<std::pair<float, std::weak_ptr<IAnimReader>>>& out, float w) const;
SAdvancementResults VAdvanceView(const CCharAnimTime& a); SAdvancementResults VAdvanceView(const CCharAnimTime& a);
CCharAnimTime VGetTimeRemaining() const; CCharAnimTime VGetTimeRemaining() const;
@ -36,7 +37,7 @@ public:
void VGetSegStatementSet(const CSegIdList& list, CSegStatementSet& setOut) const; void VGetSegStatementSet(const CSegIdList& list, CSegStatementSet& setOut) const;
void VGetSegStatementSet(const CSegIdList& list, CSegStatementSet& setOut, const CCharAnimTime& time) const; void VGetSegStatementSet(const CSegIdList& list, CSegStatementSet& setOut, const CCharAnimTime& time) const;
std::shared_ptr<IAnimReader> VClone() const; std::shared_ptr<IAnimReader> VClone() const;
std::shared_ptr<IAnimReader> VSimplified() { return {}; } std::shared_ptr<IAnimReader> VSimplified();
void VSetPhase(float); void VSetPhase(float);
SAdvancementResults VGetAdvancementResults(const CCharAnimTime& a, const CCharAnimTime& b) const; SAdvancementResults VGetAdvancementResults(const CCharAnimTime& a, const CCharAnimTime& b) const;
}; };

View File

@ -3,6 +3,11 @@
namespace urde namespace urde
{ {
CAnimTreeEffectiveContribution CAnimTreeNode::GetContributionOfHighestInfluence() const
{
return VGetContributionOfHighestInfluence();
}
u32 CAnimTreeNode::GetNumChildren() const u32 CAnimTreeNode::GetNumChildren() const
{ {
return VGetNumChildren(); return VGetNumChildren();

View File

@ -18,8 +18,9 @@ public:
virtual CAnimTreeEffectiveContribution VGetContributionOfHighestInfluence() const=0; virtual CAnimTreeEffectiveContribution VGetContributionOfHighestInfluence() const=0;
virtual u32 VGetNumChildren() const=0; virtual u32 VGetNumChildren() const=0;
virtual std::shared_ptr<IAnimReader> VGetBestUnblendedChild() const=0; virtual std::shared_ptr<IAnimReader> VGetBestUnblendedChild() const=0;
virtual void VGetWeightedReaders(std::vector<std::pair<float, std::weak_ptr<IAnimReader>>>& out, float w) const=0;
void GetContributionOfHighestInfluence() const; CAnimTreeEffectiveContribution GetContributionOfHighestInfluence() const;
u32 GetNumChildren() const; u32 GetNumChildren() const;
std::shared_ptr<IAnimReader> GetBestUnblendedChild() const; std::shared_ptr<IAnimReader> GetBestUnblendedChild() const;
}; };

View File

@ -0,0 +1,96 @@
#include "CAnimTreeSequence.hpp"
#include "IMetaAnim.hpp"
#include "CAnimSysContext.hpp"
namespace urde
{
CAnimTreeSequence::CAnimTreeSequence(const std::vector<std::shared_ptr<IMetaAnim>>& seq,
const CAnimSysContext& animSys,
const std::string& name)
: CAnimTreeSingleChild(seq[0]->GetAnimationTree(animSys, CMetaAnimTreeBuildOrders::NoSpecialOrders()), name),
x18_(animSys), x3c_fundamentals(CSequenceHelper(seq, animSys).ComputeSequenceFundamentals()), x94_curTime(0.f)
{
}
CAnimTreeSequence::CAnimTreeSequence(const std::shared_ptr<CAnimTreeNode>& curNode,
const std::vector<std::shared_ptr<IMetaAnim>>& metaAnims,
const CAnimSysContext& animSys,
const std::string& name,
const CSequenceFundamentals& fundamentals,
const CCharAnimTime& time)
: CAnimTreeSingleChild(curNode, name), x18_(animSys), x28_(metaAnims), x3c_fundamentals(fundamentals), x94_curTime(time)
{
}
CAnimTreeEffectiveContribution CAnimTreeSequence::VGetContributionOfHighestInfluence() const
{
return x14_child->GetContributionOfHighestInfluence();
}
std::shared_ptr<IAnimReader> CAnimTreeSequence::VGetBestUnblendedChild() const
{
std::shared_ptr<IAnimReader> ch = x14_child->GetBestUnblendedChild();
if (!ch)
return ch;
return std::make_shared<CAnimTreeSequence>(std::static_pointer_cast<CAnimTreeNode>(ch->Clone()),
x28_, x18_, x4_name, x3c_fundamentals, x94_curTime);
}
void CAnimTreeSequence::VGetWeightedReaders
(std::vector<std::pair<float, std::weak_ptr<IAnimReader>>>& out, float w) const
{
x14_child->VGetWeightedReaders(out, w);
}
SAdvancementResults CAnimTreeSequence::VAdvanceView(const CCharAnimTime& a)
{
}
CCharAnimTime CAnimTreeSequence::VGetTimeRemaining() const
{
if (x38_curIdx == x28_.size() - 1)
return x14_child->VGetTimeRemaining();
return x3c_fundamentals.GetSteadyStateAnimInfo().GetDuration() - x94_curTime;
}
CSteadyStateAnimInfo CAnimTreeSequence::VGetSteadyStateAnimInfo() const
{
return x3c_fundamentals.GetSteadyStateAnimInfo();
}
u32 CAnimTreeSequence::VGetBoolPOIList(const CCharAnimTime& time, CBoolPOINode* listOut,
u32 capacity, u32 iterator, u32 unk) const
{
return _getPOIList(time, listOut, capacity, iterator, unk,
x3c_fundamentals.GetBoolPointsOfInterest(), x94_curTime);
}
u32 CAnimTreeSequence::VGetInt32POIList(const CCharAnimTime& time, CInt32POINode* listOut,
u32 capacity, u32 iterator, u32 unk) const
{
return _getPOIList(time, listOut, capacity, iterator, unk,
x3c_fundamentals.GetInt32PointsOfInterest(), x94_curTime);
}
u32 CAnimTreeSequence::VGetParticlePOIList(const CCharAnimTime& time, CParticlePOINode* listOut,
u32 capacity, u32 iterator, u32 unk) const
{
return _getPOIList(time, listOut, capacity, iterator, unk,
x3c_fundamentals.GetParticlePointsOfInterest(), x94_curTime);
}
u32 CAnimTreeSequence::VGetSoundPOIList(const CCharAnimTime& time, CSoundPOINode* listOut,
u32 capacity, u32 iterator, u32 unk) const
{
return _getPOIList(time, listOut, capacity, iterator, unk,
x3c_fundamentals.GetSoundPointsOfInterest(), x94_curTime);
}
std::shared_ptr<IAnimReader> CAnimTreeSequence::VClone() const
{
return std::make_shared<CAnimTreeSequence>(std::static_pointer_cast<CAnimTreeNode>(x14_child->Clone()),
x28_, x18_, x4_name, x3c_fundamentals, x94_curTime);
}
}

View File

@ -1,11 +1,45 @@
#ifndef __URDE_CANIMTREESEQUENCE_HPP__ #ifndef __URDE_CANIMTREESEQUENCE_HPP__
#define __URDE_CANIMTREESEQUENCE_HPP__ #define __URDE_CANIMTREESEQUENCE_HPP__
#include "CAnimTreeSingleChild.hpp"
#include "CAnimSysContext.hpp"
#include "CSequenceHelper.hpp"
namespace urde namespace urde
{ {
class IMetaAnim;
class CTransitionDatabaseGame;
class CAnimTreeSequence class CAnimTreeSequence : public CAnimTreeSingleChild
{ {
CAnimSysContext x18_;
std::vector<std::shared_ptr<IMetaAnim>> x28_;
u32 x38_curIdx = 0;
CSequenceFundamentals x3c_fundamentals;
CCharAnimTime x94_curTime;
public:
CAnimTreeSequence(const std::vector<std::shared_ptr<IMetaAnim>>& seq,
const CAnimSysContext& animSys,
const std::string& name);
CAnimTreeSequence(const std::shared_ptr<CAnimTreeNode>& curNode,
const std::vector<std::shared_ptr<IMetaAnim>>& metaAnims,
const CAnimSysContext& animSys,
const std::string& name,
const CSequenceFundamentals& fundamentals,
const CCharAnimTime& time);
CAnimTreeEffectiveContribution VGetContributionOfHighestInfluence() const;
std::shared_ptr<IAnimReader> VGetBestUnblendedChild() const;
void VGetWeightedReaders(std::vector<std::pair<float, std::weak_ptr<IAnimReader>>>& out, float w) const;
SAdvancementResults VAdvanceView(const CCharAnimTime& a);
CCharAnimTime VGetTimeRemaining() const;
CSteadyStateAnimInfo VGetSteadyStateAnimInfo() const;
u32 VGetBoolPOIList(const CCharAnimTime& time, CBoolPOINode* listOut, u32 capacity, u32 iterator, u32) const;
u32 VGetInt32POIList(const CCharAnimTime& time, CInt32POINode* listOut, u32 capacity, u32 iterator, u32) const;
u32 VGetParticlePOIList(const CCharAnimTime& time, CParticlePOINode* listOut, u32 capacity, u32 iterator, u32) const;
u32 VGetSoundPOIList(const CCharAnimTime& time, CSoundPOINode* listOut, u32 capacity, u32 iterator, u32) const;
std::shared_ptr<IAnimReader> VClone() const;
}; };
} }

View File

@ -8,6 +8,7 @@ namespace urde
class CAnimTreeSingleChild : public CAnimTreeNode class CAnimTreeSingleChild : public CAnimTreeNode
{ {
protected:
std::shared_ptr<CAnimTreeNode> x14_child; std::shared_ptr<CAnimTreeNode> x14_child;
public: public:
CAnimTreeSingleChild(const std::weak_ptr<CAnimTreeNode>& node, const std::string& name); CAnimTreeSingleChild(const std::weak_ptr<CAnimTreeNode>& node, const std::string& name);

View File

@ -77,16 +77,10 @@ CSegIdToIndexConverter::CSegIdToIndexConverter(const CFBStreamedAnimReaderTotals
} }
CFBStreamedAnimReader::CFBStreamedAnimReader(const TSubAnimTypeToken<CFBStreamedCompression>& source, const CCharAnimTime& time) CFBStreamedAnimReader::CFBStreamedAnimReader(const TSubAnimTypeToken<CFBStreamedCompression>& source, const CCharAnimTime& time)
: CAnimSourceReaderBase(std::make_unique<TAnimSourceInfo<CFBStreamedCompression>>(source), time), : CAnimSourceReaderBase(std::make_unique<TAnimSourceInfo<CFBStreamedCompression>>(source), time), x54_source(source),
x54_source(source), x7c_(source), x114_(x7c_.x10_ ? x7c_.x14_ : x7c_.x3c_) x64_steadyStateInfo(source->IsLooping(), source->GetAnimationDuration(), source->GetRootOffset()),
x7c_(source), x114_(x7c_.x10_ ? x7c_.x14_ : x7c_.x3c_)
{ {
x64_steadyStateInfo.x64_duration = x54_source->GetAnimationDuration();
x64_steadyStateInfo.x6c_curRootOffset = x54_source->x14_rootOffset;
const CFBStreamedCompression::Header* header =
reinterpret_cast<const CFBStreamedCompression::Header*>(x54_source->xc_rotsAndOffs.get());
x64_steadyStateInfo.x78_ = header->unk2;
PostConstruct(time); PostConstruct(time);
} }

View File

@ -13,11 +13,11 @@ class TAnimSourceInfo : public IAnimSourceInfo
TSubAnimTypeToken<T> x4_token; TSubAnimTypeToken<T> x4_token;
public: public:
TAnimSourceInfo(const TSubAnimTypeToken<T>& token); TAnimSourceInfo(const TSubAnimTypeToken<T>& token);
bool HasPOIData() const { return x4_token->GetPOIToken(); } bool HasPOIData() const { return x4_token->HasPOIData(); }
const std::vector<CBoolPOINode>& GetBoolPOIStream() const { return x4_token->GetPOIToken()->GetBoolPOIStream(); } const std::vector<CBoolPOINode>& GetBoolPOIStream() const { return x4_token->GetBoolPOIStream(); }
const std::vector<CInt32POINode>& GetInt32POIStream() const { return x4_token->GetPOIToken()->GetInt32POIStream(); } const std::vector<CInt32POINode>& GetInt32POIStream() const { return x4_token->GetInt32POIStream(); }
const std::vector<CParticlePOINode>& GetParticlePOIStream() const { return x4_token->GetPOIToken()->GetParticlePOIStream(); } const std::vector<CParticlePOINode>& GetParticlePOIStream() const { return x4_token->GetParticlePOIStream(); }
const std::vector<CSoundPOINode>& GetSoundPOIStream() const { return x4_token->GetPOIToken()->GetSoundPOIStream(); } const std::vector<CSoundPOINode>& GetSoundPOIStream() const { return x4_token->GetSoundPOIStream(); }
CCharAnimTime GetAnimationDuration() const { return x4_token->GetAnimationDuration(); } CCharAnimTime GetAnimationDuration() const { return x4_token->GetAnimationDuration(); }
}; };

View File

@ -16,13 +16,14 @@ class CFBStreamedCompression
friend class CFBStreamedAnimReaderTotals; friend class CFBStreamedAnimReaderTotals;
friend class CFBStreamedPairOfTotals; friend class CFBStreamedPairOfTotals;
public:
struct Header struct Header
{ {
u32 unk0; u32 unk0;
float duration; float duration;
float interval; float interval;
u32 rootBoneId; u32 rootBoneId;
u32 unk2; u32 looping;
u32 rotDiv; u32 rotDiv;
float translationMult; float translationMult;
u32 boneChannelCount; u32 boneChannelCount;
@ -38,8 +39,8 @@ class CFBStreamedCompression
interval = in.readFloatBig(); interval = in.readFloatBig();
/* rootBoneId */ /* rootBoneId */
rootBoneId = in.readUint32Big(); rootBoneId = in.readUint32Big();
/* unk2 */ /* looping */
unk2 = in.readUint32Big(); looping = in.readUint32Big();
/* rotDiv */ /* rotDiv */
rotDiv = in.readUint32Big(); rotDiv = in.readUint32Big();
/* translationMult */ /* translationMult */
@ -51,6 +52,7 @@ class CFBStreamedCompression
} }
}; };
private:
bool m_pc; bool m_pc;
u32 x0_scratchSize; u32 x0_scratchSize;
ResId x4_evnt; ResId x4_evnt;
@ -61,10 +63,18 @@ class CFBStreamedCompression
u8* ReadBoneChannelDescriptors(u8* out, CInputStream& in); u8* ReadBoneChannelDescriptors(u8* out, CInputStream& in);
u32 ComputeBitstreamWords(const u8* chans); u32 ComputeBitstreamWords(const u8* chans);
std::unique_ptr<u32[]> GetRotationsAndOffsets(u32 words, CInputStream& in); std::unique_ptr<u32[]> GetRotationsAndOffsets(u32 words, CInputStream& in);
public: public:
CFBStreamedCompression(CInputStream& in, IObjectStore& objStore, bool pc); CFBStreamedCompression(CInputStream& in, IObjectStore& objStore, bool pc);
CCharAnimTime GetAnimationDuration() const { return reinterpret_cast<const Header*>(xc_rotsAndOffs.get())->duration; } const Header& MainHeader() const { return *reinterpret_cast<const Header*>(xc_rotsAndOffs.get()); }
const TLockedToken<CAnimPOIData>& GetPOIToken() const { return x8_evntToken; } bool IsLooping() const { return MainHeader().looping; }
CCharAnimTime GetAnimationDuration() const { return MainHeader().duration; }
const zeus::CVector3f& GetRootOffset() const { return x14_rootOffset; }
bool HasPOIData() const { return x8_evntToken; }
const std::vector<CBoolPOINode>& GetBoolPOIStream() const { return x8_evntToken->GetBoolPOIStream(); }
const std::vector<CInt32POINode>& GetInt32POIStream() const { return x8_evntToken->GetInt32POIStream(); }
const std::vector<CParticlePOINode>& GetParticlePOIStream() const { return x8_evntToken->GetParticlePOIStream(); }
const std::vector<CSoundPOINode>& GetSoundPOIStream() const { return x8_evntToken->GetSoundPOIStream(); }
}; };
} }

View File

@ -48,6 +48,7 @@ set(CHARACTER_SOURCES
CMetaTransSnap.hpp CMetaTransSnap.cpp CMetaTransSnap.hpp CMetaTransSnap.cpp
CAnimTreeLoopIn.hpp CAnimTreeLoopIn.cpp CAnimTreeLoopIn.hpp CAnimTreeLoopIn.cpp
CAnimTreeSequence.hpp CAnimTreeSequence.cpp CAnimTreeSequence.hpp CAnimTreeSequence.cpp
CSequenceHelper.hpp CSequenceHelper.cpp
CAnimTreeAnimReaderContainer.hpp CAnimTreeAnimReaderContainer.cpp CAnimTreeAnimReaderContainer.hpp CAnimTreeAnimReaderContainer.cpp
CAnimTreeBlend.hpp CAnimTreeBlend.cpp CAnimTreeBlend.hpp CAnimTreeBlend.cpp
CAnimTreeNode.hpp CAnimTreeNode.cpp CAnimTreeNode.hpp CAnimTreeNode.cpp

View File

@ -12,13 +12,6 @@ CMetaAnimBlend::CMetaAnimBlend(CInputStream& in)
x10_ = in.readBool(); x10_ = in.readBool();
} }
std::shared_ptr<CAnimTreeNode>
CMetaAnimBlend::GetAnimationTree(const CAnimSysContext& animSys,
const CMetaAnimTreeBuildOrders& orders) const
{
return {};
}
void CMetaAnimBlend::GetUniquePrimitives(std::set<CPrimitive>& primsOut) const void CMetaAnimBlend::GetUniquePrimitives(std::set<CPrimitive>& primsOut) const
{ {
} }

View File

@ -17,8 +17,6 @@ public:
CMetaAnimBlend(CInputStream& in); CMetaAnimBlend(CInputStream& in);
EMetaAnimType GetType() const {return EMetaAnimType::Blend;} EMetaAnimType GetType() const {return EMetaAnimType::Blend;}
std::shared_ptr<CAnimTreeNode> GetAnimationTree(const CAnimSysContext& animSys,
const CMetaAnimTreeBuildOrders& orders) const;
void GetUniquePrimitives(std::set<CPrimitive>& primsOut) const; void GetUniquePrimitives(std::set<CPrimitive>& primsOut) const;
std::shared_ptr<CAnimTreeNode> VGetAnimationTree(const CAnimSysContext& animSys, std::shared_ptr<CAnimTreeNode> VGetAnimationTree(const CAnimSysContext& animSys,
const CMetaAnimTreeBuildOrders& orders) const; const CMetaAnimTreeBuildOrders& orders) const;

View File

@ -12,13 +12,6 @@ CMetaAnimPhaseBlend::CMetaAnimPhaseBlend(CInputStream& in)
x10_ = in.readBool(); x10_ = in.readBool();
} }
std::shared_ptr<CAnimTreeNode>
CMetaAnimPhaseBlend::GetAnimationTree(const CAnimSysContext& animSys,
const CMetaAnimTreeBuildOrders& orders) const
{
return {};
}
void CMetaAnimPhaseBlend::GetUniquePrimitives(std::set<CPrimitive>& primsOut) const void CMetaAnimPhaseBlend::GetUniquePrimitives(std::set<CPrimitive>& primsOut) const
{ {
} }

View File

@ -17,8 +17,6 @@ public:
CMetaAnimPhaseBlend(CInputStream& in); CMetaAnimPhaseBlend(CInputStream& in);
EMetaAnimType GetType() const {return EMetaAnimType::PhaseBlend;} EMetaAnimType GetType() const {return EMetaAnimType::PhaseBlend;}
std::shared_ptr<CAnimTreeNode> GetAnimationTree(const CAnimSysContext& animSys,
const CMetaAnimTreeBuildOrders& orders) const;
void GetUniquePrimitives(std::set<CPrimitive>& primsOut) const; void GetUniquePrimitives(std::set<CPrimitive>& primsOut) const;
std::shared_ptr<CAnimTreeNode> VGetAnimationTree(const CAnimSysContext& animSys, std::shared_ptr<CAnimTreeNode> VGetAnimationTree(const CAnimSysContext& animSys,
const CMetaAnimTreeBuildOrders& orders) const; const CMetaAnimTreeBuildOrders& orders) const;

View File

@ -10,15 +10,9 @@ namespace urde
CMetaAnimPlay::CMetaAnimPlay(CInputStream& in) CMetaAnimPlay::CMetaAnimPlay(CInputStream& in)
: x4_primitive(in), x1c_startTime(in) {} : x4_primitive(in), x1c_startTime(in) {}
std::shared_ptr<CAnimTreeNode>
CMetaAnimPlay::GetAnimationTree(const CAnimSysContext& animSys,
const CMetaAnimTreeBuildOrders& orders) const
{
return {};
}
void CMetaAnimPlay::GetUniquePrimitives(std::set<CPrimitive>& primsOut) const void CMetaAnimPlay::GetUniquePrimitives(std::set<CPrimitive>& primsOut) const
{ {
primsOut.insert(x4_primitive);
} }
std::shared_ptr<CAnimTreeNode> std::shared_ptr<CAnimTreeNode>

View File

@ -16,8 +16,6 @@ public:
CMetaAnimPlay(CInputStream& in); CMetaAnimPlay(CInputStream& in);
EMetaAnimType GetType() const {return EMetaAnimType::Primitive;} EMetaAnimType GetType() const {return EMetaAnimType::Primitive;}
std::shared_ptr<CAnimTreeNode> GetAnimationTree(const CAnimSysContext& animSys,
const CMetaAnimTreeBuildOrders& orders) const;
void GetUniquePrimitives(std::set<CPrimitive>& primsOut) const; void GetUniquePrimitives(std::set<CPrimitive>& primsOut) const;
std::shared_ptr<CAnimTreeNode> VGetAnimationTree(const CAnimSysContext& animSys, std::shared_ptr<CAnimTreeNode> VGetAnimationTree(const CAnimSysContext& animSys,
const CMetaAnimTreeBuildOrders& orders) const; const CMetaAnimTreeBuildOrders& orders) const;

View File

@ -22,13 +22,6 @@ CMetaAnimRandom::RandomData CMetaAnimRandom::CreateRandomData(CInputStream& in)
CMetaAnimRandom::CMetaAnimRandom(CInputStream& in) CMetaAnimRandom::CMetaAnimRandom(CInputStream& in)
: x4_randomData(CreateRandomData(in)) {} : x4_randomData(CreateRandomData(in)) {}
std::shared_ptr<CAnimTreeNode>
CMetaAnimRandom::GetAnimationTree(const CAnimSysContext& animSys,
const CMetaAnimTreeBuildOrders& orders) const
{
return {};
}
void CMetaAnimRandom::GetUniquePrimitives(std::set<CPrimitive>& primsOut) const void CMetaAnimRandom::GetUniquePrimitives(std::set<CPrimitive>& primsOut) const
{ {
} }

View File

@ -16,8 +16,6 @@ public:
CMetaAnimRandom(CInputStream& in); CMetaAnimRandom(CInputStream& in);
EMetaAnimType GetType() const {return EMetaAnimType::Random;} EMetaAnimType GetType() const {return EMetaAnimType::Random;}
std::shared_ptr<CAnimTreeNode> GetAnimationTree(const CAnimSysContext& animSys,
const CMetaAnimTreeBuildOrders& orders) const;
void GetUniquePrimitives(std::set<CPrimitive>& primsOut) const; void GetUniquePrimitives(std::set<CPrimitive>& primsOut) const;
std::shared_ptr<CAnimTreeNode> VGetAnimationTree(const CAnimSysContext& animSys, std::shared_ptr<CAnimTreeNode> VGetAnimationTree(const CAnimSysContext& animSys,
const CMetaAnimTreeBuildOrders& orders) const; const CMetaAnimTreeBuildOrders& orders) const;

View File

@ -1,5 +1,6 @@
#include "CMetaAnimSequence.hpp" #include "CMetaAnimSequence.hpp"
#include "CMetaAnimFactory.hpp" #include "CMetaAnimFactory.hpp"
#include "CAnimTreeSequence.hpp"
namespace urde namespace urde
{ {
@ -19,22 +20,32 @@ std::vector<std::shared_ptr<IMetaAnim>> CMetaAnimSequence::CreateSequence(CInput
CMetaAnimSequence::CMetaAnimSequence(CInputStream& in) CMetaAnimSequence::CMetaAnimSequence(CInputStream& in)
: x4_sequence(CreateSequence(in)) {} : x4_sequence(CreateSequence(in)) {}
std::shared_ptr<CAnimTreeNode>
CMetaAnimSequence::GetAnimationTree(const CAnimSysContext& animSys,
const CMetaAnimTreeBuildOrders& orders) const
{
return {};
}
void CMetaAnimSequence::GetUniquePrimitives(std::set<CPrimitive>& primsOut) const void CMetaAnimSequence::GetUniquePrimitives(std::set<CPrimitive>& primsOut) const
{ {
for (const std::shared_ptr<IMetaAnim>& anim : x4_sequence)
anim->GetUniquePrimitives(primsOut);
} }
std::shared_ptr<CAnimTreeNode> std::shared_ptr<CAnimTreeNode>
CMetaAnimSequence::VGetAnimationTree(const CAnimSysContext& animSys, CMetaAnimSequence::VGetAnimationTree(const CAnimSysContext& animSys,
const CMetaAnimTreeBuildOrders& orders) const const CMetaAnimTreeBuildOrders& orders) const
{ {
return {}; if (orders.x0_)
{
CMetaAnimTreeBuildOrders modOrders;
modOrders.PreAdvanceForAll(*orders.x0_);
return GetAnimationTree(animSys, modOrders);
}
for (const std::shared_ptr<IMetaAnim>& anim : x4_sequence)
{
}
std::shared_ptr<CAnimTreeNode> ret =
std::make_shared<CAnimTreeSequence>(x4_sequence, animSys, "");
return ret;
} }
} }

View File

@ -15,8 +15,6 @@ public:
CMetaAnimSequence(CInputStream& in); CMetaAnimSequence(CInputStream& in);
EMetaAnimType GetType() const {return EMetaAnimType::Sequence;} EMetaAnimType GetType() const {return EMetaAnimType::Sequence;}
std::shared_ptr<CAnimTreeNode> GetAnimationTree(const CAnimSysContext& animSys,
const CMetaAnimTreeBuildOrders& orders) const;
void GetUniquePrimitives(std::set<CPrimitive>& primsOut) const; void GetUniquePrimitives(std::set<CPrimitive>& primsOut) const;
std::shared_ptr<CAnimTreeNode> VGetAnimationTree(const CAnimSysContext& animSys, std::shared_ptr<CAnimTreeNode> VGetAnimationTree(const CAnimSysContext& animSys,
const CMetaAnimTreeBuildOrders& orders) const; const CMetaAnimTreeBuildOrders& orders) const;

View File

@ -1,4 +1,9 @@
#include "CPOINode.hpp" #include "CPOINode.hpp"
#include "CBoolPOINode.hpp"
#include "CInt32POINode.hpp"
#include "CParticlePOINode.hpp"
#include "CSoundPOINode.hpp"
#include "CAnimSourceReader.hpp"
namespace urde namespace urde
{ {
@ -28,4 +33,110 @@ CPOINode::CPOINode(CInputStream& in)
x34_flags(in.readUint32Big()) x34_flags(in.readUint32Big())
{} {}
template <class T>
u32 _getPOIList(const CCharAnimTime& time,
T* listOut,
u32 capacity, u32 iterator, u32 unk1,
const std::vector<T>& stream,
const CCharAnimTime& curTime,
const IAnimSourceInfo& animInfo, u32 passedCount)
{
u32 ret = 0;
if (animInfo.HasPOIData() && stream.size())
{
CCharAnimTime dur = animInfo.GetAnimationDuration();
CCharAnimTime targetTime = curTime + time;
if (targetTime >= dur)
targetTime = dur;
if (passedCount >= stream.size())
return ret;
CCharAnimTime nodeTime = stream[passedCount].GetTime();
while (nodeTime <= targetTime)
{
u32 idx = iterator + ret;
if (idx < capacity)
listOut[idx] = T::CopyNodeMinusStartTime(stream[passedCount], curTime);
++passedCount;
++ret;
nodeTime = stream[passedCount].GetTime();
}
}
return ret;
}
template <class T>
u32 _getPOIList(const CCharAnimTime& time,
T* listOut,
u32 capacity, u32 iterator, u32 unk1,
const std::vector<T>& stream,
const CCharAnimTime& curTime)
{
u32 ret = 0;
CCharAnimTime targetTime = curTime + time;
for (u32 it = iterator ; it < stream.size() ; ++it)
{
CCharAnimTime nodeTime = stream[ret].GetTime();
if (nodeTime > targetTime)
return ret;
u32 idx = iterator + ret;
if (idx < capacity)
listOut[idx] = T::CopyNodeMinusStartTime(stream[ret], curTime);
++ret;
}
return ret;
}
template u32 _getPOIList<CBoolPOINode>(const CCharAnimTime& time,
CBoolPOINode* listOut,
u32 capacity, u32 iterator, u32 unk1,
const std::vector<CBoolPOINode>& stream,
const CCharAnimTime& curTime,
const IAnimSourceInfo& animInfo, u32 passedCount);
template u32 _getPOIList<CBoolPOINode>(const CCharAnimTime& time,
CBoolPOINode* listOut,
u32 capacity, u32 iterator, u32 unk1,
const std::vector<CBoolPOINode>& stream,
const CCharAnimTime& curTime);
template u32 _getPOIList<CInt32POINode>(const CCharAnimTime& time,
CInt32POINode* listOut,
u32 capacity, u32 iterator, u32 unk1,
const std::vector<CInt32POINode>& stream,
const CCharAnimTime& curTime,
const IAnimSourceInfo& animInfo, u32 passedCount);
template u32 _getPOIList<CInt32POINode>(const CCharAnimTime& time,
CInt32POINode* listOut,
u32 capacity, u32 iterator, u32 unk1,
const std::vector<CInt32POINode>& stream,
const CCharAnimTime& curTime);
template u32 _getPOIList<CParticlePOINode>(const CCharAnimTime& time,
CParticlePOINode* listOut,
u32 capacity, u32 iterator, u32 unk1,
const std::vector<CParticlePOINode>& stream,
const CCharAnimTime& curTime,
const IAnimSourceInfo& animInfo, u32 passedCount);
template u32 _getPOIList<CParticlePOINode>(const CCharAnimTime& time,
CParticlePOINode* listOut,
u32 capacity, u32 iterator, u32 unk1,
const std::vector<CParticlePOINode>& stream,
const CCharAnimTime& curTime);
template u32 _getPOIList<CSoundPOINode>(const CCharAnimTime& time,
CSoundPOINode* listOut,
u32 capacity, u32 iterator, u32 unk1,
const std::vector<CSoundPOINode>& stream,
const CCharAnimTime& curTime,
const IAnimSourceInfo& animInfo, u32 passedCount);
template u32 _getPOIList<CSoundPOINode>(const CCharAnimTime& time,
CSoundPOINode* listOut,
u32 capacity, u32 iterator, u32 unk1,
const std::vector<CSoundPOINode>& stream,
const CCharAnimTime& curTime);
} }

View File

@ -6,6 +6,7 @@
namespace urde namespace urde
{ {
class IAnimSourceInfo;
enum class EPOIType : u16 enum class EPOIType : u16
{ {
@ -45,6 +46,21 @@ public:
u32 GetFlags() const { return x34_flags; } u32 GetFlags() const { return x34_flags; }
}; };
template <class T>
u32 _getPOIList(const CCharAnimTime& time,
T* listOut,
u32 capacity, u32 iterator, u32 unk1,
const std::vector<T>& stream,
const CCharAnimTime& curTime,
const IAnimSourceInfo& animInfo, u32 passedCount);
template <class T>
u32 _getPOIList(const CCharAnimTime& time,
T* listOut,
u32 capacity, u32 iterator, u32 unk1,
const std::vector<T>& stream,
const CCharAnimTime& curTime);
} }
#endif // __URDE_CPOINODE_HPP__ #endif // __URDE_CPOINODE_HPP__

View File

@ -17,6 +17,7 @@ public:
ResId GetAnimResId() const { return x0_animId; } ResId GetAnimResId() const { return x0_animId; }
u32 GetAnimDbIdx() const { return x4_animIdx; } u32 GetAnimDbIdx() const { return x4_animIdx; }
const std::string& GetName() const { return x8_animName; } const std::string& GetName() const { return x8_animName; }
bool operator<(const CPrimitive& other) const { return x8_animName < other.x8_animName; }
}; };
} }

View File

@ -0,0 +1,40 @@
#include "CSequenceHelper.hpp"
#include "CAnimSysContext.hpp"
#include "CBoolPOINode.hpp"
#include "CInt32POINode.hpp"
#include "CParticlePOINode.hpp"
#include "CSoundPOINode.hpp"
namespace urde
{
CSequenceFundamentals::CSequenceFundamentals(const CSteadyStateAnimInfo& ssInfo,
const std::vector<CBoolPOINode>& boolNodes,
const std::vector<CInt32POINode>& int32Nodes,
const std::vector<CParticlePOINode>& particleNodes,
const std::vector<CSoundPOINode>& soundNodes)
: x0_ssInfo(ssInfo), x18_boolNodes(boolNodes), x28_int32Nodes(int32Nodes), x38_particleNodes(particleNodes),
x48_soundNodes(soundNodes)
{
}
CSequenceHelper::CSequenceHelper(const std::shared_ptr<CAnimTreeNode>& a,
const std::shared_ptr<CAnimTreeNode>& b,
const CAnimSysContext& animCtx)
: x0_transDB(animCtx.x0_transDB)
{
x10_treeNodes.reserve(2);
x10_treeNodes.push_back(a);
x10_treeNodes.push_back(b);
}
CSequenceHelper::CSequenceHelper(const std::vector<std::shared_ptr<IMetaAnim>>& nodes,
const CAnimSysContext& animCtx)
{
}
CSequenceFundamentals CSequenceHelper::ComputeSequenceFundamentals()
{
}
}

View File

@ -0,0 +1,53 @@
#ifndef __URDE_CSEQUENCEHELPER_HPP__
#define __URDE_CSEQUENCEHELPER_HPP__
#include "CAnimTreeNode.hpp"
#include "CBoolPOINode.hpp"
#include "CInt32POINode.hpp"
#include "CParticlePOINode.hpp"
#include "CSoundPOINode.hpp"
namespace urde
{
class CAnimSysContext;
class IMetaAnim;
class CTransitionDatabaseGame;
class CSequenceFundamentals
{
CSteadyStateAnimInfo x0_ssInfo;
std::vector<CBoolPOINode> x18_boolNodes;
std::vector<CInt32POINode> x28_int32Nodes;
std::vector<CParticlePOINode> x38_particleNodes;
std::vector<CSoundPOINode> x48_soundNodes;
public:
CSequenceFundamentals(const CSteadyStateAnimInfo& ssInfo,
const std::vector<CBoolPOINode>& boolNodes,
const std::vector<CInt32POINode>& int32Nodes,
const std::vector<CParticlePOINode>& particleNodes,
const std::vector<CSoundPOINode>& soundNodes);
const CSteadyStateAnimInfo& GetSteadyStateAnimInfo() const { return x0_ssInfo; }
const std::vector<CBoolPOINode>& GetBoolPointsOfInterest() const { return x18_boolNodes; }
const std::vector<CInt32POINode>& GetInt32PointsOfInterest() const { return x28_int32Nodes; }
const std::vector<CParticlePOINode>& GetParticlePointsOfInterest() const { return x38_particleNodes; }
const std::vector<CSoundPOINode>& GetSoundPointsOfInterest() const { return x48_soundNodes; }
};
class CSequenceHelper
{
TLockedToken<CTransitionDatabaseGame> x0_transDB;
std::vector<std::shared_ptr<CAnimTreeNode>> x10_treeNodes;
std::vector<bool> x20_;
public:
CSequenceHelper(const std::shared_ptr<CAnimTreeNode>& a,
const std::shared_ptr<CAnimTreeNode>& b,
const CAnimSysContext& animCtx);
CSequenceHelper(const std::vector<std::shared_ptr<IMetaAnim>>& nodes,
const CAnimSysContext& animCtx);
CSequenceFundamentals ComputeSequenceFundamentals();
};
}
#endif // __URDE_CSEQUENCEHELPER_HPP__

View File

@ -30,11 +30,19 @@ struct SAdvancementResults
SAdvancementDeltas x8_deltas; SAdvancementDeltas x8_deltas;
}; };
struct CSteadyStateAnimInfo class CSteadyStateAnimInfo
{ {
CCharAnimTime x64_duration; CCharAnimTime x0_duration;
zeus::CVector3f x6c_curRootOffset; zeus::CVector3f x8_offset;
bool x78_ = false; bool x14_looping = false;
public:
CSteadyStateAnimInfo(bool looping, const CCharAnimTime& duration, const zeus::CVector3f& offset)
: x0_duration(duration), x8_offset(offset), x14_looping(looping) {}
const CCharAnimTime& GetDuration() const { return x0_duration; }
const zeus::CVector3f& GetOffset() const { return x8_offset; }
bool IsLooping() const { return x14_looping; }
}; };
struct CAnimTreeEffectiveContribution struct CAnimTreeEffectiveContribution

View File

@ -2,6 +2,7 @@
#include "CCharAnimTime.hpp" #include "CCharAnimTime.hpp"
#include "IAnimReader.hpp" #include "IAnimReader.hpp"
#include "CBoolPOINode.hpp" #include "CBoolPOINode.hpp"
#include "CAnimTreeNode.hpp"
namespace urde namespace urde
{ {
@ -10,7 +11,18 @@ std::shared_ptr<CAnimTreeNode>
IMetaAnim::GetAnimationTree(const CAnimSysContext& animSys, IMetaAnim::GetAnimationTree(const CAnimSysContext& animSys,
const CMetaAnimTreeBuildOrders& orders) const const CMetaAnimTreeBuildOrders& orders) const
{ {
return {}; if (orders.x44_)
{
std::shared_ptr<CAnimTreeNode> tree =
VGetAnimationTree(animSys, CMetaAnimTreeBuildOrders::NoSpecialOrders());
if (orders.x44_->IsTime() || orders.x44_->IsString())
{
CCharAnimTime time = GetTime(*orders.x44_, *tree);
AdvanceAnim(*tree, time);
}
return tree;
}
return VGetAnimationTree(animSys, CMetaAnimTreeBuildOrders::NoSpecialOrders());
} }
void IMetaAnim::AdvanceAnim(IAnimReader& anim, const CCharAnimTime& dt) void IMetaAnim::AdvanceAnim(IAnimReader& anim, const CCharAnimTime& dt)

View File

@ -70,7 +70,7 @@ public:
const CMetaAnimTreeBuildOrders& orders) const=0; const CMetaAnimTreeBuildOrders& orders) const=0;
static void AdvanceAnim(IAnimReader& anim, const CCharAnimTime& dt); static void AdvanceAnim(IAnimReader& anim, const CCharAnimTime& dt);
CCharAnimTime GetTime(const CPreAdvanceIndicator& ind, const IAnimReader& anim); static CCharAnimTime GetTime(const CPreAdvanceIndicator& ind, const IAnimReader& anim);
}; };
} }