This repository has been archived by the owner on Sep 2, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
helpers.h
131 lines (113 loc) · 2.61 KB
/
helpers.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#pragma once
#include <string>
#include <unordered_map>
#include "../DestinyUnpackerCPP/package.h"
// forward declarations
class Texture;
class Material;
enum PrimitiveType
{
Triangles = 3,
TriangleStrip = 5
};
enum BufferType
{
VertPrimary,
VertSecondary,
OldWeights,
Unk,
Index,
VertColour,
SPSBWeights
};
class File
{
private:
public:
File(std::string x, std::string pkgsPath);
std::string hash = "";
unsigned char* data = nullptr;
std::string pkgID = "";
std::string packagesPath;
int getData();
};
class Header : public File
{
private:
public:
Header(std::string x, std::string pkgsPath) : File(x, pkgsPath) {}
};
class Model : public File
{
private:
public:
Model(std::string x, std::string pkgsPath) : File(x, pkgsPath) {};
};
class Submesh
{
private:
public:
std::vector<std::vector<float>> vertPos;
std::vector<std::vector<float>> vertNorm;
std::vector<std::vector<float>> vertUV;
std::vector<std::vector<float>> vertCol;
std::vector<std::vector<uint32_t>> faces;
int lodLevel;
std::string name;
Material* material = nullptr;
int type;
int indexCount;
int indexOffset;
PrimitiveType primType;
};
class DynamicSubmesh : public Submesh
{
private:
public:
std::vector<std::vector<uint8_t>> weightIndices;
std::vector<std::vector<float>> weights;
std::vector<std::vector<float>> vertColSlots;
int stride;
Texture* diffuse = nullptr;
int gearDyeChangeColourIndex;
int alphaClip;
int lodGroup;
};
// Forward declarations
class IndexBufferHeader;
class VertexBufferHeader;
class Mesh
{
private:
public:
//Mesh() {};
IndexBufferHeader* facesFile = nullptr;
VertexBufferHeader* vertPosFile = nullptr;
VertexBufferHeader* vertUVFile = nullptr;
VertexBufferHeader* vertColFile = nullptr;
std::vector<std::vector<float>> vertPos;
std::vector<std::vector<float>> vertNorm;
std::vector<std::vector<float>> vertUV;
std::vector<std::vector<float>> vertCol;
std::vector<std::vector<uint32_t>> faces;
std::unordered_map<int, int> faceMap;
std::vector<Submesh*> submeshes;
};
class DynamicMesh : public Mesh
{
private:
public:
//DynamicMesh() : Mesh() {};
std::vector<int16_t> vertPosW;
std::vector<int16_t> vertNormW;
bool bCloth = false;
std::vector<std::vector<uint8_t>> weightIndices;
std::vector<std::vector<float>> weights;
std::vector<DynamicSubmesh*> submeshes;
VertexBufferHeader* oldWeightsFile = nullptr;
VertexBufferHeader* spsbWeightsFile = nullptr;
};
std::string getReferenceFromHash(std::string hash, std::string pkgsPath);
std::string getHash64(uint64_t hash64, std::unordered_map<uint64_t, uint32_t> hash64Table);
std::string getPkgID(std::string hash);
uint16_t getPkgID(uint32_t hash);