Page 1 of 1

RevoluteAngularJoint doesn't seem to work

Posted: Tue Apr 10, 2012 9:28 am
by Psykocyber

Code: Select all

Box boxOne = new Box(new Vector3(0, 0,0) , 1, 1, 1, 5);
            boxOne.Orientation = Quaternion.CreateFromAxisAngle(Vector3.Forward, 0);
            Box boxTwo = new Box(new Vector3(0, 5, 0), 1, 1, 1, 5);
            boxTwo.Orientation = Quaternion.CreateFromAxisAngle(Vector3.Forward, 0);
            boxOne.Material = new Material(.3f,.2f,.2f);
            boxTwo.Material = new Material(.3f, .2f, .2f);
            RevoluteAngularJoint bsj;
            AngularMotor am;
            Space.Add(boxOne);
            Space.Add(boxTwo);
            bsj = new RevoluteAngularJoint(boxOne, boxTwo, new Vector3(0,2.5f,0));
            am = new AngularMotor(boxOne, boxTwo);
            am.Settings.Mode = MotorMode.VelocityMotor;
            am.IsActive = true;
            bsj.IsActive = true;
            EllipseSwingLimit swingLimit = new EllipseSwingLimit(boxOne, boxTwo, Vector3.Up, MathHelper.PiOver4, MathHelper.PiOver2);
            bsj.GalLimit = swingLimit;
            bsj.GalMotor = am;
            Space.Add(swingLimit);
            Space.Add(am);
            Space.Add(bsj);
In the above code, I tried to add two boxes with a RevoluteAngularJoint, but whenever I test it, the two boxes are not connected in any way. I tried the same code with a BallSocketJoint, which appears to be much alike code-wise, and it worked just fine...

Any input on why this doesn't work?

Re: RevoluteAngularJoint doesn't seem to work

Posted: Tue Apr 10, 2012 3:11 pm
by Norbo
RevoluteAngularJoint, AngularMotor, and EllipseSwingLimit all operate only on angular degrees of freedom. The three linear degrees of freedom are completely unconstrained. A BallSocketJoint, on the other hand, operates on all three linear degrees of freedom.

RevoluteAngularJoint restricts two degrees of freedom, leaving one hinge-like degree of freedom. AngularMotor operates on all three angular degrees of freedom. EllipseSwingLimit operates on one degree of freedom to form the ellipse limit. There's lots of overlaps between these three; the EllipseSwingLimit is made mostly unnecessary by the RevoluteAngularJoint and could be replaced with a RevoluteLimit to control the DOF more precisely. For similar reasons, the AngularMotor could be replaced with a RevoluteMotor.

If the goal is hinge-like behavior, I would recommend using the RevoluteJoint. It is a convenience class that combines a BallSocketJoint, RevoluteAngularJoint, RevoluteMotor, and RevoluteLimit.