This repository was 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
Expand file tree
/
Copy pathtexture.h
More file actions
90 lines (80 loc) · 1.93 KB
/
texture.h
File metadata and controls
90 lines (80 loc) · 1.93 KB
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
#pragma once
#include "helpers.h"
#include "dxgiformat.h"
#include <fstream>
struct TexHeader
{
uint32_t TextureFormat;
uint16_t Width;
uint16_t Height;
uint16_t ArraySize;
uint32_t LargeTextureHash;
};
struct DDSHeader
{
uint32_t MagicNumber;
uint32_t dwSize;
uint32_t dwFlags;
uint32_t dwHeight;
uint32_t dwWidth;
uint32_t dwPitchOrLinearSize;
uint32_t dwDepth;
uint32_t dwMipMapCount;
std::array<uint32_t, 11> dwReserved1;
uint32_t dwPFSize;
uint32_t dwPFFlags;
uint32_t dwPFFourCC;
uint32_t dwPFRGBBitCount;
uint32_t dwPFRBitMask;
uint32_t dwPFGBitMask;
uint32_t dwPFBBitMask;
uint32_t dwPFABitMask;
uint32_t dwCaps;
uint32_t dwCaps2;
uint32_t dwCaps3;
uint32_t dwCaps4;
uint32_t dwReserved2;
};
struct DXT10Header
{
uint32_t dxgiFormat;
uint32_t resourceDimension;
uint32_t miscFlag;
uint32_t arraySize;
uint32_t miscFlags2;
};
class Texture : public Header
{
private:
File* dataFile = nullptr;
int textureFormat;
uint16_t width;
uint16_t height;
uint16_t arraySize;
std::string largeHash;
std::string fullSavePath;
void getHeader(std::string x);
void writeTexture(std::string fullSavePath);
void writeFile(DDSHeader dds, DXT10Header dxt, std::string fullSavePath);
public:
Texture(std::string x, std::string pkgsPath) : Header(x, pkgsPath)
{
getData();
getHeader(x);
}
void tex2DDS(std::string fullSavePath);
void tex2Other(std::string fullSavePath, std::string saveFormat);
};
class Material : public File
{
private:
public:
std::vector<std::string> cbuffers;
std::unordered_map<uint8_t, Texture*> textures;
Material(std::string x, std::string pkgsPath) : File(x, pkgsPath) {};
void parseMaterial(std::unordered_map<uint64_t, uint32_t> hash64Table);
void exportTextures(std::string fullSavePath, std::string saveFormat);
void parseCBuffers();
void writeCBuffers(std::string fullSavePath);
};
std::string getCBufferFromOffset(unsigned char* data, int offset, int count, uint32_t cbType, std::string name);