Linking two objects with a distance/rope constraint

Please don't post Bullet support questions here, use the above forums instead.
MBellehumeur
Posts: 3
Joined: Fri Oct 07, 2011 3:31 pm

Linking two objects with a distance/rope constraint

Post by MBellehumeur »

Hello,

I've been trying for a while to implement a constraint between two RB but I cannot find anything that does what I'm trying to achieve.

The behavior I'm trying to get is to have two objects tied with an invisible rope. As long as they stay closer than the length of the rope they can move freely, but they cannot go farther apart than a specified length.

Also, if one the two object is fixed, the constraint should make the two objects act as a pendulum.

I've done quite a few tests with the btGeneric6DofConstraint and the best I could do is to have a constraint where the two objects are stuck together inside a 'box constraint', but it's not enough. At the moment, I'm adding a new spherical constraint in btGeneric6DofConstraint but it seems I'm over-complexifying the situation, I'm sure there is something I'm missing!
User avatar
Dr.Shepherd
Posts: 168
Joined: Tue Jan 04, 2011 11:47 pm

Re: Linking two objects with a distance/rope constraint

Post by Dr.Shepherd »

I suppose using a softobject to link them together is the easiest way, but if you want it invisible, I don't know how to.

Best wishes, hope others can help
MBellehumeur
Posts: 3
Joined: Fri Oct 07, 2011 3:31 pm

Re: Linking two objects with a distance/rope constraint

Post by MBellehumeur »

Thanks, I thought about softbodies but I believe it's too complex for the type of constraints I want. I'm not worried about the visual for now.

The thing is that I'm very close to obtaining the desired results with the 6dof constraints but I just can't seem to find the right settings. Also, I think it would work with the hinge constraint if it was possible for the objects to move along the rotating axis, but it is not exposed.
User avatar
Dr.Shepherd
Posts: 168
Joined: Tue Jan 04, 2011 11:47 pm

Re: Linking two objects with a distance/rope constraint

Post by Dr.Shepherd »

I don't think the SoftObject is that difficult, just check the documentation, you can have a go.
===============================================================================
Come up with another idea, put two constraints together:

OBJ_A-POINT CONSTRAINT-MIDDLE OBJ-------SLIDER CONSTRAINT-------OBJ B

so you make an extra object in the middle, make this two constraints work together. this seems odd, but I think this is what you want.
===============================================================================
As to the GenericConstraint
This generic constraint can emulate a variety of standard constraints, by configuring each of the 6
degrees of freedom (dof). The first 3 dof axis are linear axis, which represent translation of rigidbodies,
and the latter 3 dof axis represent the angular motion. Each axis can be either locked, free or limited.
If I understand clearly, you can set the 3 linear axis to [Lower Limit, Upper Limit], and set all the 3 angular axis free, is it what you want ?
MBellehumeur
Posts: 3
Joined: Fri Oct 07, 2011 3:31 pm

Re: Linking two objects with a distance/rope constraint

Post by MBellehumeur »

Thanks for the suggestion, putting a slider constraint with two rotation constraints at the end worked quite well!!

Before, I tried to use the 6dof constraint to create a slider, but it didn't work as well as the btSliderConstraint, it didn't rotated properly. Also, setting the 3 linear axis of the 6dof constraint almost worked, but it created a box around the objects while I needed a spherical constraint.
User avatar
Dr.Shepherd
Posts: 168
Joined: Tue Jan 04, 2011 11:47 pm

Re: Linking two objects with a distance/rope constraint

Post by Dr.Shepherd »

Ok, That's great to hear that you solved the problem.

Cheers !