Exemplo n.º 1
0
// fixed, breakable joint
PxJoint* createBreakableFixed(PxRigidActor* a0, const PxTransform& t0, PxRigidActor* a1, const PxTransform& t1)
{
	PxFixedJoint* j = PxFixedJointCreate(*gPhysics, a0, t0, a1, t1);
	j->setBreakForce(100000, 10000000);
	j->setConstraintFlag(PxConstraintFlag::eDRIVE_LIMITS_ARE_FORCES, true);
	return j;
}
Exemplo n.º 2
0
		/**
		 * Method is used to add joint between two scene actors. This joints can be broken when defined
		 * amount of force/troque have been applied.
		 * @param	name is first actor name id.
		 * @param	name2 is second actor name id.
		 * @param	force is amount of force needed to brake joint.
		 * @param	torque is amount of torque needed to brake joint.
		 */
		void PhysicsManager::addJoint(const string& name, const string& name2, const float force, const float torque)
		{
			DynamicActor* first = nullptr;
			DynamicActor* second = nullptr;

			DynamicActors::const_iterator it = dynamicActors.begin();
			for(; it != dynamicActors.end(); ++it)
				if((*it)->entityLogic->entityName == name)
					break;
			if(it == dynamicActors.end())
				return;
			first = (*it);

			it = dynamicActors.begin();
			for(; it != dynamicActors.end(); ++it)
				if((*it)->entityLogic->entityName == name2)
					break;
			if(it == dynamicActors.end())
				return;
			second = (*it);

			PxTransform transformation;
			PxVec3 position = PxVec3(first->entityLogic->entityState.position[0],first->entityLogic->entityState.position[1],first->entityLogic->entityState.position[2]);
			PxQuat orientation = PxQuat(first->entityLogic->entityState.orientation[0],first->entityLogic->entityState.orientation[1],first->entityLogic->entityState.orientation[2],first->entityLogic->entityState.orientation[3]);
			transformation.p = position;
			transformation.q = orientation;

			PxTransform transformation2;
			PxVec3 position2 = PxVec3(second->entityLogic->entityState.position[0],second->entityLogic->entityState.position[1],second->entityLogic->entityState.position[2]);
			PxQuat orientation2 = PxQuat(second->entityLogic->entityState.orientation[0],second->entityLogic->entityState.orientation[1],second->entityLogic->entityState.orientation[2],second->entityLogic->entityState.orientation[3]);
			transformation2.p = position2;
			transformation2.q = orientation2;

			PxFixedJoint* fixed = PxFixedJointCreate(*physicsSDK,first->entityPhysics,transformation,second->entityPhysics,transformation2);
			fixed->setBreakForce(force,torque);
		}
Exemplo n.º 3
0
PhysXFixedJoint::PhysXFixedJoint(PxPhysics* pPhysics, PxRigidActor* pActor0, const PxTransform& localFrame0, 
	PxRigidActor* pActor1, const PxTransform& localFrame1) : PhysXJoint(pPhysics, pActor0, pActor1)
{
	mJoint = PxFixedJointCreate(*mPhysics, pActor0, localFrame0, pActor1, localFrame1);
}