PxFixedJoint* pJoint = PxFixedJointCreate(*gPhysicsSDK, pRA1, local1 ,pRA2, local2) PxTransform local1 = PxTransform::createIdentity(), If the shape isn't centered on the actor, or the actor contained multiple shapes then we might want to consider different local frames. It should also be noted that the joint is formed between the two actors and not the shapes themselves. Since the boxes they are of unit length, and are one unit apart, the surfaces will be in contact.
I have set one of the actors to be kinematic so it will remain suspended despite gravity, while the other will be held up entirely by the strength of the joint. PRA2 = PxCreateDynamic(*gPhysicsSDK, kform , boxGeo,*defaultMaterial, 1.0) PRA1 = PxCreateDynamic(*gPhysicsSDK, kform ,boxGeo,*defaultMaterial, 1.0) PxTransform kform = PxTransform::createIdentity() These categories are decided by the ability of the damping to stop the oscillation.Ĭhoose Un-Damped if you want the spring to oscillate back and forth forever.Ĭhoose over damped if you want the spring to slow down a lot to start and very gradually approach equilibrium. The magnitude of the damping coefficient should be chosen to fall into one of four categories. Where 'c' is the damping coefficient, and x' is the first derivative with respect to time of the distance from the natural length (the speed)Ī spring experiencing a damping force will eventually stop at an equilibrium length (not necessarily the same as the natural length) The force experienced by the actors will need to be adjusted by a damping force Where 'k' is the spring constant, and 'x' is the distance from the natural length, or in our case, the distance from the min or max limits. Similarly a minimum distance can be set, but cannot exceed the maximum distance, the spring force will pull the actors to remain between the min and max distance limits. However if the spring flag is enabled then this becomes the distance at which the spring force becomes active. With the spring flag disabled the max distance is a hard limit for the joint. There are three flags available for the distance joint.īy default only the eMAX_DISTANCE_ENABLED is active. The distance joint may act as a string or a spring, connecting the two actors. PJoint->setConstraintFlag(PxConstraintFlag::eCOLLISION_ENABLED,true) PxDistanceJoint* pJoint = PxDistanceJointCreate(*gPhysicsSDK, pRA1, local1 ,pRA2, local2) Īnd although not necessary this time we can set the collision flag. PxTransform local1 = PxTransform::createIdentity(), local2= PxTransform::createIdentity() We will also need a couple transforms to represent the where the joint attaches to the two actors. PRA2 = PxCreateDynamic(*gPhysicsSDK, pform,geo,*defaultMaterial, 1.0) PRA1->isRigidDynamic()->setRigidDynamicFlag(PxRigidDynamicFlag::eKINEMATIC,true) PRA1 = PxCreateDynamic(*gPhysicsSDK, pform,geo,*defaultMaterial, 1.0) In our example one will be kinematic, to hold up the other. PxTransform pform = PxTransform::createIdentity() I'll give them box shapes of unit length. Just like Fixed Joints , we need a couple rigid actors.