-
Notifications
You must be signed in to change notification settings - Fork 0
/
EMD.h
244 lines (187 loc) · 5.17 KB
/
EMD.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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
/** Desenvolvido por Lucas P. Stark em 19/05/2015
** EMD é o formato de arquivos utilizados por Resident Evil 2
** ele contem modelo 3D dos personagens, inimigos e etc...
** Documentação: http://rewiki.regengedanken.de/wiki/.EMD_%28Resident_Evil_2_PC%29
**/
#ifndef EMD_H
#define EMD_H
#include <iostream>
#include <cstdlib>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <list>
#include <vector>
#include "TIM.h"
typedef struct EMD_HEADER_DIRECTORY {
unsigned int dirOffset;
unsigned int dirCount;
} EMD_HEADER_DIRECTORY;
typedef struct EMD_SECTION_1_HEADER {
unsigned short dataCount;
unsigned short dataOffset;
} EMD_SECTION_1_HEADER;
typedef struct EMD_SECTION_2_HEADER {
unsigned short relposOffset;
unsigned short lenght;
unsigned short count;
unsigned short size;
} EMD_SECTION_2_HEADER;
typedef struct EMD_SEC2_RELPOS_T {
short x;
short y;
short z;
} EMD_SEC2_RELPOS_T;
typedef struct EMD_SEC2_ARMATURE_T {
unsigned short meshCount;
unsigned short offSet;
} EMD_SEC2_ARMATURE_T;
typedef struct EMD_SEC2_VECTOR {
float x;
float y;
float z;
} EMD_SEC2_VECTOR;
typedef struct EMD_SEC2_DATA_T {
short xOffset;
short yOffset;
short zOffset;
short xSpeed;
short ySpeed;
short zSpeed;
unsigned char *angles;
EMD_SEC2_VECTOR vector[500];
} EMD_SEC2_DATA_T;
typedef struct EMD_SECTION_7_HEADER {
unsigned int lenght; // Section Lenght in Bytes
unsigned int unk32; // Desconhecido
unsigned int objCount; // Número de objetos no modelo
} EMD_SECTION_7_HEADER;
typedef struct EMD_MODEL_TRIANGLES_T {
unsigned int vertexOffset;
unsigned int vertexCount;
unsigned int normalOffset;
unsigned int normalCount;
unsigned int triOffset;
unsigned int triCount;
unsigned int triTextureOffset;
} EMD_MODEL_TRIANGLES_T;
typedef struct EMD_MODEL_QUADS_T {
unsigned int vertexOffset;
unsigned int vertexCount;
unsigned int normalOffset;
unsigned int normalCount;
unsigned int quadOffset;
unsigned int quadCount;
unsigned int quadTextureOffset;
} EMD_MODEL_QUADS_T;
typedef struct EMD_MODEL_OBJECT_T {
EMD_MODEL_TRIANGLES_T triangles;
EMD_MODEL_QUADS_T quads;
} EMD_MODEL_OBJECT_T;
typedef struct EMD_VERTEX_T {
signed short x;
signed short y;
signed short z;
signed short zero;
} EMD_VERTEX_T;
typedef struct EMD_NORMAL_T {
signed short x;
signed short y;
signed short z;
signed short zero;
} EMD_NORMAL_T;
typedef struct EMD_TRIANGLE_T {
unsigned short n0;
unsigned short v0;
unsigned short n1;
unsigned short v1;
unsigned short n2;
unsigned short v2;
} EMD_TRIANGLE_T;
typedef struct EMD_QUAD_T {
unsigned short n0;
unsigned short v0;
unsigned short n1;
unsigned short v1;
unsigned short n2;
unsigned short v2;
unsigned short n3;
unsigned short v3;
} EMD_QUAD_T;
typedef struct EMD_TRITEXTURE_T {
unsigned char u0;
unsigned char v0;
unsigned short clutid;
unsigned char u1;
unsigned char v1;
unsigned short page;
unsigned char u2;
unsigned char v2;
unsigned short zero;
} EMD_TRITEXTURE_T;
typedef struct EMD_QUADTEXTURE_T {
unsigned char u0;
unsigned char v0;
unsigned short clutid;
unsigned char u1;
unsigned char v1;
unsigned short page;
unsigned char u2;
unsigned char v2;
unsigned short zero;
unsigned char u3;
unsigned char v3;
unsigned short zero2;
} EMD_QUADTEXTURE_T;
/* Customização para melhorar a renderização */
typedef struct EMD_ANIM_INFO {
unsigned int animStart;
unsigned int animCount;
} EMD_ANIM_INFO;
class EMD {
public:
EMD();
~EMD();
void emdDebugPrint();
void verifyRelPos(unsigned int objNum, int *x, int *y, int *z);
void recurs(unsigned int objNum, int*x, int*y, int*z, int var);
void recurRelPos(unsigned int objNum, int *x, int *y, int *z, int var, int var2);
bool emdLoadFile(std::string dir);
EMD_MODEL_OBJECT_T *emdObjectBuffer;
EMD_VERTEX_T **emdVertex;
EMD_VERTEX_T **emdquadVertex;
EMD_NORMAL_T **emdNormal;
EMD_NORMAL_T **emdquadNormal;
EMD_TRIANGLE_T **emdTriangle;
EMD_QUAD_T **emdQuad;
EMD_QUADTEXTURE_T **emdQuadTexture;
EMD_TRITEXTURE_T **emdTritexture;
// Section 2
EMD_SEC2_RELPOS_T *emdSec2RelPos;
EMD_SEC2_ARMATURE_T *emdSec2Armature;
EMD_SECTION_2_HEADER emdSec2Header;
std::vector<EMD_SEC2_DATA_T> emdSec2Data;
EMD_ANIM_INFO *emdSec2AnimInfo;
// Section 3 and Section 4
EMD_SECTION_2_HEADER emdSec4Header;
std::vector<EMD_SEC2_DATA_T> emdSec4Data;
EMD_ANIM_INFO *emdSec4AnimInfo;
EMD_SECTION_1_HEADER *emdSec3Header;
unsigned int emdSec3AnimSkelT[100][500];
unsigned short sizeSec3Header;
// Section 1
EMD_SECTION_1_HEADER *emdSec1Header;
unsigned char **emdSec2Mesh;
unsigned int emdSize;
unsigned int totalAnim;
unsigned int emdTotalObj;
unsigned int emdSec1AnimSkelT[100][500];
unsigned short sizeSec1Header;
TIM emdTimTexture;
private:
unsigned char *emdBufferData;
unsigned int *emdFileSection;
EMD_HEADER_DIRECTORY emdHeader;
EMD_SECTION_7_HEADER emdSec7Header;
};
#endif