SourcePP
Several modern C++20 libraries for sanely parsing Valve's formats.
Loading...
Searching...
No Matches
VTX.h
Go to the documentation of this file.
1#pragma once
2
3#include <cstddef>
4#include <cstdint>
5#include <span>
6#include <vector>
7
8#include "MDL.h"
9
10namespace mdlpp::VTX {
11
12struct Vertex {
13 //uint8_t boneWeightIndex[3];
14 //uint8_t boneCount;
15 uint16_t meshVertexID;
16 //int8_t boneID[3];
17};
18
19struct Strip {
20 enum Flags : uint8_t {
24 };
25
26 //int32_t indicesCount;
27 int32_t indicesOffset = 0; // Offset from the start of the strip group indices
28 std::span<uint16_t> indices;
29
30 //int32_t verticesCount;
31 int32_t verticesOffset = 0; // Offset from the start of the strip group vertices
32 std::span<Vertex> vertices;
33
34 int16_t boneCount = 0;
36
37 //int32_t boneStateChangeCount;
38 //int32_t boneStateChangeOffset;
39
40 // On MDL version >= 49:
41 //int32_t numTopologyIndices;
42 //int32_t topologyOffset;
43};
45
46struct StripGroup {
47 enum Flags : uint8_t {
48 FLAG_NONE = 0,
49 FLAG_IS_FLEXED = 1 << 0,
50 FLAG_IS_HW_SKINNED = 1 << 1,
51 FLAG_IS_DELTA_FLEXED = 1 << 2,
52 FLAG_SUPPRESS_HW_MORPH = 1 << 3,
53 };
54
55 //int32_t vertexCount;
56 //int32_t vertexOffset;
57 std::vector<Vertex> vertices;
58
59 //int32_t indexCount;
60 //int32_t indexOffset;
61 std::vector<uint16_t> indices;
62
63 //int32_t stripCount;
64 //int32_t stripOffset;
65 std::vector<Strip> strips;
66
68
69 // on MDL version >= 49:
70 //int32_t numTopologyIndices;
71 //int32_t topologyOffset;
72};
74
75struct Mesh {
76 enum Flags : uint8_t {
77 FLAG_NONE = 0,
78 FLAG_IS_TEETH = 1 << 0,
79 FLAG_IS_EYES = 1 << 1,
80 };
81
82 //int32_t stripGroupCount;
83 //int32_t stripGroupHeaderOffset;
84 std::vector<StripGroup> stripGroups;
85
87};
89
90struct ModelLOD {
91 //int32_t meshCount;
92 //int32_t meshOffset;
93 std::vector<Mesh> meshes;
94
96};
97
98struct Model {
99 //int32_t LODCount;
100 //int32_t LODOffset;
101 std::vector<ModelLOD> modelLODs;
102};
103
104struct BodyPart {
105 //int32_t modelCount;
106 //int32_t modelOffset;
107 std::vector<Model> models;
108};
109
110struct VTX {
111 [[nodiscard]] bool open(const std::byte* data, std::size_t size, const MDL::MDL& mdl);
112
113 int32_t version;
118 //int32_t checksum;
119 int32_t numLODs;
120
121 //int32_t materialReplacementListOffset;
122
123 //int32_t bodyPartCount;
124 //int32_t bodyPartOffset;
125 std::vector<BodyPart> bodyParts;
126};
127
128} // namespace mdlpp::VTX
#define SOURCEPP_BITFLAGS_ENUM(Enum)
Defines bitwise operators for an enum or enum class.
Definition: Macros.h:26
Definition: VTX.h:10
std::vector< Model > models
Definition: VTX.h:107
std::vector< StripGroup > stripGroups
Definition: VTX.h:84
Flags flags
Definition: VTX.h:86
std::vector< Mesh > meshes
Definition: VTX.h:93
float switchDistance
Definition: VTX.h:95
std::vector< ModelLOD > modelLODs
Definition: VTX.h:101
std::vector< uint16_t > indices
Definition: VTX.h:61
std::vector< Strip > strips
Definition: VTX.h:65
std::vector< Vertex > vertices
Definition: VTX.h:57
int32_t indicesOffset
Definition: VTX.h:27
int32_t verticesOffset
Definition: VTX.h:31
std::span< uint16_t > indices
Definition: VTX.h:28
int16_t boneCount
Definition: VTX.h:34
Flags flags
Definition: VTX.h:35
@ FLAG_IS_TRILIST
Definition: VTX.h:22
@ FLAG_IS_TRISTRIP
Definition: VTX.h:23
std::span< Vertex > vertices
Definition: VTX.h:32
int32_t numLODs
Definition: VTX.h:119
int32_t vertexCacheSize
Definition: VTX.h:114
int32_t version
Definition: VTX.h:113
std::vector< BodyPart > bodyParts
Definition: VTX.h:125
uint16_t maxBonesPerTriangle
Definition: VTX.h:116
int32_t maxBonesPerVertex
Definition: VTX.h:117
bool open(const std::byte *data, std::size_t size, const MDL::MDL &mdl)
Definition: VTX.cpp:7
uint16_t maxBonesPerStrip
Definition: VTX.h:115
uint16_t meshVertexID
Definition: VTX.h:15