本文整理汇总了C++中PxRigidDynamic::setRigidBodyFlag方法的典型用法代码示例。如果您正苦于以下问题:C++ PxRigidDynamic::setRigidBodyFlag方法的具体用法?C++ PxRigidDynamic::setRigidBodyFlag怎么用?C++ PxRigidDynamic::setRigidBodyFlag使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PxRigidDynamic
的用法示例。
在下文中一共展示了PxRigidDynamic::setRigidBodyFlag方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PxCreateKinematic
PxRigidDynamic* PxCreateKinematic(PxPhysics& sdk,
const PxTransform& transform,
PxShape& shape,
PxReal density)
{
PX_CHECK_AND_RETURN_NULL(transform.isValid(), "PxCreateKinematic: transform is not valid.");
bool isDynGeom = isDynamicGeometry(shape.getGeometryType());
if(isDynGeom && density <= 0.0f)
return NULL;
PxRigidDynamic* actor = sdk.createRigidDynamic(transform);
if(actor)
{
actor->setRigidBodyFlag(PxRigidBodyFlag::eKINEMATIC, true);
if(!isDynGeom)
shape.setFlag(PxShapeFlag::eSIMULATION_SHAPE, false);
actor->attachShape(shape);
if(isDynGeom)
PxRigidBodyExt::updateMassAndInertia(*actor, density);
else
{
actor->setMass(1.f);
actor->setMassSpaceInertiaTensor(PxVec3(1.f,1.f,1.f));
}
}
return actor;
}
示例2: createVehicleActor
PxRigidDynamic* Vehicle::createVehicleActor(const PxVehicleChassisData& chassisData,
PxMaterial** wheelMaterials, PxConvexMesh** wheelConvexMeshes, const PxU32 numWheels,
PxMaterial** chassisMaterials, PxConvexMesh** chassisConvexMeshes, const PxU32 numChassisMeshes, PxPhysics& physics, PxVec3 initPos)
{
//We need a rigid body actor for the vehicle.
//Don't forget to add the actor to the scene after setting up the associated vehicle.
PxRigidDynamic* vehActor = physics.createRigidDynamic(PxTransform(initPos));
vehActor->setRigidBodyFlag(PxRigidBodyFlag::eENABLE_CCD, true);
//Wheel and chassis simulation filter data.
PxFilterData wheelSimFilterData;
wheelSimFilterData.word0 = COLLISION_FLAG_WHEEL;
wheelSimFilterData.word1 = COLLISION_FLAG_WHEEL_AGAINST;
PxFilterData chassisSimFilterData;
chassisSimFilterData.word0 = COLLISION_FLAG_CHASSIS;
chassisSimFilterData.word1 = COLLISION_FLAG_CHASSIS_AGAINST;
//Wheel and chassis query filter data.
//Optional: cars don't drive on other cars.
PxFilterData wheelQryFilterData;
wheelQryFilterData.word0 = FilterGroup::eWHEEL;
setupNonDrivableSurface(wheelQryFilterData);
PxFilterData chassisQryFilterData;
chassisQryFilterData.word0 = FilterGroup::eVEHICLE;
setupNonDrivableSurface(chassisQryFilterData);
//Add all the wheel shapes to the actor.
for (PxU32 i = 0; i < numWheels; i++)
{
PxConvexMeshGeometry geom(wheelConvexMeshes[i]);
PxShape* wheelShape = vehActor->createShape(geom, *wheelMaterials[i]);
wheelShape->setQueryFilterData(wheelQryFilterData);
wheelShape->setSimulationFilterData(wheelSimFilterData);
wheelShape->setLocalPose(PxTransform(PxIdentity));
}
//Add the chassis shapes to the actor.
for (PxU32 i = 0; i < numChassisMeshes; i++)
{
PxShape* chassisShape = vehActor->createShape
(PxConvexMeshGeometry(chassisConvexMeshes[i]), *chassisMaterials[i]);
chassisShape->setQueryFilterData(chassisQryFilterData);
chassisShape->setSimulationFilterData(chassisSimFilterData);
chassisShape->setLocalPose(PxTransform(PxIdentity));
}
vehActor->setMass(chassisData.mMass);
vehActor->setMassSpaceInertiaTensor(chassisData.mMOI);
vehActor->setCMassLocalPose(PxTransform(chassisData.mCMOffset, PxQuat(PxIdentity)));
return vehActor;
}
示例3: AddPhyObjects
// add some physics objects into the scene
void AddPhyObjects()
{
PxRigidStatic* groundPlane = PxCreatePlane(*gPhysics, PxPlane(0, 1, 0, 0), *gMaterial);
gScene->addActor(*groundPlane);
PxShape* shape = gPhysics->createShape(PxBoxGeometry(1.0f, 1.0f, 1.0f), *gMaterial);
PxTransform localTm(PxVec3(-3.0f, 5.0f, 0.f));
PxRigidDynamic* body = gPhysics->createRigidDynamic(localTm);
body->attachShape(*shape);
PxRigidBodyExt::updateMassAndInertia(*body, 10.0f);
gScene->addActor(*body);
shape->release();
shape = gPhysics->createShape(PxSphereGeometry(1.0f), *gMaterial);
PxTransform localTmS(PxVec3(3.0f, 5.0f, 0.f));
body = gPhysics->createRigidDynamic(localTmS);
body->attachShape(*shape);
PxRigidBodyExt::updateMassAndInertia(*body, 10.0f);
gScene->addActor(*body);
shape->release();
PxRigidDynamic* dynamic = PxCreateDynamic(*gPhysics, PxTransform(PxVec3(0, 20, 20)), PxSphereGeometry(1), *gMaterial, 10.0f);
dynamic->setAngularDamping(0.5f);
dynamic->setLinearVelocity(PxVec3(0, -5, -10));
gScene->addActor(*dynamic);
// add capsule into the scene
shape = gPhysics->createShape(PxCapsuleGeometry(1.0f, 3.0f), *gMaterial);
PxTransform localTmC(PxVec3(3.0f, 5.0f, -3.f));
body = gPhysics->createRigidDynamic(localTmC);
body->attachShape(*shape);
PxRigidBodyExt::updateMassAndInertia(*body, 10.0f);
gScene->addActor(*body);
// add a static box as the trigger
shape = gPhysics->createShape(PxBoxGeometry(1.0f, 1.0f, 1.0f), *gMaterial);
PxTransform localTmTrigger(PxVec3(0.0f, 1.0f, -10.f));
body = gPhysics->createRigidDynamic(localTmTrigger);
shape->setFlag(PxShapeFlag::eSIMULATION_SHAPE, false);
shape->setFlag(PxShapeFlag::eTRIGGER_SHAPE, true);
body->attachShape(*shape);
body->setRigidBodyFlag(PxRigidBodyFlag::eKINEMATIC, true);
gScene->addActor(*body);
shape->release();
}