| 301 | /////////////////////////////////////////////////////////////////////////////// |
| 302 | |
| 303 | PxRigidDynamic* SampleSubmarine::createSubmarine(const PxVec3& inPosition, const PxReal yRot) |
| 304 | { |
| 305 | PX_ASSERT(mSubmarineActor == NULL); |
| 306 | |
| 307 | std::vector<PxTransform> localPoses; |
| 308 | std::vector<const PxGeometry*> geometries; |
| 309 | |
| 310 | // cabin |
| 311 | PxSphereGeometry cabinGeom(1.5f); |
| 312 | PxTransform cabinPose = PxTransform(PxIdentity); |
| 313 | cabinPose.p.x = -0.5f; |
| 314 | |
| 315 | // engine |
| 316 | PxBoxGeometry engineGeom(0.25f, 1.0f, 1.0f); |
| 317 | PxTransform enginePose = PxTransform(PxIdentity); |
| 318 | enginePose.p.x = cabinPose.p.x + cabinGeom.radius + engineGeom.halfExtents.x; |
| 319 | |
| 320 | // tanks |
| 321 | PxCapsuleGeometry tankGeom(0.5f, 1.8f); |
| 322 | PxTransform tank1Pose = PxTransform(PxIdentity); |
| 323 | tank1Pose.p = PxVec3(0,-cabinGeom.radius, cabinGeom.radius); |
| 324 | PxTransform tank2Pose = PxTransform(PxIdentity); |
| 325 | tank2Pose.p = PxVec3(0,-cabinGeom.radius, -cabinGeom.radius); |
| 326 | |
| 327 | localPoses.push_back(cabinPose); |
| 328 | geometries.push_back(&cabinGeom); |
| 329 | localPoses.push_back(enginePose); |
| 330 | geometries.push_back(&engineGeom); |
| 331 | localPoses.push_back(tank1Pose); |
| 332 | geometries.push_back(&tankGeom); |
| 333 | localPoses.push_back(tank2Pose); |
| 334 | geometries.push_back(&tankGeom); |
| 335 | |
| 336 | // put the shapes together into one actor |
| 337 | mSubmarineActor = PhysXSample::createCompound(inPosition, localPoses, geometries, 0, mManagedMaterials[MATERIAL_YELLOW], gSubMarineDensity)->is<PxRigidDynamic>(); |
| 338 | |
| 339 | if(!mSubmarineActor) fatalError("createCompound failed!"); |
| 340 | |
| 341 | //disable the current and buoyancy effect for the sub. |
| 342 | mSubmarineActor->setActorFlag(PxActorFlag::eDISABLE_GRAVITY, true); |
| 343 | |
| 344 | // set the filtering group for the submarine |
| 345 | setupFiltering(mSubmarineActor, FilterGroup::eSUBMARINE, FilterGroup::eMINE_HEAD | FilterGroup::eMINE_LINK); |
| 346 | |
| 347 | mSubmarineActor->setLinearDamping(0.15f); |
| 348 | mSubmarineActor->setAngularDamping(15.0f); |
| 349 | |
| 350 | PxTransform globalPose; |
| 351 | globalPose.p = inPosition; |
| 352 | globalPose.q = PxQuat(yRot, PxVec3(0,1,0)); |
| 353 | mSubmarineActor->setGlobalPose(globalPose); |
| 354 | |
| 355 | mSubmarineActor->setCMassLocalPose(PxTransform(PxIdentity)); |
| 356 | |
| 357 | return mSubmarineActor; |
| 358 | } |
| 359 | |
| 360 | /////////////////////////////////////////////////////////////////////////////// |
nothing calls this directly
no test coverage detected