Page 1 of 1
Confused Constraints
Posted: Tue Jul 22, 2008 5:23 am
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?
Re: Confused Constraints
Posted: Tue Jul 22, 2008 5:40 am
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.
Re: Confused Constraints
Posted: Tue Jul 22, 2008 8:18 pm
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
Re: Confused Constraints
Posted: Wed Jul 23, 2008 4:53 pm
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.
Re: Confused Constraints
Posted: Wed Jul 23, 2008 6:02 pm
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.
Re: Confused Constraints
Posted: Fri Jul 25, 2008 6:35 pm
by jstroh
When's 0.60 coming?
Re: Confused Constraints
Posted: Fri Jul 25, 2008 7:29 pm
by Norbo
I really want to have it out in the next week or so; all of the 'hard stuff' is done.
Re: Confused Constraints
Posted: Fri Jul 25, 2008 11:52 pm
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