A reimplementation of Mario Kart Wii's physics engine in C++
Loading...
Searching...
No Matches
ResAnmChr.hh
1#pragma once
2
3#include "abstract/g3d/AnmObj.hh"
4#include "abstract/g3d/ResCommon.hh"
5
6#include <egg/util/Stream.hh>
7
8// Credit: kiwi515/ogws
9
10namespace Abstract {
11namespace g3d {
12
14class ResAnmChr {
15public:
16 struct InfoData {
17 void read(EGG::Stream &stream) {
18 numFrame = stream.read_u16();
19 numNode = stream.read_u16();
20 policy = static_cast<AnmPolicy>(stream.read_u32());
21 scalingRule = stream.read_u32();
22 }
23
24 u16 numFrame;
25 u16 numNode;
26 AnmPolicy policy;
27 u32 scalingRule;
28 };
29 STATIC_ASSERT(sizeof(InfoData) == 0xC);
30
31 struct Data {
32 ResBlockHeaderData header;
33 u32 revision;
34 s32 toResFileData;
35 s32 toChrDataDic;
36 s32 toResUserData;
37 s32 name;
38 s32 originalPath;
39 InfoData info;
40 };
41 STATIC_ASSERT(sizeof(Data) == 0x2C);
42
43 ResAnmChr(const void *data) : m_rawData(reinterpret_cast<const Data *>(data)) {
44 EGG::RamStream stream = EGG::RamStream(data, sizeof(Data));
45 read(stream);
46 }
47
48 void read(EGG::Stream &stream) {
49 stream.jump(offsetof(Data, info));
50 m_infoData.read(stream);
51 }
52
53 [[nodiscard]] u16 frameCount() const {
54 return m_infoData.numFrame;
55 }
56
57 [[nodiscard]] AnmPolicy policy() const {
58 return m_infoData.policy;
59 }
60
61private:
62 const Data *m_rawData;
63 InfoData m_infoData;
64};
65
66class AnmObjChrRes : public FrameCtrl {
67public:
68 AnmObjChrRes(const ResAnmChr &chr)
69 : FrameCtrl(0.0f, chr.frameCount(), GetAnmPlayPolicy(chr.policy())), m_resAnmChr(chr) {}
70
71 [[nodiscard]] u16 frameCount() const {
72 return m_resAnmChr.frameCount();
73 }
74
75private:
76 ResAnmChr m_resAnmChr;
77};
78
79} // namespace g3d
80} // namespace Abstract
Represents the CHR0 file format, which pertains to model movement animations.
Definition ResAnmChr.hh:14
A stream of data stored in memory.
Definition Stream.hh:64
A stream of data, abstracted to allow for continuous seeking.
Definition Stream.hh:10
An abstraction of components from the nw4r and RVL libraries.
Definition Archive.cc:5