MDLParser
Simple and modern library for parsing the Source engine model formats
Loading...
Searching...
No Matches
vtx.hpp
1#pragma once
2
3#include "enums.hpp"
4#include "structs/vtx.hpp"
5#include <memory>
6#include <optional>
7#include <string>
8#include <vector>
9
10namespace MdlParser {
14 class Vtx {
15 public:
19 struct Strip {
28
32 int32_t indicesCount;
37
42 };
43
47 struct StripGroup {
52 std::vector<Structs::Vtx::Vertex> vertices;
53
58 std::vector<uint16_t> indices;
59
63 std::vector<Strip> strips;
64
69 };
70
74 struct Mesh {
78 std::vector<StripGroup> stripGroups;
79
84 };
85
89 struct ModelLod {
93 std::vector<Mesh> meshes;
94
99 };
100
104 struct Model {
108 std::vector<ModelLod> levelOfDetails;
109 };
110
115 struct BodyPart {
119 std::vector<Model> models;
120 };
121
123 int16_t replacementId;
124 std::string replacementName;
125 };
126
134 explicit Vtx(
135 const std::weak_ptr<std::vector<std::byte>>& data, const std::optional<int32_t>& checksum = std::nullopt
136 );
137
143 [[nodiscard]] int32_t getChecksum() const;
144
150 [[nodiscard]] const std::vector<MaterialReplacement>& getMaterialReplacements(const int lod) const;
151
156 [[nodiscard]] const std::vector<BodyPart>& getBodyParts() const;
157
158 private:
160 std::vector<BodyPart> bodyParts;
161 std::vector<std::vector<MaterialReplacement>> materialReplacementsByLod;
162 };
163}
Definition: vtx.hpp:14
const std::vector< MaterialReplacement > & getMaterialReplacements(const int lod) const
Definition: vtx.cpp:160
const std::vector< BodyPart > & getBodyParts() const
Definition: vtx.cpp:165
int32_t getChecksum() const
Definition: vtx.cpp:156
StripGroupFlags
Definition: enums.hpp:75
StripFlags
Definition: enums.hpp:49
MeshFlags
Definition: enums.hpp:96
Definition: MDLParser.hpp:6
Definition: vtx.hpp:85
Definition: vtx.hpp:115
std::vector< Model > models
Definition: vtx.hpp:119
Definition: vtx.hpp:74
std::vector< StripGroup > stripGroups
Definition: vtx.hpp:78
Enums::Vtx::MeshFlags flags
Definition: vtx.hpp:83
Definition: vtx.hpp:89
float switchPoint
Definition: vtx.hpp:98
std::vector< Mesh > meshes
Definition: vtx.hpp:93
Definition: vtx.hpp:104
std::vector< ModelLod > levelOfDetails
Definition: vtx.hpp:108
Definition: vtx.hpp:47
std::vector< Structs::Vtx::Vertex > vertices
Definition: vtx.hpp:52
Enums::Vtx::StripGroupFlags flags
Definition: vtx.hpp:68
std::vector< uint16_t > indices
Definition: vtx.hpp:58
std::vector< Strip > strips
Definition: vtx.hpp:63
Definition: vtx.hpp:19
Enums::Vtx::StripFlags flags
Definition: vtx.hpp:41
int32_t verticesOffset
Definition: vtx.hpp:27
int32_t verticesCount
Definition: vtx.hpp:23
int32_t indicesOffset
Definition: vtx.hpp:36
int32_t indicesCount
Definition: vtx.hpp:32