- Timestamp:
- Jun 28, 2006, 9:51:05 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/single_player_map/src/lib/graphics/importer/bsp_manager.cc
r8888 r8889 1 1 /* 2 2 orxonox - the future of 3D-vertical-scrollers 3 3 4 4 Copyright (C) 2006 orx 5 5 6 6 This program is free software; you can redistribute it and/or modify 7 7 it under the terms of the GNU General Public License as published by 8 8 the Free Software Foundation; either version 2, or (at your option) 9 9 any later version. 10 10 11 11 ### File Specific: 12 12 main-programmer: bottac@ee.ethz.ch 13 13 14 14 Inspired by: 15 15 Rendering Q3 Maps by Morgan McGuire http://graphics.cs.brown.edu/games/quake/quake3.html 16 16 Unofficial Quake 3 Map Specs by Kekoa Proudfoot http://graphics.stanford.edu/~kekoa/q3/ 17 17 18 18 Collision detection adapted from: 19 19 Quake 3 Collision Detection by Nathan Ostgard http://www.devmaster.net/articles/quake3collision/ … … 69 69 BspManager::BspManager(const TiXmlElement* root) 70 70 { 71 72 71 72 73 73 if( root != NULL) 74 74 this->loadParams(root); 75 75 76 76 CDEngine::getInstance()->setBSPModel(this); 77 77 } */ … … 99 99 this->root = this->bspFile->get_root(); 100 100 this->alreadyVisible = new bool [this->bspFile->numFaces]; 101 101 102 102 CDEngine::getInstance()->setBSPModel(this); 103 103 } … … 912 912 { 913 913 leaf& curLeaf = this->bspFile->leaves[node->leafIndex]; 914 for(int i = 0; i < curLeaf.n_leaffaces ; i++) { 915 } 914 for(int i = 0; i < curLeaf.n_leaffaces ; i++) {} 916 915 return 10.0f; 917 916 } 918 917 919 918 void BspManager::checkCollisionBox(void) 920 { 921 } 919 {} 922 920 ; 923 921 … … 968 966 Vector out = dest; 969 967 970 968 971 969 bool SolidFlag = false; 972 970 bool collision = false; … … 984 982 985 983 986 if( box != NULL) 987 { 984 if( box != NULL) { 988 985 position = worldEntity->getAbsCoor() + box->center; // + box->axis[1] * box->halfLength[1]; 989 986 dest = worldEntity->getAbsCoor() + box->center - box->axis[1] * box->halfLength[1] * 40.0; … … 996 993 dest2 = worldEntity->getAbsCoor() + box->center - box->axis[2] * box->halfLength[2] * 2.0f; 997 994 998 } 999 else 1000 { 995 } else { 1001 996 // Init positions and destinations to anything useful! 1002 997 … … 1032 1027 1033 1028 1034 1029 out = dest; 1035 1030 1036 1031 } else { … … 1049 1044 plane* testPlane = this->collPlane; 1050 1045 1051 1046 1052 1047 bool xCollision = false; 1053 1048 bool zCollision = false; 1054 if(!SolidFlag) 1055 { 1056 1057 // 2nd Collision Detection 1058 this->outputStartsOut = true; 1059 this->outputAllSolid = false; 1060 this->outputFraction = 1.0f; 1061 this->inputStart = position1; 1062 this->inputEnd = dest1; 1063 this->checkCollisionRayN(this->root,0.0f,1.0f, &position1, &dest1 ); 1064 out.x = dest1.x + (dest1.x -position1.x) * this->outputFraction; 1065 xCollision = true; 1066 //out.z = this->outputFraction; 1067 1068 if(!SolidFlag) 1069 { 1070 1071 // 3rd Collision Detection 1072 this->outputStartsOut = true; 1073 this->outputAllSolid = false; 1074 this->outputFraction = 1.0f; 1075 this->inputStart = position2; 1076 this->inputEnd = dest2; 1077 this->checkCollisionRayN(this->root,0.0f,1.0f, &position2, &dest2 ); 1078 //out.x = this->outputFraction; 1079 out.z = out.z = dest2.z + (dest2.z -position2.z) * this->outputFraction; 1080 if(this->outputFraction != 1.0 ) 1081 zCollision = true; 1082 } 1083 } 1049 if(!SolidFlag) { 1050 1051 // 2nd Collision Detection 1052 this->outputStartsOut = true; 1053 this->outputAllSolid = false; 1054 this->outputFraction = 1.0f; 1055 this->inputStart = position1; 1056 this->inputEnd = dest1; 1057 this->checkCollisionRayN(this->root,0.0f,1.0f, &position1, &dest1 ); 1058 1059 if(!this->outputAllSolid != 1.0f) { 1060 out.x = dest1.x + (dest1.x -position1.x) * this->outputFraction; 1061 xCollision = true; 1062 } 1063 if(this->outputAllSolid) { 1064 SolidFlag = true; 1065 xCollision = true; 1066 } 1067 //out.z = this->outputFraction; 1068 1069 if(!SolidFlag) { 1070 1071 // 3rd Collision Detection 1072 this->outputStartsOut = true; 1073 this->outputAllSolid = false; 1074 this->outputFraction = 1.0f; 1075 this->inputStart = position2; 1076 this->inputEnd = dest2; 1077 this->checkCollisionRayN(this->root,0.0f,1.0f, &position2, &dest2 ); 1078 //out.x = this->outputFraction; 1079 1080 if(this->outputFraction != 1.0f ) { 1081 out.z = out.z = dest2.z + (dest2.z -position2.z) * this->outputFraction; 1082 zCollision = true; 1083 } 1084 if(this->outputAllSolid) { 1085 SolidFlag = true; 1086 zCollision = true; 1087 } 1088 } 1089 }//end if 1084 1090 /* 1085 1091 This is how you would calculate the Coordinates where worldEntity Collided with the BSP world. … … 1090 1096 1091 1097 // Return the normal here: Normal's stored in this->collPlane; 1092 if( collision) 1093 { 1098 if( collision) { 1094 1099 PRINTF(5)("We got a collision!! Are you sure: outputFraction = %f\n", this->outputFraction); 1095 1100 worldEntity->registerCollision(COLLISION_TYPE_AXIS_Y || (xCollision ? COLLISION_TYPE_AXIS_X :0) | (zCollision ? COLLISION_TYPE_AXIS_Z :0), this->parent, worldEntity, Vector(testPlane->x, testPlane->y, testPlane->z), out, SolidFlag); 1096 } 1097 else 1098 { 1099 if(xCollision || yCollision) 1100 { 1101 1102 worldEntity->registerCollision((xCollision ? COLLISION_TYPE_AXIS_X :0) | (zCollision ? COLLISION_TYPE_AXIS_Z :0) , this->parent, worldEntity, Vector(testPlane->x, testPlane->y, testPlane->z), out, false); 1103 } 1104 1101 } else { 1102 if(xCollision || zCollision) { 1103 1104 worldEntity->registerCollision((xCollision ? COLLISION_TYPE_AXIS_X :0) | (zCollision ? COLLISION_TYPE_AXIS_Z :0) , this->parent, worldEntity, Vector(testPlane->x, testPlane->y, testPlane->z), out, SolidFlag); 1105 } 1106 1105 1107 } 1106 1108 //else worldEntity->registerCollision(COLLISION_TYPE_AXIS_Y, this->parent, worldEntity, Vector(0.0, 2.0, 0.0), dest, false);
Note: See TracChangeset
for help on using the changeset viewer.