-
Notifications
You must be signed in to change notification settings - Fork 6
/
cModel.h
199 lines (169 loc) · 3.06 KB
/
cModel.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
#pragma once
#include "cPoint3D.h"
#include "cByteStream.h"
class cACTriFan {
public:
cACTriFan()
{
bUVs = NULL;
wVerts = NULL;
}
~cACTriFan()
{
delete []wVerts;
delete []bUVs;
}
void Unpack(cByteStream *pBS)
{
bNumVerts = pBS->ReadByte();
bType = pBS->ReadByte();
DWORD unknown = pBS->ReadDWORD();
wTexNum = pBS->ReadWORD();
WORD unknown2 = pBS->ReadWORD();
wVerts = new WORD[bNumVerts];
for (int i=0; i<bNumVerts; i++)
wVerts[i] = pBS->ReadWORD();
if (bType == 4)
{
// Some sort of lighting/partitioning poly
}
else
{
bUVs = new BYTE[bNumVerts];
for (int i=0; i<bNumVerts; i++)
bUVs[i] = pBS->ReadByte();
if (unknown == 2)
{
//???
//Added for model 0x0100326E... No idea what this is, but it seems to work...
for (unsigned int j = 0; j < bNumVerts; j++)
pBS->ReadByte();
}
}
}
BYTE bType;
WORD wTexNum;
BYTE bNumVerts;
WORD *wVerts;
BYTE *bUVs;
};
struct stACUV {
stACUV()
{
}
stACUV(float nu, float nv)
{
u = nu;
v = nv;
}
void Unpack(cByteStream *pBS)
{
u = pBS->ReadFloat();
v = pBS->ReadFloat();
}
float u, v;
};
class cACVertex {
public:
cACVertex()
{
UVs = NULL;
}
~cACVertex()
{
delete []UVs;
}
void Unpack(cByteStream *pBS)
{
wNumUVs = pBS->ReadWORD();
x = pBS->ReadFloat();
y = pBS->ReadFloat();
z = pBS->ReadFloat();
nx = pBS->ReadFloat();
ny = pBS->ReadFloat();
nz = pBS->ReadFloat();
UVs = new stACUV[wNumUVs];
for (int i=0; i<wNumUVs; i++)
UVs[i].Unpack(pBS);
}
cPoint3D GetP3D()
{
return cPoint3D(x,y,z);
}
WORD wNumUVs;
float x, y, z;
float nx, ny, nz;
stACUV *UVs;
};
class cACPreModel {
public:
cACPreModel()
{
m_Vertices = NULL;
m_TriFans = NULL;
m_bSwaps = false;
vPaletteSwaps = NULL;
}
~cACPreModel()
{
delete []m_Vertices;
delete []m_TriFans;
}
std::vector<DWORD> m_Textures;
int iNumVerts;
cACVertex * m_Vertices;
int iNumTriFans;
cACTriFan * m_TriFans;
//Swaps
bool m_bSwaps;
int iSwapModelNum;
std::vector<stPaletteSwap> *vPaletteSwaps;
std::vector<stTextureSwap> *vTextureSwaps;
};
struct renderTriangle
{
int pt[3];
};
struct stTexInfo {
DWORD dwTexID;
DWORD dwColor;
};
struct stTriSet {
public:
stTriSet()
{
pColorarray = NULL;
pTriarray = NULL;
pVertarray = NULL;
pTexarray = NULL;
}
~stTriSet()
{
delete []pColorarray;
delete []pTriarray;
delete []pVertarray;
delete []pTexarray;
}
DWORD dwGLTex;
int iTriCount;
GLuint *pColorarray;
GLuint *pTriarray;
GLfloat *pVertarray;
GLfloat *pTexarray;
};
class cModel {
public:
cModel();
~cModel();
bool ReadModel(DWORD dwModel, int iModelNum = -1, std::vector<stPaletteSwap> *vPaletteSwaps = 0, std::vector<stTextureSwap> *vTextureSwaps = 0);
bool ReadDungeonPart(DWORD dwDungeon, WORD wDungeonPart, std::vector<WORD> * v_Textures);
bool ParsePreModel(cACPreModel * pModel);
int Draw();
void SetTranslation(cPoint3D Translation);
void SetRotation(float Rot1, float Rot2, float Rot3, float Rot4);
private:
DWORD m_dwID;
cPoint3D m_pTranslation;
float m_fRotation[4];
std::vector <stTriSet *> m_vTriSets;
};