本文整理汇总了C++中PxRigidDynamic::setCMassLocalPose方法的典型用法代码示例。如果您正苦于以下问题:C++ PxRigidDynamic::setCMassLocalPose方法的具体用法?C++ PxRigidDynamic::setCMassLocalPose怎么用?C++ PxRigidDynamic::setCMassLocalPose使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PxRigidDynamic
的用法示例。
在下文中一共展示了PxRigidDynamic::setCMassLocalPose方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PxCloneDynamic
PxRigidDynamic* PxCloneDynamic(PxPhysics& physicsSDK,
const PxTransform& transform,
const PxRigidDynamic& from)
{
PxRigidDynamic* to = physicsSDK.createRigidDynamic(transform);
if(!to)
return NULL;
copyStaticProperties(*to, from);
to->setRigidDynamicFlags(from.getRigidDynamicFlags());
to->setMass(from.getMass());
to->setMassSpaceInertiaTensor(from.getMassSpaceInertiaTensor());
to->setCMassLocalPose(from.getCMassLocalPose());
to->setLinearVelocity(from.getLinearVelocity());
to->setAngularVelocity(from.getAngularVelocity());
to->setLinearDamping(from.getAngularDamping());
to->setAngularDamping(from.getAngularDamping());
to->setMaxAngularVelocity(from.getMaxAngularVelocity());
PxU32 posIters, velIters;
from.getSolverIterationCounts(posIters, velIters);
to->setSolverIterationCounts(posIters, velIters);
to->setSleepThreshold(from.getSleepThreshold());
to->setContactReportThreshold(from.getContactReportThreshold());
return to;
}
示例2: PxScaleRigidActor
void PxScaleRigidActor(PxRigidActor& actor, PxReal scale, bool scaleMassProps)
{
PX_CHECK_AND_RETURN(scale > 0,
"PxScaleRigidActor requires that the scale parameter is greater than zero");
Ps::InlineArray<PxShape*, 64> shapes;
shapes.resize(actor.getNbShapes());
actor.getShapes(shapes.begin(), shapes.size());
for(PxU32 i=0;i<shapes.size();i++)
{
shapes[i]->setLocalPose(scalePosition(shapes[i]->getLocalPose(), scale));
PxGeometryHolder h = shapes[i]->getGeometry();
switch(h.getType())
{
case PxGeometryType::eSPHERE:
h.sphere().radius *= scale;
break;
case PxGeometryType::ePLANE:
break;
case PxGeometryType::eCAPSULE:
h.capsule().halfHeight *= scale;
h.capsule().radius *= scale;
break;
case PxGeometryType::eBOX:
h.box().halfExtents *= scale;
break;
case PxGeometryType::eCONVEXMESH:
h.convexMesh().scale.scale *= scale;
break;
case PxGeometryType::eTRIANGLEMESH:
h.triangleMesh().scale.scale *= scale;
break;
case PxGeometryType::eHEIGHTFIELD:
h.heightField().heightScale *= scale;
h.heightField().rowScale *= scale;
h.heightField().columnScale *= scale;
break;
case PxGeometryType::eINVALID:
case PxGeometryType::eGEOMETRY_COUNT:
default:
PX_ASSERT(0);
}
shapes[i]->setGeometry(h.any());
}
if(!scaleMassProps)
return;
PxRigidDynamic* dynamic = (&actor)->is<PxRigidDynamic>();
if(!dynamic)
return;
PxReal scale3 = scale*scale*scale;
dynamic->setMass(dynamic->getMass()*scale3);
dynamic->setMassSpaceInertiaTensor(dynamic->getMassSpaceInertiaTensor()*scale3*scale*scale);
dynamic->setCMassLocalPose(scalePosition(dynamic->getCMassLocalPose(), scale));
}
示例3: 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;
}
示例4: CloneDynamic
PxRigidDynamic* CloneDynamic(PxPhysics& physicsSDK,
const PxTransform& transform,
const PxRigidDynamic& from,
NxMirrorScene::MirrorFilter &mirrorFilter)
{
PxRigidDynamic* to = physicsSDK.createRigidDynamic(transform);
if(!to)
return NULL;
if ( !copyStaticProperties(*to, from, mirrorFilter) )
{
to->release();
to = NULL;
return NULL;
}
to->setRigidDynamicFlags(from.getRigidDynamicFlags());
to->setMass(from.getMass());
to->setMassSpaceInertiaTensor(from.getMassSpaceInertiaTensor());
to->setCMassLocalPose(from.getCMassLocalPose());
if ( !(to->getRigidDynamicFlags() & PxRigidDynamicFlag::eKINEMATIC) )
{
to->setLinearVelocity(from.getLinearVelocity());
to->setAngularVelocity(from.getAngularVelocity());
}
to->setLinearDamping(from.getAngularDamping());
to->setAngularDamping(from.getAngularDamping());
to->setMaxAngularVelocity(from.getMaxAngularVelocity());
PxU32 posIters, velIters;
from.getSolverIterationCounts(posIters, velIters);
to->setSolverIterationCounts(posIters, velIters);
to->setSleepThreshold(from.getSleepThreshold());
to->setContactReportThreshold(from.getContactReportThreshold());
return to;
}
示例5: CreateTankActor
//.........这里部分代码省略.........
//Ackermann steer accuracy
PxVehicleAckermannGeometryData ackermann;
ackermann.mAccuracy = 0.1f;
ackermann.mAxleSeparation = wheelCentreOffsets[ 0 ].z - wheelCentreOffsets[ nWheels - 1 ].z; // Расстояние между центром передней оси и центром задней оси
ackermann.mFrontWidth = wheelCentreOffsets[ 0 ].x - wheelCentreOffsets[ 1 ].x; // Расстояние между центральной точке два передних колеса
ackermann.mRearWidth = wheelCentreOffsets[ nWheels - 2 ].x - wheelCentreOffsets[ nWheels - 1 ].x; // Расстояние между центральной точке два задних колеса
driveData.setAckermannGeometryData(ackermann);
PxTriangleMesh * pTriangleMesh = 0;
D3DXVECTOR3 vPosition;
if( GameObject * pRoller = GetDetail( WHEEL_LEFT_1ST ) )
{
if( pRoller->CreateTriangleMesh( pPhysX ) )
{
pRoller->Update( 0.f );
pTriangleMesh = pRoller->GetTriangleMesh();
Position = pRoller->GetPosition();
}
}
// Нам нужно добавить колеса столкновения форм, их местный позы, материал для колес, и моделирование фильтра для колес
PxTriangleMeshGeometry WheelGeom( pTriangleMesh );
PxGeometry* wheelGeometries[ nWheels ] = {0};
PxTransform wheelLocalPoses[ nWheels ];
for( PxU32 i = 0; i < nWheels; ++i )
{
wheelGeometries[ i ] = &WheelGeom;
wheelLocalPoses[ i ] = PxTransform::createIdentity();
}
PxMaterial* pMaterial = pPhysX->GetPhysics()->createMaterial( 0.5f, 0.5f, 0.1f ); //коэффициенты трения скольжения и покоя(Dynamic friction,Static friction), коэффициент упругости
const PxMaterial& wheelMaterial = *pMaterial;
PxFilterData wheelCollFilterData;
wheelCollFilterData.word0 = COLLISION_FLAG_WHEEL;
wheelCollFilterData.word1 = COLLISION_FLAG_WHEEL_AGAINST;
// Нам нужно добавить шасси столкновения форм, их местный позы, материала для шасси и моделирования фильтр для шасси.
//PxBoxGeometry chassisConvexGeom( 1.5f, 0.3f, 4.f );
PxBoxGeometry chassisConvexGeom( chassisDims.x/2, chassisDims.y/2, chassisDims.z/2 );
const PxGeometry* chassisGeoms = &chassisConvexGeom;
const PxTransform chassisLocalPoses = PxTransform::createIdentity();
const PxMaterial& chassisMaterial = *pMaterial;
PxFilterData chassisCollFilterData;
chassisCollFilterData.word0 = COLLISION_FLAG_CHASSIS;
chassisCollFilterData.word1 = COLLISION_FLAG_CHASSIS_AGAINST;
// Создание фильтра запроса данных для автомобилей, чтобы машины не пытайтесь ездить на себя.
PxFilterData vehQryFilterData;
SampleVehicleSetupVehicleShapeQueryFilterData( &vehQryFilterData );
PxRigidDynamic* vehActor = pPhysX->GetPhysics()->createRigidDynamic( PxTransform::createIdentity() );
//Add all the wheel shapes to the actor.
for( PxU32 i = 0; i < nWheels; ++i )
{
PxShape* wheelShape=vehActor->createShape( *wheelGeometries[ i ], wheelMaterial );
wheelShape->setQueryFilterData( vehQryFilterData );
wheelShape->setSimulationFilterData( wheelCollFilterData );
wheelShape->setLocalPose( wheelLocalPoses[ i ] );
wheelShape->setFlag( PxShapeFlag::eSIMULATION_SHAPE, true );
}
//Add the chassis shapes to the actor
PxShape* chassisShape = vehActor->createShape( *chassisGeoms, chassisMaterial );
chassisShape->setQueryFilterData( vehQryFilterData );
chassisShape->setSimulationFilterData( chassisCollFilterData );
chassisShape->setLocalPose( PxTransform( physx::PxVec3( 0, 0, 0 ) ) );
vehActor->setMass( chassisData.mMass );
vehActor->setMassSpaceInertiaTensor( chassisData.mMOI );
vehActor->setCMassLocalPose( PxTransform( chassisData.mCMOffset, PxQuat::createIdentity() ) );
vehActor->setGlobalPose( PxTransform( physx::PxVec3( 0, 8, 0 ), PxQuat::createIdentity() ) );
PxVehicleDriveTank* pTank = PxVehicleDriveTank::allocate( nWheels );
pTank->setup( pPhysX->GetPhysics(), vehActor, *wheelsSimData, driveData, nWheels );
pPhysX->AddActorScene( vehActor );
m_pActor = vehActor;
pPhysX->AddTank( pTank );
//Free the sim data because we don't need that any more.
wheelsSimData->free();
//pTank->setDriveModel( PxVehicleDriveTank::eDRIVE_MODEL_SPECIAL );
pTank->setToRestState();
pTank->mDriveDynData.setUseAutoGears( true );
return true;
}
}
return false;
}