本文整理汇总了C++中PxPhysics::createRigidDynamic方法的典型用法代码示例。如果您正苦于以下问题:C++ PxPhysics::createRigidDynamic方法的具体用法?C++ PxPhysics::createRigidDynamic怎么用?C++ PxPhysics::createRigidDynamic使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PxPhysics
的用法示例。
在下文中一共展示了PxPhysics::createRigidDynamic方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createProxyActor
bool Controller::createProxyActor(PxPhysics& sdk, const PxGeometry& geometry, const PxMaterial& material)
{
// PT: we don't disable raycasting or CD because:
// - raycasting is needed for visibility queries (the SDK otherwise doesn't know about the CCTS)
// - collision is needed because the only reason we create actors there is to handle collisions with dynamic shapes
// So it's actually wrong to disable any of those.
PxTransform globalPose;
globalPose.p = toVec3(mPosition); // LOSS OF ACCURACY
globalPose.q = mUserParams.mQuatFromUp;
mKineActor = sdk.createRigidDynamic(globalPose);
if(!mKineActor)
return false;
mKineActor->createShape(geometry, material);
mKineActor->setRigidDynamicFlag(PxRigidDynamicFlag::eKINEMATIC, true);
PxRigidBodyExt::updateMassAndInertia(*mKineActor, mProxyDensity);
mScene->addActor(*mKineActor);
return true;
}
示例2: aux
void
PhysXRigidManager::addDynamicBody(const std::string & scene, physx::PxScene * world, physx::PxCooking * mCooking, nau::physics::IPhysics::BoundingVolume shape, physx::PxMaterial * material) {
PxPhysics *gPhysics = &(world->getPhysics());
PxRigidDynamic * dynamic;
rigidBodies[scene].scalingFactor = getScalingFactor(rigidBodies[scene].info.extInfo.transform);
PxMeshScale scale = PxMeshScale(rigidBodies[scene].scalingFactor);
PxMat44 aux(rigidBodies[scene].info.extInfo.transform);
PxVec3 pos(aux.getPosition());
aux *= (1.0f / rigidBodies[scene].scalingFactor);
PxMat44 mat(
PxVec3(aux.column0.x, aux.column0.y, aux.column0.z),
PxVec3(aux.column1.x, aux.column1.y, aux.column1.z),
PxVec3(aux.column2.x, aux.column2.y, aux.column2.z),
pos
);
//PxTransform trans = PxTransform(PxMat44(rigidBodies[scene].extInfo.transform));
PxTransform trans = PxTransform(mat);
switch (shape.sceneShape)
{
case nau::physics::IPhysics::BOX:
{
dynamic = gPhysics->createRigidDynamic(trans);
dynamic->createShape(
PxBoxGeometry(
shape.max[0] * rigidBodies[scene].scalingFactor,
shape.max[1] * rigidBodies[scene].scalingFactor,
shape.max[2] * rigidBodies[scene].scalingFactor),
*material);
}
break;
case nau::physics::IPhysics::SPHERE:
{
dynamic = gPhysics->createRigidDynamic(trans);
dynamic->createShape(PxSphereGeometry(shape.max[0] * rigidBodies[scene].scalingFactor), *material);
}
break;
case nau::physics::IPhysics::CAPSULE:
{
dynamic = gPhysics->createRigidDynamic(trans);
dynamic->createShape(
PxCapsuleGeometry(
shape.max[0] * rigidBodies[scene].scalingFactor,
shape.max[1] * rigidBodies[scene].scalingFactor),
*material);
}
break;
default:
{
dynamic = gPhysics->createRigidDynamic(trans);
PxConvexMesh * convexMesh = gPhysics->createConvexMesh(*getTriangleMeshGeo(world, mCooking, rigidBodies[scene].info.extInfo, false));
dynamic->createShape(PxConvexMeshGeometry(convexMesh, scale), *material);
}
break;
}
dynamic->userData = static_cast<void*> (new std::string(scene));
rigidBodies[scene].rollingFriction = -1.0f;
rigidBodies[scene].rollingFrictionTimeStamp = 1;
world->addActor(*dynamic);
rigidBodies[scene].info.actor = dynamic;
}
示例3: convGeom
void
PhsXWorld::_addRigid(float mass, float friction, float restitution, std::shared_ptr<nau::scene::IScene> &aScene, std::string name, nau::math::vec3 aVec) {
PxPhysics *gPhysics = &(m_pDynamicsWorld->getPhysics());
if (mass == 0.0f) {
PxRigidStatic* staticActor;
if (name.compare("plane") == 0) {
staticActor = PxCreatePlane(*gPhysics,
PxPlane(0.0f, 1.0f, 0.0f, 0.0f),
*(gPhysics->createMaterial(friction, friction, restitution))
);
}
else {
/*if (name.compare("box") == 0) {
staticActor = PxCreateStatic(*gPhysics,
PxTransform(PxMat44(const_cast<float*> (aScene->getTransform().getMatrix()))),
PxBoxGeometry(1.0f,1.0f,1.0f),
*(gPhysics->createMaterial(1.0f, 1.0f, 0.6f))
);
}
else {*/
staticActor = gPhysics->createRigidStatic(PxTransform(PxMat44(const_cast<float*> (aScene->getTransform().getMatrix()))));
PxTriangleMeshGeometry triGeom;
triGeom.triangleMesh = gPhysics->createTriangleMesh(getTriangleMeshGeo(m_pDynamicsWorld, aScene));
staticActor->createShape(triGeom, *(gPhysics->createMaterial(friction, friction, restitution)));
//}
}
staticActor->userData = aScene.get();
m_pDynamicsWorld->addActor(*staticActor);
}
else {
PxRigidDynamic* dynamic;
//if (name.compare("ball") == 0) {
// dynamic = PxCreateDynamic(*gPhysics,
// PxTransform(PxMat44(const_cast<float*> (aScene->getTransform().getMatrix()))),
// PxSphereGeometry(1),
// *(gPhysics->createMaterial(0.5f, 0.5f, 0.6f)),
// 10.0f
// );
// //dynamic->setLinearVelocity(PxVec3(0, -50, -100));
//}
//else {
PxTransform trans = PxTransform(PxMat44(const_cast<float*> (aScene->getTransform().getMatrix())));
dynamic = gPhysics->createRigidDynamic(trans);
PxConvexMesh * convexMesh = gPhysics->createConvexMesh(getTriangleMeshGeo(m_pDynamicsWorld, aScene, false));
PxConvexMeshGeometry convGeom(convexMesh);
//PxConvexMeshGeometry convGeom(convexMesh, PxMeshScale(0.5f));
//convGeom.convexMesh = gPhysics->createConvexMesh(getTriangleMeshGeo(m_pDynamicsWorld, aScene, false));
//PxShape *shape = dynamic->createShape(convGeom, *(gPhysics->createMaterial(0.5f, 0.5f, 0.6f)), PxShapeFlag::eSIMULATION_SHAPE | PxShapeFlag::eVISUALIZATION | PxShapeFlag::eSCENE_QUERY_SHAPE);
PxShape *shape = dynamic->createShape(convGeom, *(gPhysics->createMaterial(friction, friction, restitution)));
//shape->setFlag(PxShapeFlag::eSIMULATION_SHAPE, true);
//dynamic->setRigidBodyFlag(PxRigidBodyFlag::eKINEMATIC, false);
//}
dynamic->userData = aScene.get();
//dynamic->setAngularDamping(0.5f);
//dynamic->setLinearVelocity(velocity);
m_pDynamicsWorld->addActor(*dynamic);
}
}