summaryrefslogtreecommitdiff
path: root/src/port/resource/importers/Vec3fFactory.cpp
blob: 4076860ea18a998387cf0904e2557244d0f92049 (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
#include "Vec3fFactory.h"
#include "../type/Vec3fArray.h"
#include "spdlog/spdlog.h"

namespace SF64 {
std::shared_ptr<Ship::IResource> ResourceFactoryBinaryVec3fV0::ReadResource(std::shared_ptr<Ship::File> file,
                                                                            std::shared_ptr<Ship::ResourceInitData> initData) {
    if (!FileHasValidFormatAndReader(file, initData)) {
        return nullptr;
    }

    auto vec = std::make_shared<Vec3fArray>(file->InitData);
    auto reader = std::get<std::shared_ptr<Ship::BinaryReader>>(file->Reader);

    auto vecCount = reader->ReadUInt32();

    SPDLOG_INFO("Vec3f Count: {}", vecCount);

    for (uint32_t i = 0; i < vecCount; i++) {
        auto x = reader->ReadFloat();
        auto y = reader->ReadFloat();
        auto z = reader->ReadFloat();
        vec->mData.emplace_back(x, y, z);
    }

    return vec;
}
} // namespace LUS