Constraints...

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
zeeba
Posts: 4
Joined: Mon Mar 01, 2010 9:42 pm

Constraints...

Post by zeeba »

A few more noob questions :P, 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!!!
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Constraints...

Post by Norbo »

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?
Sorry, I'm not sure exactly what kind of behavior you are looking for here.
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?
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.
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
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.

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.
zeeba
Posts: 4
Joined: Mon Mar 01, 2010 9:42 pm

Re: Constraints...

Post by zeeba »

Norbo wrote:Sorry, I'm not sure exactly what kind of behavior you are looking for here.
This is what I'm trying to do (seen from one side :P)
apply_angular_velocity.jpg
apply_angular_velocity.jpg (60.81 KiB) Viewed 3270 times
For some reason, the box won't go higher than the anchor points location...
Norbo 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.
My bad, it was a copy/paste error, the anchor points are setup like this
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));
Norbo 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.
cool!, I'll keep playing around with the settings then
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.
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)

Thanks a lot for your help!
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Constraints...

Post by Norbo »

With this setup:

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));
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.
Post Reply