Changeset 8894 in orxonox.OLD for trunk/src/lib/graphics/importer/bsp_manager.cc
- Timestamp:
- Jun 29, 2006, 12:19:48 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/graphics/importer/bsp_manager.cc
r8796 r8894 45 45 46 46 #include "aabb.h" 47 47 #include "cr_defs.h" 48 48 49 49 … … 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 } 922 ; 919 {} 920 923 921 924 922 void BspManager::TraceBox( Vector& inputStart, Vector& inputEnd, … … 954 952 955 953 956 Vector forwardDir = worldEntity->getAbsDirX(); 957 958 959 Vector upDir = worldEntity->getAbsDirY(); 960 upDir.x = 0.0; 961 upDir.y = 1.0; 962 upDir.z = 0.0; 963 Vector dest; 964 965 966 Vector position = worldEntity->getAbsCoor(); //+ upDir*10.0f ; 967 dest = worldEntity->getAbsCoor() - upDir*40.0f; // 968 Vector out = dest; 969 970 954 Vector forwardDir = Vector(0.0,0.0,1.0); 955 Vector upDir = Vector(0.0,1.0,0.0); 956 Vector position = worldEntity->getAbsCoor(); 957 958 bool SolidFlag = false; 971 959 bool collision = false; 972 960 Vector position1 = position; 973 961 Vector position2 = position + Vector(0.0,1.0,0.0); 962 Vector dest = worldEntity->getAbsCoor() - upDir*40.0f; // 974 963 Vector dest1 = position + forwardDir*4.0f; 975 964 Vector dest2 = position2 + forwardDir; 976 965 dest = position - Vector(0.0, 40.0,0.0); 966 Vector out = dest; 977 967 Vector out1; 978 968 Vector out2; 979 969 980 970 981 971 982 972 float height = 40; 983 984 985 if( box != NULL) 986 { 973 974 975 if( box != NULL) { 987 976 position = worldEntity->getAbsCoor() + box->center; // + box->axis[1] * box->halfLength[1]; 988 977 dest = worldEntity->getAbsCoor() + box->center - box->axis[1] * box->halfLength[1] * 40.0; 989 978 990 979 position1 = worldEntity->getAbsCoor() + box->center + box->axis[0] * box->halfLength[0] * 2.0f; 991 980 dest1 = worldEntity->getAbsCoor() + box->center - box->axis[0] * box->halfLength[0] *2.0f; 992 993 981 982 994 983 position2 = worldEntity->getAbsCoor() + box->center + box->axis[2] * box->halfLength[2] * 2.0f; 995 984 dest2 = worldEntity->getAbsCoor() + box->center - box->axis[2] * box->halfLength[2] * 2.0f; 996 997 } 998 else 999 { 1000 1001 } 1002 1003 1004 1005 // 985 986 } else { 987 // Init positions and destinations to anything useful! 988 989 } 990 991 992 993 // 1st Ray 1006 994 this->inputStart = position; 1007 995 this->inputEnd = dest; … … 1025 1013 this->collPlane->z = 0.0f; 1026 1014 collision = true; 1027 } else 1015 SolidFlag = true; 1016 } else 1028 1017 collision = false; 1029 1030 1031 1032 1018 1019 1020 out = dest; 1021 1033 1022 } else { 1034 1023 collision = true; … … 1046 1035 plane* testPlane = this->collPlane; 1047 1036 1048 1049 // 2nd Collision Detection 1050 this->outputStartsOut = true; 1051 this->outputAllSolid = false; 1052 this->outputFraction = 1.0f; 1053 this->inputStart = position1; 1054 this->inputEnd = dest1; 1055 this->checkCollisionRayN(this->root,0.0f,1.0f, &position1, &dest1 ); 1056 out.x = this->outputFraction; 1057 //out.z = this->outputFraction; 1058 1059 1060 // 3rd Collision Detection 1061 this->outputStartsOut = true; 1062 this->outputAllSolid = false; 1063 this->outputFraction = 1.0f; 1064 this->inputStart = position2; 1065 this->inputEnd = dest2; 1066 this->checkCollisionRayN(this->root,0.0f,1.0f, &position2, &dest2 ); 1067 //out.x = this->outputFraction; 1068 out.z = this->outputFraction; 1069 1070 1037 1038 bool xCollision = false; 1039 bool zCollision = false; 1040 if(!SolidFlag) { 1041 1042 // 2nd Collision Detection 1043 this->outputStartsOut = true; 1044 this->outputAllSolid = false; 1045 this->outputFraction = 1.0f; 1046 this->inputStart = position1; 1047 this->inputEnd = dest1; 1048 this->checkCollisionRayN(this->root,0.0f,1.0f, &position1, &dest1 ); 1049 1050 if(!this->outputAllSolid != 1.0f) { 1051 out.x = dest1.x + (dest1.x -position1.x) * this->outputFraction; 1052 xCollision = true; 1053 testPlane = this->collPlane; 1054 } 1055 if(this->outputAllSolid) { 1056 SolidFlag = true; 1057 xCollision = true; 1058 } 1059 //out.z = this->outputFraction; 1060 1061 if(!SolidFlag) { 1062 1063 // 3rd Collision Detection 1064 this->outputStartsOut = true; 1065 this->outputAllSolid = false; 1066 this->outputFraction = 1.0f; 1067 this->inputStart = position2; 1068 this->inputEnd = dest2; 1069 this->checkCollisionRayN(this->root,0.0f,1.0f, &position2, &dest2 ); 1070 //out.x = this->outputFraction; 1071 1072 if(this->outputFraction != 1.0f ) { 1073 out.z = out.z = dest2.z + (dest2.z -position2.z) * this->outputFraction; 1074 zCollision = true; 1075 testPlane = this->collPlane; 1076 1077 } 1078 if(this->outputAllSolid) { 1079 SolidFlag = true; 1080 zCollision = true; 1081 } 1082 } 1083 }//end if 1071 1084 /* 1072 1085 This is how you would calculate the Coordinates where worldEntity Collided with the BSP world. … … 1077 1090 1078 1091 // Return the normal here: Normal's stored in this->collPlane; 1079 if( collision) 1080 { 1092 if( collision) { 1081 1093 PRINTF(5)("We got a collision!! Are you sure: outputFraction = %f\n", this->outputFraction); 1082 worldEntity->registerCollision(this->parent, worldEntity, Vector(testPlane->x, testPlane->y, testPlane->z), out); 1083 } 1084 else worldEntity->registerCollision(this->parent, worldEntity, Vector(0.0, 2.0, 0.0), dest); 1094 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); 1095 } else { 1096 if(xCollision || zCollision) { 1097 1098 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); 1099 } 1100 1101 } 1102 //else worldEntity->registerCollision(COLLISION_TYPE_AXIS_Y, this->parent, worldEntity, Vector(0.0, 2.0, 0.0), dest, false); 1085 1103 1086 1104 }
Note: See TracChangeset
for help on using the changeset viewer.