Changeset 9088 in orxonox.OLD for branches/presentation/src/lib/graphics
- Timestamp:
- Jul 4, 2006, 2:17:07 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/presentation/src/lib/graphics/importer/bsp_manager.cc
r9086 r9088 1146 1146 1147 1147 1148 /* Vector forwardDir = Vector(0.0,0.0,1.0); 1149 Vector upDir = Vector(0.0,1.0,0.0);*/ 1150 Vector position = entity->getAbsCoor(); 1151 1152 bool SolidFlag = false; 1153 1154 plane* testPlane = NULL; 1155 1156 bool xCollisionRight = false; 1157 bool xCollisionLeft = false; 1158 1159 1160 Vector left; //!< left collision ray 1161 Vector right; //!< right collision ray 1148 plane* testPlane = NULL; //!< the collision test plane 1149 1150 Vector forward; //!< left collision ray 1151 Vector backward; //!< right collision ray 1162 1152 Vector collPos; //!< the collision position 1163 1153 1164 1165 1166 1167 Vector dirX = entity->getAbsDirX(); dirX.y = 0.0f; dirX.normalize(); 1154 bool xCollisionForward = false; //!< flag true if right collision 1155 bool xCollisionBackward = false; //!< flag true if left collision 1156 bool SolidFlag = false; //!< flag set true if solid 1157 1158 Vector position; //!< current position of the entity 1159 Vector dirX; //!< direction x 1160 1161 position = entity->getAbsCoor(); 1162 dirX = entity->getAbsDirX(); dirX.y = 0.0f; dirX.normalize(); 1168 1163 1169 1164 // calculate the rays 1170 1165 if( box != NULL) 1171 1166 { 1172 left= entity->getAbsCoor() + box->center + dirX * (box->halfLength[0] + BSP_X_OFFSET);1173 right= entity->getAbsCoor() - box->center + dirX * (box->halfLength[0] + BSP_X_OFFSET);1167 forward = entity->getAbsCoor() + box->center + dirX * (box->halfLength[0] + BSP_X_OFFSET); 1168 backward = entity->getAbsCoor() - box->center + dirX * (box->halfLength[0] + BSP_X_OFFSET); 1174 1169 } 1175 1170 else 1176 1171 { 1177 left= position + dirX * 4.0f;1178 right= position + Vector(0.0, 1.0, 0.0) + dirX * 4.0;1179 } 1180 1181 1182 /* X Ray Left*/1172 forward = position + dirX * 4.0f; 1173 backward = position + Vector(0.0, 1.0, 0.0) + dirX * 4.0; 1174 } 1175 1176 1177 /* X Ray forward */ 1183 1178 // init some member variables before collision check 1184 1179 this->outputStartsOut = true; … … 1186 1181 this->outputFraction = 1.0f; 1187 1182 this->inputStart = position; 1188 this->inputEnd = right;1189 this->checkCollisionRayN(this->root,0.0f,1.0f, &position, & right);1183 this->inputEnd = forward; 1184 this->checkCollisionRayN(this->root,0.0f,1.0f, &position, &forward ); 1190 1185 1191 1186 // collision occured 1192 1187 if( this->outputFraction < 1.0f) 1193 1188 { 1194 collPos = position + ( right- position) * this->outputFraction;1195 xCollision Right= true;1189 collPos = position + (forward - position) * this->outputFraction; 1190 xCollisionForward = true; 1196 1191 testPlane = this->collPlane; 1197 1192 } … … 1204 1199 testPlane = this->collPlane; 1205 1200 SolidFlag = true; 1206 xCollision Right= true;1201 xCollisionForward = true; 1207 1202 } 1208 1203 1209 1204 // collision registration 1210 if( xCollision Right) {1205 if( xCollisionForward) { 1211 1206 entity->registerCollision(COLLISION_TYPE_AXIS_X , 1207 this->parent, entity, 1208 Vector(testPlane->x, testPlane->y, testPlane->z), 1209 collPos, 1210 SolidFlag); 1211 } 1212 1213 1214 1215 /* X Ray backward */ 1216 // init some member variables before collision check 1217 this->outputStartsOut = true; 1218 this->outputAllSolid = false; 1219 this->outputFraction = 1.0f; 1220 this->inputStart = position; 1221 this->inputEnd = backward; 1222 this->checkCollisionRayN(this->root,0.0f,1.0f, &position, &backward ); 1223 1224 // collision occured 1225 if( this->outputFraction < 1.0f) 1226 { 1227 collPos = position + (backward - position) * this->outputFraction; 1228 xCollisionBackward = true; 1229 testPlane = this->collPlane; 1230 } 1231 if(this->outputAllSolid ) 1232 { 1233 this->collPlane = new plane; 1234 this->collPlane->x = 0.0f; 1235 this->collPlane->y = 0.0f; 1236 this->collPlane->z = 0.0f; 1237 testPlane = this->collPlane; 1238 SolidFlag = true; 1239 xCollisionBackward = true; 1240 } 1241 1242 // collision registration 1243 if( xCollisionBackward) { 1244 entity->registerCollision(COLLISION_TYPE_AXIS_X_NEG , 1212 1245 this->parent, entity, 1213 1246 Vector(testPlane->x, testPlane->y, testPlane->z),
Note: See TracChangeset
for help on using the changeset viewer.