metaforce/Runtime/Character/CFBStreamedCompression.hpp

87 lines
2.8 KiB
C++
Raw Normal View History

2018-10-07 03:42:33 +00:00
#pragma once
#include "RetroTypes.hpp"
#include "CToken.hpp"
#include "CAnimPOIData.hpp"
#include "zeus/CVector3f.hpp"
namespace urde
{
class IObjectStore;
class CFBStreamedCompression
{
friend class CFBStreamedAnimReader;
friend class CFBStreamedAnimReaderTotals;
friend class CFBStreamedPairOfTotals;
2016-08-27 21:16:44 +00:00
public:
struct Header
{
u32 unk0;
float duration;
float interval;
u32 rootBoneId;
2016-08-27 21:16:44 +00:00
u32 looping;
u32 rotDiv;
float translationMult;
u32 boneChannelCount;
u32 unk3;
void read(CInputStream& in)
{
/* unk0 */
unk0 = in.readUint32Big();
/* duration */
duration = in.readFloatBig();
/* interval */
interval = in.readFloatBig();
/* rootBoneId */
rootBoneId = in.readUint32Big();
2016-08-27 21:16:44 +00:00
/* looping */
looping = in.readUint32Big();
/* rotDiv */
rotDiv = in.readUint32Big();
/* translationMult */
translationMult = in.readFloatBig();
/* boneChannelCount */
boneChannelCount = in.readUint32Big();
/* unk3 */
unk3 = in.readUint32Big();
}
};
2016-08-27 21:16:44 +00:00
private:
2016-08-27 01:02:12 +00:00
bool m_pc;
u32 x0_scratchSize;
2017-08-13 05:26:14 +00:00
CAssetId x4_evnt;
TLockedToken<CAnimPOIData> x8_evntToken;
std::unique_ptr<u32[]> xc_rotsAndOffs;
2016-09-04 02:27:35 +00:00
float x10_averageVelocity;
zeus::CVector3f x14_rootOffset;
2016-08-27 01:02:12 +00:00
u8* ReadBoneChannelDescriptors(u8* out, CInputStream& in);
u32 ComputeBitstreamWords(const u8* chans);
std::unique_ptr<u32[]> GetRotationsAndOffsets(u32 words, CInputStream& in);
2016-09-04 02:27:35 +00:00
float CalculateAverageVelocity(const u8* chans);
2016-08-27 21:16:44 +00:00
public:
2016-08-27 01:02:12 +00:00
CFBStreamedCompression(CInputStream& in, IObjectStore& objStore, bool pc);
2016-08-27 21:16:44 +00:00
const Header& MainHeader() const { return *reinterpret_cast<const Header*>(xc_rotsAndOffs.get()); }
2016-08-28 19:57:55 +00:00
const u32* GetTimes() const;
2016-08-28 04:45:45 +00:00
const u8* GetPerChannelHeaders() const;
const u8* GetBitstreamPointer() const;
2016-08-27 21:16:44 +00:00
bool IsLooping() const { return MainHeader().looping; }
CCharAnimTime GetAnimationDuration() const { return MainHeader().duration; }
2016-09-04 02:27:35 +00:00
float GetAverageVelocity() const { return x10_averageVelocity; }
2016-08-27 21:16:44 +00:00
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(); }
};
}