- Timestamp:
- May 31, 2006, 3:22:23 PM (19 years ago)
- Location:
- branches/bsp_model/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/bsp_model/src/lib/graphics/importer/bsp_file.cc
r7805 r8030 43 43 int BspFile::read(const char* name) 44 44 { 45 this->scale = 0.4; 45 46 int offset; 46 47 int size; … … 598 599 sc = ((unsigned char *)(&lightMapTexture))[i]; 599 600 sc *= 1/255.0; 600 scale = 1. 0;601 scale = 1.4; 601 602 if(sc > 1.0f && (temp = (1.0f/sc)) < scale) scale=temp; 602 603 scale*=255.0; 603 604 sc*=scale; 604 if( sc <= 180)605 if(false) 605 606 ((unsigned char *)(&lightMapTexture))[i] = (unsigned char)sc + 75; 606 607 else … … 983 984 void BspFile::swapAllBspCoordinates() 984 985 { 986 985 987 for(int i = 0; i < this->numVertex ; ++i) 986 988 { … … 1001 1003 { 1002 1004 float sto = this->planes[i].x; 1003 this->planes[i].x = this->planes[i].y;1004 this->planes[i].y = this->planes[i].z;1005 this->planes[i].x = this->planes[i].y; 1006 this->planes[i].y = this->planes[i].z; 1005 1007 this->planes[i].z = sto; 1008 this->planes[i].d = scale * this->planes[i].d ; 1006 1009 } 1007 1010 … … 1021 1024 { 1022 1025 int sto = array[0]; 1023 array[0] = array[1] ;1024 array[1] = array[2];1025 array[2] = sto ;1026 array[0] = array[1] / (int) ( 1/ scale); 1027 array[1] = array[2] / (int) (1/scale); 1028 array[2] = sto / (int) (1/scale); 1026 1029 1027 1030 } … … 1030 1033 { 1031 1034 float sto = array[0]; 1032 array[0] = array[1];1033 array[1] = array[2];1034 array[2] = s to;1035 } 1036 1035 array[0] = scale * array[1]; 1036 array[1] = scale * array[2]; 1037 array[2] = scale * sto; 1038 } 1039 -
branches/bsp_model/src/lib/graphics/importer/bsp_file.h
r7801 r8030 21 21 22 22 23 typedef struct 23 struct plane 24 24 { 25 25 float x; //!< 1st component of the plane's normal … … 27 27 float z; //!< 3rd component of the plane's normal 28 28 float d; //!< distance of the plane to the origin 29 } 30 plane; 29 }; 31 30 32 31 typedef struct … … 193 192 int numBrushSides; 194 193 int numLightMaps; 195 196 194 195 float scale; 197 196 198 197 BspTreeNode* build_tree_rec( int i ); -
branches/bsp_model/src/lib/graphics/importer/bsp_manager.cc
r7833 r8030 52 52 53 53 54 55 56 54 this->drawDebugCube(&this->out); 55 this->out1 = this->out; 56 this->out2 = this->out; 57 if(this->collPlane != NULL) 58 { 59 this->out1.x += this->collPlane->x*5.0; 60 this->out1.y += this->collPlane->y*5.0; 61 this->out1.z += this->collPlane->z*5.0; 62 63 this->out2.x += this->collPlane->x*10.0; 64 this->out2.y += this->collPlane->y*10.0; 65 this->out2.z += this->collPlane->z*10.0; 66 } 67 this->drawDebugCube(&this->out1); 68 this->drawDebugCube(&this->out2); 69 57 70 // Draw Debug Terrain 58 71 /* … … 98 111 this->checkCollisionRay(this->root,0.0f,1.0f, &(State::getCameraTargetNode()->getLastAbsCoor()), &this->cam); 99 112 100 if(this->outputFraction != 1.0f || this->outputAllSolid ) this->drawDebugCube(&this->cam);113 //if(this->outputFraction != 1.0f || this->outputAllSolid ) this->drawDebugCube(&this->cam); 101 114 102 115 if ( viscluster < 0 || ((int *)(this->bspFile->header))[35] == 0 ) //!< if (sizeof(Visdata) == 0) … … 117 130 118 131 Vector dir; 119 dir.x = State::getCameraNode()->getAbsDir Z().x;120 dir.y = State::getCameraNode()->getAbsDir Z().y;121 dir.z = State::getCameraNode()->getAbsDir Z().z;132 dir.x = State::getCameraNode()->getAbsDirX().x; 133 dir.y = State::getCameraNode()->getAbsDirX().y; 134 dir.z = State::getCameraNode()->getAbsDirX().z; 122 135 float dist = dir.x*this->cam.x +dir.y*this->cam.y +dir.z*this->cam.z; 123 136 //if(dist < 0) dist = -dist; … … 125 138 const float dMaxs = dir.x*(float)curLeaf.maxs[0] +dir.y*(float)curLeaf.maxs[1] +dir.z*(float)curLeaf.maxs[2] - dist ; 126 139 127 if(dMins < -1 .0 && dMaxs < -1.0) {128 //continue;140 if(dMins < -150.0 && dMaxs < -150.0) { 141 continue; 129 142 } 130 143 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;144 continue; 132 145 } 133 146 … … 179 192 const float dMaxs = dir.x*(float)curLeaf.maxs[0] +dir.y*(float)curLeaf.maxs[1] +dir.z*(float)curLeaf.maxs[2] - dist; 180 193 181 if(dMins < - 30.0 && dMaxs < -30.0) {194 if(dMins < -100.0 && dMaxs < - 100.0) { 182 195 continue; 183 196 } … … 466 479 if (fraction > startFraction) 467 480 startFraction = fraction; 481 // store plane 482 this->collPlane = &curPlane; 483 468 484 } else { // line is leaving the brush 469 485 float fraction = (startDistance + EPSILON) / (startDistance - endDistance); // * 470 486 if (fraction < endFraction) 471 487 endFraction = fraction; 488 // store plane 489 this->collPlane = & curPlane; 490 472 491 } 473 492 … … 484 503 if (startFraction < 0) 485 504 startFraction = 0; 486 this->outputFraction = startFraction; 505 this->outputFraction = startFraction; 487 506 } 488 507 } … … 587 606 void BspManager::checkCollision(WorldEntity* worldEntity) 588 607 { 589 608 // return; 609 590 610 Vector position = worldEntity->getAbsCoor(); 591 611 592 612 593 613 Vector forwardDir = worldEntity->getAbsDirX(); 594 forwardDir.x = 10*forwardDir.x;595 forwardDir.y = 10*forwardDir.y;596 forwardDir.z = 10*forwardDir.z;614 forwardDir.x =2.0*forwardDir.x; 615 forwardDir.y =2.0*forwardDir.y; 616 forwardDir.z =2.0*forwardDir.z; 597 617 598 618 Vector upDir = worldEntity->getAbsDirY(); … … 643 663 out.y = position.y + (dest.y -position.y) * this->outputFraction; 644 664 out.z = position.z + (dest.z -position.z) * this->outputFraction; 665 666 Vector out3 = out + Vector(3*this->collPlane->x,3*this->collPlane->y,3*this->collPlane->z); 667 this->out = out; 668 this->out1 = out1; 669 this->out2 = out2; 670 //this->drawDebugCube(&out1); 671 //this->drawDebugCube(&out2); 672 673 //this->drawDebugCube(&out3); 645 674 646 675 } 647 676 648 if(collision) worldEntity->collidesWithGround(out,out1,out2);677 // if(collision) worldEntity->collidesWithGround(out,out1,out2); 649 678 650 679 } -
branches/bsp_model/src/lib/graphics/importer/bsp_manager.h
r7833 r8030 25 25 struct face; 26 26 struct brush; 27 struct plane; 28 27 29 class WorldEntity; 28 30 … … 57 59 Vector ship; 58 60 Vector viewDir; 61 plane* collPlane; 59 62 int lastTex; 60 63 … … 69 72 ::std::deque<int> opal; //!< the others here. 70 73 74 Vector out; 75 Vector out1; 76 Vector out2; 71 77 }; 72 78 -
branches/bsp_model/src/world_entities/world_entity.cc
r7833 r8030 288 288 { 289 289 290 PRINTF(0)("BSP_GROUND: Player collides \n", this->getClassName() ); 290 // PRINTF(0)("BSP_GROUND: Player collides \n", this->getClassName() ); 291 291 292 Vector v = this->getAbsDirX(); 292 293 v.x *= 10; 293 294 v.y *= 10; 294 295 v.z *= 10; 296 Vector u = this->getAbsDirY(); 297 298 if(feet.x == (u.x+this->getAbsCoor().x) && feet.y == u.y +this->getAbsCoor().y && feet.z == this->getAbsCoor().z) 299 { 300 295 301 this->setAbsCoor(ray_2 - v); 302 } 303 else 304 { 305 if(ray_1.x == this->getAbsCoor().x + v.x && ray_1.y == this->getAbsCoor().y + v.y + 0.1 && ray_1.z ==this->getAbsCoor().z + v.z) 306 { 307 this->setAbsCoor(feet -u ); 308 } 309 310 this->setAbsCoor(ray_2 - v); 311 312 } 296 313 } 297 314
Note: See TracChangeset
for help on using the changeset viewer.