-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmaptile.h
More file actions
169 lines (126 loc) · 2.92 KB
/
maptile.h
File metadata and controls
169 lines (126 loc) · 2.92 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
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
#ifndef MAPTILE_H
#define MAPTILE_H
#define TILESIZE (533.33333f)
#define CHUNKSIZE ((TILESIZE) / 16.0f)
#define UNITSIZE (CHUNKSIZE / 8.0f)
#define ZEROPOINT (32.0f * (TILESIZE))
#include "video.h"
#include "mpq.h"
#include "wmo.h"
#include "model.h"
#include "liquid.h"
#include <vector>
#include <string>
class MapTile;
class MapChunk;
class World;
const int mapbufsize = 9*9 + 8*8;
class MapNode {
public:
MapNode(int x, int y, int s):px(x),py(y),size(s) {}
int px, py, size;
Vec3D vmin, vmax, vcenter;
MapNode *children[4];
MapTile *mt;
virtual void draw();
void setup(MapTile *t);
void cleanup();
};
class MapChunk : public MapNode {
public:
int nTextures;
float xbase, ybase, zbase;
float r;
unsigned int areaID;
bool haswater;
bool visible;
bool hasholes;
float waterlevel;
TextureID textures[4];
TextureID alphamaps[3];
TextureID shadow;
int animated[4];
GLuint vertices, normals;
short *strip;
int striplen;
Liquid *lq;
MapChunk():MapNode(0,0,0) {}
void init(MapTile* mt, MPQFile &f);
void destroy();
void initStrip(int holes);
void draw();
void drawNoDetail();
void drawPass(int anim);
void drawWater();
};
class MapTile {
public:
std::vector<std::string> textures;
std::vector<std::string> wmos;
std::vector<std::string> models;
std::vector<WMOInstance> wmois;
std::vector<ModelInstance> modelis;
int nWMO;
int nMDX;
int x, z;
bool ok;
//World *world;
float xbase, zbase;
MapChunk chunks[16][16];
MapNode topnode;
MapTile(int x0, int z0, char* filename);
~MapTile();
void draw();
void drawWater();
void drawObjects();
void drawSky();
//void drawPortals();
void drawModels();
/// Get chunk for sub offset x,z
MapChunk *getChunk(unsigned int x, unsigned int z);
};
int indexMapBuf(int x, int y);
// 8x8x2 version with triangle strips, size = 8*18 + 7*2
const int stripsize = 8*18 + 7*2;
template <class V>
void stripify(V *in, V *out)
{
for (int row=0; row<8; row++) {
V *thisrow = &in[indexMapBuf(0,row*2)];
V *nextrow = &in[indexMapBuf(0,(row+1)*2)];
if (row>0) *out++ = thisrow[0];
for (int col=0; col<9; col++) {
*out++ = thisrow[col];
*out++ = nextrow[col];
}
if (row<7) *out++ = nextrow[8];
}
}
// high res version, size = 16*18 + 7*2 + 8*2
const int stripsize2 = 16*18 + 7*2 + 8*2;
template <class V>
void stripify2(V *in, V *out)
{
for (int row=0; row<8; row++) {
V *thisrow = &in[indexMapBuf(0,row*2)];
V *nextrow = &in[indexMapBuf(0,row*2+1)];
V *overrow = &in[indexMapBuf(0,(row+1)*2)];
if (row>0) *out++ = thisrow[0];// jump end
for (int col=0; col<8; col++) {
*out++ = thisrow[col];
*out++ = nextrow[col];
}
*out++ = thisrow[8];
*out++ = overrow[8];
*out++ = overrow[8];// jump start
*out++ = thisrow[0];// jump end
*out++ = thisrow[0];
for (int col=0; col<8; col++) {
*out++ = overrow[col];
*out++ = nextrow[col];
}
if (row<8) *out++ = overrow[8];
if (row<7) *out++ = overrow[8];// jump start
}
}
#endif