PhysX rope simulation - Dynamic length

Started by
3 comments, last by jezham 16 years, 2 months ago
Hey guys. In the past I've implemented a rope simulation where the rope itself consisted of a fixed number of bodies connected by springs between each body. Nothing revolutionary here. Illustration below (- illustrated a spring): Player - b0 - b1 - b2 - b3 I special thing about the rope I've done before was it's ability to expand / shorten itself without getting recreated. The way I did this was be adjusting the target length of the spring. Say I wanted to shorten the rope I could decrease the target length of the spring connecting the player and b0 until it fell below a fixed threshhold. When this happend I "locked" it inside the players body and disabled the spring. If the player decreased the ropes length even further it would just shorten the next springs target length ect. until the rope was completly locked. Now moving to a more advanced physics engine (Ageia's PhysX engine) I need to recreate the same scenario. The problem is that a NxDistanceJoint (a spring) connecting two NxActors (bodies) doesn't allow the target length adjusted without having to delete the rope and recreate it completly which would screw up the physics simulation. Does anyone have any ideas on how I could do this?! One way I've considered was to write the actual rope simulation (springs / bodies) myself using a simple Verlet / constraint model. But alas this would give me a world of problems when I had to connect the rope to other PhysX actors in the scene. By connect I mean allow the PhysX actor to pull the rope around and the other way around. I don't even know if this is a good idea. I really hope some of the brainiacs in here can help me out!
Advertisement
The pulley joint comes to mind. I try to do everything with D6 joints myself though, and don't have 'pulley joint' experience.
Thanks for the reply. After looking at the PhysX docs I just can't really figure out how I would configure it to do what I need since I still wouldn't be able to adjust the rest length dynamically (as far as I can tell).
NxDistanceJointDesc distanceDesc;
((NxDistanceJoint*)m_apRopeJoints)->saveToDesc(distanceDesc);
distanceDesc.maxDistance = length;
((NxDistanceJoint*)m_apRopeJoints)->loadFromDesc(distanceDesc);

Apperently this did the trick - Thanks for everyone looking.
Doh I've done similar, sorry I missed that earlier. Glad you have it sorted.

This topic is closed to new replies.

Advertisement