[7353] | 1 | /* |
---|
| 2 | orxonox - the future of 3D-vertical-scrollers |
---|
[7395] | 3 | |
---|
[7353] | 4 | Copyright (C) 2006 orx |
---|
[7395] | 5 | |
---|
[7353] | 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. |
---|
[7395] | 10 | |
---|
[7353] | 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" |
---|
[7385] | 19 | #include "bsp_tree_leaf.h" |
---|
[7353] | 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 | |
---|
[7385] | 27 | // STL Containers |
---|
| 28 | #include <vector> |
---|
| 29 | #include <deque> |
---|
[7353] | 30 | |
---|
| 31 | |
---|
| 32 | |
---|
| 33 | |
---|
| 34 | BspManager::BspManager() |
---|
| 35 | { |
---|
[7395] | 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]; |
---|
[7353] | 42 | } |
---|
| 43 | |
---|
| 44 | void BspManager::draw() |
---|
| 45 | { |
---|
| 46 | |
---|
| 47 | |
---|
| 48 | |
---|
| 49 | |
---|
| 50 | |
---|
[7395] | 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 | */ |
---|
[7353] | 60 | |
---|
| 61 | |
---|
| 62 | |
---|
[7395] | 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(); |
---|
[7353] | 68 | // Find all visible faces... |
---|
| 69 | |
---|
[7395] | 70 | this->cam = State::getCamera()->getAbsCoor() ; |
---|
| 71 | this->ship = State::getCameraTargetNode()->getAbsCoor(); |
---|
[7353] | 72 | |
---|
| 73 | |
---|
| 74 | |
---|
| 75 | |
---|
[7395] | 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); |
---|
[7353] | 79 | |
---|
[7395] | 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) |
---|
[7353] | 83 | |
---|
| 84 | |
---|
| 85 | |
---|
[7395] | 86 | |
---|
| 87 | this->checkCollision(this->root, &this->cam); //!< Test Collision Detection |
---|
| 88 | |
---|
| 89 | if ((((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 Leafs |
---|
| 94 | for(int i = 0; i < this->bspFile->numLeafs ; i++ ) |
---|
[7353] | 95 | { |
---|
[7395] | 96 | // cluster = (this->bspFile->leaves)[i].cluster; |
---|
| 97 | leaf& curLeaf = (this->bspFile->leaves)[i]; |
---|
[7353] | 98 | |
---|
| 99 | |
---|
[7395] | 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) |
---|
| 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 | } |
---|
[7353] | 115 | |
---|
| 116 | |
---|
| 117 | |
---|
| 118 | |
---|
[7395] | 119 | } //for |
---|
| 120 | } else { |
---|
| 121 | int cluster; |
---|
| 122 | int seven = 7; |
---|
| 123 | unsigned char one = 1; |
---|
| 124 | unsigned int v; |
---|
| 125 | unsigned char visSet; |
---|
[7353] | 126 | |
---|
[7395] | 127 | // Iterate through all Leafs |
---|
[7385] | 128 | |
---|
[7395] | 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 | |
---|
[7353] | 170 | }//draw |
---|
| 171 | |
---|
| 172 | void BspManager::draw_leaf() |
---|
[7395] | 173 | {} |
---|
[7353] | 174 | |
---|
| 175 | void BspManager::draw_face(int curface) |
---|
| 176 | { |
---|
[7395] | 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 | |
---|
[7353] | 182 | // PRINTF(0)("BSP Manager: "); |
---|
| 183 | // PRINTF(0)("BSP Manager: type: %i \n", curFace.texture); |
---|
[7395] | 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 | if(this->lastTex != curFace.texture) { |
---|
| 193 | this->bspFile->Materials[curFace.texture].mat->select(); |
---|
| 194 | this->lastTex = curFace.texture; |
---|
| 195 | } |
---|
[7353] | 196 | glEnableClientState(GL_VERTEX_ARRAY ); |
---|
| 197 | glEnableClientState(GL_TEXTURE_COORD_ARRAY ); |
---|
| 198 | glEnableClientState(GL_NORMAL_ARRAY ); |
---|
[7395] | 199 | // glEnableClientState(GL_COLOR_ARRAY); |
---|
| 200 | |
---|
| 201 | |
---|
[7353] | 202 | glVertexPointer(3, GL_FLOAT, stride, &(curVertex[offset].position[0])); |
---|
[7395] | 203 | // glClientActiveTextureARB(GL_TEXTURE0_ARB); |
---|
[7353] | 204 | glTexCoordPointer(2, GL_FLOAT, stride, &(curVertex[offset].texcoord[0])); |
---|
[7395] | 205 | // glClientActiveTextureARB(GL_TEXTURE1_ARB); |
---|
| 206 | // glTexCoordPointer(2, GL_FLOAT, stride, &(curVertex[offset].texcoord[1])); |
---|
[7353] | 207 | |
---|
[7395] | 208 | |
---|
[7353] | 209 | glNormalPointer( GL_FLOAT, stride, &(curVertex[offset].normal[0])); |
---|
[7395] | 210 | // glColorPointer(4, GL_BYTE, stride, &(curVertex[offset].color[0])); |
---|
[7353] | 211 | glDrawElements(GL_TRIANGLES, curFace.n_meshverts, |
---|
[7395] | 212 | GL_UNSIGNED_INT, &(((meshvert *)this->bspFile->meshverts) [curFace.meshvert])); |
---|
[7353] | 213 | |
---|
| 214 | |
---|
| 215 | glDisableClientState(GL_VERTEX_ARRAY ); |
---|
| 216 | glDisableClientState(GL_TEXTURE_COORD_ARRAY ); |
---|
| 217 | glDisableClientState(GL_NORMAL_ARRAY ); |
---|
[7395] | 218 | // glDisableClientState(GL_COLOR_ARRAY); |
---|
| 219 | |
---|
[7353] | 220 | } |
---|
| 221 | |
---|
| 222 | |
---|
| 223 | void BspManager::draw_debug_face(int curface) |
---|
| 224 | { |
---|
[7395] | 225 | face& curFace = (this->bspFile->faces)[curface]; |
---|
| 226 | const BspVertex* curVertex = (BspVertex *) this->bspFile->vertice; |
---|
| 227 | int stride = 44; // sizeof(Vertex) |
---|
| 228 | int offset = curFace.vertex; |
---|
| 229 | |
---|
[7353] | 230 | // PRINTF(0)("BSP Manager: "); |
---|
| 231 | // PRINTF(0)("BSP Manager: type: %i \n", curFace.texture); |
---|
| 232 | |
---|
[7395] | 233 | // if( curFace.texture < 0 ) return; |
---|
| 234 | if(curFace.type == 2) { |
---|
| 235 | this->draw_patch( &curFace); |
---|
| 236 | return; |
---|
| 237 | } |
---|
| 238 | if(curFace.type == 3) return; |
---|
| 239 | // if(this->bspFile->Materials[curFace.texture] != NULL) |
---|
[7353] | 240 | |
---|
[7395] | 241 | this->bspFile->Materials[2].mat->select(); |
---|
| 242 | this->lastTex = 2; |
---|
| 243 | |
---|
[7353] | 244 | glEnableClientState(GL_VERTEX_ARRAY ); |
---|
| 245 | glEnableClientState(GL_TEXTURE_COORD_ARRAY ); |
---|
| 246 | glEnableClientState(GL_NORMAL_ARRAY ); |
---|
[7395] | 247 | //glEnableClientState(GL_COLOR_ARRAY); |
---|
[7353] | 248 | // glEnableClientState(GL_VERTEX_ARRAY ); |
---|
[7395] | 249 | |
---|
[7353] | 250 | glVertexPointer(3, GL_FLOAT, stride, &(curVertex[offset].position[0])); |
---|
[7395] | 251 | // glClientActiveTextureARB(GL_TEXTURE0_ARB); |
---|
[7353] | 252 | glTexCoordPointer(2, GL_FLOAT, stride, &(curVertex[offset].texcoord[0])); |
---|
[7395] | 253 | // glClientActiveTextureARB(GL_TEXTURE1_ARB); |
---|
| 254 | // glTexCoordPointer(2, GL_FLOAT, stride, &(curVertex[offset].texcoord[1])); |
---|
| 255 | //glEnableClientState(GL_NORMAL_ARRAY ); |
---|
[7353] | 256 | |
---|
| 257 | glNormalPointer( GL_FLOAT, stride, &(curVertex[offset].normal[0])); |
---|
[7395] | 258 | // glColorPointer(4, GL_BYTE, stride, &(curVertex[offset].color[0])); |
---|
[7353] | 259 | glDrawElements(GL_TRIANGLES, curFace.n_meshverts, |
---|
[7395] | 260 | GL_UNSIGNED_INT, &(((meshvert *)this->bspFile->meshverts) [curFace.meshvert])); |
---|
| 261 | |
---|
[7353] | 262 | } |
---|
| 263 | |
---|
| 264 | void BspManager::draw_patch(face* Face) |
---|
| 265 | { |
---|
[7395] | 266 | if(this->lastTex != Face->texture) { |
---|
| 267 | this->bspFile->Materials[Face->texture].mat->select(); |
---|
| 268 | this->lastTex = Face->texture; |
---|
| 269 | } |
---|
[7353] | 270 | |
---|
[7395] | 271 | for(int i = 0; i < Face->n_meshverts ; i++) { |
---|
| 272 | //glFrontFace(GL_CW); |
---|
| 273 | //PRINTF(0)("BSP Manager: Face->size[0]: %i . \n", Face->size[0]); |
---|
| 274 | glEnableClientState(GL_VERTEX_ARRAY ); |
---|
| 275 | glEnableClientState(GL_TEXTURE_COORD_ARRAY ); |
---|
| 276 | glEnableClientState(GL_NORMAL_ARRAY ); |
---|
[7353] | 277 | |
---|
[7395] | 278 | glVertexPointer(3, GL_FLOAT,44, &((((BspVertex*)(this->bspFile->patchVertice))[8*8*(Face->meshvert+i)]).position[0])); |
---|
| 279 | glTexCoordPointer(2, GL_FLOAT, 44, &((((BspVertex*)(this->bspFile->patchVertice))[8*8*(Face->meshvert+i)]).texcoord[0][0])); |
---|
| 280 | glNormalPointer( GL_FLOAT, 44,&((((BspVertex*)(this->bspFile->patchVertice))[8*8*(Face->meshvert+i)]).normal[0]) ); |
---|
[7353] | 281 | |
---|
[7395] | 282 | // We'll need multitexture suport for lightning |
---|
| 283 | //glClientActiveTextureARB(GL_TEXTURE0_ARB); |
---|
| 284 | //glTexCoordPointer(2, GL_FLOAT,0, &vertex[0].textureCoord); |
---|
| 285 | //glClientActiveTextureARB(GL_TEXTURE1_ARB); |
---|
| 286 | //glTexCoordPointer(2, GL_FLOAT, sizeof(BSPVertex), &vertex[0].lightmapCoord); |
---|
[7353] | 287 | |
---|
| 288 | |
---|
[7395] | 289 | for(int row=0; row<7; ++row) { |
---|
| 290 | glDrawElements(GL_TRIANGLE_STRIP, 2*(8), GL_UNSIGNED_INT, |
---|
| 291 | & ( (((GLuint*) (this->bspFile->patchIndexes))[7*8*2*(Face->meshvert+i)+ row*2*8] )) ); |
---|
| 292 | } |
---|
[7353] | 293 | |
---|
[7395] | 294 | //glFrontFace(GL_CCW); |
---|
| 295 | } |
---|
| 296 | |
---|
[7353] | 297 | } |
---|
| 298 | |
---|
| 299 | bool BspManager::isAlreadyVisible(int Face) |
---|
| 300 | { |
---|
[7395] | 301 | return this->alreadyVisible[Face]; |
---|
[7353] | 302 | } |
---|
| 303 | |
---|
| 304 | |
---|
| 305 | BspTreeNode* BspManager::getLeaf(BspTreeNode* node, Vector* cam) |
---|
| 306 | { |
---|
[7395] | 307 | float dist = 0; |
---|
| 308 | while(!(node->isLeaf)) { |
---|
| 309 | dist = (node->plane.x * this->cam.x + node->plane.y*this->cam.y + node->plane.z*this->cam.z) - node->d; |
---|
| 310 | if(dist >= 0.0f) { |
---|
| 311 | node = node->left; |
---|
| 312 | } else { |
---|
| 313 | node = node->right; |
---|
| 314 | |
---|
| 315 | } |
---|
| 316 | } |
---|
| 317 | return node; |
---|
[7353] | 318 | } |
---|
| 319 | |
---|
| 320 | void BspManager::checkCollision(BspTreeNode* node, Vector* cam) |
---|
| 321 | { |
---|
[7395] | 322 | float dist = 0; |
---|
| 323 | if(!(node->isLeaf)) { |
---|
| 324 | dist = (node->plane.x * this->cam.x + node->plane.y*this->cam.y + node->plane.z*this->cam.z) - node->d; |
---|
| 325 | if(dist > 4.0f) { |
---|
| 326 | checkCollision(node->left,cam); |
---|
| 327 | return; |
---|
| 328 | } |
---|
| 329 | if(dist < -4.0f) { |
---|
| 330 | checkCollision(node->right,cam); |
---|
| 331 | return; |
---|
| 332 | } |
---|
| 333 | if(dist<=4.0f && dist >= -4.0f) { |
---|
| 334 | checkCollision(node->left,cam); |
---|
| 335 | checkCollision(node->right,cam); |
---|
| 336 | return; |
---|
| 337 | } |
---|
| 338 | return; |
---|
| 339 | } else { |
---|
[7353] | 340 | |
---|
[7395] | 341 | leaf& camLeaf = ((leaf *)(this->bspFile->leaves))[(node->leafIndex ) ]; |
---|
[7353] | 342 | |
---|
[7395] | 343 | if (camLeaf.cluster < 0) {this->drawDebugCube(&this->cam);} |
---|
| 344 | |
---|
| 345 | |
---|
| 346 | /* |
---|
| 347 | for(int i = 0; i < camLeaf.n_leafbrushes && i < 10; i++ ) |
---|
| 348 | { |
---|
| 349 | brush& curBrush = ((brush*)(this->bspFile->brushes))[(camLeaf.leafbrush_first +i)%this->bspFile->numLeafBrushes]; |
---|
| 350 | if(curBrush.n_brushsides < 0) return; |
---|
| 351 | for(int j = 0; j < curBrush.n_brushsides; j++) |
---|
| 352 | { |
---|
| 353 | float dist = -0.1; |
---|
| 354 | brushside& curBrushSide = ((brushside*)(this->bspFile->brushSides))[(curBrush.brushside +j)%this->bspFile->numBrushSides]; |
---|
| 355 | plane& testPlane = ((plane*)(this->bspFile->planes))[curBrushSide.plane % this->bspFile->numPlanes]; |
---|
| 356 | dist = testPlane.x * this->cam.x + testPlane.y * this->cam.y + testPlane.z * this->cam.z -testPlane.d ; |
---|
| 357 | |
---|
| 358 | if(dist < -0.01f) dist = -1.0f *dist; |
---|
| 359 | if(dist < 1.0f){ |
---|
| 360 | this->drawDebugCube(&this->cam); |
---|
| 361 | return; |
---|
| 362 | } |
---|
| 363 | } |
---|
| 364 | |
---|
| 365 | } */ |
---|
| 366 | |
---|
| 367 | } |
---|
| 368 | return; |
---|
[7353] | 369 | } |
---|
| 370 | |
---|
| 371 | void BspManager::drawDebugCube(Vector* cam) |
---|
| 372 | { |
---|
[7395] | 373 | glBegin(GL_QUADS); |
---|
[7353] | 374 | |
---|
[7395] | 375 | // Bottom Face. Red, 75% opaque, magnified texture |
---|
[7353] | 376 | |
---|
[7395] | 377 | glNormal3f( 0.0f, -1.0f, 0.0f); // Needed for lighting |
---|
| 378 | glColor4f(0.9,0.2,0.2,.75); // Basic polygon color |
---|
[7353] | 379 | |
---|
[7395] | 380 | glTexCoord2f(0.800f, 0.800f); glVertex3f(cam->x-1.0f, cam->y-1.0f,cam->z -1.0f); |
---|
| 381 | glTexCoord2f(0.200f, 0.800f); glVertex3f(cam->x+1.0f, cam->y-1.0f,cam->z -1.0f); |
---|
| 382 | glTexCoord2f(0.200f, 0.200f); glVertex3f(cam->x+ 1.0f,cam->y -1.0f,cam->z + 1.0f); |
---|
| 383 | glTexCoord2f(0.800f, 0.200f); glVertex3f(cam->x-1.0f, cam->y-1.0f, cam->z + 1.0f); |
---|
[7353] | 384 | |
---|
| 385 | |
---|
[7395] | 386 | // Top face; offset. White, 50% opaque. |
---|
[7353] | 387 | |
---|
[7395] | 388 | glNormal3f( 0.0f, 1.0f, 0.0f); glColor4f(0.5,0.5,0.5,.5); |
---|
[7353] | 389 | |
---|
[7395] | 390 | glTexCoord2f(0.005f, 1.995f); glVertex3f(cam->x-1.0f, cam->y+ 1.0f, cam->z -1.0f); |
---|
| 391 | glTexCoord2f(0.005f, 0.005f); glVertex3f(cam->x-1.0f, cam->y+ 1.0f, cam->z +1.0f); |
---|
| 392 | glTexCoord2f(1.995f, 0.005f); glVertex3f(cam->x+ 1.0f, cam->y+1.0f, cam->z +1.0f); |
---|
| 393 | glTexCoord2f(1.995f, 1.995f); glVertex3f(cam->x+ 1.0f, cam->y+ 1.0f, cam->z -1.0f); |
---|
[7353] | 394 | |
---|
| 395 | |
---|
[7395] | 396 | // Far face. Green, 50% opaque, non-uniform texture cooridinates. |
---|
[7353] | 397 | |
---|
[7395] | 398 | glNormal3f( 0.0f, 0.0f,-1.0f); glColor4f(0.2,0.9,0.2,.5); |
---|
[7353] | 399 | |
---|
[7395] | 400 | glTexCoord2f(0.995f, 0.005f); glVertex3f(cam->x-1.0f, cam->y-1.0f, cam->z -1.3f); |
---|
| 401 | glTexCoord2f(2.995f, 2.995f); glVertex3f(cam->x-1.0f, cam->y+ 1.0f, cam->z -1.3f); |
---|
| 402 | glTexCoord2f(0.005f, 0.995f); glVertex3f(cam->x+ 1.0f,cam->y+ 1.0f, cam->z -1.3f); |
---|
| 403 | glTexCoord2f(0.005f, 0.005f); glVertex3f( cam->x+1.0f,cam->y -1.0f, cam->z -1.3f); |
---|
[7353] | 404 | |
---|
| 405 | |
---|
[7395] | 406 | // Right face. Blue; 25% opaque |
---|
[7353] | 407 | |
---|
[7395] | 408 | glNormal3f( 1.0f, 0.0f, 0.0f); glColor4f(0.2,0.2,0.9,.25); |
---|
[7353] | 409 | |
---|
[7395] | 410 | glTexCoord2f(0.995f, 0.005f); glVertex3f(cam->x+ 1.0f,cam->y -1.0f, cam->z -1.0f); |
---|
| 411 | glTexCoord2f(0.995f, 0.995f); glVertex3f(cam->x+ 1.0f, cam->y+ 1.0f, cam->z -1.0f); |
---|
| 412 | glTexCoord2f(0.005f, 0.995f); glVertex3f(cam->x+ 1.0f, cam->y+ 1.0f, cam->z + 1.0f); |
---|
| 413 | glTexCoord2f(0.005f, 0.005f); glVertex3f(cam->x+ 1.0f, cam->y-1.0f, cam->z +1.0f); |
---|
[7353] | 414 | |
---|
| 415 | |
---|
[7395] | 416 | // Front face; offset. Multi-colored, 50% opaque. |
---|
[7353] | 417 | |
---|
[7395] | 418 | glNormal3f( 0.0f, 0.0f, 1.0f); |
---|
[7353] | 419 | |
---|
[7395] | 420 | glColor4f( 0.9f, 0.2f, 0.2f, 0.5f); |
---|
| 421 | glTexCoord2f( 0.005f, 0.005f); glVertex3f(cam->x-1.0f, cam->y-1.0f, cam->z +1.0f); |
---|
| 422 | glColor4f( 0.2f, 0.9f, 0.2f, 0.5f); |
---|
| 423 | glTexCoord2f( 0.995f, 0.005f); glVertex3f(cam->x+ 1.0f, cam->y-1.0f, cam->z +1.0f); |
---|
| 424 | glColor4f( 0.2f, 0.2f, 0.9f, 0.5f); |
---|
| 425 | glTexCoord2f( 0.995f, 0.995f); glVertex3f( cam->x+1.0f, cam->y+1.0f, cam->z +1.0f); |
---|
| 426 | glColor4f( 0.1f, 0.1f, 0.1f, 0.5f); |
---|
| 427 | glTexCoord2f( 0.005f, 0.995f); glVertex3f(cam->x-1.0f, cam->y+ 1.0f, cam->z +1.0f); |
---|
| 428 | |
---|
| 429 | |
---|
| 430 | // Left Face; offset. Yellow, varying levels of opaque. |
---|
| 431 | |
---|
| 432 | glNormal3f(-1.0f, 0.0f, 0.0f); |
---|
| 433 | |
---|
| 434 | glColor4f(0.9,0.9,0.2,0.0); |
---|
| 435 | glTexCoord2f(0.005f, 0.005f); glVertex3f(cam->x-1.0f, cam->y-1.0f, cam->z -1.0f); |
---|
| 436 | glColor4f(0.9,0.9,0.2,0.66); |
---|
| 437 | glTexCoord2f(0.995f, 0.005f); glVertex3f(cam->x-1.0f,cam->y -1.0f, cam->z +1.0f); |
---|
| 438 | glColor4f(0.9,0.9,0.2,1.0); |
---|
| 439 | glTexCoord2f(0.995f, 0.995f); glVertex3f(cam->x-1.0f, cam->y+ 1.0f, cam->z +1.0f); |
---|
| 440 | glColor4f(0.9,0.9,0.2,0.33); |
---|
| 441 | glTexCoord2f(0.005f, 0.995f); glVertex3f(cam->x-1.0f, cam->y+ 1.0f, cam->z -1.0f); |
---|
| 442 | |
---|
| 443 | glEnd(); |
---|
[7385] | 444 | } |
---|
[7353] | 445 | |
---|
[7385] | 446 | void BspManager::addFace(int f) |
---|
| 447 | { |
---|
[7395] | 448 | face& curFace = ((face *)(this->bspFile->faces))[f]; |
---|
| 449 | if(this->bspFile->Materials[curFace.texture].alpha) this->trasparent.push_back(f); |
---|
| 450 | else this->opal.push_back(f); |
---|
| 451 | } |
---|