1 | /* |
---|
2 | orxonox - the future of 3D-vertical-scrollers |
---|
3 | |
---|
4 | Copyright (C) 2006 orx |
---|
5 | |
---|
6 | This program is free software; you can redistribute it and/or modify |
---|
7 | it under the terms of the GNU General Public License as published by |
---|
8 | the Free Software Foundation; either version 2, or (at your option) |
---|
9 | any later version. |
---|
10 | |
---|
11 | ### File Specific: |
---|
12 | main-programmer: bottac@ee.ethz.ch |
---|
13 | */ |
---|
14 | |
---|
15 | |
---|
16 | #include "vector.h" |
---|
17 | #include "bsp_file.h" |
---|
18 | #include "bsp_manager.h" |
---|
19 | #include "bsp_tree_leaf.h" |
---|
20 | #include "p_node.h" |
---|
21 | #include "state.h" |
---|
22 | #include "debug.h" |
---|
23 | #include "material.h" |
---|
24 | #include "camera.h" |
---|
25 | #include "vertex_array_model.h" |
---|
26 | |
---|
27 | // STL Containers |
---|
28 | #include <vector> |
---|
29 | #include <deque> |
---|
30 | |
---|
31 | |
---|
32 | |
---|
33 | |
---|
34 | BspManager::BspManager() |
---|
35 | { |
---|
36 | // open a BSP file |
---|
37 | this->bspFile = new BspFile(); |
---|
38 | this->bspFile->read("/root/data/Kanti175.bsp"); |
---|
39 | this->bspFile->build_tree(); |
---|
40 | this->root = this->bspFile->get_root(); |
---|
41 | this->alreadyVisible = new bool [this->bspFile->numFaces]; |
---|
42 | } |
---|
43 | |
---|
44 | void BspManager::draw() |
---|
45 | { |
---|
46 | |
---|
47 | |
---|
48 | |
---|
49 | |
---|
50 | |
---|
51 | // Draw Debug Terrain |
---|
52 | /* |
---|
53 | this->bspFile->Materials[0]->select(); |
---|
54 | for(int i = 0; i < this->bspFile->numPatches ; i++) |
---|
55 | { |
---|
56 | this->bspFile->VertexArrayModels[i]->draw(); |
---|
57 | |
---|
58 | } |
---|
59 | */ |
---|
60 | |
---|
61 | |
---|
62 | |
---|
63 | // erase alreadyVisible |
---|
64 | for(int i = 0; i < this->bspFile->numFaces; i++) this->alreadyVisible[i] = false; |
---|
65 | float tmp = 0; |
---|
66 | this->opal.clear(); |
---|
67 | this->trasparent.clear(); |
---|
68 | // Find all visible faces... |
---|
69 | |
---|
70 | this->cam = State::getCamera()->getAbsCoor() ; |
---|
71 | this->ship = State::getCameraTargetNode()->getAbsCoor(); |
---|
72 | |
---|
73 | |
---|
74 | |
---|
75 | |
---|
76 | this->cam = State::getCameraTargetNode()->getAbsCoor(); |
---|
77 | this->viewDir= State::getCameraTarget()->getAbsCoor() - State::getCamera()->getAbsCoor() ; |
---|
78 | float d = (cam.x*viewDir.x + cam.y*viewDir.y + cam.z * viewDir.z); |
---|
79 | |
---|
80 | BspTreeNode* ActLeaf = this->getLeaf(this->bspFile->root, &ship); |
---|
81 | int viscluster = -1; |
---|
82 | viscluster =((leaf*)(this->bspFile->leaves))[ ActLeaf->leafIndex].cluster; // get the players cluster (viscluster) |
---|
83 | |
---|
84 | |
---|
85 | |
---|
86 | |
---|
87 | this->checkCollision(this->root, &this->cam); //!< Test Collision Detection |
---|
88 | |
---|
89 | if (true /*(((int *)(this->bspFile->header))[35] == 0 ) || viscluster < 0*/) //!< if (sizeof(Visdata) == 0) |
---|
90 | { |
---|
91 | /** Do Frustum culling and draw 'em all **/ |
---|
92 | |
---|
93 | // Iterate through all Leafspublic final double readLEDouble() |
---|
94 | for(int i = 0; i < this->bspFile->numLeafs ; i++ ) |
---|
95 | { |
---|
96 | // cluster = (this->bspFile->leaves)[i].cluster; |
---|
97 | leaf& curLeaf = (this->bspFile->leaves)[i]; |
---|
98 | |
---|
99 | |
---|
100 | // Iterate through all faces |
---|
101 | for (int j = 0; j < curLeaf.n_leaffaces ; ++j) { |
---|
102 | const int f = ( j + ((leaf *) (this->bspFile->leaves))[i].leafface) % this->bspFile->numFaces; |
---|
103 | if (f >=0 && !this->isAlreadyVisible(f)) { |
---|
104 | this->alreadyVisible[f] = true; |
---|
105 | /* if(ActLeaf->leafIndex == i)public final double readLEDouble() |
---|
106 | { |
---|
107 | this->alreadyVisible[i] = false; |
---|
108 | this->draw_debug_face(f); |
---|
109 | this->alreadyVisible[i] = true; |
---|
110 | } |
---|
111 | else */ |
---|
112 | addFace(f); // "visibleFaces.append(f)" |
---|
113 | } |
---|
114 | } |
---|
115 | |
---|
116 | |
---|
117 | |
---|
118 | |
---|
119 | } //for |
---|
120 | } else { |
---|
121 | int cluster; |
---|
122 | int seven = 7; |
---|
123 | unsigned char one = 1; |
---|
124 | unsigned int v; |
---|
125 | unsigned char visSet; |
---|
126 | |
---|
127 | // Iterate through all Leafs |
---|
128 | |
---|
129 | for(int i = 0; i < this->bspFile->numLeafs ; ++i ) { |
---|
130 | leaf& camLeaf = (this->bspFile->leaves)[ActLeaf->leafIndex] ; |
---|
131 | leaf& curLeaf = (this->bspFile->leaves)[i] ; |
---|
132 | cluster = curLeaf.cluster; |
---|
133 | |
---|
134 | if(cluster <0) continue; |
---|
135 | v = ((viscluster * ( ((int *)this->bspFile->visData)[1]) ) + (cluster / 8)); |
---|
136 | visSet =((unsigned char*) (this->bspFile->visData))[v+8]; |
---|
137 | |
---|
138 | |
---|
139 | if( ((visSet) & ((unsigned char)1 <<(unsigned char) (cluster & 7))) == 0 ) |
---|
140 | { |
---|
141 | // Iterate through all faces |
---|
142 | for (int j = 0; j < curLeaf.n_leaffaces ; ++j) |
---|
143 | { |
---|
144 | const int f = (j + curLeaf.leafface) % this->bspFile->numFaces; |
---|
145 | |
---|
146 | |
---|
147 | if (!this->isAlreadyVisible(f) && f>=0) { |
---|
148 | this->addFace(f); |
---|
149 | this->alreadyVisible[f] = true; |
---|
150 | } |
---|
151 | |
---|
152 | } |
---|
153 | |
---|
154 | }// if |
---|
155 | |
---|
156 | }//for |
---|
157 | |
---|
158 | }//else |
---|
159 | |
---|
160 | while(!this->opal.empty()) { |
---|
161 | this->draw_face(this->opal.front()); |
---|
162 | this->opal.pop_front(); |
---|
163 | } |
---|
164 | while(!this->trasparent.empty()) { |
---|
165 | this->draw_face(this->trasparent.back()); |
---|
166 | this->trasparent.pop_back(); |
---|
167 | } |
---|
168 | |
---|
169 | |
---|
170 | }//draw |
---|
171 | |
---|
172 | void BspManager::draw_leaf() |
---|
173 | {} |
---|
174 | |
---|
175 | void BspManager::draw_face(int curface) |
---|
176 | { |
---|
177 | face& curFace = (this->bspFile->faces)[curface]; |
---|
178 | const BspVertex* curVertex = (BspVertex *) this->bspFile->vertice; |
---|
179 | int stride = sizeof(BspVertex); // sizeof(Vertex) |
---|
180 | int offset = curFace.vertex; |
---|
181 | |
---|
182 | // PRINTF(0)("BSP Manager: "); |
---|
183 | // PRINTF(0)("BSP Manager: type: %i \n", curFace.texture); |
---|
184 | |
---|
185 | // if( curFace.texture < 0 ) return; |
---|
186 | if(curFace.type == 2) { |
---|
187 | this->draw_patch( &curFace); |
---|
188 | return; |
---|
189 | } |
---|
190 | if(curFace.type == 3) return; |
---|
191 | // if(this->bspFile->Materials[curFace.texture] != NULL) |
---|
192 | |
---|
193 | if(this->lastTex != curFace.texture) { |
---|
194 | this->bspFile->Materials[curFace.texture].mat->select(); |
---|
195 | this->lastTex = curFace.texture; |
---|
196 | } |
---|
197 | |
---|
198 | if(curFace.lm_index < 0) |
---|
199 | { |
---|
200 | glActiveTextureARB(GL_TEXTURE1_ARB); |
---|
201 | glBindTexture(GL_TEXTURE_2D, this->bspFile->whiteLightMap ); |
---|
202 | glEnable(GL_TEXTURE_2D); |
---|
203 | } |
---|
204 | else |
---|
205 | { |
---|
206 | glActiveTextureARB(GL_TEXTURE1_ARB); |
---|
207 | glBindTexture(GL_TEXTURE_2D, this->bspFile->glLightMapTextures[curFace.lm_index]); |
---|
208 | glEnable(GL_TEXTURE_2D); |
---|
209 | } |
---|
210 | |
---|
211 | glColor4f(3.0,3.0,3.0,1.0); |
---|
212 | glEnableClientState(GL_VERTEX_ARRAY ); |
---|
213 | glEnableClientState(GL_TEXTURE_COORD_ARRAY ); |
---|
214 | glEnableClientState(GL_NORMAL_ARRAY ); |
---|
215 | // glEnableClientState(GL_COLOR_ARRAY); |
---|
216 | |
---|
217 | |
---|
218 | glVertexPointer(3, GL_FLOAT, stride, &(curVertex[offset].position[0])); |
---|
219 | |
---|
220 | glClientActiveTextureARB(GL_TEXTURE0_ARB); |
---|
221 | glTexCoordPointer(2, GL_FLOAT, stride, &(curVertex[offset].texcoord[0])); |
---|
222 | glEnableClientState(GL_TEXTURE_COORD_ARRAY); |
---|
223 | |
---|
224 | glClientActiveTextureARB(GL_TEXTURE1_ARB); |
---|
225 | glTexCoordPointer(2, GL_FLOAT, stride, &(curVertex[offset].texcoord[1])); |
---|
226 | //glEnableClientState(GL_TEXTURE_COORD_ARRAY); |
---|
227 | |
---|
228 | |
---|
229 | glNormalPointer( GL_FLOAT, stride, &(curVertex[offset].normal[0])); |
---|
230 | // glColorPointer(4, GL_BYTE, stride, &(curVertex[offset].color[0])); |
---|
231 | glDrawElements(GL_TRIANGLES, curFace.n_meshverts, |
---|
232 | GL_UNSIGNED_INT, &(((meshvert *)this->bspFile->meshverts) [curFace.meshvert])); |
---|
233 | |
---|
234 | glDisableClientState(GL_TEXTURE0_ARB); |
---|
235 | glDisableClientState(GL_TEXTURE1_ARB); |
---|
236 | glDisableClientState(GL_VERTEX_ARRAY ); |
---|
237 | //glDisableClientState(GL_TEXTURE_COORD_ARRAY ); |
---|
238 | glDisableClientState(GL_NORMAL_ARRAY ); |
---|
239 | // glDisableClientState(GL_COLOR_ARRAY); |
---|
240 | |
---|
241 | } |
---|
242 | |
---|
243 | |
---|
244 | void BspManager::draw_debug_face(int curface) |
---|
245 | { |
---|
246 | face& curFace = (this->bspFile->faces)[curface]; |
---|
247 | const BspVertex* curVertex = (BspVertex *) this->bspFile->vertice; |
---|
248 | int stride = 44; // sizeof(Vertex) |
---|
249 | int offset = curFace.vertex; |
---|
250 | |
---|
251 | // PRINTF(0)("BSP Manager: "); |
---|
252 | // PRINTF(0)("BSP Manager: type: %i \n", curFace.texture); |
---|
253 | |
---|
254 | // if( curFace.texture < 0 ) return; |
---|
255 | if(curFace.type == 2) { |
---|
256 | this->draw_patch( &curFace); |
---|
257 | return; |
---|
258 | } |
---|
259 | if(curFace.type == 3) return; |
---|
260 | // if(this->bspFile->Materials[curFace.texture] != NULL) |
---|
261 | |
---|
262 | this->bspFile->Materials[2].mat->select(); |
---|
263 | this->lastTex = 2; |
---|
264 | |
---|
265 | glEnableClientState(GL_VERTEX_ARRAY ); |
---|
266 | glEnableClientState(GL_TEXTURE_COORD_ARRAY ); |
---|
267 | glEnableClientState(GL_NORMAL_ARRAY ); |
---|
268 | //glEnableClientState(GL_COLOR_ARRAY); |
---|
269 | // glEnableClientState(GL_VERTEX_ARRAY ); |
---|
270 | glClientActiveTextureARB(GL_TEXTURE0_ARB); |
---|
271 | glVertexPointer(3, GL_FLOAT, stride, &(curVertex[offset].position[0])); |
---|
272 | glEnableClientState(GL_TEXTURE_COORD_ARRAY); |
---|
273 | // glClientActiveTextureARB(GL_TEXTURE0_ARB); |
---|
274 | glClientActiveTextureARB(GL_TEXTURE1_ARB); |
---|
275 | glTexCoordPointer(2, GL_FLOAT, stride, &(curVertex[offset].texcoord[0])); |
---|
276 | glEnableClientState(GL_TEXTURE_COORD_ARRAY); |
---|
277 | // glClientActiveTextureARB(GL_TEXTURE1_ARB); |
---|
278 | // glTexCoordPointer(2, GL_FLOAT, stride, &(curVertex[offset].texcoord[1])); |
---|
279 | //glEnableClientState(GL_NORMAL_ARRAY ); |
---|
280 | |
---|
281 | glNormalPointer( GL_FLOAT, stride, &(curVertex[offset].normal[0])); |
---|
282 | // glColorPointer(4, GL_BYTE, stride, &(curVertex[offset].color[0])); |
---|
283 | glDrawElements(GL_TRIANGLES, curFace.n_meshverts, |
---|
284 | GL_UNSIGNED_INT, &(((meshvert *)this->bspFile->meshverts) [curFace.meshvert])); |
---|
285 | |
---|
286 | } |
---|
287 | |
---|
288 | void BspManager::draw_patch(face* Face) |
---|
289 | { |
---|
290 | if(this->lastTex != Face->texture) { |
---|
291 | this->bspFile->Materials[Face->texture].mat->select(); |
---|
292 | this->lastTex = Face->texture; |
---|
293 | } |
---|
294 | |
---|
295 | |
---|
296 | |
---|
297 | if(Face->lm_index < 0) |
---|
298 | { |
---|
299 | glActiveTextureARB(GL_TEXTURE1_ARB); |
---|
300 | glBindTexture(GL_TEXTURE_2D, this->bspFile->whiteLightMap); |
---|
301 | glEnable(GL_TEXTURE_2D); |
---|
302 | } |
---|
303 | else |
---|
304 | { |
---|
305 | glActiveTextureARB(GL_TEXTURE1_ARB); |
---|
306 | glBindTexture(GL_TEXTURE_2D, this->bspFile->glLightMapTextures[Face->lm_index]); |
---|
307 | glEnable(GL_TEXTURE_2D); |
---|
308 | } |
---|
309 | glColor4f(3.0,3.0,3.0,1.0); |
---|
310 | |
---|
311 | glEnable( GL_AUTO_NORMAL); |
---|
312 | glEnableClientState(GL_VERTEX_ARRAY ); |
---|
313 | glEnableClientState(GL_TEXTURE_COORD_ARRAY ); |
---|
314 | for(int i = 0; i < Face->n_meshverts ; i++) { |
---|
315 | glFrontFace(GL_CW); |
---|
316 | //PRINTF(0)("BSP Manager: Face->size[0]: %i . \n", Face->size[0]); |
---|
317 | |
---|
318 | |
---|
319 | glEnableClientState(GL_NORMAL_ARRAY ); |
---|
320 | |
---|
321 | glVertexPointer(3, GL_FLOAT,44, &((((BspVertex*)(this->bspFile->patchVertice))[8*8*(Face->meshvert+i)]).position[0])); |
---|
322 | |
---|
323 | |
---|
324 | glClientActiveTextureARB(GL_TEXTURE0_ARB); |
---|
325 | glTexCoordPointer(2, GL_FLOAT, 44, &((((BspVertex*)(this->bspFile->patchVertice))[8*8*(Face->meshvert+i)]).texcoord[0][0])); |
---|
326 | glEnableClientState(GL_TEXTURE_COORD_ARRAY); |
---|
327 | |
---|
328 | |
---|
329 | glClientActiveTextureARB(GL_TEXTURE1_ARB); |
---|
330 | glTexCoordPointer(2, GL_FLOAT, 44, &((((BspVertex*)(this->bspFile->patchVertice))[8*8*(Face->meshvert+i)]).texcoord[1][0])); |
---|
331 | //glEnableClientState(GL_TEXTURE_COORD_ARRAY); |
---|
332 | |
---|
333 | |
---|
334 | glNormalPointer( GL_FLOAT, 44,&((((BspVertex*)(this->bspFile->patchVertice))[8*8*(Face->meshvert+i)]).normal[0]) ); |
---|
335 | |
---|
336 | |
---|
337 | |
---|
338 | |
---|
339 | for(int row=0; row<7; ++row) { |
---|
340 | glDrawElements(GL_TRIANGLE_STRIP, 2*(8), GL_UNSIGNED_INT, |
---|
341 | & ( (((GLuint*) (this->bspFile->patchIndexes))[7*8*2*(Face->meshvert+i)+ row*2*8] )) ); |
---|
342 | } |
---|
343 | |
---|
344 | glFrontFace(GL_CCW); |
---|
345 | } |
---|
346 | glDisableClientState(GL_TEXTURE0_ARB); |
---|
347 | glDisableClientState(GL_TEXTURE1_ARB); |
---|
348 | glDisable(GL_AUTO_NORMAL); |
---|
349 | glDisableClientState(GL_VERTEX_ARRAY ); |
---|
350 | glDisableClientState(GL_TEXTURE_COORD_ARRAY ); |
---|
351 | |
---|
352 | glBegin(GL_QUADS); |
---|
353 | |
---|
354 | glEnd(); |
---|
355 | } |
---|
356 | |
---|
357 | bool BspManager::isAlreadyVisible(int Face) |
---|
358 | { |
---|
359 | return this->alreadyVisible[Face]; |
---|
360 | } |
---|
361 | |
---|
362 | |
---|
363 | BspTreeNode* BspManager::getLeaf(BspTreeNode* node, Vector* cam) |
---|
364 | { |
---|
365 | float dist = 0; |
---|
366 | while(!(node->isLeaf)) { |
---|
367 | dist = (node->plane.x * this->cam.x + node->plane.y*this->cam.y + node->plane.z*this->cam.z) - node->d; |
---|
368 | if(dist >= 0.0f) { |
---|
369 | node = node->left; |
---|
370 | } else { |
---|
371 | node = node->right; |
---|
372 | |
---|
373 | } |
---|
374 | } |
---|
375 | return node; |
---|
376 | } |
---|
377 | |
---|
378 | void BspManager::checkCollision(BspTreeNode* node, Vector* cam) |
---|
379 | { |
---|
380 | float dist = 0; |
---|
381 | if(!(node->isLeaf)) { |
---|
382 | dist = (node->plane.x * this->cam.x + node->plane.y*this->cam.y + node->plane.z*this->cam.z) - node->d; |
---|
383 | if(dist > 4.0f) { |
---|
384 | checkCollision(node->left,cam); |
---|
385 | return; |
---|
386 | } |
---|
387 | if(dist < -4.0f) { |
---|
388 | checkCollision(node->right,cam); |
---|
389 | return; |
---|
390 | } |
---|
391 | if(dist<=4.0f && dist >= -4.0f) { |
---|
392 | checkCollision(node->left,cam); |
---|
393 | checkCollision(node->right,cam); |
---|
394 | return; |
---|
395 | } |
---|
396 | return; |
---|
397 | } else { |
---|
398 | |
---|
399 | leaf& camLeaf = ((leaf *)(this->bspFile->leaves))[(node->leafIndex ) ]; |
---|
400 | |
---|
401 | if (camLeaf.cluster < 0) {this->drawDebugCube(&this->cam);} |
---|
402 | |
---|
403 | |
---|
404 | /* |
---|
405 | for(int i = 0; i < camLeaf.n_leafbrushes && i < 10; i++ ) |
---|
406 | { |
---|
407 | brush& curBrush = ((brush*)(this->bspFile->brushes))[(camLeaf.leafbrush_first +i)%this->bspFile->numLeafBrushes]; |
---|
408 | if(curBrush.n_brushsides < 0) return; |
---|
409 | for(int j = 0; j < curBrush.n_brushsides; j++) |
---|
410 | { |
---|
411 | float dist = -0.1; |
---|
412 | brushside& curBrushSide = ((brushside*)(this->bspFile->brushSides))[(curBrush.brushside +j)%this->bspFile->numBrushSides]; |
---|
413 | plane& testPlane = ((plane*)(this->bspFile->planes))[curBrushSide.plane % this->bspFile->numPlanes]; |
---|
414 | dist = testPlane.x * this->cam.x + testPlane.y * this->cam.y + testPlane.z * this->cam.z -testPlane.d ; |
---|
415 | |
---|
416 | if(dist < -0.01f) dist = -1.0f *dist; |
---|
417 | if(dist < 1.0f){ |
---|
418 | this->drawDebugCube(&this->cam); |
---|
419 | return; |
---|
420 | } |
---|
421 | } |
---|
422 | |
---|
423 | } */ |
---|
424 | |
---|
425 | } |
---|
426 | return; |
---|
427 | } |
---|
428 | |
---|
429 | void BspManager::drawDebugCube(Vector* cam) |
---|
430 | { |
---|
431 | glBegin(GL_QUADS); |
---|
432 | |
---|
433 | // Bottom Face. Red, 75% opaque, magnified texture |
---|
434 | |
---|
435 | glNormal3f( 0.0f, -1.0f, 0.0f); // Needed for lighting |
---|
436 | glColor4f(0.9,0.2,0.2,.75); // Basic polygon color |
---|
437 | |
---|
438 | glTexCoord2f(0.800f, 0.800f); glVertex3f(cam->x-1.0f, cam->y-1.0f,cam->z -1.0f); |
---|
439 | glTexCoord2f(0.200f, 0.800f); glVertex3f(cam->x+1.0f, cam->y-1.0f,cam->z -1.0f); |
---|
440 | glTexCoord2f(0.200f, 0.200f); glVertex3f(cam->x+ 1.0f,cam->y -1.0f,cam->z + 1.0f); |
---|
441 | glTexCoord2f(0.800f, 0.200f); glVertex3f(cam->x-1.0f, cam->y-1.0f, cam->z + 1.0f); |
---|
442 | |
---|
443 | |
---|
444 | // Top face; offset. White, 50% opaque. |
---|
445 | |
---|
446 | glNormal3f( 0.0f, 1.0f, 0.0f); glColor4f(0.5,0.5,0.5,.5); |
---|
447 | |
---|
448 | glTexCoord2f(0.005f, 1.995f); glVertex3f(cam->x-1.0f, cam->y+ 1.0f, cam->z -1.0f); |
---|
449 | glTexCoord2f(0.005f, 0.005f); glVertex3f(cam->x-1.0f, cam->y+ 1.0f, cam->z +1.0f); |
---|
450 | glTexCoord2f(1.995f, 0.005f); glVertex3f(cam->x+ 1.0f, cam->y+1.0f, cam->z +1.0f); |
---|
451 | glTexCoord2f(1.995f, 1.995f); glVertex3f(cam->x+ 1.0f, cam->y+ 1.0f, cam->z -1.0f); |
---|
452 | |
---|
453 | |
---|
454 | // Far face. Green, 50% opaque, non-uniform texture cooridinates. |
---|
455 | |
---|
456 | glNormal3f( 0.0f, 0.0f,-1.0f); glColor4f(0.2,0.9,0.2,.5); |
---|
457 | |
---|
458 | glTexCoord2f(0.995f, 0.005f); glVertex3f(cam->x-1.0f, cam->y-1.0f, cam->z -1.3f); |
---|
459 | glTexCoord2f(2.995f, 2.995f); glVertex3f(cam->x-1.0f, cam->y+ 1.0f, cam->z -1.3f); |
---|
460 | glTexCoord2f(0.005f, 0.995f); glVertex3f(cam->x+ 1.0f,cam->y+ 1.0f, cam->z -1.3f); |
---|
461 | glTexCoord2f(0.005f, 0.005f); glVertex3f( cam->x+1.0f,cam->y -1.0f, cam->z -1.3f); |
---|
462 | |
---|
463 | |
---|
464 | // Right face. Blue; 25% opaque |
---|
465 | |
---|
466 | glNormal3f( 1.0f, 0.0f, 0.0f); glColor4f(0.2,0.2,0.9,.25); |
---|
467 | |
---|
468 | glTexCoord2f(0.995f, 0.005f); glVertex3f(cam->x+ 1.0f, cam->y -1.0f, cam->z -1.0f); |
---|
469 | glTexCoord2f(0.995f, 0.995f); glVertex3f(cam->x+ 1.0f, cam->y+ 1.0f, cam->z -1.0f); |
---|
470 | glTexCoord2f(0.005f, 0.995f); glVertex3f(cam->x+ 1.0f, cam->y+ 1.0f, cam->z + 1.0f); |
---|
471 | glTexCoord2f(0.005f, 0.005f); glVertex3f(cam->x+ 1.0f, cam->y-1.0f, cam->z +1.0f); |
---|
472 | |
---|
473 | |
---|
474 | // Front face; offset. Multi-colored, 50% opaque. |
---|
475 | |
---|
476 | glNormal3f( 0.0f, 0.0f, 1.0f); |
---|
477 | |
---|
478 | glColor4f( 0.9f, 0.2f, 0.2f, 0.5f); |
---|
479 | glTexCoord2f( 0.005f, 0.005f); glVertex3f(cam->x-1.0f, cam->y-1.0f, cam->z +1.0f); |
---|
480 | glColor4f( 0.2f, 0.9f, 0.2f, 0.5f); |
---|
481 | glTexCoord2f( 0.995f, 0.005f); glVertex3f(cam->x+ 1.0f, cam->y-1.0f, cam->z +1.0f); |
---|
482 | glColor4f( 0.2f, 0.2f, 0.9f, 0.5f); |
---|
483 | glTexCoord2f( 0.995f, 0.995f); glVertex3f( cam->x+1.0f, cam->y+1.0f, cam->z +1.0f); |
---|
484 | glColor4f( 0.1f, 0.1f, 0.1f, 0.5f); |
---|
485 | glTexCoord2f( 0.005f, 0.995f); glVertex3f(cam->x-1.0f, cam->y+ 1.0f, cam->z +1.0f); |
---|
486 | |
---|
487 | |
---|
488 | // Left Face; offset. Yellow, varying levels of opaque. |
---|
489 | |
---|
490 | glNormal3f(-1.0f, 0.0f, 0.0f); |
---|
491 | |
---|
492 | glColor4f(0.9,0.9,0.2,0.0); |
---|
493 | glTexCoord2f(0.005f, 0.005f); glVertex3f(cam->x-1.0f, cam->y-1.0f, cam->z -1.0f); |
---|
494 | glColor4f(0.9,0.9,0.2,0.66); |
---|
495 | glTexCoord2f(0.995f, 0.005f); glVertex3f(cam->x-1.0f,cam->y -1.0f, cam->z +1.0f); |
---|
496 | glColor4f(0.9,0.9,0.2,1.0); |
---|
497 | glTexCoord2f(0.995f, 0.995f); glVertex3f(cam->x-1.0f, cam->y+ 1.0f, cam->z +1.0f); |
---|
498 | glColor4f(0.9,0.9,0.2,0.33); |
---|
499 | glTexCoord2f(0.005f, 0.995f); glVertex3f(cam->x-1.0f, cam->y+ 1.0f, cam->z -1.0f); |
---|
500 | |
---|
501 | glEnd(); |
---|
502 | } |
---|
503 | |
---|
504 | void BspManager::addFace(int f) |
---|
505 | { |
---|
506 | face& curFace = ((face *)(this->bspFile->faces))[f]; |
---|
507 | if(this->bspFile->Materials[curFace.texture].alpha) this->trasparent.push_back(f); |
---|
508 | else this->opal.push_back(f); |
---|
509 | } |
---|