Changeset 9093 in orxonox.OLD
- Timestamp:
- Jul 4, 2006, 2:59:07 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/presentation/src/lib/graphics/importer/bsp_manager.cc
r9091 r9093 1166 1166 { 1167 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);1168 backward = entity->getAbsCoor() + box->center - dirX * (box->halfLength[0] + BSP_X_OFFSET); 1169 1169 } 1170 1170 else … … 1203 1203 1204 1204 // collision registration 1205 if( xCollisionForward) { 1205 if( xCollisionForward) 1206 { 1206 1207 entity->registerCollision(COLLISION_TYPE_AXIS_X , 1207 1208 this->parent, entity, … … 1241 1242 1242 1243 // collision registration 1243 if( xCollisionBackward) { 1244 if( xCollisionBackward) 1245 { 1244 1246 entity->registerCollision(COLLISION_TYPE_AXIS_X_NEG , 1245 1247 this->parent, entity, … … 1248 1250 SolidFlag); 1249 1251 } 1250 1251 } 1252 } 1253 1252 1254 1253 1255 /** 1254 * check the collision in the ydirection (up, down)1256 * check the collision in the z direction (up, down) 1255 1257 */ 1256 1258 void BspManager::checkCollisionY(WorldEntity* entity) 1259 { 1260 1261 // Retrieve Bounding box 1262 AABB* box = entity->getModelAABB(); 1263 1264 1265 plane* testPlane = NULL; //!< the collision test plane 1266 1267 Vector up; //!< up collision ray 1268 Vector down; //!< down collision ray 1269 Vector collPos; //!< the collision position 1270 1271 bool yCollisionUp = false; //!< flag true if right collision 1272 bool yCollisionDown = false; //!< flag true if left collision 1273 bool SolidFlag = false; //!< flag set true if solid 1274 1275 Vector position; //!< current position of the entity 1276 Vector dirY; //!< direction x 1277 1278 position = entity->getAbsCoor(); 1279 collPos = position; 1280 dirY = Vector(0.0, 1.0, 0.0); 1281 1282 // calculate the rays 1283 if( box != NULL) 1284 { 1285 up = position + box->center + dirY * (box->halfLength[1] + BSP_Y_OFFSET); 1286 down = position + box->center - dirY * (box->halfLength[1] + BSP_Y_OFFSET); 1287 } 1288 else 1289 { 1290 up = position + dirY * 4.0f; 1291 down = position + Vector(0.0, 1.0, 0.0) + dirY * 4.0; 1292 } 1293 1294 1295 1296 1297 /* Y Ray up */ 1298 // init some member variables before collision check 1299 this->inputStart = position; 1300 this->inputEnd = up; 1301 this->checkCollisionRayN(this->root,0.0f,1.0f, &position, &up ); 1302 1303 if( !this->outputStartsOut ) 1304 { 1305 this->collPlane = new plane; 1306 this->collPlane->x = 0.0f; 1307 this->collPlane->y = 0.0f; 1308 this->collPlane->z = 0.0f; 1309 yCollisionUp = true; 1310 } 1311 else 1312 { 1313 if( this->outputFraction == 1.0f) 1314 { 1315 if( this->outputAllSolid ) 1316 { 1317 this->collPlane = new plane; 1318 this->collPlane->x = 0.0f; 1319 this->collPlane->y = 0.0f; 1320 this->collPlane->z = 0.0f; 1321 yCollisionUp = true; 1322 SolidFlag = true; 1323 } 1324 else 1325 { 1326 yCollisionUp = false; 1327 collPos = up; 1328 } 1329 } 1330 else 1331 { 1332 yCollisionUp = true; 1333 collPos = position + (up - position) * this->outputFraction; 1334 this->out = collPos; // why this???? 1335 } 1336 } 1337 testPlane = this->collPlane; 1338 1339 // collision registration 1340 if( yCollisionUp) 1341 { 1342 entity->registerCollision(COLLISION_TYPE_AXIS_Y , this->parent, 1343 entity, 1344 Vector(testPlane->x, testPlane->y, testPlane->z), 1345 collPos, SolidFlag); 1346 } 1347 1348 1349 1350 1351 /* Y Ray down */ 1352 // init some member variables before collision check 1353 this->inputStart = position; 1354 this->inputEnd = down; 1355 this->checkCollisionRayN(this->root,0.0f,1.0f, &position, &down ); 1356 1357 if( !this->outputStartsOut ) 1358 { 1359 this->collPlane = new plane; 1360 this->collPlane->x = 0.0f; 1361 this->collPlane->y = 0.0f; 1362 this->collPlane->z = 0.0f; 1363 yCollisionDown = true; 1364 } 1365 else 1366 { 1367 if( this->outputFraction == 1.0f) 1368 { 1369 if( this->outputAllSolid ) 1370 { 1371 this->collPlane = new plane; 1372 this->collPlane->x = 0.0f; 1373 this->collPlane->y = 0.0f; 1374 this->collPlane->z = 0.0f; 1375 yCollisionDown = true; 1376 SolidFlag = true; 1377 } 1378 else 1379 { 1380 yCollisionDown = false; 1381 collPos = down; 1382 } 1383 } 1384 else 1385 { 1386 yCollisionDown = true; 1387 collPos = position + (down - position) * this->outputFraction; 1388 this->out = collPos; // why this???? 1389 } 1390 } 1391 testPlane = this->collPlane; 1392 1393 // collision registration 1394 if( yCollisionDown) 1395 { 1396 entity->registerCollision(COLLISION_TYPE_AXIS_Y_NEG , this->parent, 1397 entity, 1398 Vector(testPlane->x, testPlane->y, testPlane->z), 1399 collPos, SolidFlag); 1400 } 1401 1402 1403 } 1404 1405 1406 1407 1408 /** 1409 * check the collision in the z direction (left, right) 1410 */ 1411 void BspManager::checkCollisionZ(WorldEntity* entity) 1257 1412 { 1258 1413 // Retrieve Bounding box … … 1280 1435 { 1281 1436 right = entity->getAbsCoor() + box->center + dirZ * (box->halfLength[2] + BSP_Z_OFFSET); 1282 left = entity->getAbsCoor() - box->center +dirZ * (box->halfLength[2] + BSP_Z_OFFSET);1437 left = entity->getAbsCoor() + box->center - dirZ * (box->halfLength[2] + BSP_Z_OFFSET); 1283 1438 } 1284 1439 else … … 1321 1476 if( zCollisionRight) { 1322 1477 entity->registerCollision(COLLISION_TYPE_AXIS_Z , this->parent, 1323 1324 1325 1478 entity, 1479 Vector(testPlane->x, testPlane->y, testPlane->z), 1480 collPos , SolidFlag); 1326 1481 } 1327 1482 … … 1366 1521 1367 1522 } 1368 1369 1370 /**1371 * check the collision in the z direction (left, right)1372 */1373 void BspManager::checkCollisionZ(WorldEntity* entity)1374 {1375 1376 }1377 1378 1523 1379 1524
Note: See TracChangeset
for help on using the changeset viewer.