Sign in to follow this  
elurahu

PhysX rope simulation - Dynamic length

Recommended Posts

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!

Share this post


Link to post
Share on other sites
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).

Share this post


Link to post
Share on other sites
NxDistanceJointDesc distanceDesc;
((NxDistanceJoint*)m_apRopeJoints[i])->saveToDesc(distanceDesc);
distanceDesc.maxDistance = length;
((NxDistanceJoint*)m_apRopeJoints[i])->loadFromDesc(distanceDesc);

Apperently this did the trick - Thanks for everyone looking.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this