3#include <BufferStream.h>
8constexpr int32_t
VVD_ID =
'I' + (
'D' << 8) + (
'S' << 16) + (
'V' << 24);
11 BufferStreamReadOnly stream{data, size};
13 if (stream.read<int32_t>() !=
VVD_ID) {
17 if (stream.read(this->version); this->version != 4) {
21 if (stream.read<int32_t>() != mdl.
checksum) {
29 const auto fixupsCount = stream.read<int32_t>();
30 const auto fixupsOffset = stream.read<int32_t>();
31 const auto verticesOffset = stream.read<int32_t>();
32 const auto tangentsOffset = stream.read<int32_t>();
34 stream.seek(verticesOffset);
36 auto& [boneWeight, position, normal, uv, tangent] = this->
vertices.emplace_back();
38 stream.read(boneWeight.weight);
40 std::array<int8_t, MAX_BONES_PER_VERTEX> bones{};
42 const auto boneCount = stream.read<int8_t>();
44 boneWeight.bones.push_back(bones[j]);
54 stream.seek(tangentsOffset);
55 for (std::size_t i = 0; i < this->numVerticesInLOD[0]; i++) {
56 this->
vertices.at(i).tangent = stream.read<math::Vec4f>();
59 stream.seek(fixupsOffset);
60 for (
int i = 0; i < fixupsCount; i++) {
61 auto& [LOD, sourceVertexID, vertexCount] = this->
fixups.emplace_back();
62 stream >> LOD >> sourceVertexID >> vertexCount;
constexpr int MAX_BONES_PER_VERTEX
std::array< int32_t, MAX_LOD_COUNT > numVerticesInLOD
std::vector< Fixup > fixups
bool open(const std::byte *data, std::size_t size, const MDL::MDL &mdl)
std::vector< Vertex > vertices