Changeset 7801 in orxonox.OLD for branches/bsp_model/src/lib/graphics/importer/bsp_manager.cc
- Timestamp:
- May 24, 2006, 1:24:39 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/bsp_model/src/lib/graphics/importer/bsp_manager.cc
r7596 r7801 30 30 #include <vector> 31 31 #include <deque> 32 32 #include "movie_player.h" 33 33 34 34 … … 88 88 89 89 this->cam = State::getCameraTargetNode()->getAbsCoor(); 90 //this->checkCollision(this->root, &this->cam); //!< Test Collision Detection90 // this->checkCollision(this->root, &this->cam); //!< Test Collision Detection 91 91 this->outputStartsOut = true; 92 92 this->outputAllSolid = false; 93 93 this->outputFraction = 1.0f; 94 94 95 //this->checkCollisionRay(this->root,0.0f,1.0f, &(State::getCameraTargetNode()->getLastAbsCoor()), &this->cam);95 this->checkCollisionRay(this->root,0.0f,1.0f, &(State::getCameraTargetNode()->getLastAbsCoor()), &this->cam); 96 96 97 97 if(this->outputFraction != 1.0f || this->outputAllSolid ) this->drawDebugCube(&this->cam); 98 98 99 if ( false ||viscluster < 0 || ((int *)(this->bspFile->header))[35] == 0 ) //!< if (sizeof(Visdata) == 0)99 if ( viscluster < 0 || ((int *)(this->bspFile->header))[35] == 0 ) //!< if (sizeof(Visdata) == 0) 100 100 { 101 101 … … 112 112 /** Do Frustum culling and draw 'em all **/ 113 113 bool inFrustum = true; 114 float dMins; 115 float dMaxs; 114 116 115 Vector dir; 117 116 dir.x = this->cam.x - State::getCameraTargetNode()->getLastAbsCoor().x; … … 120 119 float dist = dir.x*this->cam.x +dir.y*this->cam.y +dir.z*this->cam.z; 121 120 //if(dist < 0) dist = -dist; 122 dMins = dir.x*(float)curLeaf.mins[0] +dir.y*(float)curLeaf.mins[1] +dir.z*(float)curLeaf.mins[2];123 dMaxs = dir.x*(float)curLeaf.maxs[0] +dir.y*(float)curLeaf.maxs[1] +dir.z*(float)curLeaf.maxs[2];121 const float dMins = dir.x*(float)curLeaf.mins[0] +dir.y*(float)curLeaf.mins[1] +dir.z*(float)curLeaf.mins[2] - dist ; 122 const float dMaxs = dir.x*(float)curLeaf.maxs[0] +dir.y*(float)curLeaf.maxs[1] +dir.z*(float)curLeaf.maxs[2] - dist ; 124 123 125 if(dMins < - 100.0 && dMaxs < -100.0)124 if(dMins < -30.0 && dMaxs < -30.0) 126 125 { 127 continue; 126 //continue; 127 } 128 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) 129 { 130 //continue; 128 131 } 129 132 … … 176 179 const float dMaxs = dir.x*(float)curLeaf.maxs[0] +dir.y*(float)curLeaf.maxs[1] +dir.z*(float)curLeaf.maxs[2] - dist; 177 180 178 if(dMins < -1 00.0 && dMaxs < -100.0)181 if(dMins < -150.0 && dMaxs < -150.0) 179 182 { 180 183 continue; … … 208 211 this->trasparent.pop_back(); 209 212 } 210 213 glActiveTextureARB(GL_TEXTURE1_ARB); 214 glBindTexture(GL_TEXTURE_2D, this->bspFile->whiteLightMap); 215 glEnable(GL_TEXTURE_2D); 211 216 212 217 }//draw … … 220 225 int stride = sizeof(BspVertex); // sizeof(Vertex) 221 226 int offset = curFace.vertex; 222 227 if (curFace.effect != -1) return; 223 228 // PRINTF(0)("BSP Manager: "); 224 229 // PRINTF(0)("BSP Manager: type: %i \n", curFace.texture); … … 229 234 return; 230 235 } 231 if(curFace.type == 3) return;232 // if(this->bspFile->Materials[curFace.texture] != NULL)236 if(curFace.type != 1) return; 237 if((char*)(this->bspFile->textures)[curFace.texture*72]== 0) return; 233 238 234 239 if(this->lastTex != curFace.texture) { 240 if(this->bspFile->Materials[curFace.texture].animated) 241 { 242 glBlendFunc(GL_ONE,GL_ONE_MINUS_SRC_COLOR); 243 glEnable(GL_BLEND); 244 if(this->bspFile->Materials[curFace.texture].aviMat->getStatus() == 2) this->bspFile->Materials[curFace.texture].aviMat->start(0); 245 this->bspFile->Materials[curFace.texture].aviMat->tick(0.005); 246 int n = this->bspFile->Materials[curFace.texture].aviMat->getTexture(); 247 glActiveTextureARB(GL_TEXTURE0_ARB); 248 glBindTexture(GL_TEXTURE_2D, n ); 249 glDisable(GL_BLEND); 250 } 251 else 252 { 235 253 this->bspFile->Materials[curFace.texture].mat->select(); 236 254 this->lastTex = curFace.texture; 255 } 237 256 } 238 257 … … 247 266 } 248 267 268 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 269 249 270 // glColor4f(3.0,3.0,3.0,1.0); 250 271 glEnableClientState(GL_VERTEX_ARRAY ); … … 258 279 glClientActiveTextureARB(GL_TEXTURE0_ARB); 259 280 glTexCoordPointer(2, GL_FLOAT, stride, &(curVertex[offset].texcoord[0])); 260 glEnableClientState(GL_TEXTURE_COORD_ARRAY);281 //glEnableClientState(GL_TEXTURE_COORD_ARRAY); 261 282 262 283 glClientActiveTextureARB(GL_TEXTURE1_ARB); … … 273 294 glDisableClientState(GL_TEXTURE1_ARB); 274 295 glDisableClientState(GL_VERTEX_ARRAY ); 275 //glDisableClientState(GL_TEXTURE_COORD_ARRAY );296 glDisableClientState(GL_TEXTURE_COORD_ARRAY ); 276 297 glDisableClientState(GL_NORMAL_ARRAY ); 277 298 // glDisableClientState(GL_COLOR_ARRAY); … … 330 351 this->lastTex = Face->texture; 331 352 } 332 353 if (Face->effect != -1) return; 333 354 334 355 … … 344 365 //glColor4f(3.0,3.0,3.0,1.0); 345 366 346 //glEnable( GL_AUTO_NORMAL); 367 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 368 glEnable( GL_AUTO_NORMAL); 347 369 glEnableClientState(GL_VERTEX_ARRAY ); 348 370 glEnableClientState(GL_TEXTURE_COORD_ARRAY ); 349 for(int i = 0; i < Face->n_meshverts ; i++) {350 371 for(int i = Face->n_meshverts -1; i >=0 ; i--) { 372 //glFrontFace(GL_CW); 351 373 //PRINTF(0)("BSP Manager: Face->size[0]: %i . \n", Face->size[0]); 352 374 353 375 354 glEnableClientState(GL_NORMAL_ARRAY );376 //glEnableClientState(GL_NORMAL_ARRAY ); 355 377 356 378 glVertexPointer(3, GL_FLOAT,44, &((((BspVertex*)(this->bspFile->patchVertice))[8*8*(Face->meshvert+i)]).position[0])); … … 358 380 359 381 glClientActiveTextureARB(GL_TEXTURE0_ARB); 382 glEnableClientState(GL_TEXTURE_COORD_ARRAY); 360 383 glTexCoordPointer(2, GL_FLOAT, 44, &((((BspVertex*)(this->bspFile->patchVertice))[8*8*(Face->meshvert+i)]).texcoord[0][0])); 361 glEnableClientState(GL_TEXTURE_COORD_ARRAY);384 362 385 363 386 … … 367 390 368 391 369 glNormalPointer( GL_FLOAT, 44,&((((BspVertex*)(this->bspFile->patchVertice))[8*8*(Face->meshvert+i)]).normal[0]) );370 371 372 373 374 for(int row= 0; row<7; ++row) {392 // glNormalPointer( GL_FLOAT, 44,&((((BspVertex*)(this->bspFile->patchVertice))[8*8*(Face->meshvert+i)]).normal[0]) ); 393 394 395 396 397 for(int row=6; row>=0; --row) { 375 398 glDrawElements(GL_TRIANGLE_STRIP, 2*(8), GL_UNSIGNED_INT, 376 399 & ( (((GLuint*) (this->bspFile->patchIndexes))[7*8*2*(Face->meshvert+i)+ row*2*8] )) ); 377 400 } 378 401 379 glFrontFace(GL_CCW);402 //glFrontFace(GL_CCW); 380 403 } 381 404 glDisableClientState(GL_TEXTURE0_ARB); 382 405 glDisableClientState(GL_TEXTURE1_ARB); 383 //glDisable(GL_AUTO_NORMAL);406 glDisable(GL_AUTO_NORMAL); 384 407 glDisableClientState(GL_VERTEX_ARRAY ); 385 408 glDisableClientState(GL_TEXTURE_COORD_ARRAY ); 386 409 387 glBegin(GL_QUADS); 388 389 glEnd(); 410 390 411 } 391 412
Note: See TracChangeset
for help on using the changeset viewer.