blob: f4682b4db3e8cadb779f6f2d1105e2238cfca2ff (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
#include "AnimFactory.h"
#include "../type/Animation.h"
#include "spdlog/spdlog.h"
namespace SF64 {
std::shared_ptr<Ship::IResource> ResourceFactoryBinaryAnimV0::ReadResource(std::shared_ptr<Ship::File> file,
std::shared_ptr<Ship::ResourceInitData> initData) {
if (!FileHasValidFormatAndReader(file, initData)) {
return nullptr;
}
auto anim = std::make_shared<Animation>(file->InitData);
auto reader = std::get<std::shared_ptr<Ship::BinaryReader>>(file->Reader);
int16_t frameCount = reader->ReadInt16();
int16_t limbCount = reader->ReadInt16();
auto jointSize = reader->ReadUInt32();
SPDLOG_INFO("JointSize: {}", jointSize);
for (uint32_t i = 0; i < jointSize; i++) {
uint16_t xLen = reader->ReadUInt16();
uint16_t x = reader->ReadUInt16();
uint16_t yLen = reader->ReadUInt16();
uint16_t y = reader->ReadUInt16();
uint16_t zLen = reader->ReadUInt16();
uint16_t z = reader->ReadUInt16();
anim->jointKey.push_back({xLen, x, yLen, y, zLen, z});
}
auto frameSize = reader->ReadUInt32();
for (uint32_t i = 0; i < frameSize; i++) {
anim->frameData.push_back(reader->ReadInt16());
}
anim->mData.frameCount = frameCount;
anim->mData.limbCount = limbCount;
anim->mData.jointKey = anim->jointKey.data();
anim->mData.frameData = anim->frameData.data();
return anim;
}
} // namespace LUS
|