SourcePP
Several modern C++20 libraries for sanely parsing Valve's formats.
Loading...
Searching...
No Matches
mdlpp.h
Go to the documentation of this file.
1#pragma once
2
3#include <vector>
4
5#include "structs/MDL.h"
6#include "structs/VTX.h"
7#include "structs/VVD.h"
8
9namespace mdlpp {
10
14struct BakedModel {
15 struct Vertex {
16 sourcepp::math::Vec3f position;
17 sourcepp::math::Vec3f normal;
18 sourcepp::math::Vec2f uv;
19 };
20 std::vector<Vertex> vertices;
21
22 struct Mesh {
23 std::vector<uint16_t> indices;
24 int32_t materialIndex = -1;
25 };
26 std::vector<Mesh> meshes;
27};
28
30 [[nodiscard]] bool open(const std::byte* mdlData, std::size_t mdlSize,
31 const std::byte* vtxData, std::size_t vtxSize,
32 const std::byte* vvdData, std::size_t vvdSize);
33
34 [[nodiscard]] bool open(const unsigned char* mdlData, std::size_t mdlSize,
35 const unsigned char* vtxData, std::size_t vtxSize,
36 const unsigned char* vvdData, std::size_t vvdSize);
37
38 [[nodiscard]] bool open(const std::vector<std::byte>& mdlData,
39 const std::vector<std::byte>& vtxData,
40 const std::vector<std::byte>& vvdData);
41
42 [[nodiscard]] bool open(const std::vector<unsigned char>& mdlData,
43 const std::vector<unsigned char>& vtxData,
44 const std::vector<unsigned char>& vvdData);
45
46 [[nodiscard]] explicit operator bool() const;
47
48 [[nodiscard]] BakedModel processModelData(int currentLOD = ROOT_LOD) const;
49
53
54private:
55 bool opened = false;
56};
57
58} // namespace mdlpp
Definition: mdlpp.h:9
constexpr int ROOT_LOD
Definition: Generic.h:10
int32_t materialIndex
Definition: mdlpp.h:24
std::vector< uint16_t > indices
Definition: mdlpp.h:23
sourcepp::math::Vec2f uv
Definition: mdlpp.h:18
sourcepp::math::Vec3f position
Definition: mdlpp.h:16
sourcepp::math::Vec3f normal
Definition: mdlpp.h:17
A more accessible version of StudioModel's vertex data, so it can be rendered or converted more easil...
Definition: mdlpp.h:14
std::vector< Vertex > vertices
Definition: mdlpp.h:20
std::vector< Mesh > meshes
Definition: mdlpp.h:26
MDL::MDL mdl
Definition: mdlpp.h:50
bool open(const std::byte *mdlData, std::size_t mdlSize, const std::byte *vtxData, std::size_t vtxSize, const std::byte *vvdData, std::size_t vvdSize)
Definition: mdlpp.cpp:10
BakedModel processModelData(int currentLOD=ROOT_LOD) const
Definition: mdlpp.cpp:53
VVD::VVD vvd
Definition: mdlpp.h:52
VTX::VTX vtx
Definition: mdlpp.h:51