How to forbid the Position change

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
mr_join
Posts: 14
Joined: Fri Nov 01, 2013 10:03 am

How to forbid the Position change

Post by mr_join »

Hi.
How can i forbid change position and rotation of the Entity except one Axis (Y) ?
I want to simulate process of opening door by the mouse.
I used RevoluteJoint and Box to create simple door but when i try to grab door by the mouse box is moving (for short distance) and some rotate by another axiss.
If this is not god choice, plz give me advice.

Code: Select all

var door = new Box(new Vector3(0, 0.24f,0.5f), 0.3f, 0.5f, 0.02f, 100);            
            RevoluteJoint revolute = new RevoluteJoint(null, door, door.Position + new Vector3(-0.15f, 0, 0), Vector3.Up);
            revolute.Limit.IsActive = true;
            revolute.AngularJoint.ConnectionA.BecomeKinematic();                        
            revolute.Limit.Basis.SetWorldAxes(Vector3.Up, Vector3.Right);
            revolute.Limit.TestAxis = Vector3.Right;
            revolute.Limit.MinimumAngle = -MathHelper.Pi;
            revolute.Limit.MaximumAngle = 0;
Aaand i used sample of grabber from Bepu demo.
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: How to forbid the Position change

Post by Norbo »

A couple of notes:

Code: Select all

var door = new Box(new Vector3(0, 0.24f,0.5f), 0.3f, 0.5f, 0.02f, 100);   
This door is pretty heavy relative to the default strength of constraints. On top of that, using something like the grabber scales its grabbystrength by the mass of the thing it's grabbing, so the force the grabber applies will be quite large relative to the strength of the door hinge.

So, I'd recommend some combination of the following:
1) Use a low fixed strength on the grabber,
2) Decrease the mass of the door,
3) Increase the strength of the constraint by scaling up the revoluteJoint.BallSocketJoint.SpringSettings.Stiffness and Damping and the revoluteJoint.AngularJoint.SpringSettings.Stiffness and Damping.

Code: Select all

revolute.AngularJoint.ConnectionA.BecomeKinematic();      
This line isn't necessary. Passing in 'null' for the first connection will connect the joint to a kinematic 'world' entity. In fact, it's wise not to do anything to that 'world' entity because it is shared by any constraint with null passed in. It would be pretty easy to mess something up.
mr_join
Posts: 14
Joined: Fri Nov 01, 2013 10:03 am

Re: How to forbid the Position change

Post by mr_join »

Thx you very much, Norbo! =)
Post Reply