Confused Constraints

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
jstroh
Posts: 37
Joined: Fri May 02, 2008 9:33 am

Confused Constraints

Post by jstroh »

Ok how would I do this:

lamp hanging from a rope/chain.

-----------------
|
|
|
/ \
/ \

I want the light to sway.

I made two boxes with a ballsocketjoint and applied a force but it looks funny. I'm positive I'm not doing it right. Can I get an example of what to do?
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Confused Constraints

Post by Norbo »

This seems to be close to what you're looking for:

Code: Select all

                    Box ceiling = new Box(new Vector3(0, 5, 0), 5, 1, 5);
                    Cone lampShade = new Cone(new Vector3(0, -3, 0), 1, 1, 1);
                    space.add(ceiling);
                    space.add(lampShade);
                    space.add(new BallSocketJoint(ceiling, lampShade, new Vector3(0, 4.5f, 0), 0, .2f));

                    lampShade.linearVelocity = new Vector3(-1, 0, 0);
You might be encountering either a misplaced anchor location (putting it close to the lamp itself would produce some notsogood results since it is supposed to be the origin of rotation), or maybe a tweaking issue with the softness/bias factor. Softness just gives the joint a little springiness and can help stability, but you probably don't need any at all for a hanging lamp. The bias factor might be acting up as well if it is set too high (typically .2 works fine); it is responsible for correcting position error at the anchor. If it's trying too hard, you could see some jumpiness or explosions.
jstroh
Posts: 37
Joined: Fri May 02, 2008 9:33 am

Re: Confused Constraints

Post by jstroh »

Norbo wrote:This seems to be close to what you're looking for:

Code: Select all

                    Box ceiling = new Box(new Vector3(0, 5, 0), 5, 1, 5);
                    Cone lampShade = new Cone(new Vector3(0, -3, 0), 1, 1, 1);
                    space.add(ceiling);
                    space.add(lampShade);
                    space.add(new BallSocketJoint(ceiling, lampShade, new Vector3(0, 4.5f, 0), 0, .2f));

                    lampShade.linearVelocity = new Vector3(-1, 0, 0);
You might be encountering either a misplaced anchor location (putting it close to the lamp itself would produce some notsogood results since it is supposed to be the origin of rotation), or maybe a tweaking issue with the softness/bias factor. Softness just gives the joint a little springiness and can help stability, but you probably don't need any at all for a hanging lamp. The bias factor might be acting up as well if it is set too high (typically .2 works fine); it is responsible for correcting position error at the anchor. If it's trying too hard, you could see some jumpiness or explosions.
Yay for fast response. Will try it when I get home ;o
jstroh
Posts: 37
Joined: Fri May 02, 2008 9:33 am

Re: Confused Constraints

Post by jstroh »

What if I wanted to simulate a rope and then simulate an earthquake, what would you do? I'm guessing multiple joints but not sure about the forces.
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Confused Constraints

Post by Norbo »

A rope could be made out of a series of BallSocketConstraints, correct. This would also entail multiple intermediate bodies forming a chain/multipendulum. To simulate an earthquake from there, you could scoot the 'ceiling' or whatever its connected to around, or just apply forces/velocities somewhere on the rope's bodies to simulate it. General shakiness will get the point across, probably.

In v0.6.0, there's a DistanceRangeConstraint which simulates ropes by allowing for a maximum and minimum allowed distance, too.
jstroh
Posts: 37
Joined: Fri May 02, 2008 9:33 am

Re: Confused Constraints

Post by jstroh »

When's 0.60 coming?
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Confused Constraints

Post by Norbo »

I really want to have it out in the next week or so; all of the 'hard stuff' is done.
jstroh
Posts: 37
Joined: Fri May 02, 2008 9:33 am

Re: Confused Constraints

Post by jstroh »

Norbo wrote:I really want to have it out in the next week or so; all of the 'hard stuff' is done.
woot, will work on other things then ;o
Post Reply