// fixed, breakable joint
PxJoint* createBreakableFixed(PxPhysics* gPhysics, PxRigidActor* a0, const PxTransform& t0, PxRigidActor* a1, const PxTransform& t1)
{
	PxFixedJoint* j = PxFixedJointCreate(*gPhysics, a0, t0, a1, t1);
	j->setBreakForce(1000, 100000);
	j->setConstraintFlag(PxConstraintFlag::eDRIVE_LIMITS_ARE_FORCES, true);
	return j;
}
Esempio 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);
		}