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 <array>
4#include <span>
5
6#include "MDL.h"
7
8namespace mdlpp::VTX {
9
11 int16_t materialID;
12 //int32_t replacementMaterialNameOffset;
13 std::string newMaterialPath;
14};
15
17 int32_t hardwareID;
18 int32_t newBoneID;
19};
20
21struct Vertex {
22 std::array<uint8_t, 3> boneWeightIndex;
23 uint8_t boneCount;
24 uint16_t meshVertexID;
25 std::array<int8_t, 3> boneID;
26};
27
28struct Strip {
29 enum Flags : uint8_t {
33 };
34
35 //int32_t indicesCount;
36 int32_t indicesOffset = 0; // Offset from the start of the strip group indices
37 std::span<uint16_t> indices;
38
39 //int32_t verticesCount;
40 int32_t verticesOffset = 0; // Offset from the start of the strip group vertices
41 std::span<Vertex> vertices;
42
43 int16_t boneCount = 0;
45
46 //int32_t boneStateChangeCount;
47 //int32_t boneStateChangeOffset;
48 std::vector<BoneStateChange> boneStateChanges;
49
50 //int32_t numTopologyIndices;
52 std::span<uint16_t> topologyIndices;
53};
55
56struct StripGroup {
57 enum Flags : uint8_t {
63 };
64
65 //int32_t vertexCount;
66 //int32_t vertexOffset;
67 std::vector<Vertex> vertices;
68
69 //int32_t indexCount;
70 //int32_t indexOffset;
71 std::vector<uint16_t> indices;
72
73 //int32_t stripCount;
74 //int32_t stripOffset;
75 std::vector<Strip> strips;
76
78
79 //int32_t numTopologyIndices;
80 //int32_t topologyOffset;
81 std::vector<uint16_t> topologyIndices;
82};
84
85struct Mesh {
86 enum Flags : uint8_t {
88 FLAG_IS_TEETH = 1 << 0,
89 FLAG_IS_EYES = 1 << 1,
90 };
91
92 //int32_t stripGroupCount;
93 //int32_t stripGroupHeaderOffset;
94 std::vector<StripGroup> stripGroups;
95
97};
99
100struct ModelLOD {
101 //int32_t meshCount;
102 //int32_t meshOffset;
103 std::vector<Mesh> meshes;
104
106};
107
108struct Model {
109 //int32_t LODCount;
110 //int32_t LODOffset;
111 std::vector<ModelLOD> modelLODs;
112};
113
114struct BodyPart {
115 //int32_t modelCount;
116 //int32_t modelOffset;
117 std::vector<Model> models;
118};
119
120struct VTX {
126
127 [[nodiscard]] bool open(const std::byte* data, std::size_t size, const MDL::MDL& mdl, HasTopologyIndices hasTopologyIndices = HasTopologyIndices::AUTOMATIC);
128
129 int32_t version;
134 //int32_t checksum;
135 int32_t numLODs;
136
137 //int32_t materialReplacementListOffset;
138 std::array<std::vector<MaterialReplacement>, MAX_LOD_COUNT> materialReplacementLists;
139
140 //int32_t bodyPartCount;
141 //int32_t bodyPartOffset;
142 std::vector<BodyPart> bodyParts;
143};
144
145} // namespace mdlpp::VTX
#define SOURCEPP_BITFLAGS_ENUM(Enum)
Defines bitwise operators for an enum or enum class.
Definition Macros.h:29
constexpr int MAX_LOD_COUNT
Definition Generic.h:11
std::vector< Model > models
Definition VTX.h:117
std::string newMaterialPath
Definition VTX.h:13
std::vector< StripGroup > stripGroups
Definition VTX.h:94
Flags flags
Definition VTX.h:96
@ FLAG_IS_TEETH
Definition VTX.h:88
std::vector< Mesh > meshes
Definition VTX.h:103
float switchDistance
Definition VTX.h:105
std::vector< ModelLOD > modelLODs
Definition VTX.h:111
std::vector< uint16_t > topologyIndices
Definition VTX.h:81
std::vector< uint16_t > indices
Definition VTX.h:71
std::vector< Strip > strips
Definition VTX.h:75
std::vector< Vertex > vertices
Definition VTX.h:67
int32_t indicesOffset
Definition VTX.h:36
int32_t verticesOffset
Definition VTX.h:40
std::span< uint16_t > indices
Definition VTX.h:37
std::vector< BoneStateChange > boneStateChanges
Definition VTX.h:48
std::span< uint16_t > topologyIndices
Definition VTX.h:52
int16_t boneCount
Definition VTX.h:43
Flags flags
Definition VTX.h:44
@ FLAG_IS_TRILIST
Definition VTX.h:31
@ FLAG_IS_TRISTRIP
Definition VTX.h:32
int32_t topologyIndicesOffset
Definition VTX.h:51
std::span< Vertex > vertices
Definition VTX.h:41
int32_t numLODs
Definition VTX.h:135
int32_t vertexCacheSize
Definition VTX.h:130
bool open(const std::byte *data, std::size_t size, const MDL::MDL &mdl, HasTopologyIndices hasTopologyIndices=HasTopologyIndices::AUTOMATIC)
Definition VTX.cpp:12
std::array< std::vector< MaterialReplacement >, MAX_LOD_COUNT > materialReplacementLists
Definition VTX.h:138
int32_t version
Definition VTX.h:129
std::vector< BodyPart > bodyParts
Definition VTX.h:142
uint16_t maxBonesPerTriangle
Definition VTX.h:132
int32_t maxBonesPerVertex
Definition VTX.h:133
uint16_t maxBonesPerStrip
Definition VTX.h:131
std::array< uint8_t, 3 > boneWeightIndex
Definition VTX.h:22
uint16_t meshVertexID
Definition VTX.h:24
uint8_t boneCount
Definition VTX.h:23
std::array< int8_t, 3 > boneID
Definition VTX.h:25