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?
Confused Constraints
Re: Confused Constraints
This seems to be close to what you're looking for:
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.
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);
Re: Confused Constraints
Yay for fast response. Will try it when I get home ;oNorbo wrote:This seems to be close to what you're looking for:
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.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);
Re: Confused Constraints
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
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.
In v0.6.0, there's a DistanceRangeConstraint which simulates ropes by allowing for a maximum and minimum allowed distance, too.
Re: Confused Constraints
I really want to have it out in the next week or so; all of the 'hard stuff' is done.
Re: Confused Constraints
woot, will work on other things then ;oNorbo wrote:I really want to have it out in the next week or so; all of the 'hard stuff' is done.