Rope constraint

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Rope constraint

Borg
I'm trying to build a simple pearl bead necklace like object with slight elasticity in the thread. Looking at the HingeJoint example it seemed simple, but alas issues ahead. The HingeJoint used JConstraintMaxDistance internally, and whether I tried with the HingeJoint example or by specifying JConstraintMaxDistance directly between two bodies, pulling either made the other fly like a wasp on acid no matter the max allowed distance. I wonder if a rope like constraint is included in jiglib yet, or if not how to go about writing one.

If JConstraintMaxDistance works as it should I wonder if the reason it does not seem to work here is because one of the bodies in the joint is pulled by the mouse instead of world forces? What is the correct way of dragging an objects on mouse move if you want it to be locked exactly at the mouse position (and not at some imaginary rubber band)?


Basically...how do I build a necklace with some beads kept at a more or less fixed distance where each bead can be dragged and locked to mouse position? Any ideas?

Cheers
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Rope constraint

muzer
JConstraintMaxDistance is well for necklace , you can get rid of the comment at line 137 of HingeJointTest to test it. but the stretch can't be avoided with jiglib constraints.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Rope constraint

Borg
Hi Muzer,
that's what I was playing around with but it seems to me what I can achieve with jiglib now is a necklace on a thin elastic string where you can pick up a bead with another elastic string and pull it about. It doesn't seem to offer to simulate grabbing and moving an object with fixed joints, like locking the head of a ragdoll to the mouse pointer. I am guessing that JConstraintMaxDistance is not really a max distance constraint as much as a target max constraint where if it overshoots it will try to compensate. Is that correct?

I did a translation of this C++ rope class
http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=40
and it worked kinda OK, but its tricky to understand jiglib since there aren't many comments. Let's say there is no risk the comments would be patronizing at this stage :-)

A spring joint worked better but doesn't do the trick still. If the distance vector bestween two boddies is more than a max distance wouldn't a max distance joint apply a force that is negative the amount the sumtotal of forces would overshoot (multiplied by some damping)? I have no idea if that is correct or if it is one is supposed to use worldImpulse, bodyForce or setVelocity etc?

Thanks

JSpring.as
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Rope constraint

muzer
the jiglib constraints is base on impulse. I'm not sure if have other method to handle constraints. I was looked the box2d constraints is very tight. maybe we can get some idea from it.

thanks for the article and code, I will test it.
Loading...