-
Notifications
You must be signed in to change notification settings - Fork 3
/
rwext.h
155 lines (134 loc) · 4.58 KB
/
rwext.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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
#pragma once
#include "rw.h"
//#include "File.h"
#include <variant>
#include <vector>
#include "vecmat.h"
struct File;
struct RwsHeader;
struct RwExtension {
virtual ~RwExtension() {}
virtual uint32_t getType() = 0;
virtual void deserialize(File *file, const RwsHeader &header, void *parent) = 0;
virtual void serialize(File *file) = 0;
virtual std::unique_ptr<RwExtension> clone() = 0;
};
struct RwExtUnknown : RwExtension {
void *_ptr = nullptr;
uint32_t _length = 0;
uint32_t _type;
~RwExtUnknown();
uint32_t getType() override;
void deserialize(File *file, const RwsHeader &header, void *parent) override;
void serialize(File *file) override;
std::unique_ptr<RwExtension> clone() override;
};
struct RwExtHAnim : RwExtension {
struct Bone {
uint32_t nodeId, nodeIndex, flags;
};
uint32_t version, nodeId; // , numNodes;
uint32_t flags, keyFrameSize;
std::vector<Bone> bones;
uint32_t getType() override;
void deserialize(File *file, const RwsHeader &header, void *parent) override;
void serialize(File *file) override;
std::unique_ptr<RwExtension> clone() override;
};
struct RwExtSkin : RwExtension {
uint8_t numBones, numUsedBones, maxWeightPerVertex;
std::vector<uint8_t> usedBones;
std::vector<std::array<uint8_t, 4>> vertexIndices;
std::vector<std::array<float, 4>> vertexWeights;
std::vector<Matrix> matrices;
bool isSplit;
uint32_t boneLimit; // , numMeshes, numRLE;
std::vector<uint8_t> boneIndexRemap;
std::vector<std::pair<uint8_t, uint8_t>> boneGroups;
std::vector<std::pair<uint8_t, uint8_t>> boneGroupIndices;
std::vector<uint8_t> nativeData; // for consoles
uint32_t getType() override;
void deserialize(File *file, const RwsHeader &header, void *parent) override;
void serialize(File *file) override;
std::unique_ptr<RwExtension> clone() override;
void merge(const RwExtSkin &other);
};
struct RwExtBinMesh : RwExtension {
uint32_t flags = 0, /*numMeshes = 0,*/ totalIndices = 0;
struct Mesh {
uint32_t material;
std::vector<uint32_t> indices;
};
std::vector<Mesh> meshes;
bool isNative = false;
uint32_t getType() override;
void deserialize(File* file, const RwsHeader& header, void* parent) override;
void serialize(File* file) override;
std::unique_ptr<RwExtension> clone() override;
};
struct RwExtNativeData : RwExtension {
std::vector<uint8_t> data;
uint32_t getType() override;
void deserialize(File* file, const RwsHeader& header, void* parent) override;
void serialize(File* file) override;
std::unique_ptr<RwExtension> clone() override;
};
struct RwExtMaterialEffectsPLG_Material : RwExtension {
// https://gtamods.com/wiki/Material_Effects_PLG_(RW_Section)
// Effects often used in ELB games: null 0, env 2, dual 4, uv 5 (bumps are never used)
// When both dual (4) and uv (5) are used (6), first effect is 5 then second effect is 4
// 5 is seen alone, but not 4 (I mean, if multi texture doesn't animate, could as well just use one single texture)
struct NullEffect {
static constexpr int32_t ID = 0;
void read(File* file) {}
void write(File* file) {}
};
struct BumpMapEffect {
static constexpr int32_t ID = 1;
float intensity = 0.0f;
uint32_t hasBumpMap = 0;
RwTexture bumpMap;
uint32_t hasHeightMap = 0;
RwTexture heightMap;
void read(File* file);
void write(File* file);
};
struct EnvironmentEffect {
static constexpr int32_t ID = 2;
float reflectionCoeff = 1.0f;
uint32_t fbac = 1;
uint32_t hasEnvMap = 0;
RwTexture envMap;
void read(File* file);
void write(File* file);
};
struct DualTextureEffect {
static constexpr int32_t ID = 4;
uint32_t srcBlendMode = 0;
uint32_t destBlendMode = 0;
uint32_t hasTexture = 0;
RwTexture texture;
void read(File* file);
void write(File* file);
};
struct UVTransformationEffect {
static constexpr int32_t ID = 5;
void read(File* file) {}
void write(File* file) {}
};
uint32_t type = 0;
std::variant<NullEffect, BumpMapEffect, EnvironmentEffect, DualTextureEffect, UVTransformationEffect> firstEffect;
std::variant<NullEffect, BumpMapEffect, EnvironmentEffect, DualTextureEffect, UVTransformationEffect> secondEffect;
uint32_t getType() override;
void deserialize(File* file, const RwsHeader& header, void* parent) override;
void serialize(File* file) override;
std::unique_ptr<RwExtension> clone() override;
};
struct RwExtMaterialEffectsPLG_Atomic : RwExtension {
uint32_t matFxEnabled = 1;
uint32_t getType() override;
void deserialize(File* file, const RwsHeader& header, void* parent) override;
void serialize(File* file) override;
std::unique_ptr<RwExtension> clone() override;
};
std::unique_ptr<RwExtension> RwExtCreate(uint32_t type, uint32_t parentType);