SourcePP
Several modern C++20 libraries for sanely parsing Valve's formats.
Toggle main menu visibility
Loading...
Searching...
No Matches
VVD.cpp
Go to the documentation of this file.
1
#include <
mdlpp/structs/VVD.h
>
2
3
#include <BufferStream.h>
4
#include <
sourcepp/parser/Binary.h
>
5
6
using namespace
mdlpp::VVD
;
7
using namespace
sourcepp
;
8
9
constexpr
int32_t
VVD_ID
=
parser::binary::makeFourCC
(
"IDSV"
);
10
11
bool
VVD::open
(
const
std::byte* data, std::size_t size,
const
MDL::MDL
& mdl) {
12
BufferStreamReadOnly stream{data, size};
13
14
if
(stream.read<int32_t>() !=
VVD_ID
) {
15
return
false
;
16
}
17
18
if
(stream.read(this->version); this->version != 4) {
19
return
false
;
20
}
21
22
if
(stream.read<int32_t>() != mdl.
checksum
) {
23
return
false
;
24
}
25
26
stream
27
.read(this->
numLODs
)
28
.read(this->
numVerticesInLOD
);
29
30
const
auto
fixupsCount = stream.read<int32_t>();
31
const
auto
fixupsOffset = stream.read<int32_t>();
32
const
auto
verticesOffset = stream.read<int32_t>();
33
const
auto
tangentsOffset = stream.read<int32_t>();
34
35
stream.seek(verticesOffset);
36
for
(
int
i = 0; i < this->
numVerticesInLOD
[0]; i++) {
37
auto
& [boneWeight, position, normal, uv, tangent] = this->
vertices
.emplace_back();
38
39
stream
40
.read(boneWeight.weight)
41
.read(boneWeight.bones)
42
.read(boneWeight.boneCount)
43
.read(position)
44
.read(normal)
45
.read(uv);
46
// tangents are assigned below
47
}
48
49
stream.seek(tangentsOffset);
50
for
(std::size_t i = 0; i < this->numVerticesInLOD[0]; i++) {
51
this->
vertices
.at(i).tangent = stream.read<math::Vec4f>();
52
}
53
54
stream.seek(fixupsOffset);
55
for
(
int
i = 0; i < fixupsCount; i++) {
56
auto
& [LOD, sourceVertexID, vertexCount] = this->
fixups
.emplace_back();
57
stream >> LOD >> sourceVertexID >> vertexCount;
58
}
59
60
return
true
;
61
}
Binary.h
VVD_ID
constexpr int32_t VVD_ID
Definition
VVD.cpp:9
VVD.h
mdlpp::VVD
Definition
VVD.h:10
sourcepp::parser::binary::makeFourCC
consteval uint32_t makeFourCC(const char fourCC[4])
Creates a FourCC identifier from a string of 4 characters.
Definition
Binary.h:20
sourcepp
Definition
LZMA.h:11
mdlpp::MDL::MDL
Definition
MDL.h:681
mdlpp::MDL::MDL::checksum
int32_t checksum
Definition
MDL.h:707
mdlpp::VVD::VVD::numVerticesInLOD
std::array< int32_t, MAX_LOD_COUNT > numVerticesInLOD
Definition
VVD.h:46
mdlpp::VVD::VVD::numLODs
int32_t numLODs
Definition
VVD.h:44
mdlpp::VVD::VVD::fixups
std::vector< Fixup > fixups
Definition
VVD.h:50
mdlpp::VVD::VVD::open
bool open(const std::byte *data, std::size_t size, const MDL::MDL &mdl)
Definition
VVD.cpp:11
mdlpp::VVD::VVD::vertices
std::vector< Vertex > vertices
Definition
VVD.h:53
src
mdlpp
structs
VVD.cpp
Generated on
for SourcePP by
1.18.0