[7353] | 1 | /* |
---|
| 2 | orxonox - the future of 3D-vertical-scrollers |
---|
[7511] | 3 | |
---|
[7353] | 4 | Copyright (C) 2006 orx |
---|
[7511] | 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. |
---|
[7511] | 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" |
---|
[7579] | 26 | #include "world_entities/player.h" |
---|
| 27 | #include "world_entities/playable.h" |
---|
[7596] | 28 | #include "util/loading/resource_manager.h" |
---|
[7385] | 29 | // STL Containers |
---|
| 30 | #include <vector> |
---|
| 31 | #include <deque> |
---|
[7801] | 32 | #include "movie_player.h" |
---|
[7353] | 33 | |
---|
[7833] | 34 | #include "cd_engine.h" |
---|
[7353] | 35 | |
---|
[7833] | 36 | #include "world_entity.h" |
---|
[7353] | 37 | |
---|
| 38 | BspManager::BspManager() |
---|
| 39 | { |
---|
[7395] | 40 | // open a BSP file |
---|
| 41 | this->bspFile = new BspFile(); |
---|
[7596] | 42 | this->bspFile->read(ResourceManager::getFullName("test.bsp").c_str()); |
---|
[7395] | 43 | this->bspFile->build_tree(); |
---|
| 44 | this->root = this->bspFile->get_root(); |
---|
| 45 | this->alreadyVisible = new bool [this->bspFile->numFaces]; |
---|
[7833] | 46 | |
---|
| 47 | CDEngine::getInstance()->setBSPModel(this); |
---|
[7353] | 48 | } |
---|
| 49 | |
---|
| 50 | void BspManager::draw() |
---|
| 51 | { |
---|
| 52 | |
---|
| 53 | |
---|
| 54 | |
---|
| 55 | |
---|
| 56 | |
---|
[7395] | 57 | // Draw Debug Terrain |
---|
| 58 | /* |
---|
[7511] | 59 | this->bspFile->Materials[0]->select(); |
---|
[7395] | 60 | for(int i = 0; i < this->bspFile->numPatches ; i++) |
---|
[7511] | 61 | { |
---|
| 62 | this->bspFile->VertexArrayModels[i]->draw(); |
---|
| 63 | |
---|
| 64 | } |
---|
[7395] | 65 | */ |
---|
[7353] | 66 | |
---|
| 67 | |
---|
| 68 | |
---|
[7395] | 69 | // erase alreadyVisible |
---|
| 70 | for(int i = 0; i < this->bspFile->numFaces; i++) this->alreadyVisible[i] = false; |
---|
| 71 | float tmp = 0; |
---|
[7579] | 72 | //this->opal.clear(); |
---|
| 73 | //this->trasparent.clear(); |
---|
[7353] | 74 | // Find all visible faces... |
---|
| 75 | |
---|
[7395] | 76 | this->cam = State::getCamera()->getAbsCoor() ; |
---|
[7579] | 77 | //this->ship = State::getCameraTargetNode()->getAbsCoor(); |
---|
[7353] | 78 | |
---|
| 79 | |
---|
| 80 | |
---|
| 81 | |
---|
[7833] | 82 | |
---|
| 83 | // this->viewDir= State::getCameraTarget()->getAbsCoor() - State::getCamera()->getAbsCoor() ; |
---|
[7395] | 84 | float d = (cam.x*viewDir.x + cam.y*viewDir.y + cam.z * viewDir.z); |
---|
[7353] | 85 | |
---|
[7395] | 86 | BspTreeNode* ActLeaf = this->getLeaf(this->bspFile->root, &ship); |
---|
| 87 | int viscluster = -1; |
---|
| 88 | viscluster =((leaf*)(this->bspFile->leaves))[ ActLeaf->leafIndex].cluster; // get the players cluster (viscluster) |
---|
[7353] | 89 | |
---|
| 90 | |
---|
| 91 | |
---|
[7563] | 92 | this->cam = State::getCameraTargetNode()->getAbsCoor(); |
---|
[7833] | 93 | // this->checkCollision(this->root, &this->cam); //!< Test Collision Detection |
---|
[7563] | 94 | this->outputStartsOut = true; |
---|
| 95 | this->outputAllSolid = false; |
---|
| 96 | this->outputFraction = 1.0f; |
---|
[7833] | 97 | |
---|
[7801] | 98 | this->checkCollisionRay(this->root,0.0f,1.0f, &(State::getCameraTargetNode()->getLastAbsCoor()), &this->cam); |
---|
[7833] | 99 | |
---|
[7563] | 100 | if(this->outputFraction != 1.0f || this->outputAllSolid ) this->drawDebugCube(&this->cam); |
---|
[7395] | 101 | |
---|
[7801] | 102 | if ( viscluster < 0 || ((int *)(this->bspFile->header))[35] == 0 ) //!< if (sizeof(Visdata) == 0) |
---|
[7395] | 103 | { |
---|
[7833] | 104 | |
---|
| 105 | |
---|
| 106 | |
---|
[7465] | 107 | // Iterate through all Leafspublic final double readLEDouble() |
---|
[7395] | 108 | for(int i = 0; i < this->bspFile->numLeafs ; i++ ) |
---|
[7353] | 109 | { |
---|
[7395] | 110 | // cluster = (this->bspFile->leaves)[i].cluster; |
---|
| 111 | leaf& curLeaf = (this->bspFile->leaves)[i]; |
---|
[7563] | 112 | if(curLeaf.cluster<0) continue; |
---|
[7833] | 113 | |
---|
| 114 | |
---|
[7563] | 115 | /** Do Frustum culling and draw 'em all **/ |
---|
| 116 | bool inFrustum = true; |
---|
[7801] | 117 | |
---|
[7563] | 118 | Vector dir; |
---|
[7833] | 119 | dir.x = State::getCameraNode()->getAbsDirZ().x; |
---|
| 120 | dir.y = State::getCameraNode()->getAbsDirZ().y; |
---|
| 121 | dir.z = State::getCameraNode()->getAbsDirZ().z; |
---|
[7563] | 122 | float dist = dir.x*this->cam.x +dir.y*this->cam.y +dir.z*this->cam.z; |
---|
| 123 | //if(dist < 0) dist = -dist; |
---|
[7801] | 124 | const float dMins = dir.x*(float)curLeaf.mins[0] +dir.y*(float)curLeaf.mins[1] +dir.z*(float)curLeaf.mins[2] - dist ; |
---|
| 125 | const float dMaxs = dir.x*(float)curLeaf.maxs[0] +dir.y*(float)curLeaf.maxs[1] +dir.z*(float)curLeaf.maxs[2] - dist ; |
---|
[7833] | 126 | |
---|
| 127 | if(dMins < -1.0 && dMaxs < -1.0) { |
---|
| 128 | //continue; |
---|
[7563] | 129 | } |
---|
[7833] | 130 | if( (this->cam - Vector(curLeaf.mins[0],curLeaf.mins[1], curLeaf.mins[2])).len() > 3000 && (this->cam - Vector(curLeaf.maxs[0],curLeaf.maxs[1], curLeaf.maxs[2])).len() > 3000) { |
---|
| 131 | //continue; |
---|
[7801] | 132 | } |
---|
[7833] | 133 | |
---|
| 134 | |
---|
[7395] | 135 | // Iterate through all faces |
---|
| 136 | for (int j = 0; j < curLeaf.n_leaffaces ; ++j) { |
---|
[7596] | 137 | const int g = (j + curLeaf.leafface); |
---|
| 138 | const int f = ((int *)this->bspFile->leafFaces)[g]; |
---|
[7395] | 139 | if (f >=0 && !this->isAlreadyVisible(f)) { |
---|
| 140 | this->alreadyVisible[f] = true; |
---|
[7833] | 141 | |
---|
[7395] | 142 | addFace(f); // "visibleFaces.append(f)" |
---|
| 143 | } |
---|
| 144 | } |
---|
[7353] | 145 | |
---|
| 146 | |
---|
| 147 | |
---|
| 148 | |
---|
[7395] | 149 | } //for |
---|
[7833] | 150 | } else { |
---|
[7579] | 151 | |
---|
[7833] | 152 | |
---|
[7395] | 153 | unsigned int v; |
---|
| 154 | unsigned char visSet; |
---|
[7353] | 155 | |
---|
[7395] | 156 | // Iterate through all Leafs |
---|
[7385] | 157 | |
---|
[7395] | 158 | for(int i = 0; i < this->bspFile->numLeafs ; ++i ) { |
---|
| 159 | leaf& camLeaf = (this->bspFile->leaves)[ActLeaf->leafIndex] ; |
---|
| 160 | leaf& curLeaf = (this->bspFile->leaves)[i] ; |
---|
[7579] | 161 | int& cluster = curLeaf.cluster; |
---|
[7563] | 162 | |
---|
| 163 | if(cluster < 0) continue; |
---|
[7395] | 164 | v = ((viscluster * ( ((int *)this->bspFile->visData)[1]) ) + (cluster / 8)); |
---|
[7579] | 165 | visSet =((char*) (this->bspFile->visData))[v + 8]; |
---|
[7563] | 166 | |
---|
[7833] | 167 | // gets bit of visSet |
---|
[7579] | 168 | if( ((visSet) & (1 << (cluster & 7))) != 0 ) { |
---|
[7833] | 169 | |
---|
[7592] | 170 | // Frustum culling |
---|
[7833] | 171 | |
---|
[7592] | 172 | Vector dir; |
---|
[7833] | 173 | dir.x = State::getCameraNode()->getAbsDirX().x; |
---|
| 174 | dir.y = State::getCameraNode()->getAbsDirX().y; |
---|
| 175 | dir.z = State::getCameraNode()->getAbsDirX().z; |
---|
[7592] | 176 | const float dist = dir.x*this->cam.x +dir.y*this->cam.y +dir.z*this->cam.z; |
---|
[7833] | 177 | //if(dist < 0) dist = -dist; |
---|
[7592] | 178 | const float dMins = dir.x*(float)curLeaf.mins[0] +dir.y*(float)curLeaf.mins[1] +dir.z*(float)curLeaf.mins[2] - dist; |
---|
| 179 | const float dMaxs = dir.x*(float)curLeaf.maxs[0] +dir.y*(float)curLeaf.maxs[1] +dir.z*(float)curLeaf.maxs[2] - dist; |
---|
[7833] | 180 | |
---|
| 181 | if(dMins < -30.0 && dMaxs < -30.0) { |
---|
| 182 | continue; |
---|
[7592] | 183 | } |
---|
[7833] | 184 | |
---|
| 185 | |
---|
[7395] | 186 | // Iterate through all faces |
---|
[7563] | 187 | for (int j = 0; j < curLeaf.n_leaffaces ; ++j) { |
---|
[7579] | 188 | const int g = (j + curLeaf.leafface); |
---|
| 189 | const int f = ((int *)this->bspFile->leafFaces)[g]; |
---|
[7395] | 190 | |
---|
| 191 | if (!this->isAlreadyVisible(f) && f>=0) { |
---|
| 192 | this->addFace(f); |
---|
| 193 | this->alreadyVisible[f] = true; |
---|
| 194 | } |
---|
| 195 | |
---|
| 196 | } |
---|
| 197 | |
---|
[7563] | 198 | }// if |
---|
[7395] | 199 | |
---|
| 200 | }//for |
---|
| 201 | |
---|
| 202 | }//else |
---|
| 203 | |
---|
| 204 | while(!this->opal.empty()) { |
---|
| 205 | this->draw_face(this->opal.front()); |
---|
| 206 | this->opal.pop_front(); |
---|
| 207 | } |
---|
| 208 | while(!this->trasparent.empty()) { |
---|
| 209 | this->draw_face(this->trasparent.back()); |
---|
| 210 | this->trasparent.pop_back(); |
---|
| 211 | } |
---|
[7801] | 212 | glActiveTextureARB(GL_TEXTURE1_ARB); |
---|
| 213 | glBindTexture(GL_TEXTURE_2D, this->bspFile->whiteLightMap); |
---|
| 214 | glEnable(GL_TEXTURE_2D); |
---|
[7395] | 215 | |
---|
[7353] | 216 | }//draw |
---|
| 217 | |
---|
| 218 | |
---|
[7563] | 219 | |
---|
[7353] | 220 | void BspManager::draw_face(int curface) |
---|
| 221 | { |
---|
[7395] | 222 | face& curFace = (this->bspFile->faces)[curface]; |
---|
| 223 | const BspVertex* curVertex = (BspVertex *) this->bspFile->vertice; |
---|
| 224 | int stride = sizeof(BspVertex); // sizeof(Vertex) |
---|
| 225 | int offset = curFace.vertex; |
---|
[7801] | 226 | if (curFace.effect != -1) return; |
---|
[7353] | 227 | // PRINTF(0)("BSP Manager: "); |
---|
| 228 | // PRINTF(0)("BSP Manager: type: %i \n", curFace.texture); |
---|
[7395] | 229 | |
---|
| 230 | // if( curFace.texture < 0 ) return; |
---|
| 231 | if(curFace.type == 2) { |
---|
| 232 | this->draw_patch( &curFace); |
---|
| 233 | return; |
---|
| 234 | } |
---|
[7801] | 235 | if(curFace.type != 1) return; |
---|
| 236 | if((char*)(this->bspFile->textures)[curFace.texture*72]== 0) return; |
---|
[7563] | 237 | |
---|
[7544] | 238 | if(this->lastTex != curFace.texture) { |
---|
[7833] | 239 | if(this->bspFile->Materials[curFace.texture].animated) { |
---|
[7801] | 240 | glBlendFunc(GL_ONE,GL_ONE_MINUS_SRC_COLOR); |
---|
| 241 | glEnable(GL_BLEND); |
---|
| 242 | if(this->bspFile->Materials[curFace.texture].aviMat->getStatus() == 2) this->bspFile->Materials[curFace.texture].aviMat->start(0); |
---|
| 243 | this->bspFile->Materials[curFace.texture].aviMat->tick(0.005); |
---|
| 244 | int n = this->bspFile->Materials[curFace.texture].aviMat->getTexture(); |
---|
| 245 | glActiveTextureARB(GL_TEXTURE0_ARB); |
---|
| 246 | glBindTexture(GL_TEXTURE_2D, n ); |
---|
| 247 | glDisable(GL_BLEND); |
---|
[7833] | 248 | } else { |
---|
| 249 | this->bspFile->Materials[curFace.texture].mat->select(); |
---|
| 250 | this->lastTex = curFace.texture; |
---|
[7801] | 251 | } |
---|
[7544] | 252 | } |
---|
[7563] | 253 | |
---|
| 254 | if(curFace.lm_index < 0) { |
---|
[7465] | 255 | glActiveTextureARB(GL_TEXTURE1_ARB); |
---|
[7563] | 256 | glBindTexture(GL_TEXTURE_2D, this->bspFile->whiteLightMap ); |
---|
| 257 | glEnable(GL_TEXTURE_2D); |
---|
| 258 | } else { |
---|
| 259 | glActiveTextureARB(GL_TEXTURE1_ARB); |
---|
[7465] | 260 | glBindTexture(GL_TEXTURE_2D, this->bspFile->glLightMapTextures[curFace.lm_index]); |
---|
| 261 | glEnable(GL_TEXTURE_2D); |
---|
[7563] | 262 | } |
---|
| 263 | |
---|
[7801] | 264 | glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
---|
[7833] | 265 | |
---|
| 266 | // glColor4f(3.0,3.0,3.0,1.0); |
---|
[7544] | 267 | glEnableClientState(GL_VERTEX_ARRAY ); |
---|
| 268 | glEnableClientState(GL_TEXTURE_COORD_ARRAY ); |
---|
[7353] | 269 | glEnableClientState(GL_NORMAL_ARRAY ); |
---|
[7395] | 270 | // glEnableClientState(GL_COLOR_ARRAY); |
---|
| 271 | |
---|
[7563] | 272 | |
---|
[7353] | 273 | glVertexPointer(3, GL_FLOAT, stride, &(curVertex[offset].position[0])); |
---|
[7563] | 274 | |
---|
[7465] | 275 | glClientActiveTextureARB(GL_TEXTURE0_ARB); |
---|
[7353] | 276 | glTexCoordPointer(2, GL_FLOAT, stride, &(curVertex[offset].texcoord[0])); |
---|
[7801] | 277 | //glEnableClientState(GL_TEXTURE_COORD_ARRAY); |
---|
[7563] | 278 | |
---|
[7465] | 279 | glClientActiveTextureARB(GL_TEXTURE1_ARB); |
---|
| 280 | glTexCoordPointer(2, GL_FLOAT, stride, &(curVertex[offset].texcoord[1])); |
---|
[7544] | 281 | //glEnableClientState(GL_TEXTURE_COORD_ARRAY); |
---|
[7353] | 282 | |
---|
[7563] | 283 | |
---|
[7353] | 284 | glNormalPointer( GL_FLOAT, stride, &(curVertex[offset].normal[0])); |
---|
[7395] | 285 | // glColorPointer(4, GL_BYTE, stride, &(curVertex[offset].color[0])); |
---|
[7353] | 286 | glDrawElements(GL_TRIANGLES, curFace.n_meshverts, |
---|
[7395] | 287 | GL_UNSIGNED_INT, &(((meshvert *)this->bspFile->meshverts) [curFace.meshvert])); |
---|
[7353] | 288 | |
---|
[7465] | 289 | glDisableClientState(GL_TEXTURE0_ARB); |
---|
| 290 | glDisableClientState(GL_TEXTURE1_ARB); |
---|
[7353] | 291 | glDisableClientState(GL_VERTEX_ARRAY ); |
---|
[7801] | 292 | glDisableClientState(GL_TEXTURE_COORD_ARRAY ); |
---|
[7353] | 293 | glDisableClientState(GL_NORMAL_ARRAY ); |
---|
[7395] | 294 | // glDisableClientState(GL_COLOR_ARRAY); |
---|
| 295 | |
---|
[7353] | 296 | } |
---|
| 297 | |
---|
| 298 | |
---|
| 299 | void BspManager::draw_debug_face(int curface) |
---|
| 300 | { |
---|
[7395] | 301 | face& curFace = (this->bspFile->faces)[curface]; |
---|
| 302 | const BspVertex* curVertex = (BspVertex *) this->bspFile->vertice; |
---|
| 303 | int stride = 44; // sizeof(Vertex) |
---|
| 304 | int offset = curFace.vertex; |
---|
| 305 | |
---|
[7353] | 306 | // PRINTF(0)("BSP Manager: "); |
---|
| 307 | // PRINTF(0)("BSP Manager: type: %i \n", curFace.texture); |
---|
| 308 | |
---|
[7395] | 309 | // if( curFace.texture < 0 ) return; |
---|
| 310 | if(curFace.type == 2) { |
---|
| 311 | this->draw_patch( &curFace); |
---|
| 312 | return; |
---|
| 313 | } |
---|
| 314 | if(curFace.type == 3) return; |
---|
| 315 | // if(this->bspFile->Materials[curFace.texture] != NULL) |
---|
[7353] | 316 | |
---|
[7395] | 317 | this->bspFile->Materials[2].mat->select(); |
---|
| 318 | this->lastTex = 2; |
---|
| 319 | |
---|
[7353] | 320 | glEnableClientState(GL_VERTEX_ARRAY ); |
---|
| 321 | glEnableClientState(GL_TEXTURE_COORD_ARRAY ); |
---|
| 322 | glEnableClientState(GL_NORMAL_ARRAY ); |
---|
[7395] | 323 | //glEnableClientState(GL_COLOR_ARRAY); |
---|
[7353] | 324 | // glEnableClientState(GL_VERTEX_ARRAY ); |
---|
[7465] | 325 | glClientActiveTextureARB(GL_TEXTURE0_ARB); |
---|
[7353] | 326 | glVertexPointer(3, GL_FLOAT, stride, &(curVertex[offset].position[0])); |
---|
[7465] | 327 | glEnableClientState(GL_TEXTURE_COORD_ARRAY); |
---|
[7395] | 328 | // glClientActiveTextureARB(GL_TEXTURE0_ARB); |
---|
[7465] | 329 | glClientActiveTextureARB(GL_TEXTURE1_ARB); |
---|
[7353] | 330 | glTexCoordPointer(2, GL_FLOAT, stride, &(curVertex[offset].texcoord[0])); |
---|
[7465] | 331 | glEnableClientState(GL_TEXTURE_COORD_ARRAY); |
---|
[7395] | 332 | // glClientActiveTextureARB(GL_TEXTURE1_ARB); |
---|
| 333 | // glTexCoordPointer(2, GL_FLOAT, stride, &(curVertex[offset].texcoord[1])); |
---|
| 334 | //glEnableClientState(GL_NORMAL_ARRAY ); |
---|
[7353] | 335 | |
---|
| 336 | glNormalPointer( GL_FLOAT, stride, &(curVertex[offset].normal[0])); |
---|
[7395] | 337 | // glColorPointer(4, GL_BYTE, stride, &(curVertex[offset].color[0])); |
---|
[7353] | 338 | glDrawElements(GL_TRIANGLES, curFace.n_meshverts, |
---|
[7395] | 339 | GL_UNSIGNED_INT, &(((meshvert *)this->bspFile->meshverts) [curFace.meshvert])); |
---|
| 340 | |
---|
[7353] | 341 | } |
---|
| 342 | |
---|
| 343 | void BspManager::draw_patch(face* Face) |
---|
| 344 | { |
---|
[7544] | 345 | if(this->lastTex != Face->texture) { |
---|
[7510] | 346 | this->bspFile->Materials[Face->texture].mat->select(); |
---|
[7544] | 347 | this->lastTex = Face->texture; |
---|
| 348 | } |
---|
[7801] | 349 | if (Face->effect != -1) return; |
---|
[7563] | 350 | |
---|
| 351 | |
---|
| 352 | if(Face->lm_index < 0) { |
---|
[7465] | 353 | glActiveTextureARB(GL_TEXTURE1_ARB); |
---|
[7511] | 354 | glBindTexture(GL_TEXTURE_2D, this->bspFile->whiteLightMap); |
---|
[7465] | 355 | glEnable(GL_TEXTURE_2D); |
---|
[7563] | 356 | } else { |
---|
[7465] | 357 | glActiveTextureARB(GL_TEXTURE1_ARB); |
---|
| 358 | glBindTexture(GL_TEXTURE_2D, this->bspFile->glLightMapTextures[Face->lm_index]); |
---|
| 359 | glEnable(GL_TEXTURE_2D); |
---|
[7563] | 360 | } |
---|
[7579] | 361 | //glColor4f(3.0,3.0,3.0,1.0); |
---|
[7563] | 362 | |
---|
[7801] | 363 | glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
---|
| 364 | glEnable( GL_AUTO_NORMAL); |
---|
[7465] | 365 | glEnableClientState(GL_VERTEX_ARRAY ); |
---|
| 366 | glEnableClientState(GL_TEXTURE_COORD_ARRAY ); |
---|
[7801] | 367 | for(int i = Face->n_meshverts -1; i >=0 ; i--) { |
---|
[7833] | 368 | //glFrontFace(GL_CW); |
---|
[7395] | 369 | //PRINTF(0)("BSP Manager: Face->size[0]: %i . \n", Face->size[0]); |
---|
[7563] | 370 | |
---|
| 371 | |
---|
[7801] | 372 | //glEnableClientState(GL_NORMAL_ARRAY ); |
---|
[7353] | 373 | |
---|
[7395] | 374 | glVertexPointer(3, GL_FLOAT,44, &((((BspVertex*)(this->bspFile->patchVertice))[8*8*(Face->meshvert+i)]).position[0])); |
---|
[7563] | 375 | |
---|
| 376 | |
---|
[7465] | 377 | glClientActiveTextureARB(GL_TEXTURE0_ARB); |
---|
[7801] | 378 | glEnableClientState(GL_TEXTURE_COORD_ARRAY); |
---|
[7395] | 379 | glTexCoordPointer(2, GL_FLOAT, 44, &((((BspVertex*)(this->bspFile->patchVertice))[8*8*(Face->meshvert+i)]).texcoord[0][0])); |
---|
[7465] | 380 | |
---|
[7563] | 381 | |
---|
[7833] | 382 | |
---|
[7465] | 383 | glClientActiveTextureARB(GL_TEXTURE1_ARB); |
---|
| 384 | glTexCoordPointer(2, GL_FLOAT, 44, &((((BspVertex*)(this->bspFile->patchVertice))[8*8*(Face->meshvert+i)]).texcoord[1][0])); |
---|
[7544] | 385 | //glEnableClientState(GL_TEXTURE_COORD_ARRAY); |
---|
[7465] | 386 | |
---|
[7563] | 387 | |
---|
[7833] | 388 | // glNormalPointer( GL_FLOAT, 44,&((((BspVertex*)(this->bspFile->patchVertice))[8*8*(Face->meshvert+i)]).normal[0]) ); |
---|
[7353] | 389 | |
---|
| 390 | |
---|
| 391 | |
---|
[7563] | 392 | |
---|
[7801] | 393 | for(int row=6; row>=0; --row) { |
---|
[7395] | 394 | glDrawElements(GL_TRIANGLE_STRIP, 2*(8), GL_UNSIGNED_INT, |
---|
| 395 | & ( (((GLuint*) (this->bspFile->patchIndexes))[7*8*2*(Face->meshvert+i)+ row*2*8] )) ); |
---|
| 396 | } |
---|
[7563] | 397 | |
---|
[7801] | 398 | //glFrontFace(GL_CCW); |
---|
[7395] | 399 | } |
---|
[7465] | 400 | glDisableClientState(GL_TEXTURE0_ARB); |
---|
| 401 | glDisableClientState(GL_TEXTURE1_ARB); |
---|
[7801] | 402 | glDisable(GL_AUTO_NORMAL); |
---|
[7465] | 403 | glDisableClientState(GL_VERTEX_ARRAY ); |
---|
| 404 | glDisableClientState(GL_TEXTURE_COORD_ARRAY ); |
---|
[7563] | 405 | |
---|
| 406 | |
---|
[7353] | 407 | } |
---|
| 408 | |
---|
| 409 | bool BspManager::isAlreadyVisible(int Face) |
---|
| 410 | { |
---|
[7395] | 411 | return this->alreadyVisible[Face]; |
---|
[7353] | 412 | } |
---|
| 413 | |
---|
| 414 | |
---|
| 415 | BspTreeNode* BspManager::getLeaf(BspTreeNode* node, Vector* cam) |
---|
| 416 | { |
---|
[7395] | 417 | float dist = 0; |
---|
| 418 | while(!(node->isLeaf)) { |
---|
| 419 | dist = (node->plane.x * this->cam.x + node->plane.y*this->cam.y + node->plane.z*this->cam.z) - node->d; |
---|
| 420 | if(dist >= 0.0f) { |
---|
| 421 | node = node->left; |
---|
| 422 | } else { |
---|
| 423 | node = node->right; |
---|
| 424 | } |
---|
| 425 | } |
---|
| 426 | return node; |
---|
[7353] | 427 | } |
---|
| 428 | |
---|
[7563] | 429 | void BspManager::checkBrushRay(brush* curBrush) |
---|
| 430 | { |
---|
| 431 | float EPSILON = 0.000001; |
---|
| 432 | float startDistance; |
---|
| 433 | float endDistance; |
---|
[7833] | 434 | |
---|
[7563] | 435 | float startFraction = -1.0f; |
---|
| 436 | float endFraction = 1.0f; |
---|
| 437 | bool startsOut = false; |
---|
| 438 | bool endsOut = false; |
---|
[7833] | 439 | |
---|
[7563] | 440 | Vector inputStart = State::getCameraTargetNode()->getLastAbsCoor(); |
---|
| 441 | Vector inputEnd = State::getCameraTargetNode()->getAbsCoor(); |
---|
| 442 | |
---|
[7833] | 443 | for (int i = 0; i < curBrush->n_brushsides; i++) { |
---|
[7563] | 444 | brushside& curBrushSide = this->bspFile->brushSides[curBrush->brushside + i] ; |
---|
| 445 | plane& curPlane = this->bspFile->planes[curBrushSide.plane] ; |
---|
| 446 | |
---|
[7833] | 447 | startDistance = inputStart.x * curPlane.x + inputStart.y * curPlane.y+ inputStart.z * curPlane.z - curPlane.d; |
---|
| 448 | endDistance = inputEnd.x * curPlane.x +inputEnd.y * curPlane.y +inputEnd.z * curPlane.z -curPlane.d; |
---|
[7563] | 449 | |
---|
| 450 | if (startDistance > 0) |
---|
| 451 | startsOut = true; |
---|
| 452 | if (endDistance > 0) |
---|
| 453 | endsOut = true; |
---|
| 454 | |
---|
[7833] | 455 | // make sure the trace isn't completely on one side of the brush |
---|
| 456 | if (startDistance > 0 && endDistance > 0) { // both are in front of the plane, its outside of this brush |
---|
[7563] | 457 | return; |
---|
| 458 | } |
---|
[7833] | 459 | if (startDistance <= 0 && endDistance <= 0) { // both are behind this plane, it will get clipped by another one |
---|
[7563] | 460 | continue; |
---|
| 461 | } |
---|
| 462 | |
---|
[7833] | 463 | // MMM... BEEFY |
---|
| 464 | if (startDistance > endDistance) { // line is entering into the brush |
---|
[7563] | 465 | float fraction = (startDistance - EPSILON) / (startDistance - endDistance); // * |
---|
| 466 | if (fraction > startFraction) |
---|
| 467 | startFraction = fraction; |
---|
[7833] | 468 | } else { // line is leaving the brush |
---|
[7563] | 469 | float fraction = (startDistance + EPSILON) / (startDistance - endDistance); // * |
---|
| 470 | if (fraction < endFraction) |
---|
| 471 | endFraction = fraction; |
---|
| 472 | } |
---|
[7833] | 473 | |
---|
[7563] | 474 | } |
---|
[7833] | 475 | if (startsOut == false) { |
---|
| 476 | this->outputStartsOut = false; |
---|
| 477 | if (endsOut == false) |
---|
| 478 | this->outputAllSolid = true; |
---|
| 479 | return; |
---|
| 480 | } |
---|
[7563] | 481 | |
---|
[7833] | 482 | if (startFraction < endFraction) { |
---|
| 483 | if (startFraction > -1.0f && startFraction < outputFraction) { |
---|
[7563] | 484 | if (startFraction < 0) |
---|
| 485 | startFraction = 0; |
---|
| 486 | this->outputFraction = startFraction; |
---|
| 487 | } |
---|
| 488 | } |
---|
[7833] | 489 | |
---|
[7563] | 490 | } |
---|
| 491 | |
---|
| 492 | void BspManager::checkCollisionRay(BspTreeNode* node, float startFraction, float endFraction, Vector* start, Vector* end) |
---|
| 493 | { |
---|
| 494 | |
---|
| 495 | |
---|
| 496 | float EPSILON = 0.000001; |
---|
| 497 | float endDistance = (end)->x * (node->plane.x) +(end)->y * (node->plane.y) +(end)->z * (node->plane.z) - node->d; |
---|
| 498 | float startDistance = (start)->x * (node->plane.x)+ (start)->y * (node->plane.y)+ (start)->z * (node->plane.z)- node->d; |
---|
| 499 | |
---|
| 500 | |
---|
| 501 | if(node->isLeaf) { |
---|
| 502 | leaf& curLeaf = this->bspFile->leaves[node->leafIndex]; |
---|
| 503 | for (int i = 0; i < curLeaf.n_leafbrushes ; i++) { |
---|
| 504 | brush& curBrush = this->bspFile->brushes[((int*)(this->bspFile->leafBrushes))[curLeaf.leafbrush_first+i]]; |
---|
| 505 | //object *brush = &BSP.brushes[BSP.leafBrushes[leaf->firstLeafBrush + i]]; |
---|
| 506 | if (curBrush.n_brushsides > 0 && |
---|
[7833] | 507 | ((((BspTexture*)(this->bspFile->textures))[curBrush.texture]).contents & 1)) |
---|
| 508 | // CheckBrush( brush ); |
---|
| 509 | this->checkBrushRay(&curBrush); |
---|
[7563] | 510 | if(curBrush.n_brushsides <=0) this->outputAllSolid = true; |
---|
| 511 | } |
---|
| 512 | return; |
---|
| 513 | } |
---|
| 514 | |
---|
| 515 | |
---|
| 516 | if (startDistance >= 0 && endDistance >= 0) // A |
---|
| 517 | { // both points are in front of the plane |
---|
| 518 | // so check the front child |
---|
| 519 | this->checkCollisionRay(node->left,0,0,start,end); |
---|
| 520 | } else if (startDistance < 0 && endDistance < 0) // B |
---|
| 521 | { // both points are behind the plane |
---|
| 522 | // so check the back child |
---|
| 523 | this->checkCollisionRay(node->right,0,0,start,end); |
---|
| 524 | } else // C |
---|
| 525 | { // the line spans the splitting plane |
---|
| 526 | int side; |
---|
| 527 | float fraction1, fraction2, middleFraction; |
---|
| 528 | Vector middle; |
---|
| 529 | |
---|
| 530 | // STEP 1: split the segment into two |
---|
| 531 | if (startDistance < endDistance) { |
---|
| 532 | side = 1; // back |
---|
| 533 | float inverseDistance = 1.0f / (startDistance - endDistance); |
---|
| 534 | fraction1 = (startDistance + EPSILON) * inverseDistance; |
---|
| 535 | fraction2 = (startDistance + EPSILON) * inverseDistance; |
---|
| 536 | } else if (endDistance < startDistance) { |
---|
[7833] | 537 | side = 0; // front(start)->x * (node->plane.x)+ |
---|
[7563] | 538 | float inverseDistance = 1.0f / (startDistance - endDistance); |
---|
| 539 | fraction1 = (startDistance + EPSILON) * inverseDistance; |
---|
| 540 | fraction2 = (startDistance - EPSILON) * inverseDistance; |
---|
| 541 | } else { |
---|
| 542 | side = 0; // front |
---|
| 543 | fraction1 = 1.0f; |
---|
| 544 | fraction2 = 0.0f; |
---|
| 545 | } |
---|
| 546 | |
---|
| 547 | // STEP 2: make sure the numbers are valid |
---|
| 548 | if (fraction1 < 0.0f) fraction1 = 0.0f; |
---|
| 549 | else if (fraction1 > 1.0f) fraction1 = 1.0f; |
---|
| 550 | if (fraction2 < 0.0f) fraction2 = 0.0f; |
---|
| 551 | else if (fraction2 > 1.0f) fraction2 = 1.0f; |
---|
| 552 | |
---|
| 553 | // STEP 3: calculate the middle point for the first side |
---|
| 554 | middleFraction = startFraction + |
---|
| 555 | (endFraction - startFraction) * fraction1; |
---|
| 556 | |
---|
| 557 | middle.x = start->x + fraction1 * (end->x - start->x); |
---|
| 558 | middle.y = start->y + fraction1 * (end->y - start->y); |
---|
| 559 | middle.z = start->z + fraction1 * (end->z - start->z); |
---|
| 560 | |
---|
| 561 | // STEP 4: check the first side |
---|
| 562 | //CheckNode( node->children[side], startFraction, middleFraction, start, middle ); |
---|
| 563 | if(side == 0) this->checkCollisionRay(node->left,startFraction, middleFraction, start, &middle ); |
---|
| 564 | |
---|
| 565 | else this->checkCollisionRay(node->right,startFraction, middleFraction, |
---|
| 566 | start, &middle ); |
---|
| 567 | |
---|
| 568 | // STEP 5: calculate the middle point for the second side |
---|
| 569 | middleFraction = startFraction + |
---|
| 570 | (endFraction - startFraction) * fraction2; |
---|
| 571 | |
---|
| 572 | middle.x = start->x + fraction2 * (end->x - start->x); |
---|
| 573 | middle.y = start->y + fraction2 * (end->y - start->y); |
---|
| 574 | middle.z = start->z + fraction2 * (end->z - start->z); |
---|
| 575 | |
---|
| 576 | // STEP 6: check the second side |
---|
| 577 | if(side == 1)this->checkCollisionRay(node->left,middleFraction, endFraction, &middle, end); |
---|
| 578 | |
---|
| 579 | else this->checkCollisionRay(node->right,middleFraction, endFraction,&middle, end ); |
---|
| 580 | |
---|
| 581 | |
---|
| 582 | } |
---|
| 583 | |
---|
| 584 | } |
---|
[7833] | 585 | |
---|
| 586 | |
---|
| 587 | void BspManager::checkCollision(WorldEntity* worldEntity) |
---|
| 588 | { |
---|
| 589 | |
---|
| 590 | Vector position = worldEntity->getAbsCoor(); |
---|
| 591 | |
---|
| 592 | |
---|
| 593 | Vector forwardDir = worldEntity->getAbsDirX(); |
---|
| 594 | forwardDir.x =10*forwardDir.x; |
---|
| 595 | forwardDir.y =10*forwardDir.y; |
---|
| 596 | forwardDir.z =10*forwardDir.z; |
---|
| 597 | |
---|
| 598 | Vector upDir = worldEntity->getAbsDirY(); |
---|
| 599 | Vector dest = position; |
---|
| 600 | dest.x += forwardDir.x; |
---|
| 601 | dest.y += forwardDir.y; |
---|
| 602 | dest.z += forwardDir.z; |
---|
| 603 | Vector out = Vector(-1875.0,-1875.0,-1875.0); |
---|
| 604 | if(!worldEntity->isA(CL_PLAYABLE)) { |
---|
| 605 | } |
---|
| 606 | else { |
---|
| 607 | bool collision = false; |
---|
| 608 | Vector position1 = position + Vector(0.0,0.1,0.0); |
---|
| 609 | Vector position2 = position + Vector(0.0,0.2,0.0); |
---|
| 610 | Vector dest1 = position1 + forwardDir; |
---|
| 611 | Vector dest2 = position2 + forwardDir; |
---|
| 612 | dest = position - upDir; |
---|
| 613 | Vector out1; |
---|
| 614 | Vector out2; |
---|
| 615 | |
---|
| 616 | this->checkCollisionRay(this->root,0.0f,1.0f, &position1, &dest1 ); |
---|
| 617 | if(this->outputFraction == 1.0f) out1 = dest; |
---|
| 618 | else { |
---|
| 619 | collision = true; |
---|
| 620 | out1.x = position1.x + (dest1.x -position1.x) * this->outputFraction; |
---|
| 621 | out1.y = position1.y + (dest1.y -position1.y) * this->outputFraction; |
---|
| 622 | out1.z = position1.z + (dest1.z - position1.z) * this->outputFraction; |
---|
| 623 | |
---|
| 624 | } |
---|
| 625 | |
---|
| 626 | this->checkCollisionRay(this->root,0.0f,1.0f, &position2, &dest2 ); |
---|
| 627 | if(this->outputFraction == 1.0f) out2= dest; |
---|
| 628 | else |
---|
| 629 | { |
---|
| 630 | collision = true; |
---|
| 631 | out2.x = position2.x + (dest2.x -position2.x) * this->outputFraction; |
---|
| 632 | out2.y = position2.y + (dest2.y -position2.y) * this->outputFraction; |
---|
| 633 | out2.z = position2.z + (dest2.z - position2.z) * this->outputFraction; |
---|
| 634 | |
---|
| 635 | } |
---|
| 636 | |
---|
| 637 | this->checkCollisionRay(this->root,0.0f,1.0f, &position, &dest ); |
---|
| 638 | if(this->outputFraction == 1.0f) out = dest; |
---|
| 639 | else |
---|
| 640 | { |
---|
| 641 | collision = true; |
---|
| 642 | out.x = position.x + (dest.x -position.x) * this->outputFraction; |
---|
| 643 | out.y = position.y + (dest.y -position.y) * this->outputFraction; |
---|
| 644 | out.z = position.z + (dest.z -position.z) * this->outputFraction; |
---|
| 645 | |
---|
| 646 | } |
---|
| 647 | |
---|
| 648 | if(collision) worldEntity->collidesWithGround(out,out1,out2); |
---|
| 649 | |
---|
| 650 | } |
---|
| 651 | |
---|
| 652 | } |
---|
| 653 | |
---|
[7353] | 654 | void BspManager::checkCollision(BspTreeNode* node, Vector* cam) |
---|
| 655 | { |
---|
[7563] | 656 | Vector next = this->cam; |
---|
| 657 | next.x = (State::getCameraTargetNode()->getLastAbsCoor()).x ; |
---|
| 658 | next.y = (State::getCameraTargetNode()->getLastAbsCoor()).y ; |
---|
| 659 | next.z = (State::getCameraTargetNode()->getLastAbsCoor()).z ; |
---|
| 660 | |
---|
[7395] | 661 | float dist = 0; |
---|
| 662 | if(!(node->isLeaf)) { |
---|
| 663 | dist = (node->plane.x * this->cam.x + node->plane.y*this->cam.y + node->plane.z*this->cam.z) - node->d; |
---|
| 664 | if(dist > 4.0f) { |
---|
| 665 | checkCollision(node->left,cam); |
---|
| 666 | return; |
---|
| 667 | } |
---|
| 668 | if(dist < -4.0f) { |
---|
| 669 | checkCollision(node->right,cam); |
---|
| 670 | return; |
---|
| 671 | } |
---|
| 672 | if(dist<=4.0f && dist >= -4.0f) { |
---|
| 673 | checkCollision(node->left,cam); |
---|
| 674 | checkCollision(node->right,cam); |
---|
| 675 | return; |
---|
| 676 | } |
---|
| 677 | return; |
---|
| 678 | } else { |
---|
[7353] | 679 | |
---|
[7395] | 680 | leaf& camLeaf = ((leaf *)(this->bspFile->leaves))[(node->leafIndex ) ]; |
---|
[7353] | 681 | |
---|
[7579] | 682 | if (camLeaf.cluster < 0) { |
---|
[7833] | 683 | this->drawDebugCube(&this->cam); |
---|
| 684 | this->drawDebugCube(&next); |
---|
| 685 | State::getPlayer()->getPlayable()->setRelCoor(-100,-100,-100); |
---|
| 686 | State::getPlayer()->getPlayable()->collidesWith(NULL, State::getCameraTargetNode()->getLastAbsCoor()); |
---|
| 687 | } |
---|
[7395] | 688 | |
---|
| 689 | |
---|
| 690 | /* |
---|
[7511] | 691 | for(int i = 0; i < camLeaf.n_leafbrushes && i < 10; i++ ) |
---|
| 692 | { |
---|
| 693 | brush& curBrush = ((brush*)(this->bspFile->brushes))[(camLeaf.leafbrush_first +i)%this->bspFile->numLeafBrushes]; |
---|
| 694 | if(curBrush.n_brushsides < 0) return; |
---|
| 695 | for(int j = 0; j < curBrush.n_brushsides; j++) |
---|
| 696 | { |
---|
| 697 | float dist = -0.1; |
---|
| 698 | brushside& curBrushSide = ((brushside*)(this->bspFile->brushSides))[(curBrush.brushside +j)%this->bspFile->numBrushSides]; |
---|
| 699 | plane& testPlane = ((plane*)(this->bspFile->planes))[curBrushSide.plane % this->bspFile->numPlanes]; |
---|
| 700 | dist = testPlane.x * this->cam.x + testPlane.y * this->cam.y + testPlane.z * this->cam.z -testPlane.d ; |
---|
| 701 | |
---|
| 702 | if(dist < -0.01f) dist = -1.0f *dist; |
---|
| 703 | if(dist < 1.0f){ |
---|
| 704 | this->drawDebugCube(&this->cam); |
---|
| 705 | return; |
---|
| 706 | } |
---|
| 707 | } |
---|
| 708 | |
---|
| 709 | } */ |
---|
[7395] | 710 | |
---|
| 711 | } |
---|
| 712 | return; |
---|
[7353] | 713 | } |
---|
| 714 | |
---|
| 715 | void BspManager::drawDebugCube(Vector* cam) |
---|
| 716 | { |
---|
[7395] | 717 | glBegin(GL_QUADS); |
---|
[7353] | 718 | |
---|
[7395] | 719 | // Bottom Face. Red, 75% opaque, magnified texture |
---|
[7353] | 720 | |
---|
[7395] | 721 | glNormal3f( 0.0f, -1.0f, 0.0f); // Needed for lighting |
---|
| 722 | glColor4f(0.9,0.2,0.2,.75); // Basic polygon color |
---|
[7353] | 723 | |
---|
[7395] | 724 | glTexCoord2f(0.800f, 0.800f); glVertex3f(cam->x-1.0f, cam->y-1.0f,cam->z -1.0f); |
---|
| 725 | glTexCoord2f(0.200f, 0.800f); glVertex3f(cam->x+1.0f, cam->y-1.0f,cam->z -1.0f); |
---|
| 726 | glTexCoord2f(0.200f, 0.200f); glVertex3f(cam->x+ 1.0f,cam->y -1.0f,cam->z + 1.0f); |
---|
| 727 | glTexCoord2f(0.800f, 0.200f); glVertex3f(cam->x-1.0f, cam->y-1.0f, cam->z + 1.0f); |
---|
[7353] | 728 | |
---|
| 729 | |
---|
[7395] | 730 | // Top face; offset. White, 50% opaque. |
---|
[7353] | 731 | |
---|
[7395] | 732 | glNormal3f( 0.0f, 1.0f, 0.0f); glColor4f(0.5,0.5,0.5,.5); |
---|
[7353] | 733 | |
---|
[7395] | 734 | glTexCoord2f(0.005f, 1.995f); glVertex3f(cam->x-1.0f, cam->y+ 1.0f, cam->z -1.0f); |
---|
| 735 | glTexCoord2f(0.005f, 0.005f); glVertex3f(cam->x-1.0f, cam->y+ 1.0f, cam->z +1.0f); |
---|
| 736 | glTexCoord2f(1.995f, 0.005f); glVertex3f(cam->x+ 1.0f, cam->y+1.0f, cam->z +1.0f); |
---|
| 737 | glTexCoord2f(1.995f, 1.995f); glVertex3f(cam->x+ 1.0f, cam->y+ 1.0f, cam->z -1.0f); |
---|
[7353] | 738 | |
---|
| 739 | |
---|
[7395] | 740 | // Far face. Green, 50% opaque, non-uniform texture cooridinates. |
---|
[7353] | 741 | |
---|
[7395] | 742 | glNormal3f( 0.0f, 0.0f,-1.0f); glColor4f(0.2,0.9,0.2,.5); |
---|
[7353] | 743 | |
---|
[7395] | 744 | glTexCoord2f(0.995f, 0.005f); glVertex3f(cam->x-1.0f, cam->y-1.0f, cam->z -1.3f); |
---|
| 745 | glTexCoord2f(2.995f, 2.995f); glVertex3f(cam->x-1.0f, cam->y+ 1.0f, cam->z -1.3f); |
---|
| 746 | glTexCoord2f(0.005f, 0.995f); glVertex3f(cam->x+ 1.0f,cam->y+ 1.0f, cam->z -1.3f); |
---|
| 747 | glTexCoord2f(0.005f, 0.005f); glVertex3f( cam->x+1.0f,cam->y -1.0f, cam->z -1.3f); |
---|
[7353] | 748 | |
---|
| 749 | |
---|
[7395] | 750 | // Right face. Blue; 25% opaque |
---|
[7353] | 751 | |
---|
[7395] | 752 | glNormal3f( 1.0f, 0.0f, 0.0f); glColor4f(0.2,0.2,0.9,.25); |
---|
[7353] | 753 | |
---|
[7465] | 754 | glTexCoord2f(0.995f, 0.005f); glVertex3f(cam->x+ 1.0f, cam->y -1.0f, cam->z -1.0f); |
---|
[7395] | 755 | glTexCoord2f(0.995f, 0.995f); glVertex3f(cam->x+ 1.0f, cam->y+ 1.0f, cam->z -1.0f); |
---|
| 756 | glTexCoord2f(0.005f, 0.995f); glVertex3f(cam->x+ 1.0f, cam->y+ 1.0f, cam->z + 1.0f); |
---|
| 757 | glTexCoord2f(0.005f, 0.005f); glVertex3f(cam->x+ 1.0f, cam->y-1.0f, cam->z +1.0f); |
---|
[7353] | 758 | |
---|
| 759 | |
---|
[7395] | 760 | // Front face; offset. Multi-colored, 50% opaque. |
---|
[7353] | 761 | |
---|
[7395] | 762 | glNormal3f( 0.0f, 0.0f, 1.0f); |
---|
[7353] | 763 | |
---|
[7395] | 764 | glColor4f( 0.9f, 0.2f, 0.2f, 0.5f); |
---|
| 765 | glTexCoord2f( 0.005f, 0.005f); glVertex3f(cam->x-1.0f, cam->y-1.0f, cam->z +1.0f); |
---|
| 766 | glColor4f( 0.2f, 0.9f, 0.2f, 0.5f); |
---|
| 767 | glTexCoord2f( 0.995f, 0.005f); glVertex3f(cam->x+ 1.0f, cam->y-1.0f, cam->z +1.0f); |
---|
| 768 | glColor4f( 0.2f, 0.2f, 0.9f, 0.5f); |
---|
| 769 | glTexCoord2f( 0.995f, 0.995f); glVertex3f( cam->x+1.0f, cam->y+1.0f, cam->z +1.0f); |
---|
| 770 | glColor4f( 0.1f, 0.1f, 0.1f, 0.5f); |
---|
| 771 | glTexCoord2f( 0.005f, 0.995f); glVertex3f(cam->x-1.0f, cam->y+ 1.0f, cam->z +1.0f); |
---|
| 772 | |
---|
| 773 | |
---|
| 774 | // Left Face; offset. Yellow, varying levels of opaque. |
---|
| 775 | |
---|
| 776 | glNormal3f(-1.0f, 0.0f, 0.0f); |
---|
| 777 | |
---|
| 778 | glColor4f(0.9,0.9,0.2,0.0); |
---|
| 779 | glTexCoord2f(0.005f, 0.005f); glVertex3f(cam->x-1.0f, cam->y-1.0f, cam->z -1.0f); |
---|
| 780 | glColor4f(0.9,0.9,0.2,0.66); |
---|
| 781 | glTexCoord2f(0.995f, 0.005f); glVertex3f(cam->x-1.0f,cam->y -1.0f, cam->z +1.0f); |
---|
| 782 | glColor4f(0.9,0.9,0.2,1.0); |
---|
| 783 | glTexCoord2f(0.995f, 0.995f); glVertex3f(cam->x-1.0f, cam->y+ 1.0f, cam->z +1.0f); |
---|
| 784 | glColor4f(0.9,0.9,0.2,0.33); |
---|
| 785 | glTexCoord2f(0.005f, 0.995f); glVertex3f(cam->x-1.0f, cam->y+ 1.0f, cam->z -1.0f); |
---|
| 786 | |
---|
| 787 | glEnd(); |
---|
[7385] | 788 | } |
---|
[7353] | 789 | |
---|
[7385] | 790 | void BspManager::addFace(int f) |
---|
| 791 | { |
---|
[7395] | 792 | face& curFace = ((face *)(this->bspFile->faces))[f]; |
---|
| 793 | if(this->bspFile->Materials[curFace.texture].alpha) this->trasparent.push_back(f); |
---|
| 794 | else this->opal.push_back(f); |
---|
| 795 | } |
---|