A few more noob questions , I hope I don't bother you guys too much
So I have a sphere bouncing around a room, but now I want to incorporate something from the "More Constraints" demo, I want to have a box that is suspended by two "stiff" cables, or more specifically, this one (with modified values)
//Hinge connected to the space:
Box loneHingePart = new Box(new Vector3(0, 1, 0), 1, 1, 1, 100);
space.add(loneHingePart);
space.add(new BallSocketJoint(null, loneHingePart, new Vector3(0, 3, 0), 0, .2f));
space.add(new BallSocketJoint(null, loneHingePart, new Vector3(0, 3, 0), 0, .2f));
And I want to apply an angular velocity so that the box goes around the full 360 degrees in the z axis (rotating around the x axis). I've tried setting an angular velocity big enough (loneHingePart.angularVelocity = new Vector3(0.0f, 0.0f, 50.0f);) and it kind of moves the way I want, and with a good speed, but does not go above the joint locations (from what I can see). Is there a way to accomplish that?
Also, if it touches the sphere, it modifies the box current angular velocity in X/Y just a bit, is there a way to restrict the movement to the Z axis only?
And last one; I set the box mass to 10 and the sphere mass to 1, but I still see some force applied back to the box if it hits the sphere (as expected), but I would like the box to act a bit more like a kinematic, but if I set the mass value too high, it's heavier to move with the angular impulse... is there a way to accomplish that? if not, I'll just try to play around more with the mass settings hehehe
Thanks!!!
Constraints...
Re: Constraints...
Sorry, I'm not sure exactly what kind of behavior you are looking for here.And I want to apply an angular velocity so that the box goes around the full 360 degrees in the z axis (rotating around the x axis). I've tried setting an angular velocity big enough (loneHingePart.angularVelocity = new Vector3(0.0f, 0.0f, 50.0f);) and it kind of moves the way I want, and with a good speed, but does not go above the joint locations (from what I can see). Is there a way to accomplish that?
The two ball socket joints listed above are redundant and act like a single ball socket joint. In order for it to act like a hinge, the anchor points must be offset from each other a little.Also, if it touches the sphere, it modifies the box current angular velocity in X/Y just a bit, is there a way to restrict the movement to the Z axis only?
Increasing the mass of the box shouldn't have an effect on changing the angularVelocity property, so increasing mass a reasonable amount should do what you want here.And last one; I set the box mass to 10 and the sphere mass to 1, but I still see some force applied back to the box if it hits the sphere (as expected), but I would like the box to act a bit more like a kinematic, but if I set the mass value too high, it's heavier to move with the angular impulse... is there a way to accomplish that? if not, I'll just try to play around more with the mass settings hehehe
Also, v0.11.0 is going to be out very soon and includes a revamp of the constraint system. They have a lot more power in the new version and should be easier to use, too.
Re: Constraints...
This is what I'm trying to do (seen from one side ) For some reason, the box won't go higher than the anchor points location...Norbo wrote:Sorry, I'm not sure exactly what kind of behavior you are looking for here.
My bad, it was a copy/paste error, the anchor points are setup like thisNorbo wrote:The two ball socket joints listed above are redundant and act like a single ball socket joint. In order for it to act like a hinge, the anchor points must be offset from each other a little.
space.add(new BallSocketJoint(null, loneHingePart, new Vector3(1.0f, 2.0f, 0.0f), 0, .2f));
space.add(new BallSocketJoint(null, loneHingePart, new Vector3(-1.0f, 2.0f, 0.0f), 0, .2f));
cool!, I'll keep playing around with the settings thenNorbo wrote:Increasing the mass of the box shouldn't have an effect on changing the angularVelocity property, so increasing mass a reasonable amount should do what you want here.
Nice!, I like the engine a lot, it's works great and it's easy to use (it's just that I don't know much about physics, lol)Norbo wrote:Also, v0.11.0 is going to be out very soon and includes a revamp of the constraint system. They have a lot more power in the new version and should be easier to use, too.
Thanks a lot for your help!
Re: Constraints...
With this setup:
the box should spin around its 'hinge' axis as pictured.
I think what you may have observed before is the box acting like a pendulum, falling and coming back up to about level with the hinge position. Since the hinge's free axis is the X axis, the angular velocity needs to be around the X axis to have an effect.
Code: Select all
loneHingePart = new Box(new Vector3(0, 1, 0), 1, 1, 1, 100);
loneHingePart.angularVelocity = new Vector3(50, 0, 0);
space.add(loneHingePart);
space.add(new BallSocketJoint(null, loneHingePart, new Vector3(1.0f, 2.0f, 0.0f), 0, .2f));
space.add(new BallSocketJoint(null, loneHingePart, new Vector3(-1.0f, 2.0f, 0.0f), 0, .2f));
I think what you may have observed before is the box acting like a pendulum, falling and coming back up to about level with the hinge position. Since the hinge's free axis is the X axis, the angular velocity needs to be around the X axis to have an effect.